// Switch and cross fade homepage functions

//global variables for use everywhere

var opacityVal=0; // variable used to calculate opacity
var selectedOpt="option_1"; // initial selected option
var timeVar; // timeout variable
var active="trig1"; // active option variable
var imgcount=1;

// 'switch' based image stack switching function

function bringTopSwitch(grab)	{
switch (grab)	{
	case 'trig1':
		var sel="option_1";
		var choice=document.getElementById(sel).style.zIndex;
		if (choice!=5)	{
			document.getElementById("option_1").style.zIndex=5;
			opacityVal=0;
			selectedOpt="option_1";
			TWCXfader();
			document.getElementById("option_2").style.zIndex--;
			document.getElementById("option_3").style.zIndex--;
			document.getElementById("option_4").style.zIndex--;
			document.getElementById("option_5").style.zIndex--;
			document.getElementById("hplink").href="http://www.thewhitecompany.com/content.aspx?cntcode=scents_content";
		}
		break;
	case 'trig2':
		var sel="option_2";
		var choice=document.getElementById(sel).style.zIndex;
		if (choice!=5)	{
			document.getElementById("option_2").style.zIndex=5;
			opacityVal=0;
			selectedOpt="option_2";
			TWCXfader();
			document.getElementById("option_1").style.zIndex--;
			document.getElementById("option_3").style.zIndex--;
			document.getElementById("option_4").style.zIndex--;
			document.getElementById("option_5").style.zIndex--;
			document.getElementById("hplink").href="http://www.thewhitecompany.com/content.aspx?cntcode=bedroom_content";
		}
		break;
	case 'trig3':
		var sel="option_3";
		var choice=document.getElementById(sel).style.zIndex;
		if (choice!=5)	{
			document.getElementById("option_3").style.zIndex=5;
			opacityVal=0;
			selectedOpt="option_3";
			TWCXfader();
			document.getElementById("option_1").style.zIndex--;
			document.getElementById("option_2").style.zIndex--;
			document.getElementById("option_4").style.zIndex--;
			document.getElementById("option_5").style.zIndex--;
			document.getElementById("hplink").href="http://www.thewhitecompany.com/content.aspx?cntcode=clothing_content";
		}
		break;
	case 'trig4':
		var sel="option_4";
		var choice=document.getElementById(sel).style.zIndex;
		if (choice!=5)	{
			document.getElementById("option_4").style.zIndex=5;
			opacityVal=0;
			selectedOpt="option_4";
			TWCXfader();
			document.getElementById("option_1").style.zIndex--;
			document.getElementById("option_2").style.zIndex--;
			document.getElementById("option_3").style.zIndex--;
			document.getElementById("option_5").style.zIndex--;
			document.getElementById("hplink").href="http://www.thewhitecompany.com/content.aspx?cntcode=babies_content";
		}
		break;
	case 'trig5':
   		var sel="option_5";
		var choice=document.getElementById(sel).style.zIndex;
		if (choice!=5)	{
			document.getElementById("option_5").style.zIndex=5;
			opacityVal=0;
			selectedOpt="option_5";
			TWCXfader();
			document.getElementById("option_1").style.zIndex--;
			document.getElementById("option_2").style.zIndex--;
			document.getElementById("option_3").style.zIndex--;
			document.getElementById("option_4").style.zIndex--;
			document.getElementById("hplink").href="http://www.thewhitecompany.com/content.aspx?cntcode=children_content";
		}
		break;
	}
}



// cross fader function

function TWCXfader()	{
if (opacityVal==105)	{
	clearTimeout(timeVar);
	}
else	{
	// for IE browsers on Windows
	if (navigator.appName=="Microsoft Internet Explorer")	{
		document.getElementById(selectedOpt).filters.alpha.opacity=opacityVal;
		// document.getElementById('opval').innerHTML=opacityVal; for feedback only
		opacityVal=opacityVal+5;
		var timeVar=setTimeout("TWCXfader()",40);
		}
	//for safari 3.x, safari 4.x, firefox 3, firfox 3.5, chrome 2.x
	else	{
		document.getElementById(selectedOpt).style.opacity=opacityVal/100;
		opacityVal=opacityVal+5;
		var timeVar=setTimeout("TWCXfader()",40);
		}
	}	
}

// mousing FX - bling functions


function setSelected2(tabClicked)	{
active=tabClicked;
tempStrRpl=tabClicked.replace("trig","tab_");
document.getElementById('trig1').src="supplyimages/twc/homepage/newness/tab_1_inactive.jpg";
document.getElementById('trig2').src="supplyimages/twc/homepage/newness/tab_2_inactive.jpg";
document.getElementById('trig3').src="supplyimages/twc/homepage/newness/tab_3_inactive.jpg";
document.getElementById('trig4').src="supplyimages/twc/homepage/newness/tab_4_inactive.jpg";
document.getElementById('trig5').src="supplyimages/twc/homepage/newness/tab_5_inactive.jpg";
document.getElementById(tabClicked).src="supplyimages/twc/homepage/newness/"+tempStrRpl+"_active.jpg";
}
