var xmlHttp;
var catid;
var catid1;
function catval(str,ind)
{
var url="getcategory.php?sid=" + Math.random() + "&q=" + str;
xmlHttp=GetXmlHttpObject(stateChanged);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);
showmenu(str,ind);
}

function getprod(prod,mypos)
{ //alert (prod);
catid1=prod;
var url="getcategory1.php?sid=" + Math.random() + "&cat_id=" + prod;
xmlHttp=GetXmlHttpObject(stateChanged1);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);
showprod();

}

function stateChanged1()
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ ccc="catdiva"+catid1;
document.getElementById(ccc).innerHTML=xmlHttp.responseText;
} 
}

function catval1()
{ 
 //alert ("out");
//document.getElementById("cataj").innerHTML="";
document.getElementById("cataj").style.visibility="hidden";
} 
function catval2(ddd)
{
 ddd1="catdiva"+ddd;
document.getElementById(ddd1).innerHTML="";
document.getElementById(ddd1).style.visibility="hidden";
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("cataj").innerHTML=xmlHttp.responseText;
} 
} 


function createorder(subcat,subprod,prod,prodprice)
{catid=subprod;
 cqty="qty"+catid;
 myqty=document.getElementById(cqty).value;
 //alert(myqty);
var url="getcategory2.php?sid=" + Math.random() + "&action=add_product&products_id=" + subprod + "&prodid=" + prod +"&cart_quantity="+myqty +"&p_sprice=" + prodprice;
xmlHttp=GetXmlHttpObject(stateChanged2);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);
//remmenu2();
}

function stateChanged2()
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ cdiv="div"+catid;
  ctxt="qty"+catid;

resp=xmlHttp.responseText;
//alert(resp);

resparr=resp.split("^");
//alert (resp);
document.getElementById(cdiv).innerHTML="<table align=right cellspacing=0 cellpadding =0 class=odbox5><tr><td align=right><font color=navy ><b>"+resparr[2] +"</td></tr></table>";
document.getElementById(cdiv).style.textalign="right";
document.getElementById(ctxt).value=resparr[1];
document.getElementById("carttot").innerHTML="<font color=white><b>"+resparr[0]+"</b>";
//document.getElementById(cdiv).style.visibility="visible";
} 
}
function delprod(subcat,subprod,prod)
{catid=subprod;

var url="getcategory2.php?sid=" + Math.random() + "&action=del_product&products_id=" + subprod + "&prodid=" + prod ;
xmlHttp=GetXmlHttpObject(stateChanged3);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);
//remmenu2();
}

function stateChanged3()
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ cdiv="div"+catid;
ctxt="qty"+catid;
resp=xmlHttp.responseText;

resparr=resp.split("^");
if(resparr[2]==0)
document.getElementById(cdiv).innerHTML="";
else
document.getElementById(cdiv).innerHTML="<font color=navy ><b>"+resparr[2];
document.getElementById(cdiv).style.textalign="right";
if(resparr[1]==0)
document.getElementById(ctxt).value="";
else
document.getElementById(ctxt).value=resparr[1];
document.getElementById("carttot").innerHTML="<font color=white><b>"+resparr[0]+"</b>";
} 
}

function GetXmlHttpObject(handler)
{ 
var objXmlHttp=null;

if (navigator.userAgent.indexOf("Opera")>=0)
{
alert("This example doesn't work in Opera");
return 
}
if (navigator.userAgent.indexOf("MSIE")>=0)
{ 
var strName="Msxml2.XMLHTTP";
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP";
} 
try
{ 
objXmlHttp=new ActiveXObject(strName);
objXmlHttp.onreadystatechange=handler;
return objXmlHttp;
} 
catch(e)
{ 
alert("Error. Scripting for ActiveX might be disabled");
return 
} 
} 
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttp=new XMLHttpRequest();
objXmlHttp.onload=handler;
objXmlHttp.onerror=handler;
return objXmlHttp;
}
} 

function getbrowsertype()
{
    var AgntUsr=navigator.userAgent.toLowerCase();
    var AppVer=navigator.appVersion.toLowerCase();
    var DomYes=document.getElementById?1:0;
    var NavYes=AgntUsr.indexOf('mozilla')!=-1&&AgntUsr.indexOf('compatible')==-1?1:0;
    var ExpYes=AgntUsr.indexOf('msie')!=-1?1:0;
    if (NavYes==1)
    return 1;
    if (ExpYes==1)
    return 0;
    
    
    //alert(NavYes);
    //alert(ExpYes);
}


function showmenu(myid,myind)
{var x;
x=0;
//alert (myid);
var thisid;
 thisid=document.getElementById("cataj");


    thisid.style.visibility="visible";
    z=document.body.offsetWidth; 

    var btype;
    btype=getbrowsertype();
    if (btype==1)
    x=z-800+18;
    else
    x=z-800;
    x=x/2;
    x=x+70;
    //alert (x);
    thisid.style.left=x;
    mytop=94;
    topinc=myind*36.5;
    mytop=mytop+topinc;
    thisid.style.top=mytop;

    //thisid.style.visibility="hidden";


 }

function showprod()
{var x;
x=0;

var thisid;
thisid1="catdiva"+catid1;
 thisid=document.getElementById(thisid1);

 //alert (thisid1);
    thisid.style.visibility="visible";


    //thisid.style.visibility="hidden";


 }

function remmenu()
{
var thisid;
 thisid=document.getElementById("cataj");
      // alert();
   thisid.style.visibility="hidden";
}
function showmenu1()
{
var thisid;
 thisid=document.getElementById("cataj");
      // alert();
   thisid.style.visibility="visible";
}
function remmenu2()
{
var thisid;
thisid1="catdiva"+catid;
 thisid=document.getElementById(thisid1);
      // alert();
   thisid.style.visibility="hidden";
   thisid.innerHTML="";
}