		// JavaScript Document
		var xmlHttp
		
		//Show drop down  models for the selected Projector Manufacturer
		function showModel(str)
		{ 
			xmlHttp=GetXmlHttpObject()
			
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return
			} 
		
			var url="getmodel.php"
			url=url+"?q="+str
			xmlHttp.onreadystatechange=stateChanged 
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)
		}
		
		//This function is used in the showModel() function
		function stateChanged() 
		{ 
		    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{ 
				document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
			} 
		} 
		
		
		//Show Model Details
		function showModelDetails(str)
		{ 
			 xmlHttp=GetXmlHttpObject()
			 if (xmlHttp==null)
			 {
				alert ("Browser does not support HTTP Request")
				return
			 } 
			 // show loader image
			 document.getElementById('txtModel').innerHTML = '<div style="width:550px;vertical-align:middle;padding:150 0 0 0;background-color:#000000;display:block;left:0;opacity:0.4;top:0;visibility:visible;z-index:102; height:180px" align="center" ><img src="images/ajax_loader.gif"></div>'
			
			 var url="getmodeldetails.php"
			 url=url+"?model="+str
			 xmlHttp.onreadystatechange=stateChangedDetails 
			 xmlHttp.open("GET",url,true)
			 xmlHttp.send(null)
			 searchPro.SearchField.focus();
		}
		
		//Show Search Details
		function showSearchDetails(searchPro)
		{ 
			xmlHttp=GetXmlHttpObject()
			
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return
			} 
			
			if(searchPro.SearchField.value=="")
			{
				alert("Enter the text to search the product");
				searchPro.SearchField.focus();
				return false;
			}else
			{
				var str=document.getElementById("SearchField").value
				//var str=searchPro.SearchField.value
				var url="search.php"
				url=url+"?search="+str
				xmlHttp.onreadystatechange=stateChangedDetails 
				xmlHttp.open("GET",url,true)
				xmlHttp.send(null)
				return false;
			
			}
		
		}
		
		//This function is used in the showModelDetails(), showSearchDetails() function
		function stateChangedDetails() 
		{ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{ 
				document.getElementById("txtModel").innerHTML=xmlHttp.responseText 
			} 
		} 
		
		//Add quantity to shoping cart for the product
		function shopingCart(model,price)
		{ 
		
		//alert(price);
			  xmlHttp=GetXmlHttpObject()
			  if (xmlHttp==null)
			  {
			  	 alert ("Browser does not support HTTP Request")
				 return
			  } 
		      // show loader image
			  document.getElementById("txtCart").innerHTML = '<img src="images/ajax_loader1.gif">'
			  var url="shopQty.php"
			  url=url+"?model="+model+"&price="+price
			  xmlHttp.onreadystatechange=stateChangedCart
			  xmlHttp.open("GET",url,true)
			  xmlHttp.send(null)
	    }
		
		//Delete the product from shopping cart
		function shopingCartDelete(proid)
		{ 
		
			xmlHttp=GetXmlHttpObject()
			
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return
			} 
		
			var url="shopQty.php"
			url=url+"?proid="+proid
			xmlHttp.onreadystatechange=stateChangedCart 
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)
		}
		
		//Update the product from shopping cart
		function shopingCartUpdateQty(qty,product,proprice)
		{ 
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return
			} 
		
			var url="shopQty.php"
			url=url+"?quantity="+qty+"&product="+product+"&proprice="+proprice
			xmlHttp.onreadystatechange=stateChangedCart 
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)
		
		}
		
		//Confirm the order 
		
		
		
		function shopingOrderConfirm(num)
		{ 
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return
			} 
			document.getElementById("txtCart").innerHTML = '<img src="images/ajax_loader1.gif">'
			var url="confirmOrder.php"
			url=url
			xmlHttp.onreadystatechange=stateChangedCart 
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)
		}
		
		//Confirm the order 
		function showOrderSuccess(buyer)
		{ 
			 xmlHttp=GetXmlHttpObject()
			 if (xmlHttp==null)
			 {
				alert ("Browser does not support HTTP Request")
				return
			 } 
			 var url="success.php"
			 url=url
			 xmlHttp.onreadystatechange=stateChangedCart 
			 xmlHttp.open("GET",url,true)
			 xmlHttp.send(null)
		}
			
		//This function is used in the shopingCart(), shopingCartDelete(), shopingCartUpdateQty(), shopingOrderConfirm   function
		function stateChangedCart() 
		{ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{ 
	
				document.getElementById("txtCart").innerHTML=xmlHttp.responseText 
			} 
		} 
		
		// For login
		function login(rpage)
		{ 
		    xmlHttp=GetXmlHttpObject()
		    var email = document.getElementById('email').value;
		    var pass = document.getElementById('password').value;
		    if (xmlHttp==null)
		    { 
			    alert ("Browser does not support HTTP Request")
			    return
		    }  
		    var url="cust_login.php?email="+email+"&pass="+pass+"&rpage="+rpage
		    xmlHttp.onreadystatechange=stateChangedLogin
		    xmlHttp.open("GET",url,true)
		    xmlHttp.send(null)
	    }
		
		
		// Changes Login State.
		function stateChangedLogin() 
		{ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{ 
			     var response = xmlHttp.responseText;
				 var result = response.split('#');
				 var result1 = result[1].replace(/^\s+|\s+$/g,"");
				  var result2 = result[0].replace(/^\s+|\s+$/g,"");
			     if( result1 == "Succ" ){
				     location.href = result2+'.php';				     
				  }else { 
				     document.getElementById("error_msg").innerHTML = xmlHttp.responseText; 
				}
			} 
  	   } 
		
		//Check the browser compatibility
		function GetXmlHttpObject()
		{ 
			var objXMLHttp=null
			
			if (window.XMLHttpRequest)
			{
				objXMLHttp=new XMLHttpRequest()
			}else if (window.ActiveXObject)
			{
				objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
			}
			    return objXMLHttp
		}
		
		//function to get the values in confirm order field
		function GetOrderDetails(orderSuccess)
		{
			var buyer=document.frmSubmit.buyer.value;
			var billingadd=document.frmSubmit.billingadd.value;
			var shippingadd=document.frmSubmit.shippingadd.value;
			document.write(buyer);
			document.write(billingadd);
			document.write(shippingadd);
		}
		
		// for checkout
		
		function redirect()
		{
	   		location.href = 'checkout.php';
		}	 
			
		
		
		
		function copy_billing()
		{  
		    if(document.getElementById("shipping_copy").checked==true)
			{
				document.reg_form.cust_companys.value=document.reg_form.cust_companyb.value;
				document.reg_form.cust_contacts.value=document.reg_form.cust_contactb.value;
				document.reg_form.cust_addresss1.value=document.reg_form.cust_addressb1.value;
				document.reg_form.cust_addresss2.value=document.reg_form.cust_addressb2.value;
				document.reg_form.cust_states.value=document.reg_form.cust_stateb.value;
				document.reg_form.cust_citys.value=document.reg_form.cust_cityb.value;
				document.reg_form.cust_zips.value=document.reg_form.cust_zipb.value;
				document.reg_form.cust_countrys.value=document.reg_form.cust_countryb.value;
				document.reg_form.cust_phones.value=document.reg_form.cust_phoneb.value; 
				if(document.reg_form.otherState_b.value != '')
				{
					document.getElementById('cust_states').style.display='none';	 
				    document.getElementById('otherState_s').style.display='';
					document.reg_form.otherState_s.value=document.reg_form.otherState_b.value;
				}else{
					document.getElementById('otherState_s').style.display='none';
				    document.getElementById('cust_states').style.display='';
				}
				return true;        
			}
			else
			{
				document.reg_form.cust_companys.value='';
				document.reg_form.cust_contacts.value='';
				document.reg_form.cust_addresss1.value='';
				document.reg_form.cust_addresss2.value='';
				document.reg_form.cust_states.value='';
				document.reg_form.cust_citys.value='';
				document.reg_form.cust_zips.value='';
				document.reg_form.cust_countrys.value='';
				document.reg_form.cust_phones.value=''; 
				return true;        
			}
			
		}
		
		function checkCountry_b(country)
		{
			//alert(country);
			if(country !='IN - India')
			{
					//alert("dsifdisfoi");
				document.getElementById('cust_stateb').style.display='none';	
				document.getElementById('cust_stateb').value=''
				document.getElementById('otherState_b').style.display='';
			}
			else
			{
				document.getElementById('otherState_b').style.display='none';
				document.getElementById('otherState_b').value='';
				document.getElementById('cust_stateb').style.display='';
			}
		}
		
		function checkCountry_s(country)
		{
			//alert(country);
			if(country !='IN - India')
			{
				 //alert("dsifdisfoi");
				 document.getElementById('cust_states').style.display='none';	
				 document.getElementById('cust_states').value='';
				 document.getElementById('otherState_s').style.display='';
			}
			else
			{
				 document.getElementById('otherState_s').style.display='none';
				 document.getElementById('cust_states').style.display='';
				 document.getElementById('otherState_s').value='';
			}
		}
		function checkvaliadtions()
		{
			 var doc = document.reg_form;
			 if(doc.email.value=='')
			 {
				alert("Please enter Email address");	
				doc.email.focus;
				return false;
			 }
			 if (echeck(doc.email.value)==false)
			 {
		 		 doc.email.value="";
				 doc.email.focus();
				 return false
			 }
			
			 if(doc.cust_contactb.value=='')
			 {
			 	 alert("Please enter Contact Name");	
				 doc.cust_contactb.focus;
				 return false;
			 }
			 if(doc.cust_addressb1.value=="")
			 {
				 alert("Please enter Billing Address");	
				 doc.cust_addressb1.focus;
				 return false;	
			 }
			 if(doc.cust_cityb.value=="")
			 {
				 alert("Please enter Billing city");	
				 doc.cust_cityb.focus;
				 return false;
			 }
			 if(doc.cust_phoneb.value=='' ||  !IsNumeric(doc.cust_phoneb.value))
			 {
			 	 alert("Please enter valid Phone Number");	
				 doc.cust_phoneb.focus;
				 return false;
			 }
			 if(doc.cust_companys.value=='')
			 {
				 alert("Please enter Shipping Company");	
				 doc.cust_companys.focus;
				 return false;
			 }
			 if(doc.cust_contacts.value=='')
			 {
				 alert("Please enter Conatct Name for Shipping");	
				 doc.cust_contacts.focus;
				 return false;
			 }
			
			 if(doc.cust_addresss1.value=='')
			 {
				alert("Please enter Shipping Address");	
				doc.cust_addresss1.focus();
				return false;
			}
			if(doc.cust_zips.value=='')
			{
				alert("Please enter Shipping Zip Code");	
				doc.cust_zips.focus;
				return false;
			}
			if(doc.cust_citys.value=='')
			{
				alert("Please enter Shipping City");	
				doc.cust_citys.focus;
				return false;
			}
			if(doc.cust_phones.value=='' ||  !IsNumeric(doc.cust_phones.value))
			{
				alert("Please enter valid Shipping Contact Number");	
				doc.cust_phones.focus;
				return false;
			}
		}
		
function echeck(str) 
{

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Invalid E-mail ID")
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		alert("Invalid E-mail ID")
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		alert("Invalid E-mail ID")
		return false
	 }

	 return true					
}
function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

 //Check that the enter value is only number
	function numbersonly(e)
	{
		 var unicode = e.charCode? e.charCode : e.keyCode;
		 if(unicode==45) // its - means point	
		 {
			 return true; 
		 }
		 if ( unicode!=8  )
		 {  
		      //if the key isn't the backspace key (which we should allow)
			  if( unicode<48 || unicode>57 ) //if not a number
				 return false; //disable key press
			  else 
			 	 return true;
		 }
	}