var xmlHttp

function showAdvanced()
{

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
  alert ("Browser does not support HTTP Request")
   return
    }
    var url="t.php"
    url=url+"?sid="+Math.random()
    xmlHttp.onreadystatechange=stateChanged 
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)

}

function loadsearch()
{

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

var url="ssdone.php"
url=url+"?sid="+Math.random()
xmlHttp.onreadystatechange=stateChangedloaded
xmlHttp.open("GET",url,true)
xmlHttp.send(null)

}
			      


function gosearch()
{

window.location = "#s";
//alert("here");

}


function newsearch()
{

window.location = "#s";
doLists_a();

document.mainform1.min_pr.selectedIndex = 0;
document.mainform1.max_pr.selectedIndex = 0;
document.mainform1.keywords.value  = "Keyword (e.g. 520i, turbo)";
document.mainform1.min_year.selectedIndex = 0;
document.mainform1.max_year.selectedIndex = 0;
document.mainform1.mileage_RANGE.selectedIndex = 0;
document.mainform1.source.selectedIndex = 0;
document.mainform1.county.selectedIndex = 0;
document.mainform1.sort.selectedIndex = 0;

}

function newsearchs()
{

window.location = "#s";
document.mainform.model.selectedIndex = 0;
document.mainform.make.selectedIndex = 0;
document.mainform.min_pr.selectedIndex = 0;
document.mainform.max_pr.selectedIndex = 0;

}





function getResultss()
{

var ct = "ZA";
var cr ="ZAR";
var mode ="1";

var make  = document.mainform.make.value;
var model  = document.mainform.model.value;
var minp = document.mainform.min_pr.value;
var maxp  = document.mainform.max_pr.value;

document.getElementById("ajax_result").innerHTML="<img src='/pics/ajax-loader2.gif' id='loader'  width='100' height='100' />";
window.location = window.location.href='#rs';

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

	 var url="a.php"
	 url=url+"?b="+make+"&c="+model+"&d="+minp+"&e="+maxp
	 url=url+"&sid="+Math.random()
	 xmlHttp.onreadystatechange=stateChangeda
	 xmlHttp.open("GET",url,true)
	 xmlHttp.send(null)

}

//deans change 


function getResultsst()
{

var ct = "ZA";
var cr ="ZAR";
var mode ="1";

var make  = document.mainform.make.value;
var model  = document.mainform.model.value;
var minp = document.mainform.min_pr.value;
var maxp  = document.mainform.max_pr.value;

document.getElementById("ajax_result").innerHTML="<img src='/pics/ajax-loader2.gif' id='loader'  width='100' height='100' />";
window.location = window.location.href='#rs';

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

	             var url="g.php"
		              url=url+"?b="+make+"&c="+model+"&d="+minp+"&e="+maxp
			               url=url+"&sid="+Math.random()
				                xmlHttp.onreadystatechange=stateChangeda
						         xmlHttp.open("GET",url,true)
							          xmlHttp.send(null)


}




//
//




function getResults()
{
//var keywords = document.mainform1.keywords.value;
if(document.mainform1.keywords.value  == "Keyword (e.g. 520i, turbo)")
{
document.mainform1.keywords.value = "";
}

var keywords = document.mainform1.keywords.value;
var make  = document.mainform1.make.value;
var model  = document.mainform1.model.value;
var minp = document.mainform1.min_pr.value;
var maxp  = document.mainform1.max_pr.value;
var miny  = document.mainform1.min_year.value;
var maxy  = document.mainform1.max_year.value;
var mil  = document.mainform1.mileage_RANGE.value;
var sel  = document.mainform1.source.value;
var country  = document.mainform1.county.value;
var sort  = document.mainform1.sort.value;

//window.location = "#r";
//window.location.hash="rs";
//window.location = "#s";
//window.location = "#rs";
//window.location = '#rs';

document.getElementById("ajax_result").innerHTML="<img src='/pics/ajax-loader2.gif' id='loader'  width='100' height='100' />";
window.location = window.location.href='#rs';


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

var url="b.php"
url=url+"?a="+keywords+"&b="+make+"&c="+model+"&d="+minp+"&e="+maxp+"&f="+miny+"&g="+maxy+"&h="+mil+"&i="+sel+"&j="+country+"&k="+sort
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChangeda
xmlHttp.open("GET",url,true)
xmlHttp.send(null)

}

function getResultsPaged(page,filen)
{
var keywords = document.mainform1.keywords.value;

if(document.mainform1.keywords.value  == "Keyword (e.g. 520i, turbo)")
{
document.mainform1.keywords.value = "";
}
 
var pgnum = page;
var file = filen;

var keywords = document.mainform1.keywords.value;
var make  = document.mainform1.make.value;
var model  = document.mainform1.model.value;
var minp = document.mainform1.min_pr.value;
var maxp  = document.mainform1.max_pr.value;
var miny  = document.mainform1.min_year.value;
var maxy  = document.mainform1.max_year.value;
var mil  = document.mainform1.mileage_RANGE.value;
var sel  = document.mainform1.source.value;
var country  = document.mainform1.county.value;
var sort  = document.mainform1.sort.value;

//window.location = "#r";
//window.location.hash="rs";
//window.location = "#s";
//window.location = "#rs";
//ndow.location = '#rs';
//window.location = window.location.href='#rs';

//document.getElementById("c_row3_Col2Holder").focus();


//o=GetXmlHttpObject()

xmlHttp=GetXmlHttpObject()

if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}

         var url="d.php"
         url=url+"?a="+keywords+"&b="+make+"&c="+model+"&d="+minp+"&e="+maxp+"&f="+miny+"&g="+maxy+"&h="+mil+"&i="+sel+"&j="+country+"&k="+sort+"&cc="+pgnum+"&fn="+file
         url=url+"&sid="+Math.random()
         xmlHttp.onreadystatechange=stateChangeda
         xmlHttp.open("GET",url,true)
         xmlHttp.send(null)

}



function getResultsPageds(page,filen)
{

var pgnum = page;
var file = filen;

var make  = document.mainform.make.value;
var model  = document.mainform.model.value;
var minp = document.mainform.min_pr.value;
var maxp  = document.mainform.max_pr.value;

//window.location = "#r";
//window.location.hash="rs";
//window.location = "#s";
//window.location = '#rs';
//window.location = window.location.href='#rs'; 

///document.getElementById("c_row3_Col2Holder").focus();


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

        var url="e.php"
        url=url+"?b="+make+"&c="+model+"&d="+minp+"&e="+maxp+"&cc="+pgnum+"&fn="+file
        url=url+"&sid="+Math.random()
        xmlHttp.onreadystatechange=stateChangeda
       xmlHttp.open("GET",url,true)
       xmlHttp.send(null)

}








function stateChanged() 
    { 
    	     if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
     	     { 
     		 document.getElementById("c_row1_topstoriesHolderWrap").innerHTML=xmlHttp.responseText; 
		 doLists_a();
 	     }
    } 

function stateChangedloaded()
{
	     
	     if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	     {
	     	     document.getElementById("srch_ldr").innerHTML=xmlHttp.responseText;
	     }
}


    function stateChangeda()
    {
	    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	    {
		document.getElementById("ajax_result").innerHTML=xmlHttp.responseText
	    }
    }




function GetXmlHttpObject()
{

   var xmlHttp=null;

    try
    {
 	 // Firefox, 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;

}

// extra function for switch over 





function check_form()
{

var ct = "ZA";
var cr ="ZAR";
var mode ="1"; 

var keywords = document.mainform1.keywords.value;
var make  = document.mainform1.make.value; 
var model  = document.mainform1.model.value;
var minp = document.mainform1.min_pr.value;
var maxp  = document.mainform1.max_pr.value;
var miny  = document.mainform1.min_year.value;
var maxy  = document.mainform1.max_year.value;
var mil  = document.mainform1.mileage_RANGE.value;
var sel  = document.mainform1.source.value;
var country  = document.mainform1.county.value;
var sort  = document.mainform1.sort.value;

alert(" text : "+keywords+" make : "+make+" model :"+model+" min price : "+minp+" max price  :"+maxp+" min year : "+miny+" max year "+" milage "+mil+" seller "+sel+" country "+country+" sort "+sort);
if(keywords  == "Keyword (e.g. 520i, turbo)")
{
//alert("hasn't changed ");
document.mainform1.keywords.value = "";

}


}


function printDiv(printpage)
{

//alert("here : "+printpage);

var headstr = "<html><head><title></title></head><body>";
var footstr = "</body>";

tWindow = window.open("", "tWindow", 'toolbar,width=350,height=350,scroll=yes');
tWindow.document.body.innerHTML = document.getElementById(printpage).innerHTML;
tWindow.print();
						
}





function doLists_a()  
{

if (document.mainform1 && typeof get_makes == 'function' && typeof get_range =='function' && typeof _model=='object' && typeof make_v=='object' && typeof make_d=='object')  
//alert("gets here...1");
{

if(document.mainform1.make != null && document.mainform1.make.type=='select-one')
{
//alert("before get makes");
get_makes();
//alert("finishes function");
if(document.mainform1.model != null && document.mainform1.model.type=='select-one')			
{
//alert("does second function ");
get_range(_model[document.mainform1.make.selectedIndex]);
}

}

}
if (document.mainform1 && typeof start_prefill == 'function')
{
//alert("does prefill");
start_prefill();		
}	

}



