// 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 pid,name,qty,price,sh,licenses,lic1_2,lic3_4,lic5_9,lic10_24,lic_25_,licText;
	licenses=1;
	licText="";
	
	
	
	if(id!="")
	{
		
		
		pid=document.getElementById('ID' + id).value;	
		
		
		name=document.getElementById('Name' + id).value;
		
		//alert(document.getElementById('Price' + id).value);
		price=document.getElementById('Price' + id).value;
		
		qty=1;
	
		
		sh=0;
		//alert(sh);
		if(id=="200020")
		{			
			licenses=document.getElementById('txtLicenses').value;
			
			if(licenses<=0)
			{
				alert("# of Licenses You Wish To Purchase is invalid!");
				return false;
			}
			lic1_2=document.getElementById('txtLic1_2').value;
			
			lic3_4=document.getElementById('txtLic3_4').value;
			
			lic5_9=document.getElementById('txtLic5_9').value;

			lic10_24=document.getElementById('txtLic10_24').value;
			
			lic_25_=document.getElementById('txtLic_25_').value;											
			
			if(licenses>=1 && licenses<=2)
			{
				//price=parseInt(lic1_2)  * parseInt(licenses);
				price=lic1_2;				
				
			}
			else if(licenses>=3 && licenses<=4)
				//price=parseInt(lic3_4) * parseInt(licenses);
				price=lic3_4;
			else if(licenses>=5 && licenses<=9)
				//price=parseInt(lic5_9) * parseInt(licenses);
				price=lic5_9;
			else if(licenses>=10 && licenses<=24)
				//price=parseInt(lic10_24) * parseInt(licenses);
				price=lic10_24;
			else if (licenses>=25)
				//price=parseInt(lic_25_) * parseInt(licenses);
				price=lic_25_;
			else
			{
				alert("Licenses You Wish To Purchase is a numeric!");
				return false;
			}
			licText=" <b>(" + licenses + " Licenses)</b>";
			price=price*licenses;
			//alert(id);	
			
		}
		
		info="&proName="+ name + licText + "&qty=" + qty + "&price=" + price + "&sh=" +sh;

				
		var url="DesktopsAjax.asp?act=add&proID=" + id + info + "&time="+currentTime;
		
		//alert(url);
		xmlHttp=GetXmlHttpObject(stateChangedRedirect);
		xmlHttp.open("GET", url , true);
		xmlHttp.send(null);
		//window.location = "mycart.asp";
	}
	
} 
function stateChangedRedirect()
{
	//alert(xmlHttp.readyState);
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{

		//s = xmlHttp.responseText;	
		
		
		//document.getElementById('item').innerHTML=s;		
		location.href='mycart.asp';
			
		
	}
	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();                 
                }
            }        
}

//-->
