sImgPath = "./images/"

// preload main images
var main = new Image(); main.src = sImgPath + "g6f Blackground.jpg";
var main1 = new Image(); main1.src = sImgPath + "BDP.gif";
var main2 = new Image(); main2.src = sImgPath + "MUFI.gif";
var main2a = new Image(); main2a.src = sImgPath + "MUFI.gif";
var main2b = new Image(); main2b.src = sImgPath + "MUFI.gif";
var main3 = new Image(); main3.src = sImgPath + "WTT.gif";

// preload promo images
var promo1_on = new Image(); promo1_on.src = sImgPath + "index_bdp.gif";
var promo1_off = new Image(); promo1_off.src = sImgPath + "index_bdp.gif";
var promo2_on = new Image(); promo2_on.src = sImgPath + "index.mufi.gif";
var promo2_off = new Image(); promo2_off.src = sImgPath + "index.mufi.gif";
var promo2a_on = new Image(); promo2a_on.src = sImgPath + "index.mufi.gif";
var promo2a_off = new Image(); promo2a_off.src = sImgPath + "index.mufi.gif";
var promo2b_on = new Image(); promo2b_on.src = sImgPath + "index.mufi.gif";
var promo2b_off = new Image(); promo2b_off.src = sImgPath + "index.mufi.gif";
var promo3_on = new Image(); promo3_on.src = sImgPath + "index_wtt.gif";
var promo3_off = new Image(); promo3_off.src = sImgPath + "index_wtt.gif";

// setup rotation details
iRotationIndex = 0;
aRotation = [
	["2","",promo2_on.src,promo2_off.src,main2.src],
	["2a","",promo2a_on.src,promo2a_off.src,main2a.src],
	["2b","",promo2b_on.src,promo2b_off.src,main2b.src]
]

function changePromos(iPromo,bOn){

	if (bOn) {
		if (iPromo == 2){
			document.getElementById("mainImg").src = aRotation[iRotationIndex][4];
			document.getElementById("promo2ImageLink").href = aRotation[iRotationIndex][1];
			document.getElementById("promo2DetailsLink").href = aRotation[iRotationIndex][1];
		}
		else document.getElementById("mainImg").src = eval('main' + iPromo + ".src");
		document.getElementById("promo" + iPromo + "Links").style.backgroundColor = '#FF0000';

		if(!(typeof oTimer == "undefined")) clearTimeout(oTimer);//pause rotation while mouse over

		switch (iPromo) {
			case 1:
				document.getElementById("promo1").src = promo1_on.src;
				document.getElementById("promo2").src = aRotation[iRotationIndex][3];
				document.getElementById("promo3").src = promo3_off.src;
				break;
			case 2:
				document.getElementById("promo1").src = promo1_off.src;
				document.getElementById("promo2").src = aRotation[iRotationIndex][2];
				document.getElementById("promo3").src = promo3_off.src;
				break;
			case 3:
				document.getElementById("promo1").src = promo1_off.src;
				document.getElementById("promo2").src = aRotation[iRotationIndex][3];
				document.getElementById("promo3").src = promo3_on.src;
				break;
		}

	}
	else {

		document.getElementById("mainImg").src = main.src;
		document.getElementById("promo" + iPromo + "Links").style.backgroundColor = '#0075B0';
		document.getElementById("promo1").src = promo1_off.src;
		document.getElementById("promo2").src = aRotation[iRotationIndex][3];
		document.getElementById("promo3").src = promo3_off.src;
		startRotation();
	}

}


function startRotation() {
	oTimer = setTimeout('promoImageRotation()',3500);
}


function promoImageRotation() {

	for (i=0;i<aRotation.length;i++) {
		if(document.getElementById("promo2").src.indexOf(aRotation[i][0] + "_") > -1) {
			iRotationIndex = (i == 2) ? 0 : i+1;
			document.getElementById("promo2").src = sImgPath + "promo" + aRotation[iRotationIndex][0] + "_off.gif";
			break;
		}
	}
	startRotation();

}

