//------------------ Superior Manufacturing Home Page: SupManuHome.aspx----------------------//
function ChangeTopMenuColor(idwhat, whichway)
{
	if (whichway == "IN")
	{
		document.all.item(idwhat).style.backgroundColor = "rgb(109,0,0)"; //"rgb(255,102,0)";
		document.all.item(idwhat).style.borderLeft = "rgb(109,0,0) 2px solid";//"rgb(255,102,0) 2px solid";
		document.all.item(idwhat).style.borderRight = "rgb(144,10,7) 2px solid"; // to seperate this cell from the next.
		document.all.item(idwhat).style.color = "rgb(255,168,0)" //"rgb(255,204,0)"
		switch (idwhat)	//show the respective drop down menu
		{
			case 'tdDiv':
				document.all['imgline'].style.visibility = 'hidden';
				document.all['Divisions'].style.visibility = 'visible';
				break
			case 'tdPro':
				document.all['Products'].style.visibility = 'visible';
				break
			case 'tdSer':
				document.all['Services'].style.visibility = 'visible';
				break
			case 'tdInd':
				document.all['Industries'].style.visibility = 'visible';
				break
		}
	}
	else
	{
		document.all.item(idwhat).style.backgroundColor = "rgb(197,0,0)";
		document.all.item(idwhat).style.borderLeft = "rgb(255,0,0) 2px solid";
		document.all.item(idwhat).style.borderRight = "rgb(144,10,7) 2px solid";
		document.all.item(idwhat).style.color = "rgb(255,255,255)"
		document.all['imgline'].style.visibility = 'visible';
		hideMenu()
	}
}

function initialize()
{
	hideMenu()
	//startTicker()
	document.all.item("imgBannerExt").src = "../images/Superior/suptopban14a.jpg"
}

function hideMenu()
{
	document.all['Divisions'].style.visibility = 'hidden';
	document.all['Products'].style.visibility = 'hidden';
	document.all['Services'].style.visibility = 'hidden';
	document.all['Industries'].style.visibility = 'hidden';
	document.all['SUPERIOR Products'].style.visibility = 'hidden';
	//document.all['Logistics'].style.visibility = 'hidden';
	document.all['Media'].style.visibility = 'hidden';
}

function subMenuEffects(idwhat, whichway)
{
	if (whichway == "IN")
	{
		document.all.item(idwhat).style.backgroundImage = "url(../images/Superior/supmenuhl.gif)"
		document.all.item(idwhat).style.color = "rgb(255,204,0)"
	}
	else
	{
		document.all.item(idwhat).style.backgroundImage = "none" //"url(../images/Home/searchgradient.gif)"
		document.all.item(idwhat).style.backgroundColor = "rgb(255,255,255)"
		document.all.item(idwhat).style.color = "rgb(77,77,77)"
	}
	
}

function ChangeMenuBkgd(idwhat, whichway)
{
	var bVisibleHidden
	if (whichway == "IN")
	{
		//document.all.item(idwhat).style.backgroundColor = "rgb(255,102,0)"
		document.all.item(idwhat).style.backgroundImage = "url(../images/Superior/supmenuhl.gif)"
		document.all.item(idwhat).style.color = "rgb(255,204,0)"
		document.all.item('img'+ idwhat).src = "../images/Superior/arrowhl.gif"
		hideMenu()
		bVisibleHidden = 'visible'
		
	}
	else
	{
		document.all.item(idwhat).style.backgroundImage = "none"
		document.all.item(idwhat).style.backgroundColor = "rgb(255,255,255)"
		document.all.item('img'+ idwhat).src = "../images/WRS/wrsmenuarrow.gif"
		document.all.item(idwhat).style.color = "rgb(77,77,77)"
		bVisibleHidden = 'hidden'
	}
	switch(idwhat)
		{
			case 'tdM1':
				document.all.item('SUPERIOR Products').style.visibility = bVisibleHidden;
				break
			case 'tdM5':
				//document.all['Logistics'].style.visibility = bVisibleHidden;
				break
			case 'tdM6':
				document.all['Media'].style.visibility = bVisibleHidden;
				break
		}
	
}

function ChangeCatStyle(idwhat,whichway)
{
	if (whichway == "IN")
	{
		document.all.item(idwhat).src = "../images/WRS/wrscategarrowhl.gif"
		idwhat = idwhat.replace('img','td')
		document.all.item(idwhat).style.color = "rgb(197,0,0)"
	}
	else
	{
		document.all.item(idwhat).src = "../images/WRS/wrsmenuarrow.gif"
		idwhat = idwhat.replace('img','td')
		document.all.item(idwhat).style.color = "rgb(77,77,77)"
	}
}

/*function ChangeBanner(idwhatto)
{
	if (idwhatto == 0)
	{
		var imgname;
		imgname = document.all.item('imgStopPause').src;
		//alert (imgname)
		if (imgname.indexOf("supproplay") != -1) // => Play
		{
			document.all.item('imgStopPause').src = "../images/Superior/SuperiorPipelayer/suppropause.gif"
			idwhatto = '0';
		}
		else
		{
			document.all.item('imgStopPause').src = "../images/Superior/SuperiorPipelayer/supproplay.gif"
			idwhatto = '-1';
		}
	}
	//alert(idwhatto);
	if (idwhatto < 0) rotate('6000');	//PLAY	
	else
	{
		rotate('-1') //STOP
		// Change all navigation links color back to gray
		for (i=1;i<=4;i++)
			document.all.item('tdNav' + i).style.color = "rgb(125,125,125)"
		//alert("in else");
		if (idwhatto > 9)
		{
			//alert ("in else - if");
			document.all.item('imgBanner').src = "../images/Superior/SuperiorPipelayer/BannerAds/Pipelayers/SupBan" + idwhatto + ".jpg"
			document.all.item('imgStopPause').src = "../images/Superior/SuperiorPipelayer/suppropause.gif"
			document.all.item('tdNav' + idwhatto).style.color = "rgb(239,186,0)"//"rgb()"125,125,125
		}
		else
			if (idwhatto != 0) //STOP
			{
				//alert ("in else - else - if");
				document.all.item('imgBanner').src = "../images/Superior/SuperiorPipelayer/BannerAds/Pipelayers/SupBan0" + idwhatto + ".jpg"
				document.all.item('imgStopPause').src = "../images/Superior/SuperiorPipelayer/suppropause.gif"
				document.all.item('tdNav' + idwhatto).style.color = "rgb(239,186,0)"//"rgb(239,186,0)"
				
			}
	}
}*/

function Productload()
{
	window.setTimeout('rotate(6000);',6000);
	init();
}

//--- Fade out style for the Sale Menu on the top instead of the blinking effect---//


function makearray(n) {
    this.length = n;
    for(var i = 1; i <= n; i++)
        this[i] = 0;
    return this;
}

hexa = new makearray(16);
for(var i = 0; i < 10; i++)
    hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";

function hex(i) {
    if (i < 0)
        return "00";
    else if (i > 255)
        return "ff";
    else
       return "" + hexa[Math.floor(i/16)] + hexa[i%16];}

function setbgColor(r, g, b, element) {
      var hr = hex(r); var hg = hex(g); var hb = hex(b);
      element.style.color = "#"+hr+hg+hb;
}

function fade(sr, sg, sb, er, eg, eb, step, direction, element){
    for(var i = 0; i <= step; i++) {
setTimeout("setbgColor(Math.floor(" +sr+ " *(( " +step+ " - " +i+ " )/ " +step+ " ) + " +er+ " * (" +i+ "/" +step+ ")),Math.floor(" +sg+ " * (( " +step+ " - " +i+ " )/ " +step+ " ) + " +eg+ " * (" +i+ "/" +step+ ")),Math.floor(" +sb+ " * ((" +step+ "-" +i+ ")/" +step+ ") + " +eb+ " * (" +i+ "/" +step+ ")),"+element+");",i*step);
    }
}

function fadeout(element) {
          
    fade(253,253,5, 255,255,255, 30, 1, element);
}

function fadein(element) {
    fade(255,255,255, 253,253,5, 23, 1, element);
}

// ---- Superior Product OverView

// Right Click disable...
//function click()
//{ 
//	if (event.button==2) 
//		alert('Right Click Disabled'); 
//}
//document.onmousedown=click


function bookmark()
{
	window.external.AddFavorite('http://www.wwmach.com', 'Worldwide machinery');
}

var idwhichpage = '0'// This variable helps to set the highlighted color for the current page in the Menu, and not loose it in mouse over/out functionality

function SupProLeftMenu(whichway,idwho,idConstruct,shade)
{
	var isGallery = false
	// to check if it is the Gallery related menu.
	if (idwho.substr(0,1) == "G")
		isGallery = true
	if (idwho != idwhichpage)
	{
		if (whichway == "IN")
		{
			if (idConstruct == 'UC')
			{
				document.all.item('tdLM' + idwho).style.backgroundImage = "url(../images/Under-Construction.gif)"
				document.all.item('tdLM' + idwho).style.backgroundRepeat = "no-repeat"
			}
			
			if (! isGallery)
				document.all.item('imgLM' + idwho).src = "../images/Superior/SuperiorPipelayer/supproredarrowright.gif"
			else
				document.all.item('tdLM' + idwho).style.backgroundColor = "#EFEFEF";
				
			document.all.item('tdLM' + idwho).style.color = "rgb(197,0,0)";
		}
		else
		{
			if (! isGallery)
				document.all.item('imgLM' + idwho).src = "../images/Superior/SuperiorPipelayer/supproredarrowgray.gif"
			else
				document.all.item('tdLM' + idwho).style.backgroundColor = "#FFFFFF";

			if (shade == 'DARK')
				document.all.item('tdLM' + idwho).style.color = "rgb(37,37,37)";
			else
				document.all.item('tdLM' + idwho).style.color = "rgb(125,125,125)";

			document.all.item('tdLM' + idwho).style.backgroundImage = "none"
		}
	}
}

function initBuildUROwn()
{
	//init()
	//document.all.trGlide.style.height = "1px"
	//document.all.trGlide.style.visibility = "hidden"
	AddElements()
	//Calculate MSRP
	CalculateMSRP()
	document.all.item('txtBoom').style.visibility = "hidden";
	document.all.item('txtPaintChoice').style.visibility = "hidden";
	ChangeProductBanner('2', 'IN')
	var Desc = '<table cellspacing="0" cellpadding="0" border="0">'
	Desc += '<tr><td align="left" class="PCBUOSpecSubHeading"><br>SP-572 is converted from a D7 conventional tractor<br><br>CPX-572 is converted from a 572 mechanical pipelayer</td></tr>'
	
	Desc += '</table>'
	document.all.item('divDescription').innerHTML = Desc
	
}

function initBuildUROwnconfirm()
{
	AddElements()
}
/*function ProductDetailOverviewinit()
{
	window.setTimeout('rotate(6000);',6000);
	//init();
	ChangeProductBanner('2', 'IN')
}

function ProductDetailinit()
{
	divglide.style.posLeft =25
	divglide.style.active = true
	ChangeProductBanner('2', 'IN')
}*/

function getCookieData(labelName)// BYOSel for Build your own selections
{
	var labellen = labelName.length
	//read cookie property only once for speed
	var cookieData = document.cookie
	var cLen = cookieData.length
	//alert('in here: ' + cLen)
	var i = 0
	var cEnd
	while (i < cLen)
	{
		var j = i + labellen
			
		if  (cookieData.substring(i,j) == labelName)
		{
			cEnd = cookieData.indexOf(";",j)
			if (cEnd == -1)
			{
				cEnd = cookieData.length
			}
	//alert('cookie value :' + unescape(cookieData.substring(j+1, cEnd)))
			return unescape(cookieData.substring(j+1, cEnd))
		}
		i++
	}
	return "what ever"
}
function AddEntry(cat, item, selection, value, related, multiselection, catconflicted)
{
	this.cat = cat
	this.item = item
	this.selection = selection
	this.value = value
	this.related = related
	this.multiselection = multiselection // Can Multiple Options be selected from the category? 0=>false; 1=>true
	this.catconflicted = catconflicted // This helps to determine if the category is conflicted. 0=>false; 1=>true
}
function format(num)
{
// Uncomment the lines to format the amount with cents also
   if(isNaN(num))
     num = 0;
   var dol = Math.floor(num).toString();
   //var cents = Math.floor((num*100+.5)%100).toString();
   for (var i = 0; i < Math.floor((dol.length-1)/3)-i; i++)
     dol = dol.slice(0,-(4*i+3))+','+dol.slice(-(4*i+3));
   //while (cents.length&lt;2)
   // cents += "0";
   //return "$"+dol+"."+cents;
   return dol
}

function resumeglide()
{
	//alert(idwhichpage)
	if (idwhichpage == '00')
		init();
	else
		ProductDetailinit();
}
//Rotating Banner Ads
