if(typeof $ef == "function")
	$hs = $ef;
else
	$hs = $;

window.hospiceMembers = [];

function SearchHospice() {
	
	var script = document.createElement("script");
	script.type = "text/javascript";
	script.src = "http://okhospice.efwebdesign.com/Search.asp?sBy=" + encodeURIComponent($hs("#ddlHospiceFilter").val()) + "&s=" + encodeURIComponent($hs("#txtHospiceSearch").val()) + "&_=" + Math.random();
	
	var done = false;
	script.onload = script.onreadystatechange = function() {
		if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") ) {
			done = true;
			ShowList();
			$hs(this).remove();
		}
	};
	
	// Add the search script
	document.body.appendChild(script);
}

function ShowList() {
	var container = $hs("#HospiceSearchContainer");
	container.children().remove();
	
	$hs(window.hospiceMembers).each(function(index, hos) {
		container.append($hs("<div class=\"SearchRow\"><table><tr><th colspan=\"2\">" + hos.name + "</th></tr><tr><td>" + hos.addr + "<br />" + hos.city + ", " + hos.state + " " + hos.zip + "</td><td>Phone: " + hos.phone + "<br />Fax: " + hos.fax + "<br />Email: <a href=\"mailto:" + hos.email + "\">" + hos.email + "</a></td></tr></table></div>"));
	});

	if(window.hospiceMembers.length == 0)
		container.append($hs("<div class=\"SearchRow emptyRow\">There were no Hospices found. Please try again.</div>"));
}