/* CREATES HTTP OBJECT */
function getHTTPObject() { var xmlhttp; /*@cc_on @if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @else xmlhttp = false; @end @*/  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; } } return xmlhttp; } 

var undefMatch;
var thePath = "http://"+self.location.host+"/";

/***********************************************************************/

var http;

function getStates(theCountry) {
	var theURL = thePath+"ajax/statelist.php?c="+theCountry;
	http = getHTTPObject();
	http.open("GET", theURL, true);
	http.onreadystatechange = printStates;
	http.send(null);
}
function printStates()
{
	if (http.readyState == 4)
	{
		results = http.responseText;
		document.getElementById("side_state").innerHTML = results;
		clearSuburbs();
	}
}

/***********************************************************************/

var http2;

function clearSuburbs() {
	theSubs = document.getElementById('sideSuburb');
	theSubs.options.length = 1;
}


function getSuburbs(theCountry,theStateList) {
	var theURL = thePath+"ajax/suburblist.php?c="+theCountry+"&s=";
	theURL += theStateList.options[theStateList.selectedIndex].value;
	
	http2 = getHTTPObject();
	http2.open("GET", theURL, true);
	http2.onreadystatechange = printSuburbs;
	http2.send(null);
}
function printSuburbs()
{
	if (http2.readyState == 4)
	{
		results = http2.responseText;
		document.getElementById("side_suburb").innerHTML = results;
	}
}

/***********************************************************************/

var http3;

function getStateMenu(theCountry) {
	var theURL = thePath+"ajax/statelist.php?c="+theCountry+"&m=1";
	http3 = getHTTPObject();
	http3.open("GET", theURL, true);
	http3.onreadystatechange = printStateMenu;
	http3.send(null);
}
function printStateMenu()
{
	if (http3.readyState == 4)
	{
		results = http3.responseText;
		document.getElementById("state").innerHTML = results;
		// clearSuburbs();
	}
}


/***********************************************************************/

var http4;

function applySetStates(theCountry) {
	var theURL = thePath+"ajax/simple_statelist.php?c="+theCountry;
	http4 = getHTTPObject();
	http4.open("GET", theURL, true);
	http4.onreadystatechange = applyPrintStateMenu;
	http4.send(null);
}
function applyPrintStateMenu()
{
	if (http4.readyState == 4)
	{
		results = http4.responseText;
		document.getElementById("pStateHolder").innerHTML = results;
	}
}


/***********************************************************************/

var http5;

function getVerificationImage(theValue)
{
	if (document.getElementById("formImage"))
	{
		var theURL = formImageURL;
		http5 = getHTTPObject();
		http5.open("GET", theURL, true);
		http5.onreadystatechange = verificationImageResult;
		http5.send(null);
	}
}
function verificationImageResult()
{
	if (http5.readyState == 4)
	{
		document.getElementById("formImage").innerHTML  = http5.responseText;
	}
}