// JavaScript Document

var xmlHttp

//LOAD CITIES ####################################################################
function LoadCities(city_id)
{ 

	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	
	if (document.getElementById("country_id")) {
	var pagesObj = document.getElementById("country_id"); 
	var str = pagesObj.options[pagesObj.selectedIndex].value; 
	}
	var url="../ajax/load_cities.php";
	url=url+"?country_id="+str;
	if (city_id ) {
	url=url+"&city_id="+city_id;
	}
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);

}

function stateChanged() { 
	if (xmlHttp.readyState==4) { 
		document.getElementById("city_id_box").innerHTML=xmlHttp.responseText;
	}
}

var xmlHttp2
var str
//LOAD CLUBS ####################################################################
function LoadClubs(club_id,city_id)
{ 
	xmlHttp2=GetXmlHttpObject();
	if (xmlHttp2==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }

if (document.getElementById("country_id"))  {
	var pagesObj = document.getElementById("country_id"); 
	country_id = pagesObj.options[pagesObj.selectedIndex].value; 
}
if (document.getElementById("city_id"))  {
	var pagesObj = document.getElementById("city_id"); 
	str = pagesObj.options[pagesObj.selectedIndex].value; 
}
if (city_id) {
	str = city_id;	
}
	var url="../ajax/load_clubs.php";
	url=url+"?city_id="+str;
if (club_id) {
	url=url+"&club_id="+club_id;
}
if (country_id) {
	url=url+"&country_id="+country_id;
}
	url=url+"&sid="+Math.random();
	xmlHttp2.onreadystatechange=stateChanged_2;
	xmlHttp2.open("GET",url,true);
	xmlHttp2.send(null);

}

function stateChanged_2() { 
	if (xmlHttp2.readyState==4) { 
		document.getElementById("club_id_box").innerHTML=xmlHttp2.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;
} 
