// JavaScript Document

function MM_preloadImages() { //v3.0
	var d=document;
	if(d.images){
		if(!d.MM_p)
			d.MM_p=new Array();
		var i;
		var j=d.MM_p.length;
		var a=MM_preloadImages.arguments;
		for(i=0; i<a.length; i++) {
			if (a[i].indexOf("#")!=0) {
				//alert("loading"+a[i]);
				d.MM_p[j]=new Image;
				d.MM_p[j++].src=a[i];
			}
		}
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function gbSwapImgRestore() { //v3.0
	var i,x,a=document.MM_sr;

	for(i=0; a&&i<a.length&&(x=a[i])&&(x.oSrc||x.oBack); i++)
	{
		x.src=x.oSrc;
		x.background=x.oBack;
		//alert(x.oBack);
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments;
	
	document.MM_sr=new Array;

	for(i=0;i<(a.length-2);i+=3)
		if ( (x=MM_findObj(a[i])) != null )
		{
			document.MM_sr[j++]=x;
			if(!x.oSrc) x.oSrc=x.src;
			x.src=a[i+2];
		}
}

function gbSwapImage() { //v3.0
	var i,j=0,x,a=gbSwapImage.arguments;
	
	document.MM_sr=new Array;
	//alert(navigator.appName.indexOf("Netscape"));

	for(i=0;i<(a.length-2);i+=3)
		if ( (x=MM_findObj(a[i])) != null )
		{
			document.MM_sr[j++]=x;

			if(!x.oSrc) {
				x.oSrc=x.src;
			}
			if(!x.oBack) {
				x.oBack=x.background;
			}

			x.src=a[i+2];
			x.background=a[i+2];
			//alert(x.background);

		}
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function gbHiLight(sObj, sImage1, sImage2, sImage3) {
	x=MM_findObj(sObj + "_1");
	x.src=sImage;
	x=MM_findObj(sObj + "_2");
	x.src=sImage;
	x=MM_findObj(sObj + "_3");
	x.src=sImage;
}

function gbPreloadP4UImgs(sCatID)
{
	//Load Common Pics
	sPicPath='images/page/';
	MM_preloadImages(
		sPicPath+'BasketBL.gif',
		sPicPath+'BasketBR.gif',
		sPicPath+'TabTblBL.gif',
		sPicPath+'TabTblBR.gif',
		sPicPath+'TabTblLZ.jpg',
		sPicPath+'TabTblRZ.jpg',
		sPicPath+'TabTblTL.gif',
		sPicPath+'TabTblTR.gif',
		sPicPath+'  '
		);
	//Load Cat Specific Pics
	sCatPath='images/page/'+sCatID+'/';
	MM_preloadImages(
		sCatPath+'QuickZ.gif',
		sCatPath+'TabTblBL.gif',
		sCatPath+'TabTblBLIn.gif',
		sCatPath+'TabTblBR.gif',
		sCatPath+'TabTblBRIn.gif',
		sCatPath+'TabTblBZ.gif',
		sCatPath+'TabTblLZ.jpg',
		sCatPath+'TabTblRZ.jpg',
		sCatPath+'TabTblTL.gif',
		sCatPath+'TabTblTLIn.gif',
		sCatPath+'TabTblTR.gif',
		sCatPath+'TabTblTRIn.gif',
		sCatPath+'TabTblTZ.gif',
		sCatPath+'UnderMenu.gif',
		sCatPath+'BannerR.gif',
		sCatPath+'BannerTitle.jpg',
		sCatPath+'BannerZ.gif',
		sCatPath+'MenuItemHL.gif',
		sCatPath+'MenuItemHR.gif',
		sCatPath+'MenuItemHZ.gif',
		sCatPath+'MenuItemSelL.gif',
		sCatPath+'MenuItemSelR.gif',
		sCatPath+'MenuItemSelZ.gif',
		sCatPath+'MenuItemZ.gif',
		sCatPath+'MenuItemL.gif',
		sCatPath+'MenuItemR.gif',
		sCatPath+'Logo.jpg',
		sCatPath+'       ',
		sCatPath+'       ',
		sCatPath+'       ',
		sCatPath+'       ',
		sCatPath+'       ',
		sCatPath+'       ',
		sCatPath+'       ');	
	return(true);
}

function gbPreloadForAllCats(sPageImg)
{
	//sPageImg is the image name "QuickZ.gif" for the image "images/page/PER/QuickZ.gif"
}

function PopUpImg(sImage) {
	window.open(sImage,"PopUp");
	//return('');
}

function ShowImg(sImage) {
	//ppDiv.style.width=document.documentElement.offsetWidth;
	//ppDiv.style.height=document.documentElement.offsetHeight;

	ppDiv.style.width=document.body.scrollWidth;
	ppDiv.style.height=document.body.scrollHeight;
	//ppDiv.style.width="100%";
	//ppDiv.style.height="100%";
	ppImage.src=sImage;
	//stop;
	ppImg.style.left=document.body.offsetWidth/2-ppImage.width/2-20;
	ppImg.style.top=document.body.offsetHeight/2-ppImage.height/2-20;
	ppImg.style.width=ppImage.width+20;
	ppImg.style.height=ppImage.height+20;
	ppDiv.style.visibility="visible";
	ppImg.style.visibility="visible";
	frmQuick.cboQuick.style.visibility="hidden";
}
function HideImg() {
	ppDiv.style.visibility="hidden";
	ppImg.style.visibility="hidden";
	frmQuick.cboQuick.style.visibility="visible";
}

function gbCompChecks() {
	//Used for concat all check boxes for comparing
	//Not Used Yet!

	sCompChecks="";
	
	return(sCompChecks);	
}

function getAllLeft(vElement) {
if(vElement==null)
	return(0);
else
	return(vElement.offsetLeft + getAllLeft(vElement.offsetParent));
}

function getAllTop(vElement) {
if(vElement==null)
	return(0);
else
	return(vElement.offsetTop + getAllTop(vElement.offsetParent));
}

function gbCheckValidTK()
{
	//var sRet=divCheckTKRet.innerHTML;
	var sRet=divTKCity.innerHTML;

	//alert(sRet);

	switch(sRet)
	{
		case "&nbsp;":
			divTKUnknown.style.display="inline";
			break;
		default:
			//alert("No Change Old Pass Wrong");
			//gbShowPopup(ppPassError, ppPassErrorImg, getAllLeft(aChPass)+0, getAllTop(aChPass)+30, 'N');
			divTKUnknown.style.display="none";
			//get('doGetTKCity.php');
			break;
	}
	//alerte;
//	if(sChPRet=='true') {
//		alert("true");
//	} else if(sChPRet=='false') {
//		alert("false");
//	}
}


//var bValidEMail;

function eCheckEMail(sEMail)
{
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(sEMail)){
		//alert("Προσοχή : Ακυρη διεύθυνση email...Προσπαθείστε ξανά...")
		return(false);
	}
	else
		return(true);
}

function eMailPage() 
{
//	alert(document.body.outerHTML)
	var sMail= prompt('Παρακαλώ δώστε το email','');

	if (eCheckEMail(sMail)) {
		window.location = "mailto:"+sMail+"?subject="+window.document.title+"&body= \n\n"+window.location
	}
}

function gbGoHist(url) {
	hist.location=url;
}
function gbShowPopup(pPop, pPopImg, iLeft, iTop, enuStyle) {
	//1st Hide all other PopupDivs
	gbHidePopups();

	switch(enuStyle) {
		case "W":
			pPopImg.src="images/page/PopupTLW.gif";
			break;
		case "NW":
			pPopImg.src="images/page/PopupTLNW.gif";
			break;
		case "N":
			pPopImg.src="images/page/PopupTLN.gif";
			break;
		case "NR":
			pPopImg.src="images/page/PopupTRN.gif";
			break;
		case "NE":
			pPopImg.src="images/page/PopupTRNE.gif";
			break;
		case "E":
			pPopImg.src="images/page/PopupTRE.gif";
			break;
		case "CN":
			pPopImg.src="images/page/PopupTLCN.gif";
			break;
		default:
			pPopImg.src="images/page/PopupTL.gif";
			break;
	}
			
	pPop.style.left=iLeft;
	pPop.style.top=iTop;
	//popup.getElementById("popuptext").innerText=sText;
	//alert(sText.indexOf(".php"));
	//if(sText.indexOf(".php")!=-1) {
		//File here
		//popuptext.innerHTML="<div id='popupdiv' name='popupdiv'></div>";
		//popupframe.src=sText;
	//} else {
		//popuptextdiv.text=sText;
		//popuptext.innerHTML=sText;
		//popuptextdiv.innerHTML=sText;
		//document.getElementById('popuptext').innerHTML=sText;
		
		//popuptextdiv.offsetHeight="100px";
		//document.getElementById("popuptextdiv").innerHTML=sText;
	//}
	pPop.style.visibility="visible";
}

function gbHidePopup(pPop) {
	pPop.style.visibility="hidden";
	pPop.style.left="-500px";
//	try{
//		txtQuick.setFocus();
//	}catch(e){};
}

function gbHidePopups() {
	for(i=0;i<ppArray.length;i++)
		gbHidePopup(ppArray[i]);
}
function gbShowHideDiv(imgToChange, divToShow, bShow) {
	if(bShow) {
		//divToShow.height=divToShow.oldHeight;
		//divToShow.style.visibility="visible";
		divToShow.style.display="block";
	} else {
		//divToShow.oldHeight=divToShow.height;
		//divToShow.style.visibility="hidden";
		//divToShow.height=0;
		divToShow.style.display="none";
	}
	
	//alert(divToShow.style.visibility);
}

function gbShowJar(e) {
	var posx = null;
	var posy = null;
//	if (!e) var e = window.event || window.Event;
//	if (e.pageX || e.pageY) 	{
//		posx = e.pageX;
//		posy = e.pageY;
//	}
//	else if (e.clientX || e.clientY) 	{
//		posx = e.clientX + document.body.scrollLeft
//			+ document.documentElement.scrollLeft;
//		posy = e.clientY + document.body.scrollTop
//			+ document.documentElement.scrollTop;
//	}
//	else if (e.x || e.y) {
//		posx=e.x;
//		posy=e.y;
//	}

	posx=iMouseX;
	posy=iMouseY;

	if(posx!=null && posy!=null) {
		voteDiv.style.left=posx+20;
		voteDiv.style.top=posy-20;
		//voteDiv.style.left=iMouseX;
		//voteDiv.style.top=iMouseY;
	}
	
	imgVoteJar.src="images/icons/icoJar.gif";
	
	voteDiv.style.visibility="visible";
	//alert(e.pageX +" "+ e.pageY);
	//alert(e.clientX +" "+ e.clientY);
	//alert(e.x +" "+ e.y);
}

function gbShowEJar(e) {
	//Show Empty Jar
	var posx = null;
	var posy = null;
//	if (!e) var e = window.event || window.Event;
//	if (e.pageX || e.pageY) 	{
//		posx = e.pageX;
//		posy = e.pageY;
//	}
//	else if (e.clientX || e.clientY) 	{
//		posx = e.clientX + document.body.scrollLeft
//			+ document.documentElement.scrollLeft;
//		posy = e.clientY + document.body.scrollTop
//			+ document.documentElement.scrollTop;
//	}
//	else if (e.x || e.y) {
//		posx=e.x;
//		posy=e.y;
//	}

	posx=iMouseX;
	posy=iMouseY;

	if(posx!=null && posy!=null) {
		voteDiv.style.left=posx+20;
		voteDiv.style.top=posy-20;
		//voteDiv.style.left=iMouseX;
		//voteDiv.style.top=iMouseY;
	}
	
	imgVoteJar.src="images/icons/icoJarE.gif";
	voteVal.innerHTML="";
	
	voteDiv.style.visibility="visible";
	//alert(e.pageX +" "+ e.pageY);
	//alert(e.clientX +" "+ e.clientY);
	//alert(e.x +" "+ e.y);
}


function gbHideJar() {
	voteDiv.style.visibility="hidden";
}

function gbShowLoading(e) {
	var posx = null;
	var posy = null;

	posx=iMouseX;
	posy=iMouseY;

	if(posx!=null && posy!=null) {
		//Engine.progressBar.update(true);
		//divProgressBar.style.left=posx+20;
		//divProgressBar.style.top=posy+20;
		var pgb=Engine.progressBar.bar;
		pgb.style.position="absolute";
		pgb.style.top=posy+20;
		pgb.style.left=posx+20;
	}
	
	//imgVoteJar.src="images/icons/icoJar.gif";
	
	//divProgressBar.style.display="block";
	//Engine.progressBar.update(true);
}

function gbShowMenuDiv(sDivToShow)//, sImgToDown, sImgSrcToDown)
{
/*	for(i=0;i<arDivs.length;i++)
	{
		if(arDivs[i]!=sDivToShow) {
			try{
			gbToggleDisplay(document.getElementById(arDivs[i]),false);
			//new Effect.Fade(document.getElementById(arDivs[i]));
			} catch(e){};
			//try{
			//gbToggleDisplay(document.getElementById(arDivs[i]+"Title"),false);
			//} catch(e){};
			//try{
			//gbToggleDisplay(document.getElementById(arDivs[i]+"Foot"),false);
			//} catch(e){};
			try{
			document.getElementById(arImgs[i]).src="images/icons/"+arImgSrcs[i]+".gif";
			} catch(e){};
		}
	}
*/

	try {
		if(divLastMenuGroup!=sDivToShow)
			document.getElementById(divLastMenuGroup).style.display='none';
	} catch(e) {};

	try{
		//gbToggleDisplay(document.getElementById(sDivToShow),true);
		if(document.getElementById(sDivToShow).style.display!='none')
		{
			//new Effect.SlideUp(document.getElementById(sDivToShow));
			document.getElementById(sDivToShow).style.display='none';
		} else {
			//new Effect.SlideDown(document.getElementById(sDivToShow));
			document.getElementById(sDivToShow).style.display='block';
			divLastMenuGroup=sDivToShow;
		}
	} catch(e){};
}

function gbShowMyAccountDiv(sDivToShow, sImgToDown, sImgSrcToDown)
{
	var arDivs   =new Array();
	var arImgs   =new Array();
	var arImgSrcs=new Array();
	arDivs.push("divUserAll");
	//arDivs.push("divForm2");
	arDivs.push("divAddrAll");
	arDivs.push("divInvAll");
	arDivs.push("divWishAll");
	arDivs.push("divOrdersAll");
	arDivs.push("divPrefsAll");
	
	arImgs.push("imgUser");
	//arImgs.push("imgForm1");
	arImgs.push("imgAddr");
	arImgs.push("imgInv");
	arImgs.push("imgWish");
	arImgs.push("imgOrders");
	arImgs.push("imgPrefs");
	
	arImgSrcs.push("MyUser");
	arImgSrcs.push("MyAddr");
	arImgSrcs.push("MyInv");
	arImgSrcs.push("MyWish");
	arImgSrcs.push("MyOrders");
	arImgSrcs.push("MyPrefs");
	
	
	for(i=0;i<arDivs.length;i++)
	{
		if(arDivs[i]!=sDivToShow) {
			try{
			gbToggleDisplay(document.getElementById(arDivs[i]),false);
			//new Effect.Fade(document.getElementById(arDivs[i]));
			} catch(e){};
			//try{
			//gbToggleDisplay(document.getElementById(arDivs[i]+"Title"),false);
			//} catch(e){};
			//try{
			//gbToggleDisplay(document.getElementById(arDivs[i]+"Foot"),false);
			//} catch(e){};
			try{
			document.getElementById(arImgs[i]).src="images/icons/"+arImgSrcs[i]+".gif";
			} catch(e){};
		}
	}

	try{
	//gbToggleDisplay(document.getElementById(sDivToShow),true);
	new Effect.SlideDown(document.getElementById(sDivToShow));
	} catch(e){};
	//try{
	//gbToggleDisplay(document.getElementById(sDivToShow+"Title"),true);
	//} catch(e){};
	//try{
	//gbToggleDisplay(document.getElementById(sDivToShow+"Foot"),true);
	//} catch(e){};
	try{
	document.getElementById(sImgToDown).src="images/icons/"+sImgSrcToDown+"Hi.gif";
	} catch(e){};
	
}

function gbShowItemDiv(sDivToShow, sImgToDown, sImgSrcToDown)
{
	var arDivs     =new Array();
	var arImgs     =new Array();
	var arImgSrcs  =new Array();
	var arTabTitles=new Array();
	arDivs.push("divTab1");
	arDivs.push("divTab2");
	arDivs.push("divTab3");
	arDivs.push("divTab4");
	
	arImgs.push("imgProdTab1");
	arImgs.push("imgProdTab2");
	arImgs.push("imgProdTab3");
	arImgs.push("imgProdTab4");
	
	arImgSrcs.push("ProdTab1");
	arImgSrcs.push("ProdTab2");
	arImgSrcs.push("ProdTab3");
	arImgSrcs.push("ProdTab4");
	
	arTabTitles.push("Γενική Περιγραφή");
	arTabTitles.push("Αναλυτικά Χαρακτηριστικά");
	arTabTitles.push("Σχετικά Προϊόντα");
	arTabTitles.push("Περισσότερες Φωτογραφίες");
	
	for(i=0;i<arDivs.length;i++)
	{
		if(arDivs[i]!=sDivToShow) {
			try{
			gbToggleDisplay(document.getElementById(arDivs[i]),false);
			//new Effect.Fade(document.getElementById(arDivs[i]));
			} catch(e){};
			//try{
			//gbToggleDisplay(document.getElementById(arDivs[i]+"Title"),false);
			//} catch(e){};
			//try{
			//gbToggleDisplay(document.getElementById(arDivs[i]+"Foot"),false);
			//} catch(e){};
			try{
				if(!(document.getElementById(arImgs[i]).src.indexOf('Disabled')>0))
					document.getElementById(arImgs[i]).src="images/page/"+arImgSrcs[i]+".gif";
			} catch(e){};
		}
		else
		{
			try{
				document.getElementById("divTabTitle").innerHTML=arTabTitles[i];
			} catch(e){};
		}
	}

	try{
	gbToggleDisplay(document.getElementById(sDivToShow),true);
	//new Effect.SlideDown(document.getElementById(sDivToShow));
	} catch(e){};
	//try{
	//gbToggleDisplay(document.getElementById(sDivToShow+"Title"),true);
	//} catch(e){};
	//try{
	//gbToggleDisplay(document.getElementById(sDivToShow+"Foot"),true);
	//} catch(e){};
	try{
	document.getElementById(sImgToDown).src="images/page/"+sImgSrcToDown+"Sel.gif";
	} catch(e){};
	
}

function gbToggleDiv(imgToChange, divToToggle) {
	if(divToToggle.style.display=='none') {
		divToToggle.style.display='block';
		imgToChange.src="images/page/ArrowD.gif";
	} else {
		divToToggle.style.display='none';
		imgToChange.src="images/page/ArrowR.gif";
	}
}

function gbToggleSlideDiv(imgToChange, divToToggle) {
	if(divToToggle.style.display=='none') {
		//divToToggle.style.display='block';
		new Effect.SlideDown(divToToggle);
		imgToChange.src="images/page/ArrowD.gif";
	} else {
		//divToToggle.style.display='none';
		new Effect.SlideUp(divToToggle);
		imgToChange.src="images/page/ArrowR.gif";
	}
}

function gbToggleVisible(objElement, bShow) {
	if(objElement.style.visibility=="hidden" && bShow==null || bShow==true)
		objElement.style.visibility="visible";
	else
		objElement.style.visibility="hidden";
}
function gbToggleDisplay(objElement, bShow) {
	if(objElement.style.display=="none" && bShow==null || bShow==true)
		objElement.style.display="block";
	else
		objElement.style.display="none";
}
function gbMousePos(e)
{
	//Assigns to global vars iMouseX and iMouseY
	if (!e)
	var e = window.event||window.Event;
	
	if('undefined'!=typeof e.pageX)
	{
		iMouseX = e.pageX;
		iMouseY = e.pageY;
	}
	else
	{
		iMouseX = e.clientX + document.body.scrollLeft;
		iMouseY = e.clientY + document.body.scrollTop;
	}
	
	//gbinas: Make FlyProgressBar follow mouse
	try{
	var pgb=Engine.progressBar.bar;
	pgb.style.top=iMouseY+10;
	pgb.style.left=iMouseX+10;
	} catch(e){};
}

function gbScrollTop()
{
	scroll(0,0);	
}

function gbTOSearch(sCatID, sSubCatID) {
	//alert( Math.abs(iMouseX-iClickMouseX) + ":" + Math.abs(iMouseY-iClickMouseY) );
	//Check Cancel Search
	if( (Math.abs(iMouseX-iClickMouseX)>1 || Math.abs(iMouseY-iClickMouseY)>1) && iSearchPeriod<8) {
		clearTimeout(tSearchTime);
		iClickMouseX=iMouseX;
		iClickMouseY=iMouseY;
		tSearchTime=window.setTimeout('gbTOSearch("'+ sCatID + '", "'+ sSubCatID + '");', 250);
		iSearchPeriod=0;
		imgSearchAnim.src="images/icons/icoSearch0.gif";
	}
	else
	{
		if(iSearchPeriod<8)
		{
			iSearchPeriod++;
			imgSearchAnim.src="images/icons/icoSearch"+iSearchPeriod+".gif";
			tSearchTime=window.setTimeout('gbTOSearch("'+ sCatID + '", "'+ sSubCatID + '");', 250);
		}
		else
		{
			//alert(sCatID);
			//alert(arSearch.length);
			//if(sCat!="")
				//if(sDevelWhere!="")
				//sCat=document.getElementById(oCat).value;
				//sDevelWhere=document.getElementById(oDevelWhere).value;
			sQSd="";
			sQSs="";
			sQSp="";
			sQSc="";
			sParam="";
			for(var v in arSearch)
			{
				if(v.indexOf("dvl")==0)
				{
					if(arSearch[v])
						sQSd += "|" + v.substring(3);
				}
				if(v.indexOf("sub")==0)
				{
					//alert(v);
					if(arSearch[v])
						sQSs += "|" + v.substring(3);
				}
				if(v.indexOf("prc")==0)
				{
					//alert(v);
					if(arSearch[v])
						sQSp += "|" + v.substring(3);
				}
				if(v.indexOf("cust")==0)
				{
					//alert(v);
					if(arSearch[v])
					{
						if(v.indexOf("cust_param_sub")==0)
						{
							sParam="&ShowSubs=1";
							sQSc += ";" + v.substring(14);
						} else {
							sQSc += ";" + v.substring(4);
						}
					}
				}
			}

			//trim leading | or ;
			if(sQSd.substring(0,1)=="|")
				sQSd=sQSd.substring(1,sQSd.length);
			if(sQSs.substring(0,1)=="|")
				sQSs=sQSs.substring(1,sQSs.length);
			if(sQSp.substring(0,1)=="|")
				sQSp=sQSp.substring(1,sQSp.length);
			if(sQSc.substring(0,1)==";")
				sQSc=sQSc.substring(1,sQSc.length);

			//alert("SearchDevel="+sQSd+"&SearchSubCat="+sQSs+"&SearchPrice="+sQSp);
			//Clear arSearch
			arSearch=new Array();
			//get('listajax.php?SearchCat='+sCatID+'&SearchSubCat='+sSubCatID+'&SearchDevel='+sQSd+'&SearchSubCat2='+sQSs+'&SearchPrice='+sQSp+'&Extra='+sQSc+'&SubCode=1'+sParam, 'AjaxMain', null, true, gbScrollTop);
			get('listajax.php?SearchCat='+sCatID+'&SearchSubCat='+sSubCatID+'&SearchDevel='+sQSd+'&SearchSubCat2='+sQSs+'&SearchPrice='+sQSp+'&Extra='+sQSc+'&SubCode=1&ShowSubs=1', 'AjaxMain', null, true, gbScrollTop);
		} // !iSearchPeriod<4
	} //If not cancel search
}

function gbClickDevel(aclicked, sCatID, sSubCatID)
{
	//alert(sCatID);
	iClickMouseX=iMouseX;
	iClickMouseY=iMouseY;
	if(arSearch[aclicked.id]==true)
	{
		aclicked.className='DevelText1';
		arSearch[aclicked.id]=false;
	}
	else
	{
		aclicked.className='DevelTextSel';
		arSearch[aclicked.id]=true;
	}
	
	//try
	//{
		clearTimeout(tSearchTime)
	//}
	//catch(e)
	//{};
	
	if(gbArSearchHasTrue())
	{
		//alert("has true");
		tSearchTime=window.setTimeout('gbTOSearch("'+ sCatID + '", "'+ sSubCatID + '");', 1000);
	}
	iSearchPeriod=0;
	imgSearchAnim.src="images/icons/icoSearch0.gif";
	return(false);
}

function gbClickFilter(aclicked, sCatID, sSubCatID, sSort)
{
	//Select or Deselect Clicked item
	if(arSearch[aclicked.id]==true)
		arSearch[aclicked.id]=false;
	else
		arSearch[aclicked.id]=true;

	//Search (get ajax replacement)
	sQSd="";
	sQSs="";
	sQSp="";
	sQSc="";
	sQSc1="";
	sQSc2="";
	sQSc3="";
	sQSc4="";
	sQSc5="";
	sQSc6="";
	sQSc7="";
	sQSc8="";
	sQSc9="";	
	sParam="";
	for(var v in arSearch)
	{
		if(v.indexOf("dvl")==0)
			if(arSearch[v])
				sQSd += "|" + v.substring(3);
		if(v.indexOf("sub")==0)
			if(arSearch[v])
				sQSs += "|" + v.substring(3);
		if(v.indexOf("prc")==0)
			if(arSearch[v])
				sQSp += "|" + v.substring(3);
		//if(v.indexOf("cus")==0) //Matches cust (old style) and cus1 cus2 cus3 cus4 (new/correct style)
		//	if(arSearch[v])
		//		sQSc += ";" + v.substring(4); //trim cust, cus1, cus2, ...
		if(v.indexOf("cus1")==0)
			if(arSearch[v])
				sQSc1 += "|" + v.substring(4); //trim cusX
		if(v.indexOf("cus2")==0)
			if(arSearch[v])
				sQSc2 += "|" + v.substring(4); //trim cusX
		if(v.indexOf("cus3")==0)
			if(arSearch[v])
				sQSc3 += "|" + v.substring(4); //trim cusX
		if(v.indexOf("cus4")==0)
			if(arSearch[v])
				sQSc4 += "|" + v.substring(4); //trim cusX
		if(v.indexOf("cus5")==0)
			if(arSearch[v])
				sQSc5 += "|" + v.substring(4); //trim cusX
		if(v.indexOf("cus6")==0)
			if(arSearch[v])
				sQSc6 += "|" + v.substring(4); //trim cusX
		if(v.indexOf("cus7")==0)
			if(arSearch[v])
				sQSc7 += "|" + v.substring(4); //trim cusX
		if(v.indexOf("cus8")==0)
			if(arSearch[v])
				sQSc8 += "|" + v.substring(4); //trim cusX
		if(v.indexOf("cus9")==0)
			if(arSearch[v])
				sQSc9 += "|" + v.substring(4); //trim cusX
		
	}

	//trim leading | or ;
	if(sQSd.substring(0,1)=="|")
		sQSd=sQSd.substring(1,sQSd.length);
	if(sQSs.substring(0,1)=="|")
		sQSs=sQSs.substring(1,sQSs.length);
	if(sQSp.substring(0,1)=="|")
		sQSp=sQSp.substring(1,sQSp.length);
//	if(sQSc.substring(0,1)==";")
//		sQSc=sQSc.substring(1,sQSc.length);
	if(sQSc1.substring(0,1)=="|")
		sQSc1=sQSc1.substring(1,sQSc1.length);
	if(sQSc2.substring(0,1)=="|")
		sQSc2=sQSc2.substring(1,sQSc2.length);
	if(sQSc3.substring(0,1)=="|")
		sQSc3=sQSc3.substring(1,sQSc3.length);
	if(sQSc4.substring(0,1)=="|")
		sQSc4=sQSc4.substring(1,sQSc4.length);
	if(sQSc5.substring(0,1)=="|")
		sQSc5=sQSc5.substring(1,sQSc5.length);
	if(sQSc6.substring(0,1)=="|")
		sQSc6=sQSc6.substring(1,sQSc6.length);
	if(sQSc7.substring(0,1)=="|")
		sQSc7=sQSc7.substring(1,sQSc7.length);
	if(sQSc8.substring(0,1)=="|")
		sQSc8=sQSc8.substring(1,sQSc8.length);
	if(sQSc9.substring(0,1)=="|")
		sQSc9=sQSc9.substring(1,sQSc9.length);
	
	//sQSc=sQSc1+";"+sQSc2+";"+sQSc3+";"+sQSc4+";"+sQSc5+";"+sQSc6+";"+sQSc7+";"+sQSc8+";"+sQSc9;

	if(sQSc1!="")
		sQSc=sQSc1;
	if(sQSc2!="")
		sQSc=sQSc+";"+sQSc2;
	if(sQSc3!="")
		sQSc=sQSc+";"+sQSc3;
	if(sQSc4!="")
		sQSc=sQSc+";"+sQSc4;
	if(sQSc5!="")
		sQSc=sQSc+";"+sQSc5;
	if(sQSc6!="")
		sQSc=sQSc+";"+sQSc6;
	if(sQSc7!="")
		sQSc=sQSc+";"+sQSc7;
	if(sQSc8!="")
		sQSc=sQSc+";"+sQSc8;
	if(sQSc9!="")
		sQSc=sQSc+";"+sQSc9;
		
	if(sQSc.substring(0,1)==";")
		sQSc=sQSc.substring(1,sQSc.length);

	sarSearch=sQSd+'|'+sQSs+'|'+sQSp+'|'+sQSc;

	//alert("SearchDevel="+sQSd+"&SearchSubCat="+sQSs+"&SearchPrice="+sQSp+"&Extra="+sQSc);

	get('filtersajax.php?Cat='+sCatID+'&SubCat='+sSubCatID+'&SearchCat='+sCatID+'&SearchSubCat='+sSubCatID+'&SearchDevel='+sQSd+'&SearchSubCat2='+sQSs+'&SearchPrice='+sQSp+'&Extra='+sQSc+'&sLastClick='+aclicked.id+'&sArSearch='+sarSearch+'&Sort='+sSort, 'AjaxSearch', null, false, null);
	get('listajax.php?Cat='+sCatID+'&SubCat='+sSubCatID+'&SearchCat='+sCatID+'&SearchSubCat='+sSubCatID+'&SearchDevel='+sQSd+'&SearchSubCat2='+sQSs+'&SearchPrice='+sQSp+'&Extra='+sQSc+'&SubCode=1&ShowSubs=1&sArSearch='+sarSearch+'&Sort='+sSort, 'AjaxResults', null, true, gbScrollTop);
}

function gbArSearchHasTrue()
{
	bHasTrue=false;
	for(var v in arSearch)
		if(arSearch[v]==true)
			bHasTrue=true;

	return(bHasTrue);
}

function gbEortLine() {
	//eortLine++;
	new Effect.Fade(eval('eort'+eortLine), {duration: 0.5});
	eortLine++;
	if( eortLine > (eortMaxLines-1) )
		eortLine=eortLine % eortMaxLines;
	new Effect.Appear(eval('eort'+eortLine), {delay:0.7});
	eortT=window.setTimeout('gbEortLine();', 6000);
}

function gbChangeCat()
{
	//alert(sChPRet.innerHTML);
	var sRet=sChCatRet.innerHTML;
	
	imgTopLogo.src="images/page/"+sSessionCatID+"/Logo.jpg";
	document.getElementById('cmdQuick').src="images/page/"+sSessionCatID+"/Arrow1.gif";
	document.getElementById('cmdEorto').src="images/page/"+sSessionCatID+"/Arrow1.gif";
	//tdTopQuick1.background="images/page/"+sSessionCatID+"/QuickZ.gif";
	//tdTopQuick2.background="images/page/"+sSessionCatID+"/QuickZ.gif";
	document.getElementById('tdTopQuick1').background="images/page/"+sSessionCatID+"/QuickZ.gif";
	document.getElementById('tdTopQuick2').background="images/page/"+sSessionCatID+"/QuickZ.gif";
	document.getElementById('tdTopQuick3').background="images/page/"+sSessionCatID+"/QuickZ.gif";
	document.getElementById('tdTopQuickBell').background="images/page/"+sSessionCatID+"/QuickZ.gif";
	document.getElementById('tdTopQuick1').style.backgroundImage="url(images/page/"+sSessionCatID+"/QuickZ.gif)";
	document.getElementById('tdTopQuick2').style.backgroundImage="url(images/page/"+sSessionCatID+"/QuickZ.gif)";
	document.getElementById('tdTopQuick3').style.backgroundImage="url(images/page/"+sSessionCatID+"/QuickZ.gif)";
	document.getElementById('tdTopQuickBell').style.backgroundImage="url(images/page/"+sSessionCatID+"/QuickZ.gif)";
	document.getElementById('AjaxMenu').style.backgroundImage="url(images/page/"+sSessionCatID+"/UnderMenu.gif)";

	switch(sRet)
	{
		case "change":
			//alert("change");
			//gbShowPopup(ppPassOK, ppPassOKImg, getAllLeft(aChPass)+0, getAllTop(aChPass)+30, 'CN');
			get('menuajax.php', 'AjaxMenu',null,false);
			break;
		case "stay":
			//alert("No Change Old Pass Wrong");
			//gbShowPopup(ppPassError, ppPassErrorImg, getAllLeft(aChPass)+0, getAllTop(aChPass)+30, 'N');
			//alert('stay');
			break;
		case "not found":
			//alert("Not Found");
			break;
		default:
			//alert('sChCatRet='+sRet);
			break;
	}
	get(sItemNext, 'AjaxMain',null,true);
	window.scroll(0,0);
}

function gbShowItemXar(sID, sXar1, sXar2, sXar3)
{
	//alert('id='+sID+', Xar1='+sXar1+', Xar2='+sXar2);
	if(sXar2)
		get('itemajax.php?ID='+sID+'&Xar1='+sXar1+'&Xar2='+sXar2,'AjaxMain',null,true);
	else
		get('itemajax.php?ID='+sID+'&Xar1='+sXar1,'AjaxMain',null,true);
}

function gbRestoreAjaxMain(divToChange)
{
	document.getElementById('AjaxMain').innerHTML=divCache.innerHTML;
}