/* Create topmenus, submenus, flying menus, left menus. */
//var sSiteLang = "English";

//Links and Tables Definition Functions
/* Create aLL topmenus's images and their mouse events */
function createTopMenu()
{
	var menuSize = topMenu.length;
	document.write('<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"><TR>');
	for (i = 0;  i < menuSize; i++)
	{
		var theMenu = topMenu[i];
		if (theMenu == "About")
			document.write('<TH><A HREF="CenterPage/TopMenu/HTML/' + sSiteLang + '/History.htm" TARGET="insideFrame" BORDER="0">');
		else if (theMenu == "News")
			document.write('<TH><A HREF="CenterPage/TopMenu/HTML/' + sSiteLang + '/Announcements.htm" TARGET="insideFrame" BORDER="0">');
		else if (theMenu == "Contacts")
			document.write('<TH><A HREF="CenterPage/TopMenu/HTML/' + sSiteLang + '/Support%20Staff.htm" TARGET="insideFrame" BORDER="0">');
		else
			document.write('<TH><A HREF="CenterPage/TopMenu/HTML/' + sSiteLang + '/' + theMenu + '.htm" TARGET="insideFrame" BORDER="0">');

		//Load image without showing to be save in cache
		document.write('<IMG CLASS="itop" BORDER="0" SRC="Index/Images/' + sSiteLang + '/TopMenu/' + theMenu + '.gif" NAME="' + theMenu + '" onMouseOver=topMenuOverWithTimer("' + theMenu + '"); onMouseOut=topMenuOutWithTimer("' + theMenu + '")>');

		document.write('<IMG STYLE="display:none;" SRC="Index/Images/' + sSiteLang + '/TopMenu/' + theMenu + 'Over.gif">');
		document.write('</A></TH>');
		if (i < menuSize - 1)
			document.write('<TH><IMG SRC="Index/Images/' + sSiteLang + '/TopMenu/Slash.gif"></TD>');
	}

	//Account
	var accountName = "SignIn";
	document.write('<TH><A HREF="CenterPage/Cart/ASPX/' + accountName +'.aspx" TARGET="insideFrame" BORDER="0">');
	document.write('<IMG CLASS="itop" BORDER="0" SRC="Index/Images/' + sSiteLang + '/TopMenu/' + accountName + '.gif" NAME="' + accountName + '" onMouseOver=\'this.src="Index/Images/' + sSiteLang + '/TopMenu/SignInOver.gif";\' onMouseOut=\'this.src="Index/Images/' + sSiteLang + '/TopMenu/SignIn.gif";\'>');
	document.write('</A></TH>');

	//View Cart
	var cartName = "ViewCart";
	document.write('<TH><A HREF="CenterPage/Cart/ASPX/' + cartName +'.aspx" TARGET="insideFrame" BORDER="0">');
	document.write('<IMG CLASS="itop" BORDER="0" SRC="Index/Images/' + sSiteLang + '/TopMenu/' + cartName + '.gif" NAME="' + cartName + '" onMouseOver=\'this.src="Index/Images/' + sSiteLang + '/TopMenu/ViewCartOver.gif";\' onMouseOut=\'this.src="Index/Images/' + sSiteLang + '/TopMenu/ViewCart.gif";\'>');
	document.write('</A></TH>');

	document.write('</TR></TABLE>');
}

/* Create all leftmenus' images and mouse events */
function createLeftMenu(leftMenu)
{
	var menuSize = leftMenu.length;
	document.write('<TABLE ID="mainleftmenu" CLASS="leftmenu" BORDER="0" CELLPADDING="0" CELLSPACING="0">');
	for (i = 0; i < menuSize; i++)
	{
		var theMenu = leftMenu[i];
		document.write('<TR><TD>');
		document.write('<A HREF="CenterPage/' + theMenu + '/HTML/' + sSiteLang + '/' + theMenu + lv2Postfix[0] + '.htm" TARGET="insideFrame" BORDER="0" onClick=mainLeftMenuUp("' + theMenu + '");>');
		document.write('<IMG BORDER="0" NAME="' + theMenu + '" SRC="Index/Images/' + sSiteLang + '/LeftMenu/MainPage/' + theMenu + '.gif" onMouseOver=leftMenuOverWithTimer("' + theMenu + '") onMouseOut=leftMenuOutWithTimer("' + theMenu + '") WIDTH="188">');
		//Load image without showing to be save in cache
		document.write('<IMG STYLE="display:none;" SRC="Index/Images/' + sSiteLang + '/LeftMenu/MainPage/' + theMenu + 'Over.gif">');
		document.write('</A>');
		document.write('</TD></TR>');
	}
	document.write('</TABLE>');
}

/*
This function creates ONE level 2's flying menu by taking FOUR parameters:
	keyId: Id of flying menu (table)
	optionId: array of Ids for each option (link) in flying menu
	optionName: array of names for each option (link) in flying menu
	topOrLeft: specification if this flying menus belongs to a topmenu or leftmenu with keyword "top" or "left"
*/
function createLv2Flying(keyId, optionId, optionName, topOrLeft)
{
	if (optionId == "none")	//In case, the menu doesn't have children
	{
		document.write('<TABLE ID="' + keyId + '"><TR>');
		document.write('<TD>&nbsp;</TD>');
		document.write('</TR></TABLE>');
	}
	else
	{
		if (keyId == leftMenu[2]) //if selection is valves
			document.write('<TABLE ID="' + keyId + '" CLASS="leftvalveflying" CELLPADDING="1" onMouseOver=leftFlyingMenuOverWithTimer("' + keyId + '") onMouseOut=leftFlyingMenuOutWithTimer("' + keyId + '")>');
		else if (topOrLeft == "top")	//if selection from top menu
			document.write('<TABLE ID="' + keyId + '" CLASS="flying" CELLPADDING="1" onMouseOver=topFlyingMenuOverWithTimer("' + keyId + '") onMouseLeave=topFlyingMenuOutWithTimer("' + keyId + '")>');
		else if (topOrLeft == "left") //if selection from left menu
			document.write('<TABLE ID="' + keyId + '" CLASS="leftflying" CELLPADDING="1" onMouseOver=leftFlyingMenuOverWithTimer("' + keyId + '") onMouseLeave=leftFlyingMenuOutWithTimer("' + keyId + '")>');

		var menuSize = optionId.length;
		if (keyId == leftMenu[4]) // Controls do not have Virtual Catalog and Selection Software
			menuSize = contCataId.length;

		for (i = 0; i < menuSize; i++)
		{
			document.write('<TR>');

			if (keyId == leftMenu[4]) //Controls
			{
				var folderName = leftMenu[4];
				document.write('<TD onMouseOver=flyingOverWithTimer("' + contCataId[i] + '") onMouseOut=flyingOutWithTimer("' + contCataId[i] + '");>');
				document.write('<A HREF="CenterPage/' + folderName + '/ASPX/ControlsDetailsTable.aspx?pid=' + contCataId[i] + '" TARGET="insideFrame">');
				document.write('<DIV ID="' + contCataId[i] + '" CLASS="flying">');
				document.write(contCataNameFlying[i]);
			}
			else
			{
				if (topOrLeft == "left" && optionName[i] == humiName[0]) //if Virtual Catalogue
				{
					var folderName = optionId[i].substring(0, optionId[i].length - lv2Postfix[0].length);
					if (keyId == leftMenu[2]) //Valves hide Pressure Independant
						document.write('<TD onMouseOver=cataValveFlyingOverWithTimer("' + optionId[i] + '") onMouseOut=cataFlyingOutWithTimer("' + optionId[i] + '");>');
					else
						document.write('<TD onMouseOver=cataFlyingOverWithTimer("' + optionId[i] + '") onMouseOut=cataFlyingOutWithTimer("' + optionId[i] + '");>');
					document.write('<A HREF="CenterPage/' + folderName + '/HTML/' + sSiteLang + '/' + optionId[i] + '.htm" TARGET="insideFrame">');
					document.write('<DIV ID="' + optionId[i] + '" CLASS="flying" onClick=mainLeftMenuUp("' + keyId + '");>');
				}
				else if (topOrLeft == "top")
				{
					document.write('<TD onMouseOver=topFlyingOverWithTimer("' + optionId[i] + '") onMouseOut=topFlyingOutWithTimer("' + optionId[i] + '")>');
					if (optionId[i] == "Chronicles")
						document.write('<A HREF="CenterPage/' + sSiteLang + '/home1.htm" TARGET="insideFrame">');
					else
						document.write('<A HREF="CenterPage/TopMenu/HTML/' + sSiteLang + '/' + optionId[i] + '.htm" TARGET="insideFrame">');
					document.write('<DIV ID="' + optionId[i] + '" CLASS="flying">');
				}
				else
				{
					var folderName = optionId[i].substring(0, optionId[i].length - lv2Postfix[1].length);

					if (keyId == leftMenu[0])
					{
						document.write('<TD onMouseOver=lv2SSFlyingOverWithTimer("' + optionId[i] + '") onMouseOut=flyingOutWithTimer("' + optionId[i] + '");>');
						document.write('<A HREF="http://www.Humidisoft.com" TARGET="_blank">');
						document.write('<DIV ID="' + optionId[i] + '" CLASS="flying">');
					}
					else if (keyId == leftMenu[2]) //Selection Software for Valve, include Standard and Pressure Independant
					{
						document.write('<TD onMouseOver=lv3SSFlyingOverWithTimer("' + keyId + '") onMouseOut=lv3SSTableOutWithTimer("' + keyId + '");>');
						document.write('<DIV ID="' + optionId[i] + '" CLASS="flying">');
					}
					else if (keyId == leftMenu[3]) //Selection Software for Heater
					{
						document.write('<TD onMouseOver=lv2SSFlyingOverWithTimer("' + optionId[i] + '") onMouseOut=flyingOutWithTimer("' + optionId[i] + '");>');
						document.write('<A HREF="http://www.jess-nep.com" TARGET="_blank">');
						document.write('<DIV ID="' + optionId[i] + '" CLASS="flying">');
					}
					else
					{
						document.write('<TD onMouseOver=lv2SSFlyingOverWithTimer("' + optionId[i] + '") onMouseOut=flyingOutWithTimer("' + optionId[i] + '");>');
						document.write('<A HREF="CenterPage/' + folderName + '/ASPX/' + optionId[i] + '.aspx" TARGET="insideFrame">');
						document.write('<DIV ID="' + optionId[i] + '" CLASS="flying" onClick=openSelection("' + optionId[i] + '")>');
					}
				}
				document.write(optionName[i]);
			}

			document.write('</DIV>');
			if (keyId != leftMenu[2])
				document.write('</A>');
			document.write('</TD>');
			document.write('</TR>');
		}
		document.write('</TABLE>');
	}
}

/*
This function creates ONE level 3's flying menu by taking THREE parameters:
	keyId: Id of flying menu (table)
	optionId: array of Ids for each option (link) in flying menu
	optionName: array of names for each option (link) in flying menu
*/
function createLv3Flying(keyId, optionId, optionName)
{
	var tableClassName;
	if (keyId == leftMenu[2]) //Valve Table is shorter
		tableClassName = "lv3Valveflying";
	else
		tableClassName = "lv3flying";

	document.write('<TABLE ID="' + keyId +  lv2Postfix[0] + 'Lv3" CLASS="' + tableClassName+ '" CELLPADDING="1" onMouseOver=lv3TableOverWithTimer("' + keyId + '") onMouseLeave=lv3TableOutWithTimer("' + keyId + '")>');

	var menuSize = optionId.length;
	for (i = 0; i < menuSize; i++)
	{
		document.write('<TR>');
		if (keyId == leftMenu[2] && i < 6) //Valve 2way 3way
			document.write('<TD onMouseOver=lv3ValveFlyingOverWithTimer("'+optionId[i]+'") onMouseOut=lv3ValveFlyingOutWithTimer("'+optionId[i]+'")>');
		else
			document.write('<TD onMouseOver=lv3FlyingOverWithTimer("' + optionId[i] + '") onMouseOut=lv3FlyingOutWithTimer("' + optionId[i] + '")>');

		if (keyId == leftMenu[0] || keyId == leftMenu[3]) //Humidifier and Heaters
		{
			if (i == 9 && keyId == leftMenu[0]) //Europe Model
				document.write('<A HREF="javascript:ToggleEuropeMode(1);">');
			else if (optionId[i] == 'Hz5060')
				document.write('<A HREF="http://www.Humidisoft.com" target="_blank">');
			else
				document.write('<A HREF="CenterPage/' + keyId + '/HTML/' + sSiteLang + '/' + keyId + optionId[i] + '.htm" TARGET="insideFrame">');
		}
		else if (keyId != leftMenu[2] || i >= 6) //Valve PDF Menu
		{
			var pid = getPID(keyId, optionId[i]);
			if (i == 5 && keyId == leftMenu[2]) //Pressure Independent
				document.write('<A HREF="CenterPage/' + keyId + '/PDF/' + sSiteLang + '/GPValveFlyer.pdf" TARGET="_blank">');
			else if (i == 6 && keyId == leftMenu[2]) //Retro Fit
				document.write('<A HREF="CenterPage/' + keyId + '/PDF/' + sSiteLang + '/retroFit.pdf" TARGET="_blank">');
			else if (i == 7 && keyId == leftMenu[2]) //Engineering
				document.write('<A HREF="CenterPage/' + keyId + '/PDF/' + sSiteLang + '/engineering.pdf" TARGET="_blank">');
			else
				document.write('<A HREF="CenterPage/' + keyId + '/ASPX/' + keyId + 'DetailsTable.aspx?pid=' + pid + '" TARGET="insideFrame">');
		}

		document.write('<DIV ID="' + optionId[i] + '" CLASS="lv3flying">' + optionName[i] + '</DIV>');
		if (keyId != leftMenu[2] || i >= 6) //Link disabled for first five elements of Valve
			document.write('</A>');
		document.write('</TD>');
		document.write('</TR>');
	}
	document.write('</TABLE>');
}
//Set SK300 to SKE300, SKR to SKRE, SKG3000 to SKGE3000 and their links in lv3 flying level
var GlobalIsEuropeModel = 0;
function ToggleEuropeMode(IsEuropeModel)
{
	EuropeModeSwitchInFlying(IsEuropeModel);
	EuropeModeSwitchInClip(IsEuropeModel);
	GlobalIsEuropeModel = IsEuropeModel;
	SwitchEuropeModeArrays();
	UpdateHumiFlyingMenu();

	if (IsEuropeModel == 1)
		document.getElementById('TRSK300SubA2SAX115').style.display = "none";
	else
		document.getElementById('TRSK300SubA2SAX115').style.display = "inline";

}
function SwitchEuropeModeArrays()
{
	if (GlobalIsEuropeModel == 1)
	{
		SK300SubPdfArray = SK300SubPdfArray50;
		SK300AccSubPdfArray = SK300AccSubPdfArray50;
		SteamdMultiSubPdfArray = SteamdMultiSubPdfArray50;
		SteamdSubPdfArray = SteamdSubPdfArray50;
		ControlsHSubPdfArray = ControlsHSubPdfArray50;
		SKRSubPdfArray = SKRSubPdfArray50;
		SKRInstallSubPdfArray = SKRInstallSubPdfArray50;
		SKRConSubPdfArray = SKRConSubPdfArray50;
		SKG3000SubPdfArray = SKG3000SubPdfArray50;
	}
	else
	{
		SK300SubPdfArray = SK300SubPdfArray60;
		SK300AccSubPdfArray = SK300AccSubPdfArray60;
		SteamdMultiSubPdfArray = SteamdMultiSubPdfArray60;
		SteamdSubPdfArray = SteamdSubPdfArray60;
		ControlsHSubPdfArray = ControlsHSubPdfArray60;
		SKRSubPdfArray = SKRSubPdfArray60;
		SKRInstallSubPdfArray = SKRInstallSubPdfArray60;
		SKRConSubPdfArray = SKRConSubPdfArray60;
		SKG3000SubPdfArray = SKG3000SubPdfArray60;
	}
}
function UpdateHumiFlyingMenuReferences(ArraySubName)
{
	var SubIDArray = eval(ArraySubName + 'IDArray');
	var SubPDFArray = eval(ArraySubName + 'PdfArray');
	var SubLabelArray = eval(ArraySubName + 'LabelArray');

	var i, Obj;
	for (i = 0; i < SubIDArray.length; i++)
	{
		Obj = document.getElementById('A' + SubIDArray[i]);
		if (Obj != null)
			Obj.href = 'CenterPage/Humidifiers/HTML/' + sSiteLang + '/PDF/' + SubPDFArray[i];
	}
}
function GetHumiNumColsOnScreen(ArraySubName)
{
	var SubIDArray = eval(ArraySubName + 'IDArray');
	//got up the element tree and find the Table for our TR and get the number of TRs
	return document.getElementById(SubIDArray[0]).parentElement.parentElement.parentElement.parentElement.rows.length;
}
function UpdateHumiFlyingMenu()
{
	UpdateHumiFlyingMenuReferences('SK300Sub');
	UpdateHumiFlyingMenuReferences('SK300AccSub');
	UpdateHumiFlyingMenuReferences('SteamdMultiSub');
	UpdateHumiFlyingMenuReferences('SteamdSub');
	UpdateHumiFlyingMenuReferences('ControlsHSub');
	UpdateHumiFlyingMenuReferences('SKRSub');
	UpdateHumiFlyingMenuReferences('SKRInstallSub');
	UpdateHumiFlyingMenuReferences('SKRConSub');
	UpdateHumiFlyingMenuReferences('SKG3000Sub');
}
function EuropeModeSwitchInFlying(IsEuropeModel)
{
	var lv3HumiTab = document.getElementById("HumidifiersCatalogLv3");
	var tdSK300 = lv3HumiTab.rows[0].cells[0];
	var tdSKR = lv3HumiTab.rows[1].cells[0];
	var tdSKG3000 = lv3HumiTab.rows[2].cells[0];
	var europeModeLink = lv3HumiTab.rows[9].cells[0].childNodes[0];
	if (IsEuropeModel == 1)
	{
		//Change Labels
		//TD	/	A			/DIV
		tdSK300.childNodes[0].childNodes[0].innerText = tdSK300.childNodes[0].childNodes[0].innerText.replace("SK 300","SKE");
		//tdSKR.childNodes[0].childNodes[0].innerText = tdSKR.childNodes[0].childNodes[0].innerText.replace("SKR","SKRE").replace("SKREE","SKRE");
		tdSKG3000.childNodes[0].childNodes[0].innerText = tdSKG3000.childNodes[0].childNodes[0].innerText.replace("SKG 3000","SKGE");
		//Change Links
		//TD	/	A
		tdSK300.childNodes[0].href = "CenterPage/Humidifiers/HTML/" + sSiteLang + "/HumidifiersSKE300.htm";
		tdSKR.childNodes[0].href = "CenterPage/Humidifiers/HTML/" + sSiteLang + "/HumidifiersSKRE.htm";
		tdSKG3000.childNodes[0].href = "CenterPage/Humidifiers/HTML/" + sSiteLang + "/HumidifiersSKGE3000.htm";
		//europeModeLink
		europeModeLink.href = "javascript:ToggleEuropeMode(0);";
		//	A			/	DIV		/	FONT
		if (iSiteLang == 1)
			europeModeLink.childNodes[0].childNodes[0].innerText = "Click here for 60Hz Models";
		else
			europeModeLink.childNodes[0].childNodes[0].innerText = "Cliquez ici pour les modèles 60Hz";
		}
	else
	{
		tdSK300.childNodes[0].childNodes[0].innerText = tdSK300.childNodes[0].childNodes[0].innerText.replace("SKE","SK 300");
		//tdSKR.childNodes[0].childNodes[0].innerText = tdSKR.childNodes[0].childNodes[0].innerText.replace("SKRE","SKR").replace("SKREE","SKR");
		tdSKG3000.childNodes[0].childNodes[0].innerText = tdSKG3000.childNodes[0].childNodes[0].innerText.replace("SKGE","SKG 3000");
		tdSK300.childNodes[0].href = "CenterPage/Humidifiers/HTML/" + sSiteLang + "/HumidifiersSK300.htm";
		tdSKR.childNodes[0].href = "CenterPage/Humidifiers/HTML/" + sSiteLang + "/HumidifiersSKR.htm";
		tdSKG3000.childNodes[0].href = "CenterPage/Humidifiers/HTML/" + sSiteLang + "/HumidifiersSKG3000.htm";
		europeModeLink.href = "javascript:ToggleEuropeMode(1);";
		if (iSiteLang == 1)
			europeModeLink.childNodes[0].childNodes[0].innerText = "Click here for 50Hz Models";
		else
			europeModeLink.childNodes[0].childNodes[0].innerText = "Cliquez ici pour les modèles 50Hz";
	}
}
function EuropeModeSwitchInClip(IsEuropeMode)
{
	var humiClip = document.getElementById("HumidifiersClip");
	var objTBody = humiClip.childNodes[0];
	var SK300Label = objTBody.childNodes[2].childNodes[0].childNodes[0].childNodes[0];
	var SKRLabel = objTBody.childNodes[3].childNodes[0].childNodes[0].childNodes[0];
	var SKG3000Label = objTBody.childNodes[4].childNodes[0].childNodes[0].childNodes[0];
	var SK300Link = objTBody.childNodes[2].childNodes[0].childNodes[0];
	var SKRLink = objTBody.childNodes[3].childNodes[0].childNodes[0];
	var SKG3000Link = objTBody.childNodes[4].childNodes[0].childNodes[0];
	if (IsEuropeMode == 1)
	{
		SK300Label.innerHTML = (SK300Label.innerHTML).replace("SK&nbsp;300","SKE");
		//SKRLabel.innerHTML = (SKRLabel.innerHTML).replace("SKR","SKRE").replace("SKREE","SKRE");
		SKG3000Label.innerHTML = (SKG3000Label.innerHTML).replace("SKG&nbsp;3000","SKGE");
		SK300Link.href = "CenterPage/Humidifiers/HTML/" + sSiteLang + "/HumidifiersSKE300.htm";
		SKRLink.href = "CenterPage/Humidifiers/HTML/" + sSiteLang + "/HumidifiersSKRE.htm";
		SKG3000Link.href = "CenterPage/Humidifiers/HTML/" + sSiteLang + "/HumidifiersSKGE3000.htm";
	}
	else
	{
		SK300Label.innerHTML = (SK300Label.innerHTML).replace("SKE", "SK&nbsp;300");
		//SKRLabel.innerHTML = (SKRLabel.innerHTML).replace("SKRE", "SKR").replace("SKREE", "SKR");
		SKG3000Label.innerHTML = (SKG3000Label.innerHTML).replace("SKGE", "SKG&nbsp;3000");
		SK300Link.href = "CenterPage/Humidifiers/HTML/" + sSiteLang + "/HumidifiersSK300.htm";
		SKRLink.href = "CenterPage/Humidifiers/HTML/" + sSiteLang + "/HumidifiersSKR.htm";
		SKG3000Link.href = "CenterPage/Humidifiers/HTML/" + sSiteLang + "/HumidifiersSKG3000.htm";
	}
}

/* Return a string without HTML <BR> tag */
function removeBreakLineInLv3(label)
{
	var labelArray = label.split("<BR>")
	if (labelArray.length > 1)
	{
		var returnStr = "";
		for (k=0; k < labelArray.length; k++)
			returnStr += labelArray[k] + " ";
		return returnStr;
	}
	else
		return label;
}

/* Create all hidden flying menus */
function createAllFlyings()
{
	createLv2Flying(topMenu[0], aboutId, aboutName, "top");
	createLv2Flying(topMenu[1], newsId, newsName, "top");
	createLv2Flying(topMenu[2], patentsId, patentsName, "top");
	createLv2Flying(topMenu[3], contactsId, contactsName, "top");

	createLv2Flying(leftMenu[0], humiId, humiName, "left");
	createLv2Flying(leftMenu[1], actuId, actuName, "left");
	createLv2Flying(leftMenu[2], valvId, valvName, "left");
	createLv2Flying(leftMenu[3], heatId, heatName, "left");
	createLv2Flying(leftMenu[4], contId, contName, "left");

	createLv3Flying(leftMenu[0], humiCataId, humiCataNameFlying);
	createLv3Flying(leftMenu[1], actuCataId, actuCataNameFlying);
	createLv3Flying(leftMenu[2], valvCataId, valvCataNameFlying);
	createLv3Flying(leftMenu[3], heatCataId, heatCataNameFlying);
	createLv3Flying(leftMenu[4], contCataId, contCataNameFlying);
}

/* Initialize all hidden products' leftmenus */
function createAllProductsClips(allProductsIds, leftMenu, allProductsNames)
{
	createLeftMenuClip(allProductsIds[0], leftMenu[0], allProductsNames[0], allProductsLabelColor[0], allProductsShowCategory[0]);
 	createLeftMenuClip(allProductsIds[1], leftMenu[1], allProductsNames[1], allProductsLabelColor[1], allProductsShowCategory[1]);
	createLeftMenuClip(allProductsIds[2], leftMenu[2], allProductsNames[2], allProductsLabelColor[2], allProductsShowCategory[2]);
	createLeftMenuClip(allProductsIds[3], leftMenu[3], allProductsNames[3], allProductsLabelColor[3], allProductsShowCategory[3]);
	createLeftMenuClip(allProductsIds[4], leftMenu[4], allProductsNames[4], allProductsLabelColor[4], allProductsShowCategory[4]);
}

/* Initialize all left menus links, product left menu down when click */
function createAllProductLinks(menuArray)
{
	for (i = 0; i < menuArray.length; i++)
	{
		var indexID = menuArray[i];
		var outputStr = '<IMG ID="' + indexID + 'productline" ';
		outputStr += 'NAME="' + indexID + 'productline" ';
		outputStr += 'SRC="Index/Images/' + sSiteLang + '/LeftMenu/' + indexID + '/' + indexID + 'ProductLine.gif" ';
		outputStr += 'onClick=productMenuMoveDown("' + indexID + '"); ';
		outputStr += 'onMouseOver=productLineOver("' + indexID + '"); ';
		outputStr += 'onMouseOut=productLineOut("' + indexID + '");';
		outputStr += '>';
		document.write(outputStr);
	}
}

/* Mouse Events on Search buttons' image */
function searchOver()
{
	document.images['search'].src = "Index/Images/SearchOver.gif";
}
function searchOut()
{
	document.images['search'].src = "Index/Images/Search.gif";
}

/* Create a left product menu */
function createLeftMenuClip(leftMenuId, leftId, label, labelcolor, labelajust)
{
	var menuSize = label.length;
	document.write('<TABLE ID="' + leftId+'Clip" BORDER="0" CELLPADDING="0" CELLSPACING="0">');

	document.write('<TR><TH CLASS="productline" ALIGN="center"><IMG SRC="Index/Images/' + sSiteLang + '/Leftmenu/' + leftId + '/' + leftId + 'ProductLine.gif" onClick=backToProductLine("' + leftId + '")></TH></TR>');
	document.write('<TR><TD HEIGHT="3"></TD></TR>');
	for (i = 0; i < menuSize; i++)
	{
		var theMenu = leftId + leftMenuId[i];
		var pid = getPID(leftId, leftMenuId[i]);
		var imageHeight = 76;
		if (i == menuSize - 1)	//Last menu gif id 1 pixel highter than others
			imageHeight = 77;

		if (leftId == leftMenu[2] && i < 6) //if valves AND first 6 elements
			document.write('<TR><TD WIDTH="188" HEIGHT="' + imageHeight + '" ID="' + theMenu + '" BACKGROUND="Index/Images/' + sSiteLang + '/LeftMenu/' + leftId + '/' + theMenu + '.gif" onMouseOver=linkValveOverWithHide("' + leftId + '",' + '"' + theMenu + '") onMouseOut=linkValveOut("' + leftId + '",' + '"' + theMenu + '")>');
		else if (leftId == leftMenu[0] && i <= 7) //if humidifiers SK300, SKR, SKG3000 ,Steam or Controls
			document.write('<TR><TD WIDTH="188" HEIGHT="' + imageHeight + '" ID="' + theMenu + '" BACKGROUND="Index/Images/' + sSiteLang + '/LeftMenu/' + leftId + '/' + theMenu + '.gif" onMouseOver=linkHumiOverWithHide("' + leftId + '",' + '"' + theMenu + '") onMouseOut=linkHumiOut("' + leftId + '",' + '"' + theMenu + '")>');
		else
			document.write('<TR><TD WIDTH="188" HEIGHT="' + imageHeight + '" ID="' + theMenu + '" BACKGROUND="Index/Images/' + sSiteLang + '/LeftMenu/' + leftId + '/' + theMenu + '.gif" onMouseOver=linkOver("' + leftId + '",' + '"' + theMenu + '") onMouseOut=linkOut("' + leftId + '",' + '"' + theMenu + '")>');

		if (leftId == leftMenu[0] || leftId == leftMenu[3]) //if humidifiers or heaters
		{
			if (leftMenuId[i] == 'SelectSoft')
				document.write('<A HREF="http://www.Humidisoft.com" target="_blank">');
			else
				document.write('<A HREF="Centerpage/' + leftId + '/HTML/' + sSiteLang + '/' + leftId + leftMenuId[i] + '.htm" TARGET="insideFrame">');
			formatLeftMenuLabel(i, leftId, label, labelcolor, labelajust, menuSize)
			document.write('</A>');
		}
		else if (leftId == leftMenu[4]) //controls.. builds left menu links
		{
			document.write('<A HREF="CenterPage/' + leftId + '/ASPX/' + leftId + 'DetailsTable.aspx?pid=' + pid + '" TARGET="insideFrame">');
			formatLeftMenuLabel(i, leftId, label, labelcolor, labelajust, menuSize)
			document.write('</A>');
		}
		else if (leftId == leftMenu[2] && i >= 6) //Remove Valve Pressure Independant's link
		{
			if (i == 5) //Pressure Independent
				document.write('<A HREF="CenterPage/' + leftId + '/ASPX/ValvesPressureSelect.aspx" TARGET="insideFrame">');
			else if (i == 6) //Retro Fit
				document.write('<A HREF="CenterPage/' + leftId + '/PDF/' + sSiteLang + '/retroFit.pdf" TARGET="_blank">');
			else if (i == 7) //Engineering
				document.write('<A HREF="CenterPage/' + leftId + '/PDF/' + sSiteLang + '/engineering.pdf" TARGET="_blank">');
			formatLeftMenuLabel(i, leftId, label, labelcolor, labelajust, menuSize)
			document.write('</A>');
		}
		else
		{
			if (i < menuSize-1 || leftId == leftMenu[1])
			{
				if (leftId != leftMenu[2])
					document.write('<A HREF="CenterPage/' + leftId + '/ASPX/' + leftId + 'DetailsTable.aspx?pid=' + pid + '" TARGET="insideFrame">');
			}

			formatLeftMenuLabel(i, leftId, label, labelcolor, labelajust, menuSize)

			if (i < menuSize-1 || leftMenuId != leftMenu[2])
				document.write('</A>');
		}

		//Load image without showing to be save in cache
		document.write('<IMG STYLE="display:none;" SRC="Index/Images/' + sSiteLang + '/LeftMenu/' + leftId + '/' + theMenu + 'Over.gif">');
		document.write('</TD></TR>');
	}
	document.write('</TABLE>');
}

/* Back to Productline inside frame page once click on ProductLine Image */
function backToProductLine(idName)
{
	var path = "CenterPage/" + idName + "/HTML/" + sSiteLang + "/" + idName + lv2Postfix[0] + ".htm"
	//Mozilla Firefox
	document.insideFrame.location.href = path;
}

/* Format left menu's label based on Photoshop documents */
function formatLeftMenuLabel(index, leftId, label, labelcolor, labelajust, menuSize)
{
	if (label[index].split("<BR>").length > 1) //If label string's has "<BR>" as substring, use top ajust CSS, otherwise use normal CSS.
	{
		if (i < menuSize-1)
		{
			if (leftId == leftMenu[0] || leftId == leftMenu[2] || leftId == leftMenu[3] || leftId == leftMenu[4]) //if humidifiers, valves, heaters or controls
			{
				if ((iSiteLang == 0 && leftId == leftMenu[2] && index == 1)
					|| (iSiteLang == 0 && leftId == leftMenu[0] && index == 9))
					document.write('<DIV CLASS="leftmenuintegral">');
				else if ((iSiteLang == 0 && leftId == leftMenu[3] && index == 1)
					|| (iSiteLang == 0 && leftId == leftMenu[0] && index == 3))
					document.write('<DIV CLASS="leftmenushort">');
				else
					document.write('<DIV CLASS="leftmenulong">');

			}
			else
				document.write('<DIV CLASS="leftmenulong" onClick=productLeftMenuUp("' + leftId + '")>');
		}
		else //Last menu option may be a special link and is disabled
			document.write('<DIV CLASS="leftmenulong">');
	}
	else
	{
		if (i < menuSize-1 || leftId == leftMenu[1])
		{
			if (leftId == leftMenu[0] || (leftId == leftMenu[1] && index == 13) || leftId == leftMenu[2] || leftId == leftMenu[3] || leftId == leftMenu[4]) //if humidifiers, valves, heaters or controls, do not leftmenu up
				document.write('<DIV CLASS="leftmenushort">');
			else
				document.write('<DIV CLASS="leftmenushort" onClick=productLeftMenuUp("' + leftId + '")>');
		}
		else //Last menu option may be a special link and is disabled right now
			document.write('<DIV CLASS="leftmenushort">');
	}
	var capitalLetter = "";
	if (leftId == leftMenu[1])
		capitalLetter = 'STYLE="text-transform:none;"';
	if (labelajust == showAll)
	{
		document.write('<SPAN STYLE="color:' + labelcolor + '" ' + capitalLetter + '>' + label[index] + '</SPAN><BR>' + leftId);
	}
	else if (labelajust == showNone)
		document.write('<SPAN STYLE="color:' + labelcolor + '" ' + capitalLetter + '>' + label[index] + '</SPAN>');
	else if (labelajust[index] == showed)
		document.write('<SPAN STYLE="color:' + labelcolor + '" ' + capitalLetter + '>' + label[index] + '</SPAN><BR>' + leftId);
	else if (labelajust[index] == notShowed)
		document.write('<SPAN STYLE="color:' + labelcolor + '" ' + capitalLetter + '>' + label[index] + '</SPAN><BR>&nbsp;');
	else if (labelajust[index] == hasOwnLabel)
	{
		var labelArray = label[index].split(" ");
		var contentDisplayed = "";
		var titleDisplayed = labelArray[labelArray.length-1];
		for (var j=0; j<labelArray.length-1; j++)
			contentDisplayed += labelArray[j] + " ";
		document.write('<SPAN STYLE="color:' + labelcolor + '" ' + capitalLetter + '>' + contentDisplayed + '</SPAN><BR>' + titleDisplayed);
	}
	else
		document.write('ALERT!!!');
	document.write('</DIV>');
}

/* Display labels on product's leftmenu */
function actuatorsLeftMenuLabel(index, leftId, label, labelcolor, labelajust, menuSize)
{
	if (index < 7) //7 first menu label has different unique formats
	{
		if (i < menuSize - 1)
			document.write('<DIV CLASS="leftmenulong" onClick=productLeftMenuUp("'+leftId+'")>');
		else //Last menu option may be a special link and is disabled right now
			document.write('<DIV CLASS="leftmenulong">');

		var inPosition = label[index].indexOf(" ");
		var newLabel = '<B STYLE="font-size:13px;">' + label[index].substring(0, inPosition) + '</B><BR>' + label[index].substring(inPosition);
		document.write('<SPAN STYLE="color:' + labelcolor + '" STYLE="text-transform:none;">' + newLabel + '</SPAN><BR>' + leftId);
		document.write('</DIV>');
	}
	else
	{
		if (label[index].split("<BR>").length > 1) //If label string's has "<BR>" as substring, use top ajust CSS, otherwise use normal CSS.
		{
			if (i < menuSize-1)
				document.write('<DIV CLASS="leftmenulong" onClick=productLeftMenuUp("'+leftId+'")>');
			else //Last menu option may be a special link and is disabled right now
				document.write('<DIV CLASS="leftmenulong">');
		}
		else
		{
			if (i < menuSize-1)
				document.write('<DIV CLASS="leftmenushort" onClick=productLeftMenuUp("'+leftId+'")>');
			else //Last menu option may be a special link and is disabled right now
				document.write('<DIV CLASS="leftmenushort">');
		}
		document.write('<SPAN STYLE="color:' + labelcolor + '" STYLE="text-transform:none;">' + label[index] + '</SPAN><BR>' + leftId);
		document.write('</DIV>');
	}
}

/* Get product id based on its type */
function getPID(idName, productDescription)
{
	if (idName == leftMenu[1] || idName == leftMenu[4])
		return productDescription;
	else
		return "none";

}

/* Get actuators pid to communicate with file aspx */
function getActuatorsPID(pDescription)
{
	var pidArray = pDescription.split(" ");
	if (pidArray[1] != "to" && !isNaN(pidArray[0]))
		return pidArray[0];
	else if (pidArray[1] == "to" && !isNaN(pidArray[0]) && !isNaN(pidArray[2])) //1800 to 4000
		return pidArray[0] + "&" + pidArray[2];
	else if (pidArray[0] == "A&M" && pidArray[1] == "-")
		return pidArray[2];
	else
	{
		if (pidArray[0] == "50&nbsp;in.lb.")
			return "50Slow";
		else
			return pidArray[0];
	}
}