// Carousel Functions

// global variables for use everywhere on this carousel

// Array for links of carousel images
var carouselLinks=["http://www.thewhitecompany.com/category.aspx?id=1000805","http://www.thewhitecompany.com/category.aspx?ID=1000768","http://www.thewhitecompany.com/category.aspx?id=1000817","http://www.thewhitecompany.com/category.aspx?ID=1000792","http://www.thewhitecompany.com/category.aspx?ID=1000786","http://www.thewhitecompany.com/category.aspx?ID=1000829","http://www.thewhitecompany.com/category.aspx?ID=2000125","http://www.thewhitecompany.com/category.aspx?ID=1000812","http://www.thewhitecompany.com/category.aspx?ID=1000773","http://www.thewhitecompany.com/category.aspx?ID=1000785"]

var TWCcount1=0;
var arrayLength1=carouselLinks.length;
var leftpos=0;
var objID123="ribbon";
var ribbonLength=(arrayLength1*225)+((arrayLength1-1)*14); // previously *197 in first bracket and *10 in second bracket
var windowLength=ribbonLength-710;
var timeVar2;
var countme=0;
var release="sp10wk3";

function writeToPage()	{
if (TWCcount1<arrayLength1)	{
	if (TWCcount1==0)	{
		document.write("<a href=\""+carouselLinks[TWCcount1]+"\"><img id=\"carouselendleft\" src=\"SupplyImages/twc/homepage/newness/carousel_"+release+"_"+(TWCcount1+1)+".jpg\" width=\"225px\" height=\"138px\" border=\"0\" /></a>");
		TWCcount1++;
		}
	else if (TWCcount1==arrayLength1-1) {
		document.write("<a href=\""+carouselLinks[TWCcount1]+"\"><img id=\"carouselendright\" src=\"SupplyImages/twc/homepage/newness/carousel_"+release+"_"+(TWCcount1+1)+".jpg\" width=\"225px\" height=\"138px\" border=\"0\" /></a>");
		TWCcount1++;
		}
	else	{
		document.write("<a href=\""+carouselLinks[TWCcount1]+"\"><img class=\"carouselmid\" src=\"SupplyImages/twc/homepage/newness/carousel_"+release+"_"+(TWCcount1+1)+".jpg\" width=\"225px\" height=\"138px\" border=\"0\" /></a>");
		TWCcount1++;
		}
	writeToPage();
	}
else	{
	TWCcount1=0;
	}
}



// set length of ribbon at runtime function

function setLength()	{
	document.getElementById(objID123).style.width=ribbonLength+"px"; // previsouly used objID variable
}

// detectors for IE6 and IE7

function correctors()	{
var brwsN=navigator.appName;
var brwsV=navigator.appVersion;
var brwsCheck=brwsV.indexOf("MSIE 6.0");
var brwsCheck2=brwsV.indexOf("MSIE 7.0");


if (brwsCheck>(-1) || brwsCheck2>(-1))	{
	document.getElementById('ribbonContainer').style.position="absolute";
	}

}

// move left UI function

function moveleft()	{
if (leftpos==0)	{
	clearTimeout(timeVar2);
	document.getElementById('left_button').src="SupplyImages/twc/homepage/newness/arrow_left_end.jpg";
	countme=0;
	}
else {
	if	(leftpos<windowLength)	{
		document.getElementById('right_button').src="SupplyImages/twc/homepage/newness/arrow_right.jpg";
		}
	leftpos=leftpos-20;
	document.getElementById('ribbon').style.left=-(leftpos-10)+"px";
	countme=countme+20;
	if (countme>=710)
	{
		stopmove();
		countme=0;
	}
	else
	{
	timeVar2=setTimeout("moveleft()",10);
	}
	}
}


// move right UI function

function moveright()	{
if (leftpos>=windowLength)	{
	clearTimeout(timeVar2);
	document.getElementById('right_button').src="SupplyImages/twc/homepage/newness/arrow_right_end.jpg";
	countme=0;
	}
else {
	if	(leftpos>1)	{
		document.getElementById('left_button').src="SupplyImages/twc/homepage/newness/arrow_left.jpg";
		}
	leftpos=leftpos+20;
	document.getElementById('ribbon').style.left=-(leftpos-10)+"px";
	countme=countme+20;
	if (countme>=710)
	{
		stopmove();
		countme=0;
	}
	else
	{
	timeVar2=setTimeout("moveright()",10);
	}
	
	}
}


// function to stop moving ribbon

function stopmove()	{
clearTimeout(timeVar2);
}