

//globals
var glb_statePos = 0;

//dynamic color array
var ary_colors=new Array();
	ary_colors[0] = "#000000";
	ary_colors[1] = "#ff7f00";
	ary_colors[2] = "#e62e4c";
	ary_colors[3] = "#0072bc";
	ary_colors[4] = "#7fbf00";

//function used to toggle colors
function fnc_passColor(par_targetState,par_targetColor) {
	//check state
	if(par_targetState==1) {
		//change color
		document.getElementById("stageColor3").style.backgroundColor = par_targetColor;
		//show item
		document.getElementById("stageColor3").style.display = "block";
	} else {
		//hide item
		document.getElementById("stageColor3").style.display = "none";		
	}
}

//function used to initialize color fading
function fnc_initColors() {
	//set front color
	fnc_setColor(2)
	//set back color
	fnc_setColor(1)
	//start process
	fnc_startColorize()
}

//function used to set colors
function fnc_setColor(par_targetColor) {

	//internal vars
	var var_color1
	var var_color2

	//check if last item
	if(glb_statePos+1==ary_colors.length) {
		//define back color
		var_color1 = ary_colors[1]
		//define front color
		var_color2 = ary_colors[glb_statePos]
	} else {
		//define back color
		var_color1 = ary_colors[glb_statePos+1]		
		//define front color
		var_color2 = ary_colors[glb_statePos]
	}	

	//check if front or back
	if(par_targetColor==1) {
		//change back color
		document.getElementById("stageColor1").style.backgroundColor = var_color1;

	} else {
		//change front color
		document.getElementById("stageColor2").style.backgroundColor = var_color2;
		//show front
		document.getElementById("stageColor2").style.opacity = 1.0;
		document.getElementById("stageColor2").style.filter = 'alpha(opacity=' + 100 + ')';
	}
	
}

//function used to set up the fade
function fnc_startColorize() {
	//setup 100 stages
	for (var i=0;i<101;i++) {
		//call for timeout
		setTimeout('fnc_setOpacity('+( 100-i )+')', (100*i) );
	}

	//add to statePos
	glb_statePos++

	//check if last item
	if(glb_statePos==ary_colors.length) {
		//reset
		glb_statePos = 1;
	}

}

//function used to change opacity
function fnc_setOpacity(par_value) {
	//change opacity
	document.getElementById("stageColor2").style.opacity = (par_value/100);
	document.getElementById("stageColor2").style.filter = 'alpha(opacity=' + par_value + ')';
	//check if finished
	if (par_value==0) {
		//set front color
		setTimeout('fnc_setColor(2)',1000)
		//set back color
		setTimeout('fnc_setColor(1)',2000)
		//start process
		setTimeout('fnc_startColorize()',3000)
	}
}



















