var xmlHttp;

function searchProduct(str) { 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
 alert ("Browser does not support HTTP Request");
 return;
 }

var url="searchProduct.php?searchstring="+str;
xmlHttp.onreadystatechange=searchChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function searchChanged() { 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
	if(xmlHttp.responseText=="test" || xmlHttp.responseText==""){
		document.getElementById('searchResults').innerHTML = "";
		document.getElementById("searchResults").style.height=1+"px";
		}else{
		document.getElementById('searchResults').innerHTML = xmlHttp.responseText;
		document.getElementById("searchResults").style.height=100+"%";
	}
 } 
}


function quoteForm(thisform) {
                xmlHttp=GetXmlHttpObject();
                if (xmlHttp==null) {
 alert ("Browser does not support HTTP Request");
 return;
 }
 var formdata = "";
 formdata = "name=" + thisform.elements['name'].value + "&company=" + thisform.elements['company'].value + "&phone=" + thisform.elements['phone'].value  + "&email=" + thisform.elements['email'].value + "&address=" + thisform.elements['address'].value + "&city=" + thisform.elements['city'].value + "&State=" + thisform.elements['State'].value + "&p1=" + thisform.elements['p1'].value + "&p2=" + thisform.elements['p2'].value + "&p3=" + thisform.elements['p3'].value + "&zip=" + thisform.elements['zip'].value + "&quantity1=" + thisform.elements['quantity1'].value + "&quantity2=" + thisform.elements['quantity2'].value + "&quantity3=" + thisform.elements['quantity3'].value + "&date1=" + thisform.elements['date1'].value + "&date2=" + thisform.elements['date2'].value + "&date3=" + thisform.elements['date3'].value + "&where2Internet=" + thisform.elements['where2Internet'].value + "&where2News=" + thisform.elements['where2News'].value + "&where2Other=" + thisform.elements['where2Other'].value + "&otherText=" + thisform.elements['otherText'].value;
 
                xmlHttp.onreadystatechange=formSubmitted;  
				
                xmlHttp.open("POST", "requestQuoteScript.php",true);
                xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                xmlHttp.setRequestHeader("Content-length", formdata.length);
                xmlHttp.setRequestHeader("Connection", "close");
                xmlHttp.send(formdata);
                return false;
}

function formSubmitted(){
                if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
                	document.getElementById("feedback").innerHTML = xmlHttp.responseText;
					
					if(xmlHttp.responseText == "<strong>Thank-you - your message has been submitted</strong>. A representative will contact you shortly"){
						document.getElementById("webform").reset();
						alert("Thank-you - your message has been submitted. A representative will contact you shortly");	
					}
					
                }
	}
	
	
	function contactForm(thisform) {
                xmlHttp=GetXmlHttpObject();
                if (xmlHttp==null) {
 alert ("Browser does not support HTTP Request");
 return;
 }
 var formdata = "";
 formdata = "name=" + thisform.elements['name'].value + "&company=" + thisform.elements['company'].value + "&phone=" + thisform.elements['phone'].value  + "&email=" + thisform.elements['email'].value + "&address=" + thisform.elements['address'].value + "&city=" + thisform.elements['city'].value + "&com=" + thisform.elements['com'].value + "&whereInternet=" + thisform.elements['whereInternet'].value + "&whereNews=" + thisform.elements['whereNews'].value + "&whereOther=" + thisform.elements['whereOther'].value + "&otherText=" + thisform.elements['otherText'].value;
               
			    xmlHttp.onreadystatechange=contactFormSubmitted;  
                xmlHttp.open("POST", "contactScript.php",true);
                xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                xmlHttp.setRequestHeader("Content-length", formdata.length);
                xmlHttp.setRequestHeader("Connection", "close");
                xmlHttp.send(formdata);
                return false;
}

function contactFormSubmitted(){
                if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
                	document.getElementById("feedback").innerHTML = xmlHttp.responseText;
				
					if(xmlHttp.responseText == "<strong>Thank-you - your message has been submitted</strong>. A representative will contact you shortly"){
						
						document.getElementById("webform").reset();
						alert("Thank-you - your message has been submitted. A representative will contact you shortly");	
					}
                }
	}
	
	
	function internet(){
		if(document.getElementById("internet").value="no"){
			document.getElementById("internet").value="yes";
			alert('fdsfds');
		}
	}
	
	function news(){
		if(document.getElementById("news").value="no"){
			document.getElementById("news").value="yes";
			alert('fdafsd');
		}
	}
	
	function other(){
		if(document.getElementById("other").value="no"){
			document.getElementById("other").value="yes";
			alert(fdafsd);
		}
	}


function GetXmlHttpObject() {
xmlHttp=null;
try
 {
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}


