function GetXmlHttpObject(){
	var objXMLHttp=null
	if (window.XMLHttpRequest){
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject){
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
} 

function add_to_cart(qty_id,pricename,prodthumbnail)
{
	xmlHttp1=GetXmlHttpObject()
	
	if (xmlHttp1==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 


	var temp2=document.getElementById("quantity_"+qty_id).selectedIndex;
	var qty=document.getElementById("quantity_"+qty_id).options[temp2].value;

	if(document.getElementById("color_"+qty_id)){
		var temp3=document.getElementById("color_"+qty_id).selectedIndex;
	        var color=document.getElementById("color_"+qty_id).options[temp3].value;
	}
	if(document.getElementById("size_"+qty_id)){
                var temp4=document.getElementById("size_"+qty_id).selectedIndex;
                var size=document.getElementById("size_"+qty_id).options[temp4].value;
        }
	var url="/pbj/include/add_to_cart.php"
	url=url+"?name="+pricename
	if(size>''){
		url=url+"&size="+size
	}
	if(color>''){
	        url=url+"&color="+color
        }
	url=url+"&quantity="+qty+"&imagethmb="+prodthumbnail
	xmlHttp1.onreadystatechange=stateChangedaddfunction
	xmlHttp1.open("GET",url,true)
	xmlHttp1.send(null)
	if(size=='choose'){
		document.getElementById("final_"+qty_id).innerHTML="<font color=red>!</font>Please select a size"
	}
	if(color=='choose'){
                document.getElementById("final_"+qty_id).innerHTML="<font color=red>!</font>Please select a color"
        }
	if(color!='choose'&&size!='choose'){
		document.getElementById("final_"+qty_id).innerHTML="<font color='#ff6600' size='2'><b>"+qty+" - Item Added to Cart</b></font>"
	}
} 
function stateChangedaddfunction(prid) 
{
	if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete")
	{ 
	/*	document.getElementById("final_"+prid).innerHTML=xmlHttp1.responseText*/ 
	} 
	
}


function dropdowncart()
{
        xmlHttp2=GetXmlHttpObject()

        if (xmlHttp2==null)
        {
                alert ("Browser does not support HTTP Request")
                return
        }


        var url="/pbj/include/shop_dropdown.php"
        xmlHttp2.onreadystatechange=stateChangeddropdown
        xmlHttp2.open("GET",url,true)
        xmlHttp2.send(null)
}
 
function stateChangeddropdown()
{
        if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
        {
              document.getElementById("dropdown").innerHTML=xmlHttp2.responseText
      	}

}

function updatecount()
{
        xmlHttp3=GetXmlHttpObject()
        if (xmlHttp3==null)
        {
                alert ("Browser does not support HTTP Request")
                return
        }


        var url="/pbj/include/itemcount.php"
        xmlHttp3.onreadystatechange=stateChangeditemcount
        xmlHttp3.open("GET",url,true)
        xmlHttp3.send(null)
}

function stateChangeditemcount()
{
        if (xmlHttp3.readyState==4 || xmlHttp3.readyState=="complete")
        {
              document.getElementById("itemcount").innerHTML=xmlHttp3.responseText
      }

}
function updatecart()
{
        xmlHttp4=GetXmlHttpObject()
        if (xmlHttp4==null)
        {
                alert ("Browser does not support HTTP Request")
                return
        }
	document.getElementById("updatecart").innerHTML='<br><br><br><center><b>Please Wait...</b><br><img src="/sc/ajax-loader.gif"></center><br><br>';

        var url="/sc/itemlisting.php"
        xmlHttp4.onreadystatechange=stateChangedupdatecart
        xmlHttp4.open("GET",url,true)
        xmlHttp4.send(null)
}

function stateChangedupdatecart()
{
        if (xmlHttp4.readyState==4 || xmlHttp4.readyState=="complete")
        {
              document.getElementById("updatecart").innerHTML=xmlHttp4.responseText
      }

}

