/*
(C) copyright 2009 by jeff clemmer, chris sehenuk, and detour sites.

all rights reserved.

http://detoursites.com/
*/

//delay between frames
var navTimeOut=70;
//holds what each animation has in terms of the max frame
var navFrameCounts=[5,5,5,5,5,4,3,4,4];
//holds the current frame for the various buttons
var navButtonCurFrames=[0,0,0,0,0,0,0,0,0];
//if a button is being animated, it is 1, if its being unanimated, it's 0
var navButtonSituation=[0,0,0,0,0,0,0,0,0];
//holds the ids of the buttons that get updated
var navIds=["illustrationbut","designbut","logosbut", "apparelbut","multimediabut","penbut","paperclipbut", "nextarrowbut", "prevarrowbut"];
//start filenames for each animation
var navFilenames=["illobutton1","designbutton1", "logosbutton1","apparelbutton1","multimediabutton1","pen1","paperclip1", "nextarrow1", "prevarrow1"];

var navAnimationRunning=false;

function navButtonOn(id)
{
	
	for (var t=0;t<navButtonSituation.length;t++) {
	
		if (navIds[t]==id) {
			
			navButtonSituation[t]=1;
			if (navAnimationRunning==false) {
				navAnimationRunning=true;
				setTimeout(doNavAnimation, navTimeOut);
			}
			break;
			
		}
	
	}

}

function navButtonOff(id)
{
	
	for (var t=0;t<navButtonSituation.length;t++) {
	
		if (navIds[t]==id) {
			
			navButtonSituation[t]=0;
			
			if (navAnimationRunning==false) {
				navAnimationRunning=true;
				setTimeout(doNavAnimation, navTimeOut);
			}
			
			break;
			
		}
	
	}

}

function doNavAnimation()
{
	var doAgain=false;

	for (var t=0;t<navButtonSituation.length;t++) {
	
		//are we winding and still need to wind?
		if (navButtonSituation[t]==1 && navButtonCurFrames[t] < navFrameCounts[t]) {
		
			navButtonCurFrames[t]++;
			assocAnimation(navIds[t], navFilenames[t], navButtonCurFrames[t]);
			
			doAgain=true;
		
		}
	
		if (navButtonSituation[t]==0 && navButtonCurFrames[t] > 0) {
		
			navButtonCurFrames[t]--;
			assocAnimation(navIds[t], navFilenames[t], navButtonCurFrames[t]);
			
			doAgain=true;
		
		}

	}
	
	if (doAgain==true)
		setTimeout(doNavAnimation, navTimeOut);
	else
		navAnimationRunning=false;

}

