

var xmlHttp; 


function createXMLHttpRequest() 
{ 
var xmlHttp=null; 
try 
{ 
// FF, Opera 8.0+, Safari 
xmlHttp=new XMLHttpRequest(); 
} 
catch (e) 
{ 
//Internet Explorer 
try 
  { 
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
  } 
catch (e) 
  { 
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 
  } 
} 
return xmlHttp; 
}



function startRequest(text) 
{ 
  
    // var price=this.value;
	  
	  //alert(price);
	  
      xmlHttp = createXMLHttpRequest();
      xmlHttp.onreadystatechange = handleStateChange; 
	  var myRand=parseInt(Math.random()*999999999);
      xmlHttp.open("GET", "field_match.php?text="+escape(text) +"&rand="+myRand, true);  
	  
	  //startrequest2 används då man ska sortera prdoukterna
      xmlHttp.send(null); 


}  



function handleStateChange() 
{ 
  

  
  if(xmlHttp.readyState == 4) 
   { 
   
  
   
   
   if(xmlHttp.status == 200) 
   { 
   
 
      var response = xmlHttp.responseText; 
      var update = new Array(); 
      if(response.indexOf('||' != -1)) 
      { 
         update = response.split('||'); 
       
         document.getElementById('result').innerHTML = update[1]; 
		 //alert ('vanlig');
        // document.getElementById('submit').disabled  = true; 
        
      } 
   } 
}
  if(xmlHttp.readyState < 4) 
   { 
  
  document.getElementById('result').innerHTML = ''; 
   
   }
}

 
