function getphp(page,sendget,resultid,openin)
{

 var myurl=page+"?"+sendget;
    try{xmlHttp=new XMLHttpRequest(); }
    catch (e)
    {try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
    catch (e)
    {try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
    catch (e)
    {alert("Ajax is not supported by your browser.");return false;}}}
    
    xmlHttp.onreadystatechange=function()
    {
	    if(xmlHttp.readyState==4)
	    {
		    if(openin=="div")
		    {
		    	document.getElementById(resultid).innerHTML="";
		    	document.getElementById(resultid).innerHTML=xmlHttp.responseText;
		    	document.getElementById('reset').style.visibility="visible";
                document.getElementById('reset').value="Återställ";
                document.getElementById('reset').disabled=false;
		    }
		    else if(openin=="window")
		    {
		    	mywindow(xmlHttp.responseText);
		    }
		    else
		    {
		    	return xmlHttp.responseText;
		    }
	    }
    }
    xmlHttp.open("GET", myurl, true);
    xmlHttp.send(null);
}
function sendform(i)
{
	//var kategori="transport";
    document.getElementById('reset').disabled="true";
    document.getElementById('reset').value="Laddar";
	var xmm="test="+rand(1,1500);
	var obj=document.seekform;
	var getstring="endprice="+obj.endprice.value+"&";
	getstring+="startprice="+obj.startprice.value+"&";
	getstring+="stopyear="+obj.stopyear.value+"&";
	getstring+="startyear="+obj.startyear.value+"&";
	getstring+="startmile="+obj.startmile.value+"&";
	getstring+="city="+obj.city.value+"&";
	getstring+="endmile="+obj.endmile.value+"&";
	getstring+="kategori="+kategori+"&";
	//if(i==2)
	//	getstring+="sortval="+obj.sortval.value+"&";
	if(obj.seek.value=="Ange sökord här")
	{
		
		getstring+="seek=&"+xmm;
	}
	else
		getstring+="seek="+obj.seek.value+"&"+xmm;	
	if(i==2)
	{
		getstring+="&sortval="+obj.sortval.value+"&";
		getphp("modulx/seek.php",getstring,'searchresult','div');
	}
	else if(i==1)
		getphp("modulx/seek.php",getstring,'searchresult','div');
	else
		getphp("modulx/seek.php",getstring+"&campain=0",'searchresult','div');
	obj.sortval.selectedIndex=0;
}
function rand( min, max ) 
{
	if( max ) 
	{
		return Math.floor(Math.random() * (max - min + 1)) + min;
	} 
	else 
	{
		return Math.floor(Math.random() * (min + 1));
	}
}

