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;
} 

function city_to_state(sid,type,id){
	xmlHttp2=GetXmlHttpObject()
	if (xmlHttp2==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	if(sid=="all_state"){
		return		
	}
	var url="./javascript/ajax.php?state_id="+sid+"&type="+type+"&id="+id;
	xmlHttp2.onreadystatechange=stateChanged;
	xmlHttp2.open("GET",url,true)
	xmlHttp2.send(null)		
}
function stateChanged() 
{ 
	if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
	{
		//alert(xmlHttp2.responseText);
		div=document.getElementById("mycity");
		div.style.display='block';
		div.innerHTML=xmlHttp2.responseText;
		
	}
}
////////// select box according to variables ///////////////////////////////
var divname;
var con_name;
var catid;
function sel_box(type,codition_name,codition_id,box_tbl_name,field_id,field_name,div_name,not_necessary){
//	alert(codition_id);
if(div_name =="my_state_box" && codition_name =="chain_name"){
	cat = document.adv_search.find_by_category.value;
	if(cat && cat!=""){ 
		codition_name = "category,chain_name";
		codition_id = cat+','+codition_id;
//		sel_box('state','category,chain_name',cat+','+codition_id,'state_master','ID','Statename','my_state_box');
	}
}

	if(div_name=="my_city_box"){ 
	
		chk_city = document.getElementById("find_by_city");
		if(codition_id=="" || codition_id=="all_state"){
			if(chk_city){
				//document.getElementById("lable_city_box").style.display='none';
				document.getElementById(divname).style.display='none';
			}
			return;	
		}
		if(not_necessary == "all_state" || not_necessary == ""){
			//document.getElementById("lable_city_box").style.display='none';
			document.getElementById("my_city_box").style.display='none';
			return;
		}else{
			//document.getElementById("lable_city_box").style.display='block';	
		}
		
	}else{ 
		chk_city = document.getElementById("find_by_city");
		if(chk_city){
			//document.getElementById("lable_city_box").style.display='none';
			document.getElementById("my_city_box").style.display='none';
		}
	}
	divname = div_name;
	con_name = codition_name;
	con_id = codition_id;
	xmlHttp2=GetXmlHttpObject()
	if (xmlHttp2==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	if(codition_id=="" || codition_id=="all_cat" || codition_id=="all_grp"){
		var url="./javascript/ajax.php?all=y&box_type="+type+"&codition_name="+codition_name+"&codition_id="+codition_id+"&box_tbl_name="+box_tbl_name+"&field_id="+field_id+"&field_name="+field_name;
	}else{
		var url="./javascript/ajax.php?box_type="+type+"&codition_name="+codition_name+"&codition_id="+codition_id+"&box_tbl_name="+box_tbl_name+"&field_id="+field_id+"&field_name="+field_name;
	}
//	alert(url);
	xmlHttp2.onreadystatechange=stateChanged2;
	xmlHttp2.open("GET",url,true)
	xmlHttp2.send(null)		
}
function stateChanged2() 
{ 
	if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
	{
		//alert(xmlHttp2.responseText);
		div=document.getElementById(divname);
		if(div.id=="my_city_box"){
			div.innerHTML="<table class='color_darkblue bold myhead' cellpadding='0' cellspacing='0' width='100%'><tr><td>Find By City</td><td>"+xmlHttp2.responseText+"</td></tr></table>";
			//document.getElementById("lable_city_box").style.display='block';
		}else{
			//document.getElementById("lable_city_box").style.display='none';
			
			div.innerHTML=xmlHttp2.responseText;
		}
		div.style.display='block';
		if(divname == "my_group_box"){
			sel_box('state','category',con_id,'state_master','ID','Statename','my_state_box');
		}
		
	}
}

////////////////////////////////////////////////////////////////

////////count banner clicks////////////////////////////////////
function count_click(bannerid){
	xmlHttp2=GetXmlHttpObject()
	if (xmlHttp2==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url="./javascript/ajax.php?banner_id="+bannerid;
	xmlHttp2.onreadystatechange=stateChanged3;
	xmlHttp2.open("GET",url,true)
	xmlHttp2.send(null)		
}
function stateChanged3() 
{
	if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
	{
		//alert(xmlHttp2.responseText);
				
	}
}

//////////////////////////////////////////////////////////////