var xmlhttp;

function checkip()
{
		xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
  	{
  		alert ("Your browser does not support XMLHTTP!");
  		return;
  	}

	xmlhttp.open("GET", "ip.php",true);
	xmlhttp.onreadystatechange=stateChanged;
	/*xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');*/
	xmlhttp.send(null);
}

var result;

function stateChanged()
{
	
	if (xmlhttp.readyState != 4)
    	return;

	
  	result = xmlhttp.responseText;
	//alert(result);
	if (result == 'US'){ 
		xmlhttp.open("GET", "location_us.php",true);
	}else{// AUS
		
	  	xmlhttp.open("GET", "location_au.php",true);
	}
	
	if (document.getElementById("reg_location")){
		
		
		if (result == 'US'){ 
  			document.getElementById('AU_box').src = "../images/ytr_tick_empty.png";
			document.getElementById('US_box').src = "../images/ytr_tick.png";
	 		document.getElementById('aus_content').className = 'hide';
			document.getElementById('us_content').className = 'show';
		}else{// AUS
 	  		document.getElementById('US_box').src = "../images/ytr_tick_empty.png";
			document.getElementById('AU_box').src = "../images/ytr_tick.png";
			document.getElementById('us_content').className = 'hide';
			document.getElementById('aus_content').className = 'show';
 		}
	}
}

/*
var reg_xmlhttp;

function reg_checkip()
{
	reg_xmlhttp=GetXmlHttpObject();
	if (reg_xmlhttp==null)
  	{
  		alert ("Your browser does not support XMLHTTP!");
  		return;
  	}

	reg_xmlhttp.open("GET", "ip.php",true);
	reg_xmlhttp.onreadystatechange=reg_stateChanged;
	/*xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');*/
/*	reg_xmlhttp.send(null);
  	
}


function reg_stateChanged()
{
  if (xmlhttp.readyState != 4)
    return;

  result = xmlhttp.responseText;
   if (result == 'US'){ 
  
	  document.getElementById('us_radio').checked = true;
	  document.getElementById('reg_us_radio').checked = true;
	  
	}else{// AUS
 
	  document.getElementById('aus_radio').checked = true;
	  document.getElementById('reg_aus_radio').checked = true;
	 
  	}

}

*/


function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
  	 	return new XMLHttpRequest();
  	
	if (window.ActiveXObject)
  	  	return new ActiveXObject("Microsoft.XMLHTTP"); 	
	return null;
}



var xmlhttp_form;


function changeCountry(country)
{
	
	xmlhttp_form=GetXmlHttpObject();
	if (xmlhttp_form==null)
  	{
  		alert ("Your browser does not support XMLHTTP!");
  		return;
  	}
	if (country =='US'){
		xmlhttp_form.open("GET", "location_us.php",true);
	}else{
		xmlhttp_form.open("GET", "location_au.php",true);
	}
	xmlhttp_form.onreadystatechange=stateChanged_form;
	/*xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');*/
	xmlhttp_form.send(null);
}

function stateChanged_form()
{
  if (xmlhttp_form.readyState != 4)
    return;

  var country = xmlhttp_form.responseText;
  
 /* if (document.getElementById('reg_us_radio')){
 
	if (country == 'US'){ 
  
  		//document.getElementById('reg_us_radio').checked = true;
		document.getElementById('aus_content').className = 'hide';
		document.getElementById('us_content').className = 'show';
  	}else{// AUS
 
	  	//document.getElementById('reg_aus_radio').checked = true;
	  	document.getElementById('us_content').className = 'hide';
		document.getElementById('aus_content').className = 'show';
 	 }
  }*/
}

var reg_xmlhttp_form;


function reg_changeCountry(country)
{
	
	reg_xmlhttp_form=GetXmlHttpObject();
	if (reg_xmlhttp_form==null)
  	{
  		alert ("Your browser does not support XMLHTTP!");
  		return;
  	}
	if (country =='US'){
		document.getElementById('US_box').src = "../images/ytr_tick.png";
		document.getElementById('AU_box').src = "../images/ytr_tick_empty.png";
		reg_xmlhttp_form.open("GET", "location_us.php",true);
	}else{
		document.getElementById('AU_box').src = "../images/ytr_tick.png";
		document.getElementById('US_box').src = "../images/ytr_tick_empty.png";
		reg_xmlhttp_form.open("GET", "location_au.php",true);
	}
	reg_xmlhttp_form.onreadystatechange= reg_stateChanged_form;
	/*xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');*/
	reg_xmlhttp_form.send(null);
}

function reg_stateChanged_form()
{
  if (reg_xmlhttp_form.readyState != 4)
    return;

  var country = reg_xmlhttp_form.responseText;
  
  if (country == 'US'){ 
 
	  //document.getElementById('us_radio').checked = true;
	  document.getElementById('us_content').className = 'show';
	  document.getElementById('aus_content').className = 'hide';
  }else{// AUS
 
	  //document.getElementById('aus_radio').checked = true;
	  document.getElementById('aus_content').className = 'show';
	  document.getElementById('us_content').className = 'hide'
  }
 
}


