var xmlHttp


function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
 } 
 setTimeout('history.go(0)',3000);
}
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 select_activityCategoryHeading_change() {  // This function does the AJAX request
divid="activitySubCategorydiv";

  http.open("POST", "activityCategoryHeading.php", true);
  http.onreadystatechange = getHttpRes;

  // Make our POST parameters string…
  var params = "&activityCategoryHeading="+encodeURI(document.getElementById("activityCategoryHeading").value);
	

  // Set our POST header correctly…
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");

  // Send the parms data…
  http.send(params);

}

function select_activityCategoryHeading_change1() {  // This function does the AJAX request
divid="activitySubCategorydiv";

  http.open("POST", "activityCategoryHeading1.php", true);
  http.onreadystatechange = getHttpRes;

  // Make our POST parameters string…
  var params = "&activityCategoryHeading="+encodeURI(document.getElementById("activityCategoryHeading").value);
	

  // Set our POST header correctly…
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");

  // Send the parms data…
  http.send(params);

}


function search_clicked() {  // This function does the AJAX request
divid="SearchResults";
//document.getElementById(divid).innerHTML = "searching";
if(document.getElementById("postcode").value==""||document.getElementById("ageGroup").value ==""||document.getElementById("dateRange").value ==""||document.getElementById("ActivitySubCategory").value==""){
	
	alert("Please enter a postcode or type all.");
}else{
  http.open("POST", "dropdownSearchResults.php", true);
  http.onreadystatechange = getHttpRes;

  // Make our POST parameters string…
  var params = "&postcode="+encodeURI(document.getElementById("postcode").value)+
  "&ageGroup="+encodeURI(document.getElementById("ageGroup").value)+
  "&dateRange="+encodeURI(document.getElementById("dateRange").value)+
  "&ActivitySubCategory="+encodeURI(document.getElementById("ActivitySubCategory").value)+
  "&ActivityCategory="+encodeURI(document.getElementById("activityCategoryHeading").value);
	

  // Set our POST header correctly…
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");

  // Send the parms data…
  http.send(params);
}
}

function find_clicked() {  // This function does the AJAX request
divid="SearchResults";
//document.getElementById(divid).innerHTML = "searching";
 var params ="";
  
  if(document.getElementById("schoolClubSearch").value==""&&document.getElementById("personalTrainerSearch").value==""){
	alert("Please enter a search!");
}else{
	if(document.getElementById("schoolClubSearch").value==""){
		  http.open("POST", "findResults.php", true);
          http.onreadystatechange = getHttpRes;
  
		  var params = "&personalTrainerSearch="+encodeURI(document.getElementById("personalTrainerSearch").value)+"&postcode="+encodeURI(document.getElementById("postcodeFind").value);
	}else{
		  http.open("POST", "findResults.php", true);
  http.onreadystatechange = getHttpRes;
 
	  var params = "&schoolClubSearch="+encodeURI(document.getElementById("schoolClubSearch").value)+"&postcode="+encodeURI(document.getElementById("postcodeFind").value);	
		
	}
	
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");

  // Send the parms data…
  http.send(params);	
	
}


  // Make our POST parameters string…

	

  // Set our POST header correctly…

}

function nextresultsdropdown(lower) {
divid="SearchResults";
//document.getElementById(divid).innerHTML = "searching";
if(document.getElementById("postcode").value==""||document.getElementById("ageGroup").value ==""||document.getElementById("dateRange").value ==""||document.getElementById("ActivitySubCategory").value==""){
	
	alert("Please select all the options.");
}else{
  http.open("POST", "dropdownSearchResults.php", true);
  http.onreadystatechange = getHttpRes;

  // Make our POST parameters string…
  var params = "&postcode="+encodeURI(document.getElementById("postcode").value)+
  "&ageGroup="+encodeURI(document.getElementById("ageGroup").value)+
  "&dateRange="+encodeURI(document.getElementById("dateRange").value)+
  "&ActivitySubCategory="+encodeURI(document.getElementById("ActivitySubCategory").value)+
  "&ActivityCategory="+encodeURI(document.getElementById("activityCategoryHeading").value)+"&lower="+lower;
	

  // Set our POST header correctly…
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");

  // Send the parms data…
  http.send(params);
}
}

function nextresultsdropdownfind(lower) {
divid="SearchResults";
//document.getElementById(divid).innerHTML = "searching";
 var params ="";
  
  if(document.getElementById("schoolClubSearch").value==""&&document.getElementById("personalTrainerSearch").value==""){
	alert("Please enter a search!");
}else{
	if(document.getElementById("schoolClubSearch").value==""){
		  http.open("POST", "findResults.php", true);
          http.onreadystatechange = getHttpRes;
  
		  var params = "&personalTrainerSearch="+encodeURI(document.getElementById("personalTrainerSearch").value)+"&postcode="+encodeURI(document.getElementById("postcodeFind").value)+"&lower="+lower;
	}else{
		  http.open("POST", "findResults.php", true);
  http.onreadystatechange = getHttpRes;
 
	  var params = "&schoolClubSearch="+encodeURI(document.getElementById("schoolClubSearch").value)+"&postcode="+encodeURI(document.getElementById("postcodeFind").value)+"&lower="+lower;	
		
	}
	
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");

  // Send the parms data…
  http.send(params);	
	
}


}

function expandclicked(detailsID){

var obj= document.getElementById(detailsID);
var obj1= document.getElementById("activity"+detailsID);
if( obj.style.display == 'block'){

obj.style.display = 'none';
obj1.style.display = 'none';
}else{
	obj.style.display = 'block';
	obj1.style.display = 'block';
}


	
}
function nextresultsschoolclub(lower) {  // This function does the AJAX request
divid="SearchResults";
//document.getElementById(divid).innerHTML = "searching";
  http.open("POST", "findResults.php", true);
  http.onreadystatechange = getHttpRes;
  var params ="";
  
  if(document.getElementById("schoolClubSearch").value==""&&document.getElementById("personalTrainerSearch").value==""){
	alert("Please enter a search!");
}else{
	if(document.getElementById("schoolClubSearch").value==""){
		  var params = "&personalTrainerSearch="+encodeURI(document.getElementById("personalTrainerSearch").value)+"&lower="+lower;
	

	}else{
		
	  var params = "&schoolClubSearch="+encodeURI(document.getElementById("schoolClubSearch").value)+"&lower="+lower;
	
	
		
	}
	
	
	
}
}



//----------------ajax





function getHttpRes( ) {
  if (http.readyState == 4 && http.status == 200) { 
    res = http.responseText;  // These following lines get the response and update the page

	document.getElementById(divid).innerHTML = res;

	

  }
}

function getXHTTP( ) {
  var xhttp;
   try {   // The following "try" blocks get the XMLHTTP object for various browsers…
      xhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e2) {
 		 // This block handles Mozilla/Firefox browsers...
	    try {
	      xhttp = new XMLHttpRequest();
	    } catch (e3) {
	      xhttp = false;
	    }
      }
    }
  return xhttp; // Return the XMLHTTP object
}

var http = getXHTTP(); // This executes when the page first loads.
var divid="";

