
function removeCountry(){

		var regionDiv =document.getElementById("regionDiv");
	  var countryDiv =document.getElementById("countryDiv");
	  
		var cityDiv =document.getElementById("cityDiv");
		
		
		cityDiv.innerHTML ="<a href='javascript:showCitySelection()'>Click here to select city</a><input type='hidden' name='city' id='city' value=\"-1\"/>\n";
		regionDiv.innerHTML ="<a href='javascript:showStateSelection()'>Click here to select region</a><input type='hidden' name='region' id='region' value=\"-1\"/>\n";
		countryDiv.innerHTML ="<a href='javascript:showCountrySelection()'>Click here to select country</a><input type='hidden' name='country' id='country' value=\"-1\"/>\n";
				
}


function removeRegion(){

		var regionDiv =document.getElementById("regionDiv");
	  
		var cityDiv =document.getElementById("cityDiv");
		
		
		cityDiv.innerHTML ="<a href='javascript:showCitySelection()'>Click here to select city</a><input type='hidden' name='city' id='city' value=\"-1\"/>\n";
		regionDiv.innerHTML ="<a href='javascript:showStateSelection()'>Click here to select region</a><input type='hidden' name='region' id='region' value=\"-1\"/>\n";
		
}


function removeCity(){

		
	  
		var cityDiv =document.getElementById("cityDiv");
		
		
		cityDiv.innerHTML ="<a href='javascript:showCitySelection()'>Click here to select city</a><input type='hidden' name='city' id='city' value=\"-1\"/>\n";
		
		
}

function selectCountry(country){

	
	var regionDiv =document.getElementById("countryDiv");
	
	regionDiv.innerHTML ="<a href='javascript:showCountrySelection()'>"+country+"</a><input type='hidden' name='country' id='country' value=\""+country+"\"/>\n";
	ajaxwin.close();
}

function selectRegion(region){

	
	var regionDiv =document.getElementById("regionDiv");
	
	regionDiv.innerHTML ="<a href='javascript:showStateSelection()'>"+region+"</a><input type='hidden' name='region' id='region' value=\""+region+"\"/>\n";
	ajaxwin.close();
}

function selectCity(city){

	
	var regionDiv =document.getElementById("cityDiv");
	
	regionDiv.innerHTML ="<a href='javascript:showCitySelection()'>"+city+"</a><input type='hidden' name='city' id='city' value=\""+city+"\"/>\n";
	ajaxwin.close();
}

function getRegion(obj){
	
	
	
	
	if(obj.value != -1){
		
		
		var rsearchDiv =document.getElementById("rsearchDiv");
		rsearchDiv.innerHTML = 	"<img width=20 src='/images/bar-circle.gif' />";

		var countryObj = document.getElementById("country");
			
		
		xmlHttp=GetXmlHttpObject(populateInfo);
		//alert(''+obj.value);
    var url= "/includes/region_list.php?country="+countryObj.value+"&text="+obj.value;
    xmlHttp.open("GET", url , true);
    xmlHttp.send(null);	
	}
	else{
		 obj.innerHTML = "";
	}
}



function selectDay(day){

	var obj = document.getElementById(currentDateObj);
	obj.value ="";
	
	var year = variableDate.getFullYear()
	
		
		if(year < 1900)
		   year = year + 1900;
		
	obj.value = (variableDate.getMonth()+1)+"-"+day+"-"+year; //""+(variableDate.getMonth()+1)+"-"+day+"-"+year;
	
	inlinewin.close();
}

function showCalendar(objname){

    currentDateObj = objname;
	  var obj = document.getElementById(objname);
	  
	  if(obj.value =="MM-DD-YYYY"){
	  	 
	  	 obj.value ="";
	  }
	
	 inlinewin=dhtmlwindow.open("broadcastbox", "inline", "This is some inline content. <a href='http://dynamicdrive.com'>Dynamic Drive</a>", "#2: Broadcast Title", "width=100,height=200px,left=400px,top=10px,resize=1,scrolling=0", "recal");
	
	 getCalendar(objname, false, inlinewin);

}

function showCountrySelection(){
	
	ajaxwin=dhtmlwindow.open("ajaxbox", "ajax", "/includes/sel_search_country_ajax.php?" , "Select Country", "width=450px,height=300px,left=300px,top=100px,resize=1,scrolling=1");
}


function showStateSelection(){
	
	//alert("hi");
	var countryObj = document.getElementById("country");
	//alert(countryObj.value);
	if(countryObj.value == "" || countryObj.value == -1){
		alert("Plesae select country first");
	}
	else{
	
	 	ajaxwin=dhtmlwindow.open("ajaxbox", "ajax", "/includes/sel_search_state_ajax.php?country="+countryObj.value , "Select State/Region", "width=450px,height=300px,left=300px,top=100px,resize=1,scrolling=1");
	}
	
	
}
function showCitySelection(){
	
	
	var countryObj = document.getElementById("country");
	var regionObj  = document.getElementById("region");
	
	
	if(regionObj.value == "" || regionObj.value == -1){
		alert("Plesae select region/state first");
	}
	else{
	
	
		ajaxwin=dhtmlwindow.open("ajaxbox", "ajax", "/includes/sel_search_city_ajax.php?region="+regionObj.value+"&country="+countryObj.value , "Select City", "width=450px,height=300px,left=300px,top=100px,resize=1,scrolling=1");
	}
	
	
}


function selectCityRegionCountry(id){

		var selcountryOBJ = document.getElementById(id+"_country");
		var selregionOBJ  = document.getElementById(id+"_region");
		var selcityOBJ    = document.getElementById(id+"_city");
		
	
		var cityDiv =document.getElementById("cityDiv");
		
		if(selcityOBJ.value != -1){
				cityDiv.innerHTML ="<a href='javascript:showCitySelection()'>"+selcityOBJ.value+"</a><input type='hidden' name='city' id='city' value=\""+selcityOBJ.value+"\"/>\n";
		}
		else{
			cityDiv.innerHTML ="<a href='javascript:showCitySelection()'>Click here to select city</a><input type='hidden' name='city' id='city' value=\"-1\"/>\n";
		}
		
		
		
		var regionDiv =document.getElementById("regionDiv");
		
		if(selregionOBJ.value != -1){
				regionDiv.innerHTML ="<a href='javascript:showStateSelection()'>"+selregionOBJ.value+"</a><input type='hidden' name='state' id='region' value=\""+selregionOBJ.value+"\"/>\n";
		}
		else{
			 regionDiv.innerHTML ="<a href='javascript:showStateSelection()'>Click here to select region</a><input type='hidden' name='state' id='region' value=\"-1\"/>\n";
		}
				
		var countryDiv =document.getElementById("countryDiv");
				countryDiv.innerHTML ="<a href='javascript:showCountrySelection()'>"+selcountryOBJ.value+"</a><input type='hidden' name='country' id='country' value=\""+selcountryOBJ.value+"\"/>\n";
				
				ajaxwin.close();
}


function cityBlanketSearch(){
	
	
	
	 ajaxwin=dhtmlwindow.open("ajaxbox", "ajax", "/includes/sel_blanket_city_ajax.php" , "Type City Name", "width=450px,height=300px,left=300px,top=100px,resize=1,scrolling=1");
	
	
}

function getBlanketCity(obj){


		
		if(obj.value != -1){
			
			
			var rsearchDiv =document.getElementById("rsearchDiv");
			rsearchDiv.innerHTML = 	"<img width=20 src='/images/bar-circle.gif' />";
	
			var countryObj = document.getElementById("country");
				
			
			xmlHttp=GetXmlHttpObject(populateInfo);
			//alert(''+obj.value);
	    var url= "/includes/city_list.php?&text="+obj.value;
	    xmlHttp.open("GET", url , true);
	    xmlHttp.send(null);	
		}
		else{
			 obj.innerHTML = "";
		}
	
}


function populateRegion(){

	
	   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	   { 
	   	
	   	//alert("hi");
	   	var rsearchDiv =document.getElementById("rsearchDiv");
	   	rsearchDiv.innerHTML = ""+xmlHttp.responseText;
	   		/*var regionWaitDiv = document.getElementById("regionWaitDiv");
		
	   		if(regionWaitDiv != null){
					regionWaitDiv.innerHTML = 	"";
				}
	   	var str = xmlHttp.responseText;
		
		  eval(str);*/
		  
	   }
}


function populateCountry(){

	
	   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	   { 
	   	
	   	//alert("hi");
	   	var rsearchDiv =document.getElementById("rsearchDiv");
	   	rsearchDiv.innerHTML = ""+xmlHttp.responseText;
	   		/*var regionWaitDiv = document.getElementById("regionWaitDiv");
		
	   		if(regionWaitDiv != null){
					regionWaitDiv.innerHTML = 	"";
				}
	   	var str = xmlHttp.responseText;
		
		  eval(str);*/
		  
	   }
}




function getCountry(obj){
	
	if(obj.value != -1){
		
		
		var rsearchDiv =document.getElementById("rsearchDiv");
		rsearchDiv.innerHTML = 	"<img width=20 src='/images/bar-circle.gif' />";

		
		xmlHttp=GetXmlHttpObject(populateInfo);
		//alert(''+obj.value);
    var url= "/includes/country_list.php?text="+obj.value;
    xmlHttp.open("GET", url , true);
    xmlHttp.send(null);	
	}
	else{
		 obj.innerHTML = "";
	}
	
}

function getCity(obj){
	
	
	
	
	if(obj.value != -1){
		
		var rsearchDiv =document.getElementById("rsearchDiv");
		rsearchDiv.innerHTML = 	"<img width=20 src='/images/bar-circle.gif' />";

		var countryObj = document.getElementById("country");
		var regionObj = document.getElementById("region");	
		
		xmlHttp=GetXmlHttpObject(populateInfo);
		
    var url= "/includes/city_list.php?region="+regionObj.value+"&country="+countryObj.value+"&text="+obj.value;
    
    xmlHttp.open("GET", url , true);
    xmlHttp.send(null);	
	}
	else{
		 obj.innerHTML = "";
	}
}



function populateInfo(){


	
	
	   if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	   { 
	
	   	var rsearchDiv =document.getElementById("rsearchDiv");
	   	rsearchDiv.innerHTML = ""+xmlHttp.responseText;
		
		 		 
	   }
}


function getYogiList(){
	
	var c = document.getElementById("city");
	var s = document.getElementById("region");
	var cnt = document.getElementById("country");
	var yoga_styles  = document.getElementById("yoga_styles");
		
		
	var category  = document.getElementsByName("category[]");
	var catStr = "";
	var catCnt = 0;
	var styleStr = "";
	
	
	for(i = 0; i < category.length; i++){
			
			if(category[i].checked ){
			  catStr +="category[]="+category[i].value+"&";
			  catCnt++;
			}
	}
	
	var hasError = false;
	var errorStr= "";
	
	if(catCnt == 0 ){
		hasError = true;
		errorStr += "You haven't selected any Categories<BR>";
	}
	
	
	var styleStr = "";
	for(i = 0; i < yoga_styles.options.length; i++){
			
			if(yoga_styles.options[i].selected){
			  styleStr +="styles[]="+yoga_styles.options[i].value+"&";
			  catCnt++;
			}
	}
	
	
	if(cnt.value == "-1"){
		hasError = true;
		errorStr += "You haven't selected a Country<BR>";
	}
	
	
	if(s.value == "-1"){
	//	hasError = true;
	//	errorStr += "You haven't selected a State<BR>";
	}
	
	obj = document.getElementById("yogi_list"); 
		
	if(hasError){
			obj.innerHTML =""+errorStr;  
	}
	else{
		 var url= "/yogi_list.php?country="+cnt.value+"&state="+s.value+"&city="+c.value+"&"+catStr+"&"+styleStr;
		 document.location = url;
	}
		
	//xmlHttp=GetXmlHttpObject(populateList);
  //xmlHttp.open("GET", url , true);
  //xmlHttp.send(null);	
	
}


function getYogiListAjax( sort, styleStr){

 	var url= "/includes/yogi_list.php?sort="+sort+"&"+styleStr;
	xmlHttp=GetXmlHttpObject(populateList);
  xmlHttp.open("GET", url , true);
  xmlHttp.send(null);	
	
}


function populateList(){
	
	  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	   { 
		  obj = document.getElementById("yogi_list"); 
		  obj.innerHTML = xmlHttp.responseText;
	   }
	
}

function GetXmlHttpObject(handler)
{ 
	var objXmlHttp=null
	
	if (navigator.userAgent.indexOf("Opera")>=0)
	{
		alert("This example doesn't work in Opera") 
		return 
	}
	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
	}
} 
