﻿	var currentDiv = 'landing' ;
	var nextDivToSet = '' ;
	
	function setBoxBGColor(divname) { 
	
		if (document.getElementById(divname) && (currentDiv == 'landing')) 
			document.getElementById(divname).style.backgroundColor = '#CEF5F2';
	}
	
	function setBoxNormalColor(divname) {
		if (document.getElementById(divname))
			document.getElementById(divname).style.backgroundColor = '#E4F3F2';
	}
	
	function SetImageRollOver(imagename) {
		if (document.getElementById(imagename)) 
			document.getElementById(imagename).style.backgroundPosition = '-364px';
	}
	
	function SetImageRollOut(imagename) {
		if (document.getElementById(imagename) && (imagename != nextDivToSet ) ) 
			document.getElementById(imagename).style.backgroundImage= '' ;
	}
	
	function SetActiveBtn(btnname) {
		btnname = "btn_" + btnname;
		if (document.getElementById(btnname)) 
			document.getElementById(btnname).style.backgroundPosition = '0 -364px';
	}
	
	function SetInactiveBtn(btnname) {
		btnname = "btn_" + btnname;
		if (document.getElementById(btnname)) 
			document.getElementById(btnname).style.backgroundPosition = '0 0';
	}
	
	function SetRolloverBtn(btnname) {
		if (currentDiv != btnname) {
			btnname = "btn_" + btnname;
			if (document.getElementById(btnname))
				if (currentDiv != btnname)
					document.getElementById(btnname).style.backgroundPosition = '0 -182px';
		}
	}
	
	function SetRolloutBtn(btnname) {
		if (currentDiv != btnname) {
			btnname = "btn_" + btnname;
			if (document.getElementById(btnname))
					document.getElementById(btnname).style.backgroundPosition = '0 0';
		}
	}
	
	function ShowHide(shownblock, hiddenblock) {
		var landingBlock = document.getElementById(shownblock + "Div") ;
		if ( !(landingBlock) ) { 
			landingBlock = document.getElementById(shownblock) ;
		}
		
		var preBlock = document.getElementById(hiddenblock + "Div") ;
		if ( !(preBlock) ) {
			preBlock = document.getElementById(hiddenblock) ;
		}
		
		if ( landingBlock && preBlock ) {
			// NOTE: this section turns off old div and turns on new
			// should instead leave divs turned on and shuffle them with z-index
			//with one shuffling to top having it's image opac'ed to zero to start and fade in
			landingBlock.style.display = "none" ;
			landingBlock.style.visibility = "hidden" ;
			preBlock.style.display = "block";
			preBlock.style.visibility = "visible" ;
		}
	}
	
	function setArrowOn(divname) {
		var divObj = document.getElementById(divname + '_arrow') ;
		var containingDiv = document.getElementById(divname) ;
		
		if ( divObj ) {
		   // alert("Turning on arrow " + divname ) ;
			divObj.style.position = "relative" ;
			divObj.style.border = "solid 1px red" ;
			divObj.style.top = "10px" ;
			divObj.style.left = "-90px" ;
			divObj.style.zIndex = "1000" ;
			divObj.style.display = "inline" ;
			divObj.style.visibility = "visible" ;
			//containingDiv.style.width = "134px" ;
			//containingDiv.backgroundRepeat = "no-repeat" ;
		   /* divObj.style.backgroundImage = "url('images/arrow.gif')" ;*/
		}
	}
	
	function setArrowOff(divname) { 
		var divObj = document.getElementById(divname + '_arrow') ;
		
		if ( divObj) { 
			divObj.style.display = "none" ;
			divObj.style.visibility = "hidden" ;
		}
	}
	
	function SetCurrentDiv(nextDiv) {
	
 	   if (currentDiv == nextDiv) return;
		//setArrowOn(nextDiv)
		switch(nextDiv) {
			case 'pre' :
			   SetInactiveBtn('fasten');
			   SetInactiveBtn('add') ;
			   SetInactiveBtn('swirl') ;
			   SetInactiveBtn('turnover') ;
			   break;
			case 'fasten' :
			   SetActiveBtn('fasten');
			   SetInactiveBtn('add') ;
			   SetInactiveBtn('swirl') ;
			   SetInactiveBtn('turnover') ;
			   break ;
			case 'add' :
			   SetInactiveBtn('fasten');
			   SetActiveBtn('add') ;
			   SetInactiveBtn('swirl') ;
			   SetInactiveBtn('turnover') ; 
			   break ;
			case 'swirl' :
			   SetInactiveBtn('fasten');
			   SetInactiveBtn('add') ;
			   SetActiveBtn('swirl') ;
			   SetInactiveBtn('turnover') ;
			   break ;
			case 'turnover' :
			   SetInactiveBtn('fasten');
			   SetInactiveBtn('add') ;
			   SetInactiveBtn('swirl') ;
			   SetActiveBtn('turnover') ;
			   break ;
			case 'post' :
			   SetInactiveBtn('fasten');
			   SetInactiveBtn('add') ;
			   SetInactiveBtn('swirl') ;
			   SetInactiveBtn('turnover') ;
			   break;
	   }
	   
	   
	   if (currentDiv == "landing") {
		   ShowHide(currentDiv, nextDiv) ;
		   document.getElementById('FAST_box_landing').style.height = "640px";
	   } else {
		   //set all divs except current to z-index:400
		   //alert('CurrentDiv is ' + currentDiv);
		   if (currentDiv != "pre") document.getElementById("preDiv").style.zIndex = "400";
		   if (currentDiv != "fasten") document.getElementById("fastenDiv").style.zIndex = "400";
		   if (currentDiv != "add") document.getElementById("addDiv").style.zIndex = "400";
		   if (currentDiv != "swirl") document.getElementById("swirlDiv").style.zIndex = "400";
		   if (currentDiv != "turnover") document.getElementById("turnoverDiv").style.zIndex = "400";
		   if (currentDiv != "post") document.getElementById("postDiv").style.zIndex = "400";
		   fadeDiv(currentDiv, nextDiv, 500);
	   }
	   
	   currentDiv = nextDiv ;
	   
   } /* end function SetCurrentDiv */

/* blend transparency functions */
function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function shiftOpacity(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
	if(document.getElementById(id).style.opacity == 0) {
		opacity(id, 0, 100, millisec);
	} else {
		opacity(id, 100, 0, millisec);
	}
}

function blendimage(divid, imageid, imagefile, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	//set the current image as background
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	
	//make image transparent
	changeOpac(0, imageid);
	
	//make new image
	document.getElementById(imageid).src = imagefile;

	//fade in image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function currentOpac(id, opacEnd, millisec) {
	//standard opacity is 100
	var currentOpac = 100;
	
	//if the element has an opacity set, get it
	if(document.getElementById(id).style.opacity < 100) {
		currentOpac = document.getElementById(id).style.opacity * 100;
	}

	//call for the function that changes the opacity
	opacity(id, currentOpac, opacEnd, millisec)
}

function shuffleTop(sendDown, sendUp) {
	var descender = document.getElementById(sendDown + "Div") ;
	if ( !(descender) ) { 
		descender = document.getElementById(sendDown) ;
	}
	
	var ascender = document.getElementById(sendUp + "Div") ;
	if ( !(ascender) ) {
		ascender = document.getElementById(sendUp) ;
	}
	
	if ( descender && ascender ) {
		// NOTE: this section turns off old div and turns on new
		// should instead leave divs turned on and shuffle them with z-index
		//with one shuffling to top having it's image opac'ed to zero to start and fade in
		
		// old way of turning divs off/on
		/*descender.style.display = "none" ; 
		descender.style.visibility = "hidden" ;
		ascender.style.display = "block";
		ascender.style.visibility = "visible" ;*/
		
		// new way of fading div img in
		fadeDiv(sendDown, sendUp, 500);
	}
}

function fadeDiv(divDown, divUp, millisec) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	
	imageid = divUp + "Img";
	divUp = divUp + "Div";
	divDown = divDown + "Div";
	//alert('ImageID = ' + imageid);
	
	//make ascender's img transparant
	changeOpac(0, imageid);
	
	// reveal ascender, set to z-index 500
	ascender = document.getElementById(divUp);
	ascender.style.zIndex = "500"
	ascender.style.display = "block";
	ascender.style.visibility = "visible" ;

	//move descender down
	document.getElementById(divDown).style.zIndex = "450";
	
	//fade in ascender image
	for(i = 0; i <= 100; i++) {
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}


	
