function changeCountry() {
	if($id("province")) {
		 
		removeNode($id("province").parentNode);
	}
	if($id("town")) {
		removeNode($id("town").parentNode);
	}
	
	request = new HttpRequest();
	request.addHeader("Content-Type", "text/html");
	request.onComplete = function(response) {
		country = $id("country").value;
		if(country == "GBR" || country == "USA" || country == "BRA" || country == "ITA" || country == "AUS" || country == "FRA" || country=="CAN" || country == "ARG") {
			l = document.createElement("label");
			if(country == "GBR") {
				l.innerHTML = " County ";
			} else {
				l.innerHTML = " State ";
			}
			p = document.createElement("select");
			p.id = "province";
			p.name = "state";
			p.onchange = changeProvince
			createSelectOptions(p,"<option value=''></option>" + response.text)
			l.appendChild(p);
			$id("location").appendChild(l);
		} else {
			
			request2 = new HttpRequest();
			request2.addHeader("Content-Type", "text/html");
			request2.onComplete = function(response) {
				l = document.createElement("label");
				l.innerHTML = " City ";
				p = document.createElement("select");
				p.id = "town";
				p.name = "city";
				p.onchange = doOther;
				createSelectOptions(p,"<option value=''></option>" + response.text + "<option value='other'>Other</option>")
				l.appendChild(p);
				$id("location").appendChild(l);
			}
			request2.get("/helper/town/" + $id("country").value);
		}
	}
	request.get("/helper/province/" + $id("country").value);
}
function changeProvince() {
	request = new HttpRequest();
	request.addHeader("Content-Type", "text/html");
	request.onComplete = function(response) {
				if($id("town")) {
					removeNode($id("town").parentNode);
				}
				l = document.createElement("label");
				l.innerHTML = " City ";
				p = document.createElement("select");
				p.id = "town";
				p.name = "city";
				p.onchange = doOther;
				createSelectOptions(p,"<option value=''></option>" + response.text + "<option value='other'>Other</option>")
				l.appendChild(p);
				$id("location").appendChild(l);

	}
	request.get("/helper/town/" + $id("country").value + "/" + $id("province").value);
}
function countryInit() {
	p = $id("province");
	if(p) {
		p.onchange = changeProvince;
	}
	t = $id("town");
	if(t) {
		t.onchange = doOther;
	}

}

