$(document).ready(function(){
//lavalamp
	$(function() { $(".main-menu").lavaLamp({ fx: "backout", speed: 700 })});
	
//togle sub-menu
	$(".sub-menu").hide();
	
	$(".main-menu > li").hover(function() {
		$(".sub-menu", this).fadeIn();
	},function(){
		$(".sub-menu", this).hide();
	});
	
//header images
	var $images = new Array('header-img1.jpg', 'header-img2.jpg', 'header-img3.jpg', 'header-img4.jpg', 'header-img5.jpg');
	var $random = Math.random() * $images.length;
	var $count = Math.floor($random);
	$('#header-img').css('background-image','url("../images/'+$images[$count++]+'")') // first background is random and count is increased so the event loads the next one
	.everyTime(6000, 'controlled', function() {
		if ($count >= $images.length) $count = 0;
		$(this).fadeOut('slow', function(){
			$(this).css('background-image','url("../images/'+$images[$count]+'")').fadeIn('slow');
			$count++;
		});
	});	
});
