// JavaScript Document
//<!--
	var currentTime=new Date();
	//alert(AddProduct);
  


 
function GetXmlHttpObject(handler)
{ 
	var objXmlHttp=null;

	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 AddProduct(id,time)
{ 
	
	var ram,hd,warr,drive,caseprice,ramtx,hdtx,warrtx,drivetx;
	var pid,name,price,warrinf,fee,sh,cpu,groupid,info;
	
	if(id!="")
	{
		
		pid=document.getElementById('ID' + id).value;			
		name=document.getElementById('Name' + id).value;
		price=document.getElementById('Price' + id).value;
		sh=document.getElementById('SH' + id ).value;
		
		
		info="pid="+pid+ "&name="+name +"&price=" + price + "&sh=" + sh;

										
		
		var url="DesktopsAjax.asp?act=add&productID=" + id + "&" + info+"&time="+currentTime;
		

		xmlHttp=GetXmlHttpObject(stateChanged);
		xmlHttp.open("GET", url , true);
		xmlHttp.send(null);
	}
	
} 
function FillData()
{ 
	
	var url="DesktopsAjax.asp?productID=&time="+currentTime;
	xmlHttp=GetXmlHttpObject(stateChanged);
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
	
	
} 

function EditProduct(id)
{ 
	
	var url="DesktopsAjax.asp?orderID=" + id + "&act=edit&time="+currentTime;
	xmlHttp=GetXmlHttpObject(stateChanged);
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
	
	
} 

var pQty,rQty,hQty;
pQty=rQty=hQty="0";

function GetValue(txt)
{ 
			
	var subStr = "";
	var fail = "";
		
		if (txt.value == "") {
			subStr = subStr + "- Please enter quantity.\n";		
		}

		if (subStr != ""){
		    messStr="The following fields are required:\n";
		    messStr=messStr + "____________________________________\n\n";		
		    endStr="Please enter the requested information.  Thank you!";
		    alert(messStr + subStr + "____________________________________\n\n" + endStr);
		    
	    }
		else
		{
			
			if(txt.id=="product")
				pQty=txt.value;
			else if(txt.id=="ram")
				rQty=txt.value;
			else if(txt.id=="hd")
				hQty=txt.value;
				
		}			
} 

function UpdateQuantity(id)
{ 
	
	
		try{
				pQty=document.getElementById(id).value;
		}catch(err){; }
		if(!isNaN(pQty) && pQty>=0)
		{
			try{
				//rQty=document.getElementById('ram2').value;
				rQty=document.getElementById(id).value;
			}catch(err){; }
			try{
				//hQty=document.getElementById('hd22').value;
				hQty=document.getElementById(id).value;
			}catch(err){; }
			//alert("DesktopsAjax.asp?act=updateQuantity&pQty="+ pQty +"&rQty=" + rQty + "&hQty="+ hQty);
		//	alert(document.getElementById('hd22').value);
			var url="DesktopsAjax.asp?act=updateQuantity&pQty="+ pQty +"&rQty=" + rQty + "&hQty="+ hQty +"&id="+ 

id +"&time="+currentTime;
			xmlHttp=GetXmlHttpObject(stateChanged);
			xmlHttp.open("GET", url , true);
			xmlHttp.send(null);
		}
		else		
			alert("Invalid value!");
	
	
} 
function stateChanged() 
{ 
	//alert(xmlHttp.readyState);
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{

		s = xmlHttp.responseText;
		ss = s.split("__,__");				
		
		if(ss.length>1)
		{
			document.getElementById('item').innerHTML=ss[0];
			document.getElementById('amount').innerHTML=ss[1];
			
			
			
			
			document.getElementById('yourcart').innerHTML=ss[2];
		
		
		}
		
		
		
	}
	currentTime=new Date();

} 


function numberOnly(txt,e) {
    obj = document.all ? window.event : e;
            touch = document.all ? obj.keyCode : obj.which;
            var txtValue = txt.value;
            var ch = String.fromCharCode(touch)                    
            if(String(parseFloat(txtValue + ch)) == "NaN" || (touch < 48 || touch > 57) && touch != 46 || (txtValue.indexOf(".") != -1 && touch == 46) )
            {                     
                if(document.all) 
                {                 
                    obj.returnValue = false;                                 
                } 
                else 
                {               
                    obj.preventDefault();                 
                }
            }        
}

//-->
