

var splashResetInt = 0 ;
var splashFadeInt = 0 ;
var splashCount = 5;
var thisSplash = "";
var prevSplash = "";
var activeZ = -100;
var fadeOutSpeed = 400;
var fadeInSpeed = 400;

var execDelay = 300;
var resetSpeed = 150;

function splash_init($){

	$("#splashOverlay").mouseover(function () {
		clearInterval(splashResetInt);
		clearInterval(splashFadeInt);
	});
	$("#splashOverlay").mouseout(function () {
		splashResetInt = setTimeout(function(){resetSplash()}, resetSpeed)
	});
	$("#splashButtons div").mouseover(function () {
		setSplash(this.id);
	}); 
	$("#splashButtons div").mouseout(function () {
		splashResetInt = setTimeout(function(){resetSplash()}, resetSpeed)
	});			 
}

function setSplash(id){

	thisSplash = id.substr(id.indexOf("_")+1);
	
	clearInterval(splashResetInt);
	clearInterval(splashFadeInt);
		
	splashFadeInt = setTimeout(function(){
				
		for(i=1;i<=splashCount;i++){
			if(thisSplash!=i){
				
				$("div#splash_"+i).fadeOut(fadeOutSpeed, '');
				$("div#splashBtnDivOn_"+i).fadeOut(fadeOutSpeed, '');
			}
		}
		
		$("div#splash_0").fadeOut(fadeOutSpeed, '');	
				
		$("div#splash_"+thisSplash).fadeIn(fadeInSpeed, function(){});		
		
		$("div#splashBtnDivOn_"+thisSplash).fadeIn(fadeInSpeed, '');
				
		activeZ++;
	
		prevSplash = thisSplash;
		
	},execDelay)
}

function resetSplash(){
	
	clearInterval(splashFadeInt);
		   
	if(prevSplash.length>0){
		$("div#splash_"+prevSplash).fadeOut(fadeOutSpeed, '');
		$("div#splashBtnDivOn_"+prevSplash).fadeOut(fadeOutSpeed, '');
				
		$("div#splash_0").fadeIn(fadeInSpeed, '');
	}
}

