var ImgBoxIdx = 1;
var StartLeftImgRotation = function(){
	$("#ImgBoxId").ImageSwitch({Type:"FadeIn", NewImage:"img/rotation/"+(ImgBoxIdx+1)+".jpg", Speed:1500});
	ImgBoxIdx++;
	if(ImgBoxIdx==15) {ImgBoxIdx = 0;}
}

function slide(navigation_id, pad_out, pad_in, time, multiplier)  
{  
	var list_elements = navigation_id + " li.menu-element";  
	var link_elements = list_elements + " a";     
	var timer = 0;  
       
	$(list_elements).each(function(i)  
	{  
		$(this).css("margin-top","-15px");  
		timer = (timer*multiplier + time);  
		$(this).animate({ marginTop: "0px" }, timer);  
		$(this).animate({ marginTop: "5px" }, timer);  
		$(this).animate({ marginTop: "0px" }, timer);  
	});  
	
	$(link_elements).each(function(i){  
		$(this).hover(function(){$(this).animate({ paddingTop: pad_out }, 150);},function(){$(this).animate({ paddingTop: pad_in }, 150);});  
	});  
}  

$(function(){

	$(".accordion h3:first").addClass("active");
	$(".accordion p:not(:first)").hide();
	slide("#menu", 3, 0, 150, .8);

	var $div = $("#Content");
	var height = "-" + ($div.height() - 15) + "px";
	$('#Content,#ImgBox').css("margin-top",height);
	$('#Content,#ImgBox').animate({ marginTop: "0px" }, 1200, function(){																	   
		IntervalID = setInterval(StartLeftImgRotation, 7000);			
	});
	
	$(".accordion h3").click(function(){
		$(this).next("p").slideToggle(500).siblings("p:visible").slideUp(500);
		$(this).toggleClass("active");
		$(this).siblings("h3").removeClass("active");
	});

	$('ul#menu li.menu-element a').click(function(ev){																 
		ev.preventDefault();
		var $self = $(this);										
		var $div = $("#Content");
		height = "-" + ($div.height() - 15) + "px";
		
		$('#Content,#ImgBox').animate({ marginTop : height }, 800, function(){
			document.location = $self.attr('href');
		});
	});

	$('#footer img').css('opacity','0.3');
	$('#footer img').hover(function(){$(this).stop().fadeTo(500,1);},function(){$(this).stop().fadeTo(700,0.3);});	
});