// JavaScript Document

$(document).ready(function(){		
	/* Main Menu */	
	$("#mainMenu li").hover(function(){
		$(this).children("ul").show();
		$(this).children("a.sub").addClass("on");
	},function(){
		$(this).children("ul").hide();			
		$(this).children("a.sub").removeClass("on");					 
	});
	/* Main Menu */	
	
	slideShow();
	
});

	
/* Slide Show */
function slideShow() 
{
	 //Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	 setInterval('gallery()',6000); 
}

function gallery() 
{
 	 //if no IMGs have the show class, grab the first image
	 var current = ($('#gallery li.show')?  $('#gallery li.show') : $('#gallery li.img1'));
	
	 //Get next image, if it reached the end of the slideshow, rotate it back to the first image
	 var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery li:first') :current.next()) : $('#gallery li.img1')); 
	 
	 //Set the fade in effect for the next image, show class has higher z-index
	next.removeClass("top");
	next.addClass("top");
	next.addClass('show').animate({right: '+=340'},200);
	next.addClass('show').animate({right: 0},400);
	next.children("a").addClass("first");
	
	 //Hide the current image
	current.addClass("top");
	current.children("a").removeClass("first").css("z-index","-100");
	current.removeClass('show').animate({right: 0},400);
	current.removeClass("top");
}
/* //Slide Show */
