var xmlhttp;

function GetXmlHttpObject() {
	if (window.XMLHttpRequest) {
	  	// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}
	if (window.ActiveXObject) {
		// code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}

function getOffices(location){
	xmlhttp=GetXmlHttpObject()
	if (xmlhttp==null) {
  		alert ("Your browser does not support XML HTTP Request");
  		return;
	}
	var url="functions/get_offices.php?location="+location;
	
	xmlhttp.onreadystatechange=renderOffices;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
}
function renderOffices() {
	if (xmlhttp.readyState==4) {  
		document.getElementById("result_office").innerHTML=xmlhttp.responseText;
  	}
}

function getMaintenance(maintenance){
	xmlhttp=GetXmlHttpObject()
	if (xmlhttp==null) {
  		alert ("Your browser does not support XML HTTP Request");
  		return;
	}
	var url="functions/get_maintenance.php?maintenance="+maintenance;
	
	xmlhttp.onreadystatechange=renderMaintenance;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
}
function renderMaintenance() {
	if (xmlhttp.readyState==4) {  
		document.getElementById("result_maintenance").innerHTML=xmlhttp.responseText;
  	}
}
function getFronts(id){
	xmlhttp=GetXmlHttpObject()
	if (xmlhttp==null) {
  		alert ("Your browser does not support XML HTTP Request");
  		return;
	}
	var url="functions/get_fronts.php?id="+id;
	
	xmlhttp.onreadystatechange=renderFront;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
}
function renderFront() {
	if (xmlhttp.readyState==4) {  
		document.getElementById("result_7front").innerHTML=xmlhttp.responseText;
  	}
}
function getSolutions(id){
	xmlhttp=GetXmlHttpObject()
	if (xmlhttp==null) {
  		alert ("Your browser does not support XML HTTP Request");
  		return;
	}
	var url="functions/get_solutions.php?id="+id;
	
	xmlhttp.onreadystatechange=renderSolutions;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);	
}
function renderSolutions() {
	if (xmlhttp.readyState==4) {  
		document.getElementById("result_greensolutions").innerHTML=xmlhttp.responseText;
  	}
}
function mapHover(id) {
	var img = document.getElementById("map_location");
	if(id == "Tokyo") {
		$(img).attr('src','images/asia_map/Tokyo.jpg');
	}
	else if (id == "Korea") {
		$(img).attr('src','images/asia_map/Seoul.jpg');
	}
	else if (id == "Philippines") {
		$(img).attr('src','images/asia_map/Philipines.jpg');
	}
	else if (id == "Indonesia") {
		$(img).attr('src','images/asia_map/Indonesia.jpg');
	}
	else if (id == "Singapore") {
		$(img).attr('src','images/asia_map/Singapore.jpg');
	}
	else if (id == "Malaysia") {
		$(img).attr('src','images/asia_map/Malaysia.jpg');
	}
	else if (id == "Vietnam") {
		$(img).attr('src','images/asia_map/Vietnam.jpg');
	}
	else if (id == "Thailand") {
		$(img).attr('src','images/asia_map/Thailand.jpg');
	}
	else if (id == "Bangkok") {
		$(img).attr('src','images/asia_map/Bangkok.jpg');
	}
	else if (id == "Hong Kong") {
		$(img).attr('src','images/asia_map/HongKong.jpg');
	}
	else if (id == "Beijing") {
		$(img).attr('src','images/asia_map/Beijing.jpg');
	}
	else if (id == "IndoChina") {
		$(img).attr('src','images/asia_map/Indochina.jpg');
	}
	else if (id == "Shanghai") {
		$(img).attr('src','images/asia_map/Shanghai.jpg');
	}
	else if (id == "TaiCang") {
		$(img).attr('src','images/asia_map/China.jpg');
	}
}
function clearMap() {
	var img = document.getElementById("map_location");
	$(img).attr('src','images/asia_map/map2.jpg');
}
