// JavaScript Document
var qry;
	function EmptyStates() {
	if(document.getElementById("state"))
	{
		document.getElementById("state").options.length = 0;
		}
	else if(document.getElementById("state"))
	{
	document.getElementById("state").options.length = 0;
		}	
	}
	
function show() { 
alert("Under Construction"+" "+ document.getElementById("country").value);
//alert(document.getElementById("party").value);
//alert(document.getElementById("country").value);
/*var http = createQCObject(); 
				http.open('get', 'savetofilter.php?pal='+str,true);
				http.onreadystatechange = function() {
					if(http.readyState == 4 && http.status == 200) { 
						var response = http.responseText;
						if(response) { 
							document.getElementById("quickCalender").innerHTML = http.responseText; 
						} 
					} 
				} 
				http.send(null);*/
}
	

function countryChanged() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
			var xmlresp=xmlHttp.responseText;
			
			var arrxml = xmlresp.split("<delim>");
		
			var states=arrxml[0];
			var arrStates=states.split("|");
			document.getElementById("state").options[0] = new Option("Select a state","");
			for (i=0;i<arrStates.length;i++) {
				if (arrStates[i].length>0) {
					var arrState_split = arrStates[i].split("/");
					
					document.getElementById("state").options[i+1] = new Option(arrState_split[1],arrState_split[0]);
				}
			}
			
				WaitOff();					
		} 
	
	} 

function showStates(str) {
		EmptyStates();
		if (str.length == 0)return;
		WaitOn();
		
		var url="searchparty.helper.php?$sid=" + Math.random() + "&countryid=" + str
		//alert(str)
		xmlHttp=GetXmlHttpObject(countryChanged)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		
	}

	function stateChanged() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 

			var xmlresp=xmlHttp.responseText;
			var arrxml = xmlresp.split("<delim>");
			
			var cities = arrxml[0];
			var arrCities=cities.split("|");
			if(document.getElementById("bspcity"))
				{
			document.getElementById("bspcity").options[0] = new Option("Select a city","");
			
			j=1;
				if(arrCities.length>1)
				{
				for (i=0;i<arrCities.length;i++) {
					if (arrCities[i].length>0) {
						var arrCities_split = arrCities[i].split("/");
						document.getElementById("bspcity").options[i+1] = new Option(arrCities_split[1],arrCities_split[0]);
						j++;
					}
				}
				}
			
			}
			else if(document.getElementById("bscity"))
				{
			document.getElementById("bscity").options[0] = new Option("Select a city","");
			for (i=0;i<arrCities.length;i++) {
				if (arrCities[i].length>0) {
					var arrCities_split = arrCities[i].split("/");
					document.getElementById("bscity").options[i+1] = new Option(arrCities_split[1],arrCities_split[0]);
				}
			}
			}
			

			
			
			
			WaitOff();		
		} 
	} 

function showCities(str) {
		var vlid;
		if (str.length == 0)
			return;
		
		WaitOn();
		
	}	

	function chek(str) 
	{
	}
	
	function onclik(uid) {
				//alert(uid);
				var ran_no=(Math.round((Math.random()*9999))); 
				var http = createQCObject(); 
				var http_sav = createQCObject(); 
				var act=document.getElementById("act").value;
				
				var state=document.getElementById("state").value;
				var countryx=document.getElementById("country").value;
				var spotx=document.getElementById("spot").value;
				var palgx=document.getElementById("palg").value;
				var palx=document.getElementById("pal").value;
				
				var countryy=countryx.split("/");
				var spoty=spotx.split("/");
				var palgy=palgx.split("/");
				var paly=palx.split("/");
				
				var country=countryy[0];
				var spot=spoty[0];
				var palg=palgy[0];
				var pal=paly[0];
				
				var ary=act.split("/");
				var party="";
				if(document.getElementById("sp_events").checked==true)
				{
					var	sp_events=1;
				}
				else
				{
					var	sp_events=0;
				}
				//
				var txtaction=document.getElementById("txtaction").value;
				var txtspot=document.getElementById("txtspot").value;
				var txtpalg=document.getElementById("txtpalg").value;
				var txtpal=document.getElementById("txtpal").value;
				var txtparty="";
				var txtsrch=document.getElementById("txtsrch").value;
				//alert(sp_events);
				if(txtsrch.length==0)
				{
				http.open('get', 'quick_calendar.php?pal='+pal+'&act='+ary[0]+'&party='+party+'&country='+country+'&spot='+spot+'&palg='+palg+'&state='+state+'&txtspot='+txtspot+'&txtpalg='+txtpalg+'&txtpal='+txtpal+'&txtparty='+txtparty+'&txtaction='+txtaction+'&sp_events='+sp_events+'&uid='+uid+'&pref=0',true);
				if(document.getElementById("my_setting").checked==true)
				{
					//alert("sdadas");
				http_sav.open('get', 'save_my_pref.php?pal='+pal+'&act='+ary[0]+'&country='+country+'&spot='+spot+'&palg='+palg+'&state='+state+'&txtspot='+txtspot+'&txtpalg='+txtpalg+'&txtpal='+txtpal+'&txtparty='+txtparty+'&txtaction='+txtaction+'&sp_events='+sp_events,true);
				}
				}
				else
				{
				http.open('get', 'quick_calendar.php?txtsrch='+txtsrch+'&pref=0'+'&spec=0',true);
				}
				http.onreadystatechange = function() {
					if(http.readyState == 4 && http.status == 200) { 
						var response = http.responseText;
						if(response) { 
							document.getElementById("quickCalender").innerHTML = http.responseText; 
						} 
					} 
				} 
				http.send(null);
				
				if(document.getElementById("my_setting").checked==true)
				{
				http_sav.onreadystatechange = function() {
					if(http_sav.readyState == 4 && http_sav.status == 200) { 
						var response = http_sav.responseText;
						if(response) { 
						//alert(response);con_id,st_id,ac_id,fun_id,pa_id,pg_id
							//document.getElementById("mychoice").innerHTML = 'hhhhh';
							document.getElementById("msg_sav").style.display="block";
							document.getElementById("con_id").innerHTML =countryy[1];
							document.getElementById("st_id").innerHTML = 'STATE UNDER '+countryy[1];
							document.getElementById("ac_id").innerHTML = ary[1]+","+txtaction;
							document.getElementById("fun_id").innerHTML = spoty[1]+","+txtspot;
							document.getElementById("pa_id").innerHTML = paly[1]+","+txtpal;
							document.getElementById("pg_id").innerHTML = palgy[1]+","+txtpalg;
						} 
					} 
				} 
				http_sav.send(null);
				}
	}