
	//2007
	//functions for Jump To (search) box. Display results as you type.
	//Uses AJAX to call /ecourse/common2/ReturnSearchSuggestions.asp
		function localGetJumpToAjax() 
			{
			//Retrieve JumpTo suggestions and display in div id=OutputBox
			//example: var poststr = "MyName=" + encodeURI("Fred Flintstone") + "&amp;MyAddress=HOMER"
			var st=document.getElementById("localsearchterm").value
			var poststr = "searchterm=" + encodeURI(st) 
			makePOSTRequest('/ecourse/common2/ReturnPublicWebSearchSuggestions.asp', poststr,'OutputBox');
			}
		function localJumpToFocus()
			{
			//Delete "Search" from JumpTo input box
			var localsearchterm=document.getElementById("localsearchterm")
			if (localsearchterm.value=="Search School of Dentistry"){localsearchterm.value=""}
			localsearchterm.style.backgroundColor="#ffffff"		
			}		
		function localJumpToBlur()
			{
			//Put "Search" into JumpTo input box (if empty)
			var localsearchterm=document.getElementById("localsearchterm")
			if (localsearchterm.value==""){localsearchterm.value="Search School of Dentistry"}
			localsearchterm.style.backgroundColor="#e8e8e8"
			}
			
		function ecourseGetJumpToAjax() 
			{
			//Retrieve JumpTo suggestions and display in div id=OutputBox
			//example: var poststr = "MyName=" + encodeURI("Fred Flintstone") + "&amp;MyAddress=HOMER"
			var st=document.getElementById("searchterm").value
			var poststr = "searchterm=" + encodeURI(st) 
			makePOSTRequest('/ecourse/common2/ReturnSearchSuggestions.asp', poststr,'OutputBox');
			//makePOSTRequest('/ecourse/common2/ReturnSearchSuggestions.asp', poststr,'ShowAlert');
			}
		function ecourseJumpToFocus()
			{
			//Delete "Search" from JumpTo input box
			var searchterm=document.getElementById("searchterm")
			if (searchterm.value=="Search dental ecourse"){searchterm.value=""}
			searchterm.style.backgroundColor="#ffffff"		
			}		
		function ecourseJumpToBlur()
			{
			//Put "Search" into JumpTo input box (if empty)
			var searchterm=document.getElementById("searchterm")
			if (searchterm.value==""){searchterm.value="Search dental ecourse"}
			searchterm.style.backgroundColor="#e8e8e8"
			}


	//AJAX SCRIPTS
	var http_request = false;
	var AjaxTargetElement
	function makePOSTRequest(url, parameters, ATE)
	{
	http_request = false;	
	if (ATE=="ShowAlert") {AjaxTargetElement="ShowAlert"} else {AjaxTargetElement=document.getElementById("OutputBox")}	
	if (window.XMLHttpRequest) // Mozilla, Safari,...
		{ 		
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
			{         	
            http_request.overrideMimeType('text/html');// set type accordingly to anticipated content type
			}
		} 
    else if (window.ActiveXObject)  // IE 
		{ 
		try 
			{http_request = new ActiveXObject("Msxml2.XMLHTTP");} 
		catch (e) 
			{
			try {http_request = new ActiveXObject("Microsoft.XMLHTTP");} 
			catch (e) {document.getElementById("OutputBox").innerHTML = e.name + ": " + e.message}
			}
		}      
		if (!http_request) 
			{
			alert('Cannot create XMLHTTP instance. This may be because you are using an old or outdated browser.');
			return false;
			}        
        try 
        {
		http_request.onreadystatechange = ShowAjaxResult;
		http_request.open('POST', url, true);
		http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http_request.setRequestHeader("Content-length", parameters.length);
		http_request.setRequestHeader("Connection", "close");
		http_request.send(parameters);
		}
		catch (e) {document.getElementById("OutputBox").innerHTML = e.name + ": " + e.message}
   }
  
function ShowAjaxResult() 
	{
    if (http_request.readyState == 4) 
		{
        if (http_request.status == 200) 
			{
			result = http_request.responseText; 
			//Check if page relocation (go dph)
			if (String(result).length>9)
				{
				if (String(result).substring(0,9)=="/fruit/")
					{
					document.location.href = result
					return
					}
				}
			//Check if response is an alert or Div HTML				 
			if (AjaxTargetElement=="ShowAlert")
				{
				alert(result)
				} 
				else      
				{
				document.getElementById("OutputBox").innerHTML = result
				}
			} 
			else 
			{	
			if (AjaxTargetElement=="ShowAlert")
				{alert("There was a problem sending/retrieving this information.")}
				else
				{document.getElementById("OutputBox").innerHTML = "There was a problem sending/retrieving this information.";}
            }
		}
	}

