loc1 = location.href;
wwwloc=loc1.indexOf("www");
if(wwwloc>0)
	var site_url ='http://www.auto.in/';
else
	var site_url ='http://auto.in/';
//var site_url ='http://sys4/automobiles/';
var xmlHttp;
var id;
//************* Xml object creation for ajax**********	

function GetXmlHttpObject(handler)	{
	var objXmlHttp=null
	if (navigator.userAgent.indexOf("Opera")>=0)
	{
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler
		return objXmlHttp
	}
	if (navigator.userAgent.indexOf("MSIE")>=0)
	{
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
			strName="Microsoft.XMLHTTP"
		}
		try
		{
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler
			return objXmlHttp
		}
		catch(e)
		{
			alert("Error. Scripting for ActiveX might be disabled")
			return
		}
	}
	if (navigator.userAgent.indexOf("Mozilla")>=0)
	{
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler
		return objXmlHttp
	}
} 
/*
				function GetXmlHttpObject(handler){ 
						var objXmlHttp=null;
						
						if (window.XMLHttpRequest){
								objXmlHttp=new XMLHttpRequest();
								objXmlHttp.onload=handler;
								objXmlHttp.onerror=handler;
								return objXmlHttp;
						}else if (window.ActiveXObject){
								try{ 
										objXmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
										objXmlHttp.onreadystatechange=handler ;
										return objXmlHttp;
								} 
								catch(e){ 
										alert("Error. Scripting for ActiveX might be disabled");
										return;
								} 
						}else{
								alert("Error. Scripting for ActiveX might be disabled");
								return;
						}
						return objXmlHttp

						
						
				}
				*/
					
	function showDialect5(str,id2,id3){
			idcata = id2;
			var url=site_url+"common/model_list.php?search_model="+ str+"&Selected=" + id3;
			xmlHttp11=GetXmlHttpObject(stateChanged5);
			xmlHttp11.open("GET", url , true);
			xmlHttp11.send(null);
	}
	
	function showmodel(str,id2,id3){
		idcata = id2;
		var url=site_url+"common/model_list.php?search_model="+ str+"&Selected=" + id3;
		xmlHttp_m=GetXmlHttpObject(modelchanged);
		xmlHttp_m.open("GET", url , true);
		xmlHttp_m.send(null);
	}
	function modelchanged(){ 
			if (xmlHttp_m.readyState==4 || xmlHttp_m.readyState=="complete"){ 
					document.getElementById(idcata).innerHTML=xmlHttp_m.responseText ;
			}
	} 
	function reg_bike(id,id2) {
		idcata = id2;
		var url=site_url+"common/bike.php?type_id=" + id+"&id2="+id2;
		xmlHttp1=GetXmlHttpObject(reg_bikeChanged);
		xmlHttp1.open("GET", url , true);
		xmlHttp1.send(null);
	}
	function reg_bikeChanged(){ 
			if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete"){ 
					document.getElementById(idcata).innerHTML=xmlHttp1.responseText ;
			}
	}
	function reg_bikes(id,id2) {
		   idcata = id2;
			var url=site_url+"common/bikes.php?type_id=" + id;
			xmlHttp=GetXmlHttpObject(reg_bikesChanged);
			xmlHttp.open("GET", url , true);
			xmlHttp.send(null);
	}

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

	/* Leads page */
	function reg_bike1(id,id2,sel) {
		idcata = id2;
		var url=site_url+"common/bike.php?type_id=" + id+"&id2="+id2+"&sel="+sel;
		xmlHttp1=GetXmlHttpObject(reg_bikeChanged1);
		xmlHttp1.open("GET", url , true);
		xmlHttp1.send(null);
	}

	function reg_bikeChanged1(){ 
			if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete"){ 
					document.getElementById(idcata).innerHTML=xmlHttp1.responseText;
			}
	} 
	/* END Leads page */
	function reg_cars(id,id2) {
		   idcata = id2;
			var url=site_url+"common/cars.php?type_id=" + id;
			xmlHttp=GetXmlHttpObject(reg_carsChanged);
			xmlHttp.open("GET", url , true);
			xmlHttp.send(null);
	}
	function reg_carsChanged(){ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
					setTimeout("","1200");
					document.getElementById(idcata).innerHTML=xmlHttp.responseText ;
			}
	} 
	function sear_bike(id,id2) {
		   idcata = id2;
			var url=site_url+"common/search_make.php?type_id=" + id;
			xmlHttp=GetXmlHttpObject(search_bikeChanged);
			xmlHttp.open("GET", url , true);
			xmlHttp.send(null);
	}

	function search_bikeChanged(){ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
					document.getElementById(idcata).innerHTML=xmlHttp.responseText ;
				//	document.getElementById("caritem").innerHtml='test';
			}
	} 

	function index_reg_bike1(id,id2) {
	
		   idcata = id2;
			var url=site_url+"common/index_make1.php?type_id="+ id;
			xmlHttp=GetXmlHttpObject(index_reg_bikeChanged1);
			xmlHttp.open("GET", url , true);
			xmlHttp.send(null);
	}
	function index_reg_bikeChanged1(){ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
					document.getElementById(idcata).innerHTML=xmlHttp.responseText ;
					//document.getElementById("caritem").innerHtml='test';
			}
	} 
	function index_reg_bike2(id,id2) {
			idcata = id2;
			var url=site_url+"common/index_make2.php?type_id=" + id;
			xmlHttp=GetXmlHttpObject(index_reg_bikeChanged2);
			xmlHttp.open("GET", url , true);
			xmlHttp.send(null);
	}
	function index_reg_bikeChanged2(){ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
					document.getElementById(idcata).innerHTML=xmlHttp.responseText ;
					//document.getElementById("caritem").innerHtml='test';
			}
	} 

function index_reg_bike5(id,id2) {
		   idcata = id2;
			var url=site_url+"common/index_make5.php?type_id=" + id;
			xmlHttp=GetXmlHttpObject(index_reg_bikeChanged1);
			xmlHttp.open("GET", url , true);
			xmlHttp.send(null);
	}
	function index_reg_bikeChanged5(){ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
					document.getElementById(idcata).innerHTML=xmlHttp.responseText ;
					
			}
	} 
	function makemodel(str,id2,selected){
		   idcata = id2;
			var url=site_url+"common/make_model.php?search_make=" + str+"&divid="+id2+"&Selected="+selected;		
			xmlHttp=GetXmlHttpObject(makemodelChanged);
			xmlHttp.open("GET", url , true);
			xmlHttp.send(null);
	}

	function makemodelChanged(){ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
				document.getElementById(idcata).innerHTML=xmlHttp.responseText ;
			}
	} 
	function showmodels(str,id2){
		   idcata = id2;
			var url=site_url+"forms/show_model.php?make_id=" + str+"&divid="+id2;			
			xmlHttp=GetXmlHttpObject(showmodelChanged);
			xmlHttp.open("GET", url , true);
			xmlHttp.send(null);
	}

	function showmodelChanged(){ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
					document.getElementById(idcata).innerHTML=xmlHttp.responseText ;
			}
	}
function showshowrooms(str,id2){
		   idcata = id2;
			var url=site_url+"forms/show_showroom.php?model_id=" + str+"&divid="+id2;			
			xmlHttp1=GetXmlHttpObject(showroomsChanged);
			xmlHttp1.open("GET", url , true);
			xmlHttp1.send(null);
	}

	function showroomsChanged(){ 
			if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete"){ 
					alert('AAAAAAAAA');	
					document.getElementById(idcata).innerHTML=xmlHttp1.responseText ;
			}
	} 	
function removeshowrooms(str,id2,type){
		   idcata = id2;
			var url=site_url+"forms/show_showroom.php?model_id=" + str+"&divid="+id2+"&type="+type;						
			xmlHttp=GetXmlHttpObject(removeshowroomsChanged);
			xmlHttp.open("GET", url , true);
			xmlHttp.send(null);
	}

	function removeshowroomsChanged(){ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
					document.getElementById(idcata).innerHTML=xmlHttp.responseText ;
			}
	}	
	function makevarient(str,div,varient,add){
		   idcata = div;
			var url=site_url+"common/make_varient.php?model="+str+"&search_varient="+varient+"&div="+div+"&add="+add;
			xmlHttp=GetXmlHttpObject(makevarientChanged);
			xmlHttp.open("GET", url , true);
			xmlHttp.send(null);
	}

	function makevarientChanged(){ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
			document.getElementById(idcata).innerHTML=xmlHttp.responseText ;
		}
	} 
	// Compare
	function makevarientcompare(str,div,varient,add,d){
		   idcata = div;
			var url=site_url+"common/make_varientcompare.php?model="+str+"&search_varient="+varient+"&div="+div+"&add="+add+"&d="+d;
			xmlHttp=GetXmlHttpObject(makevarientChanged);
			xmlHttp.open("GET", url , true);
			xmlHttp.send(null);
	}

	function makevarientcompareChanged(){ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
			document.getElementById(idcata).innerHTML=xmlHttp.responseText ;
		}
	} 
	
	function searchmodel(str,id2){
		   idcata = id2;
			var url=site_url+"common/search_model.php?search_model=" + str;
			xmlHttp=GetXmlHttpObject(makemodelChanged);
			xmlHttp.open("GET", url , true);
			xmlHttp.send(null);
	}

	function searchmodelChanged(){ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
					document.getElementById(idcata).innerHTML=xmlHttp.responseText ;
			}
	} 
	function showDialect7(str,id2,id3){
			idcata = id2;
			var url=site_url+"common/model_list1.php?search_model=" + str+"&Selected=" + id3;
			xmlHttp11=GetXmlHttpObject(stateChanged5);
			xmlHttp11.open("GET", url , true);
			xmlHttp11.send(null);
	}
	function stateChanged5(){ 
			if (xmlHttp11.readyState==4 || xmlHttp11.readyState=="complete"){ 
					document.getElementById(idcata).innerHTML=xmlHttp11.responseText ;
			}
	} 
	function showvar(str,id){
			idcomp = id;
			var url=site_url+"forms/var_compare.php?search_var=" + str+"&id=" + id;
			xmlHttp11=GetXmlHttpObject(showvarstate);
			xmlHttp11.open("GET", url , true);
			xmlHttp11.send(null);
	}
	function showvarstate(){ 
			if (xmlHttp11.readyState==4 || xmlHttp11.readyState=="complete"){ 
					document.getElementById(idcomp).innerHTML=xmlHttp11.responseText ;
			}
	} 
	function showcomparelist(str,id2,id3,id4,d){
			idcomp = id2;
			var url=site_url+"common/model_list_compare.php?search_model=" + str+"&field=" + id3+"&var=" + id4+"&d=" + d;
			xmlHttp11=GetXmlHttpObject(showcompareliststate);
			xmlHttp11.open("GET", url , true);
			xmlHttp11.send(null);
	}
	function showcompareliststate(){ 
			if (xmlHttp11.readyState==4 || xmlHttp11.readyState=="complete"){ 
					document.getElementById(idcomp).innerHTML=xmlHttp11.responseText ;
			}
	} 

	function showcomparelistvariant(str,id2,id3){
			idcomp = id2;
			var url=site_url+"common/model_varient_compare.php?search_varient=" + str+"&field=" + id3;
			xmlHttpvar=GetXmlHttpObject(showcomparelistvariantstate);
			xmlHttpvar.open("GET", url , true);
			xmlHttpvar.send(null);
	}

	function showcomparelistvariant(){ 
			if (xmlHttpvar.readyState==4 || xmlHttpvar.readyState=="complete"){ 
					document.getElementById(idcomp).innerHTML=xmlHttpvar.responseText ;
			}
	} 

	
	function showDialect6(str,id2,id3){
			idcata1 = id2;
			var url=site_url+"common/city_list.php?search_city=" + str+"&Selected=" + id3;
			xmlHttp=GetXmlHttpObject(stateChanged6);
			xmlHttp.open("GET", url , true);
			xmlHttp.send(null);
	}
	function showDialect11(str,id2,id3){
			idcata1 = id2;
			var url=site_url+"common/city_list1.php?search_city=" + str+"&Selected=" + id3;
			xmlHttp=GetXmlHttpObject(stateChanged6);
			xmlHttp.open("GET", url , true);
			xmlHttp.send(null);
	}
	function stateChanged6(){ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
					document.getElementById(idcata1).innerHTML=xmlHttp.responseText ;
			}
	} 

	function Search_City(str,id2,id3){
			idcata = id2;
			var url=site_url+"common/search_city_list.php?search_city=" + str+"&Selected=" + id3+"&id2=" + id2;
			xmlHttp=GetXmlHttpObject(Search_stateChanged);
			xmlHttp.open("GET", url , true);
			xmlHttp.send(null);
	}
	function Search_stateChanged(){ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
					document.getElementById(idcata).innerHTML=xmlHttp.responseText ;
			}
	}
function Add_City(str,id2,id3){
			idcata = id2;
			var url=site_url+"common/add_city_list.php?search_city=" + str+"&Selected=" + id3;
			xmlHttp=GetXmlHttpObject(Add_stateChanged);
			xmlHttp.open("GET", url , true);
			xmlHttp.send(null);
	}
	function Add_stateChanged(){ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
					document.getElementById(idcata).innerHTML=xmlHttp.responseText ;
			}
	} 	
function showDialect(str){

	idstate = "txtResult";
	var url=site_url+"common/model_list1.php?search_model=" + str;
	xmlHttp=GetXmlHttpObject(stateChanged);
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
	document.getElementById("txtResult1").innerHTML = "<input type=\"text\" class=\"textboxCls\" name=\"City\"> <span color=red class=\"Bold11Orange\">&nbsp;*</span>";	
 } 

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


function showDialect1(str){

	idstate = "txtResult";
	var url=site_url+"common/city_list.php?search_city=" + str;
	
	xmlHttp=GetXmlHttpObject(stateChanged1);
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
	document.getElementById("txtResult1").innerHTML = "<input type=\"text\" class=\"textboxCls\" name=\"City\"> <span color=red class=\"Bold11Orange\">&nbsp;*</span>";	
 } 

function stateChanged1() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
document.getElementById(idstate).innerHTML=xmlHttp.responseText ;


}
} 


function showDialect8(str){

	idstate = "txtResult";
	var url=site_url+"common/city_list1.php?search_city=" + str;
	
	xmlHttp=GetXmlHttpObject(stateChanged1);
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
	document.getElementById("txtResult1").innerHTML = "<input type=\"text\" class=\"textboxCls\" name=\"City\"> <span color=red class=\"Bold11Orange\">&nbsp;*</span>";	
 } 

function stateChanged8() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
document.getElementById(idstate).innerHTML=xmlHttp.responseText ;


}
} 

	function showDialect2(str){
			idcata = "Cat1";
			var url=site_url+"common/model_list.php?search_model=" + str;
			xmlHttp=GetXmlHttpObject(stateChanged2);
			xmlHttp.open("GET", url , true);
			xmlHttp.send(null);
	}

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

	function showDialect3(str){
			idcata = "Cat4";
			var url=site_url+"common/city_list.php?search_city=" + str;
			xmlHttp=GetXmlHttpObject(stateChanged2);
			xmlHttp.open("GET", url , true);
			xmlHttp.send(null);
	}

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


	function check_pass(str,act,divid){
		div_id=divid
		//alert(div_id);
		var url=site_url+"common/changepassword.php?pass="+str+"&act="+act;	
		//alert(url);
		xmlHttp_pass=GetXmlHttpObject(checkpass_changed);
		xmlHttp_pass.open("GET", url , true);
		xmlHttp_pass.send(null);

		}
		function checkpass_changed() 
		{ 
			document.getElementById(div_id).innerHTML="<div align='center'><img src='"+site_url+"images/loading.gif'></div>" ;

			if (xmlHttp_pass.readyState==4 || xmlHttp_pass.readyState=="complete")
			{ 
			document.getElementById(div_id).innerHTML=xmlHttp_pass.responseText ;
			}
		} 


function comment_submit(divname,url123) {
	idstate=divname;
    var url=site_url+"contents/user_comments.php?act=submit&"+url123;
	//alert(url);
	xmlHttp=GetXmlHttpObject(media_comment_change);
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
}

function media_comment_change() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(idstate).innerHTML=xmlHttp.responseText ;
		//window.location.reload();
	}
} 
	

function review_submit(divname,url123) {
	idstate=divname;

    var url=site_url+"contents/review_contents.php?act=submit&"+url123;
	//alert(url);
	xmlHttp=GetXmlHttpObject(review_comment_change);
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
}

function review_comment_change() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(idstate).innerHTML=xmlHttp.responseText ;
		//window.location.reload();
	}
} 


function news_submit(divname,url123) {
	idstate=divname;
    var url=site_url+"contents/news_comment.php?act=submit&"+url123;
	//alert(url);
	xmlHttp=GetXmlHttpObject(news_comment_change);
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
}

function news_comment_change() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(idstate).innerHTML=xmlHttp.responseText ;
		//window.location.reload();
	}
} 


function show_city(id2,id3){
			idcata = id3;
			var url=site_url+"common/indexcity.php?value="+id2;
			xmlHttp111=GetXmlHttpObject(show_citychanged);
			xmlHttp111.open("GET", url , true);
			xmlHttp111.send(null);
	}

	function show_citychanged(){ 
	
			if (xmlHttp111.readyState==4 || xmlHttp111.readyState=="complete"){ 
					document.getElementById('City1').innerHTML=xmlHttp111.responseText ;
			}
	} 
	
	
function show_dealer(id2,id3){
	
			idcata = id3;
			var url=site_url+"common/indexdealer.php?value="+id2;
			//alert(url);
			xmlHttp7=GetXmlHttpObject(show_dealerchanged);
			xmlHttp7.open("GET", url , true);
			xmlHttp7.send(null);
	}

	function show_dealerchanged(){ 
	
			if (xmlHttp7.readyState==4 || xmlHttp7.readyState=="complete"){ 
					document.getElementById('dealer1').innerHTML=xmlHttp7.responseText ;
			}
	} 
	
		
function show_add(id2,id3){
	
			idcata = id3;
			var url=site_url+"common/indexdealer_add.php?value="+id2;
			xmlHttp71=GetXmlHttpObject(show_addchanged);
			xmlHttp71.open("GET", url , true);
			xmlHttp71.send(null);
	}

	function show_addchanged(){ 
	
			if (xmlHttp71.readyState==4 || xmlHttp71.readyState=="complete"){ 
					document.getElementById('add1').innerHTML=xmlHttp71.responseText ;
			}
	} 


	function blogs_ajax(act) {
	idname='blog_id';
	var url=site_url+"blogs/blogs_home.php?act="+act;
	xmlHttp=GetXmlHttpObject(blogs_change);
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
	
}
	
function blogs_change(){ 
	document.getElementById(idname).innerHTML="<div align='center'><img src='images/loading.gif'></div>" ;
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		
		document.getElementById(idname).innerHTML=xmlHttp.responseText;
	}
}

function add_comm_ajax(urls) {
	idname='comm_div';
	var url=site_url+"blogs/form/addblogcomment_report.php?"+urls;
	xmlHttp=GetXmlHttpObject(add_comm_ajax_change);
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
	
}
	
function add_comm_ajax_change(){ 
	document.getElementById(idname).innerHTML="<div align='center'><img src='images/loading.gif'></div>" ;
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		
		document.getElementById(idname).innerHTML=xmlHttp.responseText;
	}
}


function sendmsg(id,total){
	idmsg = id;
	alert(idmsg)
	var url=site_url+"forum/forms/sendmsg_report.php?total="+total;
	xmlHttp1=GetXmlHttpObject(msgchanged1);
	xmlHttp1.open("GET", url , true);
	xmlHttp1.send(null);

	}
function msgchanged1() 
{ 
	document.getElementById('msgdiv1').innerHTML="<div align='center'><img src='images/loading.gif'></div>";
	if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete")
	{ 
		document.getElementById('msgdiv').innerHTML=xmlHttp.responseText ;
	}
} 
	
	
	function showuseravailChanged(){ 
			if (xmlHttpACN.readyState==4 || xmlHttpACN.readyState=="complete")
			{ 
				document.getElementById('load').style.display="none";
				document.getElementById('NameDiv').style.display="";
				document.getElementById(idcata).innerHTML=xmlHttpACN.responseText ;
			}
	} 
function showuseravail(name,id2){
		document.getElementById('NameDiv').style.display="none";
		document.getElementById('load').style.display="";	
		idcata = id2;
		var url=site_url+"common/useravail.php?name=" + name;
		xmlHttpACN=GetXmlHttpObject(showuseravailChanged);
		xmlHttpACN.open("GET", url , true);
		xmlHttpACN.send(null);
}

function showsearchresult(id2,str){
		showtotal("total","template/get_total.php?"+str);
		showprint("printresult",str);
		document.getElementById(id2).style.display="none";
		document.getElementById('load').style.display="";	
		idcata = id2;
		var url=site_url+"template/searchresult_template.php?" + str;
		xmlsearch=GetXmlHttpObject(showsearchresultstate);
		xmlsearch.open("GET", url , true);
		xmlsearch.send(null);
}
function showsearchresultstate(){ 
if (xmlsearch.readyState==4 || xmlsearch.readyState=="complete")
{ 
	document.getElementById('load').style.display="none";	
	document.getElementById(idcata).style.display="";
	document.getElementById(idcata).innerHTML=xmlsearch.responseText ;
}
} 
function showdealerresult(id2,str){
		document.getElementById(id2).style.display="none";
		idcata = id2;
		var url=site_url+"forms/dealer-result.php?" + str;
		xmlsearch=GetXmlHttpObject(showdealerresultstate);
		xmlsearch.open("GET", url , true);
		xmlsearch.send(null);
}
function showdealerresultstate(){ 
if (xmlsearch.readyState==4 || xmlsearch.readyState=="complete")
{ 
	document.getElementById(idcata).style.display="";
	document.getElementById(idcata).innerHTML=xmlsearch.responseText ;
}
} 
function showaccessoriesresult(id2,str){
		document.getElementById(id2).style.display="none";
		//document.getElementById('load').style.display="";	
		idcata = id2;
		var url=site_url+"template/accessoriesresult_template.php?" + str;
		xmlsearch=GetXmlHttpObject(showaccessoriesresultstate);
		xmlsearch.open("GET", url , true);
		xmlsearch.send(null);
}
function showaccessoriesresultstate(){ 
if (xmlsearch.readyState==4 || xmlsearch.readyState=="complete")
{ 
	//document.getElementById('load').style.display="none";
	document.getElementById(idcata).style.display="";
	document.getElementById(idcata).innerHTML=xmlsearch.responseText ;
}
} 
function showsearchresultleft(id2,str){
		document.getElementById(id2).style.display="none";
		document.getElementById('loadleft').style.display="";	
		idleft = id2;
		var url=site_url+"template/searchleft.php?" + str;
		xmlsearchleft=GetXmlHttpObject(showsearchresultleftstate);
		xmlsearchleft.open("GET", url , true);
		xmlsearchleft.send(null);
}
function showsearchresultleftstate(){ 
if (xmlsearchleft.readyState==4 || xmlsearchleft.readyState=="complete")
{ 
	document.getElementById('loadleft').style.display="none";
	document.getElementById(idleft).style.display="";
	document.getElementById(idleft).innerHTML=xmlsearchleft.responseText ;
}
} 
function showaccessoriesresultleft(id2,str){
		document.getElementById(id2).style.display="none";
		document.getElementById('loadleft').style.display="";	
		idleft = id2;
		var url=site_url+"template/accessoriesleft.php?" + str;
		xmlsearchleft=GetXmlHttpObject(showaccessoriesresultleftstate);
		xmlsearchleft.open("GET", url , true);
		xmlsearchleft.send(null);
}
function showaccessoriesresultleftstate(){ 
if (xmlsearchleft.readyState==4 || xmlsearchleft.readyState=="complete")
{ 
	document.getElementById('loadleft').style.display="none";
	document.getElementById(idleft).style.display="";
	document.getElementById(idleft).innerHTML=xmlsearchleft.responseText ;
}
} 
function showmenuitems(id2,qrystring)
{
	idcata = id2;
	document.getElementById(idcata).innerHTML = "<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td valign='middle' align='center'><img src='images/loading.gif'></img></td></tr></table>";	
	var url=site_url+qrystring;
	xmlHttpACN=GetXmlHttpObject(showmenustate);
	xmlHttpACN.open("GET", url , true);
	xmlHttpACN.send(null);
}
function showmenustate()
{ 
	if (xmlHttpACN.readyState==4 || xmlHttpACN.readyState=="complete")
	{ 
		if(xmlHttpACN.responseText=="failure"){
			window.location="index.php";
		}
		else
		{
			document.getElementById(idcata).innerHTML=xmlHttpACN.responseText ;
		}
	}
} 
function delajaxphoto(id2,qrystring)
{
	idcata = id2;
	document.getElementById(idcata).innerHTML = "<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td valign='middle' align='center'><img src='images/loading.gif'></img></td></tr></table>";	
	var url=site_url+qrystring;
	xmlHttpACN=GetXmlHttpObject(delajaxphotostate);
	xmlHttpACN.open("GET", url , true);
	xmlHttpACN.send(null);
}
function delajaxphotostate()
{ 
	if (xmlHttpACN.readyState==4 || xmlHttpACN.readyState=="complete")
	{ 
		if(xmlHttpACN.responseText=="failure"){
			window.location="index.php";
		}
		else
		{
			document.getElementById(idcata).innerHTML=xmlHttpACN.responseText ;
		}
	}
} 
function delajaxphoto1(id2,qrystring)
{
	idcata = id2;
	document.getElementById(idcata).innerHTML = "<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td valign='middle' align='center'><img src='images/loading.gif'></img></td></tr></table>";	
	var url=site_url+qrystring;
	xmlHttpACN=GetXmlHttpObject(delajaxphotostate1);
	xmlHttpACN.open("GET", url , true);
	xmlHttpACN.send(null);
}
function delajaxphotostate1()
{ 
	if (xmlHttpACN.readyState==4 || xmlHttpACN.readyState=="complete")
	{ 
		if(xmlHttpACN.responseText=="failure"){
			window.location="index.php";
		}
		else
		{
			document.getElementById(idcata).innerHTML=xmlHttpACN.responseText ;
		}
	}
}
function filtermakeleft(id2,str){	
		idfilter = id2;
		document.getElementById("mid").style.display="";
		var url=site_url+"template/filtermake.php?" + str;
		xmlfilterleft=GetXmlHttpObject(filtermakeleftstate);
		xmlfilterleft.open("GET", url , true);
		xmlfilterleft.send(null);
}
function filtermakeleftstate(){ 
	if (xmlfilterleft.readyState==4 || xmlfilterleft.readyState=="complete")
	{ 
		document.getElementById(idfilter).innerHTML=xmlfilterleft.responseText ;
	}
} 
function filteraccessoriesleft(id2,str){	
		idfilter = id2;
		document.getElementById("mid").style.display="";
		var url=site_url+"template/filteraccessories.php?" + str;
		xmlfilterleft=GetXmlHttpObject(filteraccessoriesleftstate);
		xmlfilterleft.open("GET", url , true);
		xmlfilterleft.send(null);
}
function filteraccessoriesleftstate(){ 
if (xmlfilterleft.readyState==4 || xmlfilterleft.readyState=="complete")
{ 
	document.getElementById(idfilter).innerHTML=xmlfilterleft.responseText ;
}
} 
function showsearchresult_timeout(id,qstring)
{
	setTimeout("showsearchresult('"+id+"','"+qstring+"');","1000");
}
function showaccessoriesresult_timeout(id,qstring)
{
	setTimeout("showaccessoriesresult('"+id+"','"+qstring+"');","1000");
}
function showfilters(id,arrow)
{
	if(document.getElementById(id).style.display=='none'){
		document.getElementById(id).style.display='';
		document.getElementById(arrow).innerHTML='<img src="images/icon_minimize.gif" border="0"/>';
	}else{
		document.getElementById(id).style.display='none';
		document.getElementById(arrow).innerHTML='<img src="images/icon_maximize.gif" border="0"/>';
	}
}

function Compare_Car()
{
	counting=0;
	for (var i=0;i<(document.usedcar_form.elements["Fav_Itme_ID"].length);i++)
	{
		if (document.usedcar_form.elements[i].checked == true)
		{
			counting++;
		}
	}
	if (counting==0)
	{
		alert ("You must Select any three!...");
		return false;
	} else if (counting==1)
	{
		alert("You must select at least 2");
		return false;
	}	

}
function SubmitCheckForm()
{
	frmCheckform        = document.usedcar_form;
	// assigh the name of the checkbox;
	var chks = document.getElementsByName('Fav_Itme_ID[]');
	var counting=0;
	var hasChecked = false;
	// Get the checkbox array length and iterate it to see if any of them is selected
	for (var i = 0; i < chks.length; i++)
	{
			if (chks[i].checked)
			{
					hasChecked = true;
					counting++;
			}
	}
	// if ishasChecked is false then throw the error message
	if (counting==0)
	{
		alert ("You must Select any three!...");
		return false;
	} else if (counting==1)
	{
		alert("You must select at least 2");
		return false;
	}	
		
}

function showtotal(idt,qry)
{
	idtotal = idt;
	document.getElementById(idtotal).innerHTML = "<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td valign='middle' align='center'><img src='images/loading.gif'></img></td></tr></table>";	
	var url=site_url+qry;
	xmlHttptotal=GetXmlHttpObject(showtotalstate);
	xmlHttptotal.open("GET", url , true);
	xmlHttptotal.send(null);
}
function showtotalstate()
{ 
	if (xmlHttptotal.readyState==4 || xmlHttptotal.readyState=="complete")
	{ 
		document.getElementById(idtotal).innerHTML=xmlHttptotal.responseText ;
	}
} 
function sendcontactmail(contactid,qstr)
{
	idcontact = contactid;
	document.getElementById(idcontact).innerHTML = "<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td valign='middle' align='center'><img src='images/loading.gif'></img></td></tr></table>";	
	var url=site_url+qstr;
	xmlHttpcontact=GetXmlHttpObject(sendcontactmailstate);
	xmlHttpcontact.open("GET", url , true);
	xmlHttpcontact.send(null);
}
function sendcontactmailstate()
{ 
	if (xmlHttpcontact.readyState==4 || xmlHttpcontact.readyState=="complete")
	{ 
		document.getElementById(idcontact).innerHTML=xmlHttpcontact.responseText ;
	}
} 

function browseresults(mids,qstr)
{
	idmid = mids;
	document.getElementById(idmid).innerHTML = "<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td valign='middle' align='center'><img src='images/loading.gif'></img></td></tr></table>";	
	var url=site_url+qstr;
	xmlHttpbrowse=GetXmlHttpObject(browseresultsstate);
	xmlHttpbrowse.open("GET", url , true);
	xmlHttpbrowse.send(null);
}
function browseresultsstate()
{ 
	if (xmlHttpbrowse.readyState==4 || xmlHttpbrowse.readyState=="complete")
	{ 
		document.getElementById(idmid).innerHTML=xmlHttpbrowse.responseText ;
	}
} 
function SaveAd(id,div)
{
	itemid = id;
	divval= div;
	document.getElementById(divval).innerHTML = "<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td valign='middle' align='center'><img src='images/loading.gif'></img></td></tr></table>";	
	var url=site_url+"forms/add_bookmark.php?Item_ID="+itemid;
	xmlHttpbrowse=GetXmlHttpObject(SaveAdState);
	xmlHttpbrowse.open("GET", url , true);
	xmlHttpbrowse.send(null);
}
function SaveAdState()
{ 
	if (xmlHttpbrowse.readyState==4 || xmlHttpbrowse.readyState=="complete")
	{ 
		document.getElementById(divval).innerHTML=xmlHttpbrowse.responseText ;
	}
} 

function SaveAdinSR(id,div,sessid)
{
	sid = sessid;
	if(sessid==''){
		alert("Please Login to Save Ad");
		return false;
	}
	else
	{
		itemid = id;
		divval= div;
		document.getElementById(divval).innerHTML = "<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td valign='middle' align='center'><img src='images/loading.gif'></img></td></tr></table>";	
		var url=site_url+"forms/add_bookmarkforsearch.php?Item_ID="+itemid;
		xmlHttpSaved=GetXmlHttpObject(SaveAdinSRState);
		xmlHttpSaved.open("GET", url , true);
		xmlHttpSaved.send(null);
	}
}
function SaveAdinSRState()
{ 
	if (xmlHttpSaved.readyState==4 || xmlHttpSaved.readyState=="complete")
	{ 
		alert(xmlHttpSaved.responseText);
		document.getElementById(divval).innerHTML='<input type="checkbox" name="savead" onclick=SaveAdinSR("'+itemid+'","divsavead'+itemid+'","'+sid+'"); value="">';
		totalsaved();
	}
} 

function totalsaved()
{
	document.getElementById('totalsaved').innerHTML = "<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td valign='middle' align='center'><img src='images/loading.gif'></img></td></tr></table>";	
	var url=site_url+"forms/get_totalbookmark.php?ajx=1";
	xmlHttpSavedtotal=GetXmlHttpObject(totalsavedState);
	xmlHttpSavedtotal.open("GET", url , true);
	xmlHttpSavedtotal.send(null);
}
function totalsavedState()
{ 
	if (xmlHttpSavedtotal.readyState==4 || xmlHttpSavedtotal.readyState=="complete")
	{ 
		document.getElementById('totalsaved').innerHTML=xmlHttpSavedtotal.responseText;
	}
} 

function download(qstr)
{
	var url=site_url+qstr;
	xmlHttpbrowse=GetXmlHttpObject(browseresultsstate);
	xmlHttpbrowse.open("GET", url , true);
	xmlHttpbrowse.send(null);
}

function makelistdisplay(iddd,id222222,sel) {
		chid = id222222;
		var urlmake=site_url+"common/makelist.php?type_id="+iddd+"&id2="+id222222+"&sel="+sel;
		xmlHttpmakelist=GetXmlHttpObject(makelistdisplayChanged);
		xmlHttpmakelist.open("GET", urlmake, true);
		xmlHttpmakelist.send(null);
	}

	function makelistdisplayChanged(){ 
			if (xmlHttpmakelist.readyState==4 || xmlHttpmakelist.readyState=="complete"){ 
					document.getElementById(chid).innerHTML=xmlHttpmakelist.responseText ;
				}
	} 

function makemodeldisplay(str,divvv,selected){
		   makemodelid= divvv;
		   var urlmakemodel=site_url+"common/make_model.php?search_make="+str+"&divid="+divvv+"&Selected="+selected;			
		   xmlHttpmakemodel=GetXmlHttpObject(makemodeldisplayChanged);
		   xmlHttpmakemodel.open("GET", urlmakemodel , true);
		   xmlHttpmakemodel.send(null);
	}
function makemodeldisplayChanged(){ 
			if (xmlHttpmakemodel.readyState==4 || xmlHttpmakemodel.readyState=="complete"){ 
				document.getElementById(makemodelid).innerHTML=xmlHttpmakemodel.responseText ;
				}
	} 
	//  ADDED TO AJAX.JS JEBA
function showdealersresultleft(id2,str){
		document.getElementById(id2).style.display="none";
		document.getElementById('loadleft').style.display="";	
		idleft = id2;
		var url=site_url+"template/dealleft.php?" + str;
		xmlsearchleft=GetXmlHttpObject(showdealersresultleftstate);
		xmlsearchleft.open("GET", url , true);
		xmlsearchleft.send(null);
}
function showdealersresultleftstate(){ 
if (xmlsearchleft.readyState==4 || xmlsearchleft.readyState=="complete")
{ 
	document.getElementById('loadleft').style.display="none";
	document.getElementById(idleft).style.display="";
	document.getElementById(idleft).innerHTML=xmlsearchleft.responseText ;
}
}
function showdealersresult_timeout(id,qstring)
{
	setTimeout("showdealersresult('"+id+"','"+qstring+"');","1000");
}
function showdealersresult(id2,str){
		document.getElementById(id2).style.display="none";
		idcata = id2;
		var url=site_url+"template/dealerresult_template.php?" + str;
		xmlsearch=GetXmlHttpObject(showdealersresultstate);
		xmlsearch.open("GET", url , true);
		xmlsearch.send(null);
}
function showdealersresultstate(){ 
if (xmlsearch.readyState==4 || xmlsearch.readyState=="complete")
{ 
	document.getElementById(idcata).style.display="";
	document.getElementById(idcata).innerHTML=xmlsearch.responseText ;
}
} 
// END ADDED TO AJAX.JS JEBA

function setsearch(id,qstr){
		setTimeout("showsearchresult('"+id+"','"+qstr+"');","1200");
	}
function showtotalset(id,qstr){
		setTimeout("showtotal('"+id+"','"+qstr+"');","1200");
	}

function validateb(form,qstr) 
{
	var namelist = "";
	for(var i = 0; i < document.form1.chktype.length; i++){
		if(document.form1.chktype[i].checked) {
			namelist += ','+document.form1.chktype[i].value;
		}
	}
	
	var str = namelist.substring(1);
	showtotal("total","template/get_total.php?"+qstr+"&n="+str);
	showprint("printresult",qstr+"&n="+str);
	showsearchresultleft('search_left',qstr+"&n="+str);
	setTimeout("showsearchresult('search_right','"+qstr+"&n="+str+"');","1200");
return false;
}



function showprint(iddd,qtr) {
		pid = iddd;
		var urlmake=site_url+"template/showprint.php?"+qtr;
		xmlHttpshowprint=GetXmlHttpObject(showprintChanged);
		xmlHttpshowprint.open("GET", urlmake, true);
		xmlHttpshowprint.send(null);
	}

	function showprintChanged(){ 
			if (xmlHttpshowprint.readyState==4 || xmlHttpshowprint.readyState=="complete"){ 
					document.getElementById(pid).innerHTML=xmlHttpshowprint.responseText ;
				}
	} 
/* AJAX popup */

	function ForwardMail(id2,qrystring){
	if(document.sendfrm.FName.value=='')
	{
		alert('You cannot leave Name empty');
		document.sendfrm.FName.focus();
		return false;
	}
	
	if(document.sendfrm.Mobile1.value=='')
	{
		alert('You cannot leave Mobile blank');
		document.sendfrm.Mobile1.focus();
		return false;
	}
	if(document.sendfrm.Mobile1.value!='')
	{
		st=numOnlyacccomma1(sendfrm,Mobile1);
		if(st==false)
			return false;
	}

	
	if(document.sendfrm.Location.value=='')
	{
		alert('You cannot leave Location field blank');
		document.sendfrm.Location.focus();
		return false;
	}
		idcataSR = id2;
		document.getElementById(idcataSR).innerHTML = "<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td valign='middle' align='center'><img src='images/loading.gif'></img></td></tr></table>";	
		var url=site_url+"forms/test_testdrive_main.php?"+qrystring;
		xmlHttpm=GetXmlHttpObject(ForwardMailchanged);
		xmlHttpm.open("GET", url , true);
		xmlHttpm.send(null);
	
}
function ForwardMailchanged(){ 
	if (xmlHttpm.readyState==4 || xmlHttpm.readyState=="complete")
	{ 
		if(xmlHttpm.responseText=="failure"){
			window.location="index.php";
		}
		else
		{
			document.getElementById(idcataSR).innerHTML=xmlHttpm.responseText ;
		}
	}
} 
function ForwardMail1(id2,qrystring){
	if(document.sendfrm.FName.value=='')
	{
		alert('You cannot leave Name empty');
		document.sendfrm.FName.focus();
		return false;
	}
	
	if(document.sendfrm.Mobile1.value=='')
	{
		alert('You cannot leave Mobile blank');
		document.sendfrm.Mobile1.focus();
		return false;
	}	
	if(document.sendfrm.Mobile1.value!='')
	{
		st=numOnlyacccomma1(sendfrm,Mobile1);
		if(st==false)
			return false;
	}
	if(document.sendfrm.Finance_Amount.value=='')
	{
		alert('You cannot leave Finance Amount field blank');
		document.sendfrm.Finance_Amount.focus();
		return false;
	}
	if(document.sendfrm.Location.value=='')
	{
		alert('You cannot leave Location field blank');
		document.sendfrm.Location.focus();
		return false;
	}
		idcataSR = id2;
		document.getElementById(idcataSR).innerHTML = "<table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td valign='middle' align='center'><img src='images/loading.gif'></img></td></tr></table>";	
		var url=site_url+"forms/finance_test_main.php?"+qrystring;
		xmlHttpm=GetXmlHttpObject(ForwardMailchanged1);
		xmlHttpm.open("GET", url , true);
		xmlHttpm.send(null);
	
}
function ForwardMailchanged1(){ 
	if (xmlHttpm.readyState==4 || xmlHttpm.readyState=="complete")
	{ 
		if(xmlHttpm.responseText=="failure"){
			window.location="index.php";
		}
		else
		{
			document.getElementById(idcataSR).innerHTML=xmlHttpm.responseText ;
		}
	}
} 
	/* END Ajax popup */
	
