  var IE4 = document.all; 
function getDummyID(id)
{
time=new Date();
if (!id)
  id='DUMMY';
var loc=id+'=';
loc+=time.getTime();
return loc;
}
function getbaseurl(url)
{
var index=url.indexOf('?');
if (index==-1)
    return url;
return url.substr(0,index);
}
function replace(string,text,by) {
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}
function go_page(cmd,selectobj)
{
var value=selectobj.options[selectobj.selectedIndex].value;
do_command(cmd,'PAGE',value);
}
function do_command(cmd,varname,val)
{
var cmdstring='CMD='+cmd;
if (varname!=''){
	if (IE4){
	 cmdstring+='&'+varname+'='+escape(val);
	}else{
 cmdstring+='&'+varname+'='+val;  
	}
}
loc=getbaseurl(location.href);
loc+='?'+cmdstring;
loc+='&'+getDummyID();
location=loc;
}
function go_lang(langid)
{
loc=location.href;
var index=loc.indexOf('LANGID=');
if (index==-1){
   if (loc.indexOf('?')==-1){
	 		loc+='?LANGID='+langid
	 }else{
	 		loc+='&LANGID='+langid;
	 }
}else{
	 var oldlangid=loc.charAt(index+7);
	 var oldlangcmd='LANGID='+oldlangid;
	 var newlangcmd='LANGID='+langid;
	 loc=replace(loc,oldlangcmd,newlangcmd);
}
location=loc;
}
function gosearch()
{
var loc='search_result.php?CMD=SEARCH';
//var method=document.searchform.METHOD.options[document.searchform.METHOD.selectedIndex].value;
	var method=document.searchform.METHOD.value;
	 loc+='&METHOD='+method;
if (document.searchform.searchall){
if (document.searchform.searchall.checked){
	 loc+='&searchall=YES';
}	 
}
if (document.searchform.catsearch){
	 if (document.searchform.catsearch.checked){
	 		loc+='&catsearch=YES';
	 }
}
if (method == '1'){
	 loc+='&keywords='+escape(document.searchform.keywords.value);
}
if (method == '2'){
	 loc+='&below='+escape(document.searchform.below.value);
	 loc+='&above='+escape(document.searchform.above.value);
}

 location=loc;
}
function gosearch1()
{
var loc='search_result.php?CMD=SEARCH';
var method=document.cat1form.METHOD1.value;
	 loc+='&METHOD1='+method;
if (method == '3'){
	 if (document.cat1form.astext1)
	 loc+='&astext1='+escape(document.cat1form.astext1.options[document.cat1form.astext1.selectedIndex].value);
if (document.cat1form.astext2)
	 loc+='&astext2='+escape(document.cat1form.astext2.options[document.cat1form.astext2.selectedIndex].value);
if (document.cat1form.astext3)
	 loc+='&astext3='+escape(document.cat1form.astext3.options[document.cat1form.astext3.selectedIndex].value);
if (document.cat1form.astext4)
	 loc+='&astext4='+escape(document.cat1form.astext4.options[document.cat1form.astext4.selectedIndex].value);
if (document.cat1form.astext5)
	 loc+='&astext5='+escape(document.cat1form.astext5.options[document.cat1form.astext5.selectedIndex].value);
if (document.cat1form.astext6)
	 loc+='&astext6='+escape(document.cat1form.astext6.options[document.cat1form.astext6.selectedIndex].value);
if (document.cat1form.astext7)
	 loc+='&astext7='+escape(document.cat1form.astext7.options[document.cat1form.astext7.selectedIndex].value);
	 				 
}

 location=loc;
}

function changeSearch(selectobj)
{
     var value=selectobj.options[selectobj.selectedIndex].value;
		 pagename=getbaseurl(location.href);
     loc=pagename+'?CMD=CHGSEARCH&METHOD='+value;
     location=loc;
}
function prevcat()
{
pagename=getbaseurl(location.href);
 var loc=pagename+'?CMD=PREVCAT';
		 loc+='&'+getDummyID('PCNS');

     location=loc;
       
}

function changeCat(catid,reset)
{
pagename='catalog.php';
     var loc=pagename+'?CMD=CHGCAT&CATID='+catid;
		 loc+='&'+getDummyID('CNS');
		 if (reset)
		    loc+='&CATRESET=1';
     location=loc;
}
function changeCat1(selectobject)
{
var pagename=getbaseurl(location.href);;
var catid=selectobject.options[selectobject.selectedIndex].value;
     var loc=pagename+'?CMD=CHGCAT1&PRESISTRESET=1&CATID='+escape(catid);
		 loc+='&'+getDummyID('CNS');
     location=loc;
}
function searchCatTree()
{
var pagename=getbaseurl(location.href);;
var catid=document.cattreeform.lastcatid.value;
var loc=pagename+'?CMD=SRCHCATTREE&PRESISTRESET=1&LASTCATID='+escape(catid);
		loc+='&'+getDummyID('CNS');
		if (document.cat1form){
	 if (document.cat1form.astext1)
	 loc+='&astext1='+escape(document.cat1form.astext1.options[document.cat1form.astext1.selectedIndex].value);
if (document.cat1form.astext2)
	 loc+='&astext2='+escape(document.cat1form.astext2.options[document.cat1form.astext2.selectedIndex].value);
if (document.cat1form.astext3)
	 loc+='&astext3='+escape(document.cat1form.astext3.options[document.cat1form.astext3.selectedIndex].value);
if (document.cat1form.astext4)
	 loc+='&astext4='+escape(document.cat1form.astext4.options[document.cat1form.astext4.selectedIndex].value);
if (document.cat1form.astext5)
	 loc+='&astext5='+escape(document.cat1form.astext5.options[document.cat1form.astext5.selectedIndex].value);
if (document.cat1form.astext6)
	 loc+='&astext6='+escape(document.cat1form.astext6.options[document.cat1form.astext6.selectedIndex].value);
if (document.cat1form.astext7)
	 loc+='&astext7='+escape(document.cat1form.astext7.options[document.cat1form.astext7.selectedIndex].value);
}
     location=loc;
}

function loadProdDetail(prd_sku)
{
	var IE4 = document.all; 
     if (IE4){
     var fromhref=escape(location.href);
     var loc='product_detail.php?PRD_SKU='+escape(prd_sku)+'&PRDFROMURL='+fromhref;
	}else{
	var temphref=location.href;
	 var fromhref=escape(temphref);
     var loc='product_detail.php?PRD_SKU='+prd_sku+'&PRDFROMURL='+fromhref; 

	}
     location=loc;
}                  

function addCartItem(prd_sku,urlencode)
{
     var href=location.href;
		 var index=href.indexOf('PRDFROMURL');
		 if (index!=-1){
		 		 href=href.substr(0,index);
		 }
	if (IE4){
	   var fromhref=escape(href);
	}else{
	var fromhref=escape(escape(href));
	}
      var CTSN=getDummyID('CTSN');
     if (IE4){ 
     var loc='cart.php?CMD=ADDCARTITEM&'+CTSN+'&PRD_SKU='+escape(prd_sku)+'&FROMURL='+fromhref;
	}else{
	   if (urlencode)
	     prd_sku=escape(prd_sku);
 var loc='cart.php?CMD=ADDCARTITEM&'+CTSN+'&PRD_SKU='+prd_sku+'&FROMURL='+fromhref;
	}
		 /*
		 document.cmdform.CMD.value='ADDCARTITEM';
		 document.cmdform.PRD_SKU.value=prd_sku;
		 document.cmdform.FROMURL.value=fromhref;
		 document.cmdform.submit();
		 */
		 location=loc;
}
function addCartItem1()
{
     var href=location.href;
		 var index=href.indexOf('PRDFROMURL');
		 if (index!=-1){
		 		 href=href.substr(0,index);
		 }
     var fromhref=escape(href);
     
      var CTSN=getDummyID('CTSN');
     
     var loc;
     loc='cart.php?CMD=ADDCARTITEM&'+CTSN+'&FROMURL='+fromhref;
      var checkbox;
			var inumitem;
			inumitem=0;
      for (i=0;i<document.productsel.elements.length;i++){
         checkbox=document.productsel.elements[i];
	 if (checkbox.checked){
	    if (checkbox.checked==true){
				 inumitem++;				 
	       loc+='&'+escape('PRD_SKU[]')+'='+escape(checkbox.value);
	    }
	 }
      }
			if (inumitem<=0){
				 alert('No product selected!\nPlease click checkbox to select product.');
			}else
      location=loc;
      /*
      document.productsel.CTSN.value=loc;
     document.productsel.FROMURL.value=fromhref;
     document.productsel.submit();
     */
}

function delCartItem(id)
{
	if (IE4){
     fromhref=escape(location.href);
	}else{
 fromhref=location.href;
	}
	if (IE4){
     var loc='cart.php?CMD=DELETECARTITEM&ID='+escape(id);
	}else{
  var loc='cart.php?CMD=DELETECARTITEM&ID='+id;
	}
		 location=loc;
}
function updateCart(url)
{   
	if (document.cartform){ 
		 document.cartform.CMD.value='UPDATECART';
                 if (url){
		    if (IE4){
		       url=unescape(url);
		    }else{
		       url=unescape(unescape(url));
		    }
		    if (document.cartform.gourl)
		      document.cartform.gourl.value=url;
		 }
                    
		 document.cartform.submit();
	}else{
	location=url;
	}
}
function go_url1(url)
{
   updateCart(url);
   
}
function go_checkout1()
{
   
   updateCart('checkout.php');
   
}
function go_url(url)
{
   if (IE4){
      location=unescape(url);
   }else{
      location.href=unescape(unescape(url));
   }
   //location.href=unescape(url);
}
function go_cart()
{
   
   var href=location.href;
   var index=href.indexOf('PRDFROMURL');
   if (index!=-1){
		 		 href=href.substr(0,index);
		 }
	if (IE4){
		 var fromhref=escape(href);
	}else{
		var fromhref=escape(href);
	}

     var loc='cart.php?FROMURL='+fromhref;
		 location=loc;
}
function go_checkout()
{
		 var href=location.href;
		 var index=href.indexOf('PRDFROMURL');
		 if (index!=-1){
		 		 href=href.substr(0,index);
		 }
	if (IE4){
    fromhref=escape(href);
	}else{
	fromhref=escape(href);
	}
    var loc='checkout.php?FROMURL='+fromhref;
		loction=loc;
}
function logout()
{
loc=getbaseurl(location.href);
loc+='?CMD=LOGOUT';
location=loc;

}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
//MM_reloadPage(true);



