function hospitalInfo(id_str) { 
	window.location = "/hospital_details/" + id_str; 
}

function hospitalMap(id_str) { 
	map_obj = document.getElementById("fmASEngine");
	map_obj.SetVariable("_root.outsideHospital", id_str);
	map_obj.SetVariable("_root.outsideAction", "hospitalMap");
	map_obj.TCallLabel("_root.outside_mc", "outsideAction");
}

function hospitalHelp(message_str) {
	document.getElementById('map_help').innerHTML = message_str;
}
		
function hospitalList(level_str, area_str, zip_str, distance_str, msg_str) {
	if (level_str == "1") {
		document.getElementById('map_help').innerHTML = "Click on a State or use the Zip Code Search to find a hospital near you.";
	} else {
		if (msg_str != "") {
			document.getElementById('map_help').innerHTML = msg_str;
		} else {
			document.getElementById('map_help').innerHTML = "";
		}
	}

	document.getElementById('list').innerHTML =  "";
	
	try {
		xmlvar = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xmlvar = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlvar = false;
		}
	}

	if (!xmlvar && typeof XMLHttpRequest!='undefined') {
		xmlvar = new XMLHttpRequest();
	}

	xmlvar_URL = "/flashmap/fmMap/info/list.php?level=" + level_str + "&area=" + area_str + "&zip=" + zip_str + "&distance=" + distance_str + "&";
	xmlvar.open("GET", xmlvar_URL, true);
	xmlvar.onreadystatechange=function() {
		if(xmlvar.readyState==4) {
			document.getElementById('list').innerHTML = xmlvar.responseText;
		}   
	}
	xmlvar.send(null);
}

function hospitalZipcode() {
	var zipexp = /^\d{5}$/;
	var zip_str = document.getElementById("zipcode").value;
	var dis_str = document.getElementById("distance").value;
	
	if (zip_str == "") {
		alert("Please, enter a Zip Code");
		document.getElementById("zipcode").focus();
	} else {
		if (zip_str.match(zipexp) == false) {
			alert("Please, enter a valid Zip Code");
			document.getElementById("zipcode").focus();
		} else {
			map_obj = document.getElementById("fmASEngine");
			map_obj.SetVariable("_root.outsideZip", zip_str);
			map_obj.SetVariable("_root.outsideDistance", dis_str);
			map_obj.SetVariable("_root.outsideAction", "searchZip");
			map_obj.TCallLabel("_root.outside_mc", "outsideAction");
		}
	}
}
