function fetchAddress() {
	var loc;
	if (window.location.hostname == 'everest') {
		loc = 'http://everest:8888/ACVECC/website/inc/ajax/';
	} else {
		loc = 'http://acvecc.org:80/inc/ajax/';
	}
	return loc;
}


// Country Select Box on change populates state select with appropriate states if available

function updateNation(id) {
	
	var loc;
	var method;
	
	loc = fetchAddress();
	loc += "nation_updater.php?nation_id=" + id;
	
	// Prints errors or whatever out to a div called ajax_error
	// document.getElementById('ajax_error').innerHTML=loc;
	
	try {
		
		if (window.XMLHttpRequest) {
			xmlhttp = new XMLHttpRequest()
			method = 'GET';
		} else {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			method= 'POST';
		}
	}
	
	catch (e) {}
	
	xmlhttp.onreadystatechange = sbvTriggered;
	xmlhttp.open(method, loc);
	xmlhttp.send(null);
}

function sbvTriggered() {
	if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
		var response = xmlhttp.responseText;
		var update = [];
		update = response.split('||');
		document.getElementById(update[0]).innerHTML = update[1];
	}
}



// Member Status

function changePosition(id) {
	
	var loc;
	var method;
	
	loc = fetchAddress();
	loc += "change_position.php?person_id=" + id;
	
	// Prints errors or whatever out to a div called ajax_error
	//document.getElementById('ajax_error').innerHTML=loc;
	
	try {
		
		if (window.XMLHttpRequest) {
			xmlhttp = new XMLHttpRequest()
			method= 'GET';
		} else {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			method= 'POST';
		}
	}
	
	catch (e) {}
	
	xmlhttp.onreadystatechange = sbvTriggered1;
	xmlhttp.open(method, loc);
	xmlhttp.send(null);
}

function sbvTriggered1() {
	if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
		var response = xmlhttp.responseText;
		var update = [];
		
		update = response.split('||');
		document.getElementById(update[0]).style.background=update[1];
		document.getElementById(update[0]).style.color=update[2];
		//document.getElementById('ajax_error').innerHTML=update[3];
	}
}




