// JavaScript Document
//////////////////////////////////////////////////////////////
var teststring

function showmanufacturer(str)
{
	if(document.getElementById(str).innerHTML != "") 
	{
		document.getElementById(str).innerHTML = ""
		return
	}
	teststring = str
	//document.getElementById(str).innerHTML = "<br><img src='../loading.gif'>"
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="showmanufacturer.asp"
	url=url+"?sid="+Math.random()
	url=url+"&type="+str	
	xmlHttp.onreadystatechange=stateChangedshowmanufacturer
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 

function stateChangedshowmanufacturer()
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(teststring).innerHTML = xmlHttp.responseText
	}
} 
/////////////////////////////////////////////////////////////////////////////////

function compare(str)
{
	teststring = str
	document.getElementById("comparestatus"+str).innerHTML = "<br><img src='../newloading.gif'>"
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="compare.asp"
	url=url+"?sid="+Math.random()
	url=url+"&productid="+str	
	xmlHttp.onreadystatechange=stateChangedcompare
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 

function stateChangedcompare()
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("comparestatus"+teststring).innerHTML = ""
		document.getElementById("comparesection").innerHTML = xmlHttp.responseText
		return 1
	}
} 
/////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////

function addtocart(str)
{
	teststring = str
	document.getElementById("cartitems").innerHTML = "<br><img src='../newloading.gif'>"
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="addtocart.asp"
	url=url+"?sid="+Math.random()
	url=url+"&productid="+str	
	xmlHttp.onreadystatechange=stateChangedaddtocart
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 

function stateChangedaddtocart()
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		alert("Successfully Added To Cart.")
		document.getElementById("cartitems").innerHTML = xmlHttp.responseText
	}
} 
////////////////////////////////////////////////////////////////////////////////
function addtowishlist(str)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="addtowishlist.asp"
	url=url+"?sid="+Math.random()
	url=url+"&productid="+str	
	xmlHttp.onreadystatechange=stateChangedaddtowishlist
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 

function stateChangedaddtowishlist()
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		alert(xmlHttp.responseText)
	}
} 
/////////////////////////////////////////////////////////////////////////////////

function addquantity(str)
{
	teststring = str
	//document.getElementById("quantity"+str).innerHTML = "<br><img src='../loading.gif'>"
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="addquantity.asp"
	url=url+"?sid="+Math.random()
	url=url+"&productid="+str	
	url=url+"&action=add"	
	xmlHttp.onreadystatechange=stateChangedaddquantity
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 

function stateChangedaddquantity()
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("quantity"+teststring).innerHTML = xmlHttp.responseText
		calculateprice()
	}
} 
/////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////////

function removecart(str)
{
	teststring = str
	//document.getElementById("quantity"+str).innerHTML = "<br><img src='../loading.gif'>"
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="addquantity.asp"
	url=url+"?sid="+Math.random()
	url=url+"&productid="+str	
	url=url+"&action=remove"	
	xmlHttp.onreadystatechange=stateChangedremovecart
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 

function stateChangedremovecart()
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		window.location.href="shoppingcart.asp"
	}
} 
/////////////////////////////////////////////////////////////////////////////////

function subquantity(str)
{
	teststring = str
	//document.getElementById("quantity"+str).innerHTML = "<br><img src='../loading.gif'>"
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="addquantity.asp"
	url=url+"?sid="+Math.random()
	url=url+"&productid="+str	
	url=url+"&action=sub"	
	xmlHttp.onreadystatechange=stateChangedaddquantity
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 

/////////////////////////////////////////////////////////////////////////////////

function calculateprice()
{
	//document.getElementById("totalprice").innerHTML = "<br><img src='../loading.gif'>"
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="calculateprice.asp"
	url=url+"?sid="+Math.random()
	xmlHttp.onreadystatechange=stateChangedcalculateprice
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 

function stateChangedcalculateprice()
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById("totalprice").innerHTML = xmlHttp.responseText
	}
} 
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////

function addtocartaccess(str)
{
	teststring = str
	document.getElementById("cartitems").innerHTML = "<br><img src='../newloading.gif'>"
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="../store/addtocart.asp"
	url=url+"?sid="+Math.random()
	url=url+"&productid="+str	
	xmlHttp.onreadystatechange=stateChangedaddtocartaccess
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 

function stateChangedaddtocartaccess()
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		alert("Successful Add To Cart")
		window.location.href="shoppingcart.asp"
	}
} 
////////////////////////////////////////////////////////////////////////////////

function addtocartfeatured(str)
{
	teststring = str
	document.getElementById("cartitems").innerHTML = "<br><img src='../newloading.gif'>"
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="../store/addtocart.asp"
	url=url+"?sid="+Math.random()
	url=url+"&productid="+str	
	xmlHttp.onreadystatechange=stateChangedaddtocartfeatured
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 

function stateChangedaddtocartfeatured()
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		alert("Successful Add To Cart")
		document.getElementById("cartitems").innerHTML = xmlHttp.responseText
	}
} 
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) /2 -100;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}
/////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////

function GetXmlHttpObject()
{ 
	var objXMLHttp=null
		if (window.XMLHttpRequest)
		{
		objXMLHttp=new XMLHttpRequest()
		}
		else if (window.ActiveXObject)
		{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
		}
	return objXMLHttp
} 
