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) 
{ 
 
      // xmlHttp = createXMLHttpRequest();
      //xmlHttp.onreadystatechange = handleStateChange; 
	 //var myRand=parseInt(Math.random()*999999999);
      //xmlHttp.open("GET", "field_match.php?text="+escape(text)+"&rand="+myRand, true); 
      //xmlHttp.send(null);
	  
	     parameters = "&text=" + encodeURI(document.getElementById("name").value );
   

	 var icollection;
 var xcollection;
 xcollection=0
 
 for(icollection=document.form_sok.collection.options.length-1;icollection>=0;icollection--)
 {
  if(document.form_sok.collection.options[icollection].selected)
  {
   parameters = parameters + "&collection["+xcollection+"]="+document.form_sok.collection.options[icollection].value;
   xcollection=xcollection+1;
   //alert ('hej')
  }
   
 }
		 var icolor;
 var xcolor;
 xcolor=0
 
 for(icolor=document.form_sok.color.options.length-1;icolor>=0;icolor--)
 {
  if(document.form_sok.color.options[icolor].selected)
  {
   parameters = parameters + "&color["+xcolor+"]="+document.form_sok.color.options[icolor].value;
   xcolor=xcolor+1;
   //alert ('hej')
  }
   
 }
	
	
		 var iprice;
 var xprice;
 xprice=0
 
 for(iprice=document.form_sok.price.options.length-1;iprice>=0;iprice--)
 {
  if(document.form_sok.price.options[iprice].selected)
  {
   parameters = parameters + "&price["+xprice+"]="+document.form_sok.price.options[iprice].value;
   xprice=xprice+1;
   //alert ('hej')
  }
   
 }
	
	


	   xmlHttp = createXMLHttpRequest();
      xmlHttp.onreadystatechange = handleStateChange; 
      xmlHttp.open("POST", "field_match.php", true);
   xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      xmlHttp.send(parameters); 
	  
} 
 


function startRequest2(text) 
{ 
  
    // var price=this.value;
	  
      xmlHttp = createXMLHttpRequest();
      xmlHttp.onreadystatechange = handleStateChange2; 
	  var myRand=parseInt(Math.random()*999999999);
      xmlHttp.open("GET", "http://www.clasalenius.se/sokning.php?text="+escape(text) +"&rand="+myRand, true);  
	  
	  //startrequest2 används då man ska sortera prdoukterna
      xmlHttp.send(null); 


} 



function startRequest3(text2) 
{ 
   if(text2 != "") 
   { 
   
    
       xmlHttp = createXMLHttpRequest();
      xmlHttp.onreadystatechange = handleStateChange3; 
	 var myRand=parseInt(Math.random()*999999999);
      xmlHttp.open("GET", "http://www.clasalenius.se/adresser.php?text2="+escape(text2)+"&rand="+myRand, true); 
      xmlHttp.send(null);
	  
	 
	 	 
	  
   } 
   else 
   { 
      document.getElementById('kundvagn').innerHTML = ""; 
	   
   } 
} 
 


function handleStateChange3() 
{ 
  

  
  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('kundvagn').innerHTML = update[1]; 
		 //alert ('vanlig');
        // document.getElementById('submit').disabled  = true; 
        
      } 
   } 
}
  if(xmlHttp.readyState < 4) 
   { 
  
  document.getElementById('kundvagn').innerHTML = '<div align="center"><br><br><br><br>laddas...vanta...<br><br><br><br></div>'; 
   
   }
}








function handleStateChange2() 
{ 
  

  
  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('result44').innerHTML = update[1]; 
		 //alert ('vanlig');
        // document.getElementById('submit').disabled  = true; 
        
      } 
   } 
}
  if(xmlHttp.readyState < 4) 
   { 
  
  document.getElementById('result44').innerHTML = '<br><br><div align=center>Laddas...</div><br><br>'; 
   
   }
}






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 = '<div align=center><img src="loading2.gif" width="138" height="136"></div><br><br>'; 
   
   }
}



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; 
} 




	<!--
	
	//Create a boolean variable to check for a valid Internet Explorer instance.
	var xmlhttp = false;
	
	//Check if we are using IE.
	try {
		//If the Javascript version is greater than 5.
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		//alert ("You are using Microsoft Internet Explorer.");
	} catch (e) {
		//If not, then use the older active x object.
		try {
			//If we are using Internet Explorer.
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			//alert ("You are using Microsoft Internet Explorder");
		} catch (E) {
			//Else we must be using a non-IE browser.
			xmlhttp = false;
		}
	}
	
	//If we are using a non-IE browser, create a javascript instance of the object.
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
		//alert ("You are not using Microsoft Internet Explorer");
	}
	
	
	function makerequest(serverPage, objID) {
		
		var obj = document.getElementById(objID);
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}
	
	//-->
	
	
	
	


