//////////////////////////////////////////////////////////
// display ajax results
//////////////////////////////////////////////////////////
function ajaxLocation(whichPressed){
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	setTimeout("hideDiv('messages')", 3000);
	var message='';	
	var countryid = 0;
	var stateregionid = 0;
	var citydistrictid = 0;
	var townsuburbid = 0;
	var addstateregion = '';
	var addcitydistrict = '';
	var addtownsuburb = '';
	var stateregion = null;
	var citydistrict = null;
	var townsuburb = null;

	var ctlCountryId = document.getElementById('countryid');
	if (ctlCountryId != null){
		if (document.all || document.getElementById){
			countryid = ctlCountryId.value;
		}
	}
	else {
		alert ("Invalid country object");
		return;
	}
	var ctlStateRegionId = document.getElementById('stateregionid');
	if (ctlStateRegionId != null){
		if (document.all || document.getElementById){
			stateregionid = ctlStateRegionId.value;
		}
	}
	else {
		alert ("Invalid state or region object");
		return;
	}
	var stateregionaddbutton = document.getElementById('stateregionaddbutton');
	if (stateregionaddbutton != null){
		if (stateregionaddbutton.name == whichPressed) {
			if (document.all || document.getElementById){
				stateregion = document.getElementById('stateregion');
				if (stateregion != null){
					// validation
					if (stateregion.value == '') {
						message+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Enter the state or region name<br>';
					}
					else {
						addstateregion = stateregion.value;
					}
				}
			}
		}
	}
	var ctlCityDistrictId = document.getElementById('citydistrictid');
	if (ctlCityDistrictId != null){
		if (document.all || document.getElementById){
			citydistrictid = ctlCityDistrictId.value;
		}
	}
	else {
		alert ("Invalid city or district object");
		return;
	}
	var citydistrictaddbutton = document.getElementById('citydistrictaddbutton');
	if (citydistrictaddbutton != null){
		if (citydistrictaddbutton.name == whichPressed) {
			if (document.all || document.getElementById){
				citydistrict = document.getElementById('citydistrict');
				if (citydistrict != null){
					// validation
					if (citydistrict.value == '') {
						message+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Enter the city or district name<br>';
					}
					else {
						addcitydistrict = citydistrict.value;
					}
				}
			}
		}
	}
	var townsuburbaddbutton = document.getElementById('townsuburbaddbutton');
	if (townsuburbaddbutton != null){
		if (townsuburbaddbutton.name == whichPressed) {
			if (document.all || document.getElementById){
				townsuburb = document.getElementById('townsuburb');
				if (townsuburb != null){
					// validation
					if (townsuburb.value == '') {
						message+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Enter the town or suburb name<br>';
					}
					else {
						addtownsuburb = townsuburb.value;
					}
				}
			}
		}
	}
	if (message.length == 0){
		// submitOnce(frm);
	}
	else {
		displayError(message);
		return;
	}

	var url="location.ajax.php";
	url=url+"?countryid="+countryid;
	if (stateregionid>0)url=url+"&stateregionid="+stateregionid;
	if (citydistrictid>0)url=url+"&citydistrictid="+citydistrictid;
	if (addstateregion != '')url=url+"&addstateregion="+addstateregion;
	if (addcitydistrict != '')url=url+"&addcitydistrict="+addcitydistrict;
	if (addtownsuburb != '')url=url+"&addtownsuburb="+addtownsuburb;
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlhttp.onreadystatechange=stateLocation;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}





//////////////////////////////////////////////////////////
// display ajax results event
//////////////////////////////////////////////////////////
function stateLocation(){
	if (xmlhttp.readyState==4) {
		document.getElementById("ajax_panel_location").innerHTML=xmlhttp.responseText;
	}
}





//////////////////////////////////////////////////////////
// display ajax results
//////////////////////////////////////////////////////////
function reloadLocationMap(){
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	setTimeout("hideDiv('messages')", 3000);
	var memberid = document.getElementById('memberid');
	if (memberid == null){
		alert ("Invalid query string(s)");
		return;
	}
	
	var url="member.ajax.location.php";
	url=url+"?memberid="+memberid.value;
	url=url+"&sid="+Math.random();
	//alert(url);
	xmlhttp.onreadystatechange=stateLocationMap;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

//////////////////////////////////////////////////////////
// display ajax results event
//////////////////////////////////////////////////////////
function stateLocationMap(){
	if (xmlhttp.readyState==4) {
		document.getElementById("ajax_panel_location_map").innerHTML=xmlhttp.responseText;
	}
}


