GIF89a php
Current File : /home/hencockfreshchic/public_html/js/serachBox.js
function serachBox(page)
{
	document.getElementById("overlay").style.display = "block";
	var Search=$("#searchText").val();
	if(Search==""){
		document.getElementById("overlay").style.display = "none";
		 alert("Search box can not be empty");
     	 $("#searchText").focus();
     	 return false;
	}
	
		//window.location.href = ("serachBox.php?text="+Search);
		if (window.XMLHttpRequest) {           
            xmlhttp = new XMLHttpRequest();
        } else {            
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } 
  xmlhttp.onreadystatechange=function() 
   {
    if (this.readyState==4 && this.status==200) 
	{	
		if(this.responseText==0){
			document.getElementById("overlay").style.display = "none";
			alert("No product found on this keyword");
		}
		else
		{

      var id=this.responseText;   
        
         var strArray = id.split(",");  
         document.getElementById("overlay").style.display = "none";
         if(strArray[3]=="")
         {               
        window.location.href = ("shop.php?cat="+btoa(strArray[0])+"&subcat="+btoa(strArray[1]));
   		 }
   		 else if(strArray[3]=="C")
   		 {
   		 	window.location.href = ("shop.php?cat="+btoa(strArray[0])+"&subcat="+btoa(strArray[1]));
   		 }
   		 else if(strArray[3]=="P")
   		 {        
   		 	window.location.href = ("product-page.php?prod_id="+btoa(strArray[2]));
   		 }
       else if(strArray[3]=="MP")
       {
        window.location.href = ("shop.php?cat="+btoa(strArray[0])+"&subcat="+btoa(strArray[1]));
       }
        // Display array values on page
       /* for(var i = 0; i < strArray.length; i++){
            
        }*/	
		}
	}
  };
  xmlhttp.open("GET","serachBox.php?text="+Search,true);
  xmlhttp.send();
}