// JavaScript Document

var xmlHttp;

// Manage Sublocaiton combobox
function changeSublocaiton(URL,locid)
{	
	/*if (locid == 0){ 
		alert('Please select location');
	  	return;
	}*/
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
	  	return;
	}
	
	var url=URL+"ajax_includes/get_sublocations.php";
	url=url+"?main=search&locid="+locid;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

function changeSublocaitonSearch(URL,locid)
{	
	/*if (locid == 0){ 
		alert('Please select location');
	  	return;
	}*/
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
	  	return;
	}
	
	var url=URL+"ajax_includes/get_sublocations.php";
	url=url+"?main=search&ajax=yes&reload=no&locid="+locid;
	xmlHttp.onreadystatechange=stateChangedAjax;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}


function changeSublocaitonSearchLoad(URL,locid)
{	
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
	  	return;
	}
	
	var url=URL+"ajax_includes/get_sublocations.php";
	url=url+"?main=search&ajax=yes&reload=yes&locid="+locid;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	ajax_search_reload(URL);
}



// Manage Sublocaiton combobox
function changeSublocaitonMain(locid)
{	
	/*if (locid == 0){ 
		alert('Please select location');
	  	return;
	}*/
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
	  	return;
	}
	var url="ajax_includes/get_sublocations.php";
	url=url+"?main=main&locid="+locid;
	xmlHttp.onreadystatechange=stateChangedMain;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function changeSublocaitonSecond(locid)
{	
	/*if (locid == 0){ 
		alert('Please select location');
	  	return;
	}*/
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
	  	return;
	}
	
	var url="ajax_includes/get_sublocations.php";
	url=url+"?main=second&locid="+locid;
	xmlHttp.onreadystatechange=stateChangedSecond;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function showHint(str)
{
	if (str.length==0){ 
		document.getElementById("txtHint").innerHTML="";
	  	return;
	}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Your browser does not support AJAX!");
	  	return;
	}
	var url="gethint.asp";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4){ 
		//document.getElementById("subloc").innerHTML= "";
		document.getElementById("subloc").innerHTML=xmlHttp.responseText;
	}
}
function stateChangedAjax() 
{ 
	if (xmlHttp.readyState==4){ 
		document.getElementById("subloc").innerHTML=xmlHttp.responseText;
		ajax_search();
	}
}



function stateChangedMain() 
{ 
	if (xmlHttp.readyState==4){ 
		//document.getElementById("subloc").innerHTML= "";
		if(xmlHttp.responseText != ''){
			document.getElementById("primary_subloc_main").innerHTML=xmlHttp.responseText;
		}
	}
}
function stateChangedSecond() 
{ 
	if (xmlHttp.readyState==4){ 
		//document.getElementById("subloc").innerHTML= "";
		if(xmlHttp.responseText != ''){
			document.getElementById("primary_subloc_second").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;
}
function clubnameValidate(URL) {
	var clubname = document.getElementById('txtclubname').value;
	if(clubname == "Search for a Club" || clubname == ''){
		alert("Please enter the Club Name");
		document.getElementById('txtclubname').focus();
		return false;
	}else{
		//document.frmclubnamesearch.action = "search_result.php";
		document.frmclubnamesearch.submit();
	}	
}
function clubnameValidate1() {
	var clubname = document.getElementById('txtclubname').value;
	if(clubname == "Enter club's name" || clubname == ''){
		alert("Please enter the Club Name");
		document.getElementById('txtclubname').focus();
		return false;
	}else{
		document.frmclubnamesearch.action = "search_result.php";
		document.frmclubnamesearch.submit();
	}	
}
function searchValidate() {	
	
	/*document.frmsearch.action = "search_result.php";
	document.frmsearch.submit();*/
	if(document.frmsearch.club_gayvenues.checked && document.frmsearch.club_gayvenues_exclude.checked){
		alert('Please select any one option from Gay Nights Only & Exclude Gay Nights')
		return false;
	}
	return true;
	
}
function searchValidate1() {	
	
	document.frmsearch.action = "search_result.php";
	document.frmsearch.submit();
	
}
function clearFields(){
	document.frmsearch.sellocation.selectedIndex=0;
	if(document.frmsearch.selsublocation){
		document.frmsearch.selsublocation.selectedIndex=0;
	}
	document.frmsearch.selday.selectedIndex=0;
	document.frmsearch.selavgdrinkprice.selectedIndex=0;
	document.frmsearch.selnightrating.selectedIndex=0;
	document.frmsearch.selstudentrating.selectedIndex=0;
	document.frmsearch.selstudentrating.selectedIndex=0;
	document.frmsearch.selagerange.selectedIndex=0;
  	music = document.getElementsByName('chkmusic[]');
  	for(var i=0; i < music.length; i++){
	  music[i].checked = false ;
 	}
	selguysgirls = document.getElementsByName('selguysgirls[]');
  	for(var i=0; i < selguysgirls.length; i++){
	  selguysgirls[i].checked = false ;
 	}
	chkdominant = document.getElementsByName('chkdominant[]');
  	for(var i=0; i < chkdominant.length; i++){
	  chkdominant[i].checked = false ;
 	}
	document.frmsearch.club_student_night.checked = false;
	document.frmsearch.club_gayvenues_exclude.checked = false;
	document.frmsearch.club_gayvenues.checked = false;
	
}