// select country fader - English, orange

var countryURL = "/educationportal/preference/selectCountry.do?cid=US";
var colorChangeSpeed = "110";				
var countryChangeSpeed = "2310";
var loopNumber = 2;
var colorCount = "0";
var countryCount = "0";
var loopCount = "0";
var timerID = "0";
var timeOutID = "0";

var countries = new Array (
	"SELECT COUNTRY",				// ENGLISH																											
	"SELECTIONNER LE PAYS",	// FRENCH																											
	"ELIJA UN PAÍS",				// SPANISH																										
	"<span style='font-size:9px;'>&#36873;&#25321;&#22269;&#23478;</span>", // CHINESE
	"LAND AUSWÄHLEN" 				// GERMAN																							
);

var colors = new Array ( 
	'#ffffff', //start with color white
	'#fff6f1', 
	'#fefaf7',
	'#fef0e5',
	'#feebdd', 
	'#fee4d3',
	'#fdddc5', 
	'#fdd6b9',
	'#fbceaa', 
	'#fbc69e',
	'#fabe90', 
	'#f9b681',
	'#f9ad74', 
	'#f8a768',
	'#f89f5a', 
	'#f9974c',
	'#f78f41', 
	'#f58a38',
	'#f6842e', 
	'#f68028',
	'#f57c1f'	//end with color orange
);

function fade() {
	colorCount = "0";
	switchColor();
	timerID = window.setInterval("switchColor()", countryChangeSpeed);
}

function switchColor() { 		
	if (countryCount < countries.length && loopCount < loopNumber) {	
		if (colorCount < colors.length) {
			fader.innerHTML = "<a href='" + countryURL + "' class='ts_3_11_b' style='color:" + colors[colorCount] + "' onMouseover='stopFading();'>" + countries[countryCount] + "</a>"; 												
			colorCount++;
  		timeOutID = setTimeout("switchColor()", colorChangeSpeed);   
		} else {
			colorCount = "0";		
    	countryCount++;	
		}
	}	else { // last country		
		if (loopCount == loopNumber - 1) {
			clearInterval(timerID); 	
			fader.innerHTML = "<a href='" + countryURL + "' class='ts_3_11_b' style='color:" + colors[0] + "'>" + countries[0] + "</a>"; 	
		}	else { // keep looping	
			loopCount++;
			countryCount = "0";
			colorCount = "0";
			switchColor();
		}
	}
}  

function stopFading() {
	clearInterval(timerID);
	clearTimeout(timeOutID);	
	if (countryCount == countries.length ) {	//display last country of one loop (German)	
		fader.innerHTML = "<a href='" + countryURL + "' class='ts_3_11_b' style='color:" + colors[0] + "' onMouseout='fade();'>" + countries[countries.length - 1] + "</a>"; 					
	}	else {
		fader.innerHTML = "<a href='" + countryURL + "' class='ts_3_11_b' style='color:" + colors[0] + "' onMouseout='fade();'>" + countries[countryCount] + "</a>"; 							
	}
}