// JavaScript Document
//
//BEGIN FUNCTION DECLARATION
//
//
//Fade to next slide in splash [no input]
//
function slideNext()
{
	splashinterval=clearInterval(splashinterval); //stop automatic slide switching

	var $active = $("#imagecontainer IMG.active");
	$active.stop(); //stop animation if already in progress
	if ( $active.length == 0 )
	{
		$active = $("#imagecontainer IMG.slide:last");  //prevent it from getting stuck in the event of it somehow getting outside the bounds of the slides(error)
	}
	
	var $next= $active.next().length ? $active.next()  //if there is a next slide transition to it if not transition to the first slide
		: $("#imagecontainer IMG.slide:first");
	$active.addClass("lastactive");

	$next.css({opacity:0.0})
		.addClass("active")
		.animate({opacity: 1.0}, 500, function() {  //actual fade animation and class removal from previous slide
			$active.removeClass("active lastactive");
		});
	splashinterval=setInterval( "slideNext()", 5000); //restart automatic slide switching
}
//
//Fade to previous slide in splash [no input]
//
function slidePrev()
{
	splashinterval=clearInterval(splashinterval);           
	var $active = $("#imagecontainer IMG.active");			 
	$active.stop();
	if ( $active.length == 0 )
	{														//////////////////////////////////
		$active = $("#imagecontainer IMG.slide:first");		//								//
	}														//								//
															//								//
	var $next= $active.prev().length ? $active.prev()		// See comments for slideNext()	//
		: $("#imagecontainer IMG.slide:last");				//								//
	$active.addClass("lastactive");							//								//
															//								//
	$next.css({opacity:0.0})								//////////////////////////////////
		.addClass("active")
		.animate({opacity: 1.0}, 500, function() {
			$active.removeClass("active lastactive");
		});
	splashinterval=setInterval( "slideNext()", 5000);
}
//
//Set up interval for auto slide switching
//
$(function() {
	splashinterval=setInterval( "slideNext()", 5000);
});
//
//END FUNCTION DECLARATION
//
//

//
//
//BEGIN DOCUMENT.READY CODE
//
//
$(document).ready(function(){
	
	$("#splash").mouseenter(
		function(){
			$('#rightarrow').stop().animate({left: '0px'},300,function(){
			//completion
			});
			$('#leftarrow').stop().animate({right: '0px'},300,function(){
			//completion
			});
			$('#textBox').stop().animate({bottom: '0px'},300,function(){
			//completion
			});
		}
	);
	
	$("#splash").mouseleave(
		function(){
			$('#rightarrow').stop().animate({left: '-20px'},300,function(){
			//completion
			});
			$('#leftarrow').stop().animate({right: '-20px'},300,function(){
			//completion
			});
			$('#textBox').stop().animate({bottom: '-50px'},300,function(){
			//completion
			});
		}
	);					
	//
	//When right arrow is clicked advance the slide to the next
	//
	$("#rightarrowanchor").click(
		function(){
			slideNext();
		}
	);
	//
	//When left arrow is clicked advance the slide to the previous
	//
	$("#leftarrowanchor").click(
		function(){
			slidePrev();
		}
	);

}
);
//
//
//END DOCUMENT.READY CODE
//
//
