/* hypnos Main JS */

$(document).ready(function() {
		
	// NAV COLORS
	var colors = new Array('e76fa2', '9f0b71', 'ee1505', 'ff9902', 'b1ba17', '03cd00', '009800', '32cbca', '359aca', '01679a', '676767');
	$('#mainNav ul li.depth1').each(function(index) {
		$('a', this).css('background-color', '#' + colors[index]);
	});
});

$(window).load(function(){
	var img = $("#background");
	var realWidth = img.width();
	var realHeight = img.height();
	
	resizeBgImage(realWidth, realHeight);

	$(window).resize(function(){
		resizeBgImage(realWidth, realHeight);
	});
});

function resizeBgImage(realWidth, realHeight) {
	var bgRatio = realWidth/realHeight;
		
	var winW = $(window).width(), winH = $(window).height(), imgW = 0, imgH = 0;
	imgW = winW;
	imgH = winW / bgRatio;
	if(imgH < winH){
		imgH = winH;
		imgW = imgH * bgRatio;
	}
	$("#background").width(Math.ceil(imgW))
					.height(Math.ceil(imgH))
					.css("visibility", "visible");
}

