/*****************************************************************
Company: MediLexicon International Ltd.

Description: Performs the "rate this article" functionality 
asynchonously using AJAX technology, including updating and 
displaying the rating score in the form of star images and 
textual format.

Warning: This code cannot be copied, reused, distributed in any 
manner without written consent from MediLexicon International Ltd.

*******************************************************************/


// holds an instance of XMLHttpRequest
var xmlHttp = createXmlHttpRequestObject();
var xmlHttpStars = createXmlHttpRequestObject();

/***************************************************************************************/
// creates an XMLHttpRequest instance
function createXmlHttpRequestObject() 
{
  // will store the reference to the XMLHttpRequest object
  var xmlHttp;
  // this should work for all browsers except IE6 and older
  try
  {
    // try to create XMLHttpRequest object
    xmlHttp = new XMLHttpRequest();
  }
  catch(e)
  {
    // assume IE6 or older
    var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
                                    "MSXML2.XMLHTTP.5.0",
                                    "MSXML2.XMLHTTP.4.0",
                                    "MSXML2.XMLHTTP.3.0",
                                    "MSXML2.XMLHTTP",
                                    "Microsoft.XMLHTTP");
    // try every prog id until one works
    for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++) 
    {
      try 
      { 
        // try to create XMLHttpRequest object
        xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
      } 
      catch (e) {}
    }
  }
  // return the created object or display an error message
  if (!xmlHttp)
    alert("Error creating the XMLHttpRequest object.");
  else 
    return xmlHttp;
}

/***************************************************************************************/
// called to read a file from the server
function rate()
{
	hideSubmitButton();
  // only continue if xmlHttp isn't void
  if (xmlHttp)
  {
    // try to connect to the server
    try
    {
		// build the url with parameters: rating, usertype, newsid, categoryid - pass these to raterserver.php db(s)
		var url = "../raterserver.php?rating=" + getRatingsInfo() + "&usertype=" + getUserTypeInfo() + "&newsid=" + getNewsIdInfo() + "&categoryid=" + getCategoryIdInfo();
		// initiate reading the url file from the server	
		xmlHttp.open("GET", url, true);
		xmlHttp.onreadystatechange = handleRateRequestStateChange;
		xmlHttp.send(null);	
    }
    // display the error in case of failure
    catch (e) 
    {
      alert("Can't connect to server:\n" + e.toString());
    }
  }
}

/***************************************************************************************/
// function that handles the HTTP response
function handleRateRequestStateChange() 
{
  // obtain a reference to the <div> element on the page
  var myDiv = document.getElementById("txtHint");
  var response = "";
  // when readyState is 4, we also read the server response
  if (xmlHttp.readyState == 4) 
  {
    // continue only if HTTP status is "OK"
    if (xmlHttp.status == 200) 
    {
      try
      { 	  		
		// read the message from the server
        response = xmlHttp.responseText;

		// display the message (string received from server file - rateserver.php)
		myDiv.innerHTML = response;


      }
      catch(e)
      {
        // display error message
        alert("Error reading the response: " + e.toString());
      }
    } 
    else
    {
      // display status message
      alert("There was a problem retrieving the data:\n" + 
            xmlHttp.statusText);
    }
  }
}





var functionbool = 0;   // used to identify the current function (the selected search on the title search bar)
var icd9laststate = 0;  // used to check whether the icd9 search was the last to be used on the title search bar (needed for function resetSearchBoxes)
var otherlaststate = 0; // used to check whether the other search was the last to be used on the title search bar (needed for function resetSearchBoxes)

function initButton(){   // is this still used !!!!!!!
	var searchbutton = document.getElementById("search_button");
	searchbutton.setAttribute("value", "Abbreviations Search");
}

function setSearchBoxSize(){
	var searchbox = document.getElementById("search_box");
	searchbox.setAttribute("style", "width:523px;");				// both...
	searchbox.style.width = "523px";								// ...needed for browser compatability issues
	searchbox.setAttribute("style", "height:24px;");
}

function removeIcd9SelectBox(){
	
	var icd9form = document.getElementById("search_form");
	var icd9select = document.getElementById("icd9_select");	 
	if (icd9select != null){
		while (icd9select.hasChildNodes()) {
 			icd9select.removeChild(icd9select.firstChild);
		}	  
 		icd9form.removeChild(icd9select);
	}
	var space = document.getElementById("spaceid");
	if (space != null){
		while (space.hasChildNodes()) {
   			space.removeChild(space.firstChild);
  		}
		icd9form.removeChild(space);
	}	
}

function removeOtherSelectBox(){
	
	var otherform = document.getElementById("search_form");	
	var otherselect = document.getElementById("other_select");	 
	if (otherselect != null){
		while (otherselect.hasChildNodes()) {
   			otherselect.removeChild(otherselect.firstChild);
	  	}	  
	  	otherform.removeChild(otherselect);
	}
		
	var otherspace = document.getElementById("otherspaceid");
	if (otherspace != null){
		while (otherspace.hasChildNodes()) {
  	  		otherspace.removeChild(otherspace.firstChild);
	  	}
		otherform.removeChild(otherspace);
	}
}

function resetSearchBoxes(){

	if ((functionbool != 3) && (icd9laststate == 1)){				
		setSearchBoxSize();
		icd9laststate = 0;
		removeIcd9SelectBox();
	}
	else if ((functionbool == 3) && (icd9laststate == 1) && (otherlaststate == 1)){
		otherlaststate = 0;
		removeIcd9SelectBox();
		removeOtherSelectBox();
	}		
	else if ((functionbool == 3) && (icd9laststate == 1)){
		removeIcd9SelectBox();	
	}
	else if ((functionbool != 5) && (otherlaststate == 1)){
		setSearchBoxSize();
		otherlaststate = 0;
		removeOtherSelectBox();
	}
	else if ((functionbool == 5) && (otherlaststate == 1)){
		removeOtherSelectBox();
	}	
	else{
		setSearchBoxSize();
	}
}
	
	// drop down menu function - this is currently not in use!
	function toggleMenu(sublink) {
		var morearrow;
     	if(document.getElementById(sublink).style.visibility == 'hidden'){
          	document.getElementById(sublink).style.visibility = 'visible';
			if(document.getElementById("dropdownarrow_down")){	
				morearrow = document.getElementById("dropdownarrow_down");
				morearrow.setAttribute("src","images/icons/uparrow.gif");
				morearrow.setAttribute("id", "dropdownarrow_up");
			}
		}
     	else{
          	document.getElementById(sublink).style.visibility = 'hidden';
			if(document.getElementById("dropdownarrow_up")){
				morearrow = document.getElementById("dropdownarrow_up");
				morearrow.setAttribute("src","images/icons/downarrow.gif");
				morearrow.setAttribute("id", "dropdownarrow_down");
			}
		}
	}

    function searchAbbreviations() {
	  functionbool = 0;
	  var searchform = document.getElementById("search_form");	
	  var searchbox = document.getElementById("search_box");
	  var hidden = document.getElementById("hiddensearchtype");	
      var newselect = document.getElementById("abbreviations");	
      newselect.setAttribute("class", "searchnav_selector");
	  newselect.setAttribute("className", "searchnav_selector");
	  newselect.setAttribute("href", "#");
      var temp = document.getElementById("definitions");	  
      temp.setAttribute("class", "searchnav");							// class and
	  temp.setAttribute("className", "searchnav");						// className both needed for browser compatability issues IE, Firefox etc
      var button = document.getElementById("search_button");	  	   
      button.setAttribute("value", "Abbreviations Search");
      temp = document.getElementById("dictionary");	
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("icd9codes");	
      temp.setAttribute("class", "searchnav"); 
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("equipment");	
      temp.setAttribute("class", "searchnav");	  
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("hospitals");	
      temp.setAttribute("class", "searchnav");	  
	  temp.setAttribute("className", "searchnav");	  
      temp = document.getElementById("other");	
      temp.setAttribute("class", "searchnav"); 
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("drugs");	
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
	  hidden.setAttribute("value","abbreviation");
	  searchbox.setAttribute("name", "keywords");
      var url = "/medicalabbreviations.php";
	  searchform.setAttribute("method", "post");
	  searchform.setAttribute("target", "_self");
	  searchform.setAttribute("action", url); 
	  resetSearchBoxes();
	  
	  document.topsearch.search_box.focus();
	  
	  return false; 
    }
   
    function searchDefinitions() {
	  functionbool = 1;
	  var searchform = document.getElementById("search_form");	
	  var searchbox = document.getElementById("search_box");
	  var hidden = document.getElementById("hiddensearchtype");	
      var temp = document.getElementById("abbreviations");	
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
      var newselect = document.getElementById("definitions");	  
      newselect.setAttribute("class", "searchnav_selector");
	  newselect.setAttribute("className", "searchnav_selector");
	  newselect.setAttribute("href", "#");
      var button = document.getElementById("search_button");	  	   
      button.setAttribute("value", "Definitions Search");
      temp = document.getElementById("dictionary");	
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("icd9codes");	
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("equipment");	
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("hospitals");	
      temp.setAttribute("class", "searchnav");	  
	  temp.setAttribute("className", "searchnav");	  
      temp = document.getElementById("other");	
      temp.setAttribute("class", "searchnav"); 
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("drugs");	
      temp.setAttribute("class", "searchnav"); 
	  temp.setAttribute("className", "searchnav");
	  hidden.setAttribute("value","definition");
	  searchbox.setAttribute("name", "keywords");
	  var url = "/medicalabbreviations.php";
	  searchform.setAttribute("method", "post");
	  searchform.setAttribute("target", "_self");
	  searchform.setAttribute("action", url); 
	  resetSearchBoxes();
	  
	  document.topsearch.search_box.focus();
	  
	  return false; 
    }

    function searchDictionary() {
	  functionbool = 2;
	  var searchform = document.getElementById("search_form");	
	  var searchbox = document.getElementById("search_box");
      var temp = document.getElementById("abbreviations");	
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("definitions");	  
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
      var newselect = document.getElementById("dictionary");
      newselect.setAttribute("class", "searchnav_selector");
	  newselect.setAttribute("className", "searchnav_selector");
	  newselect.setAttribute("href", "#");
      var button = document.getElementById("search_button");	  	   
      button.setAttribute("value", "Dictionary Search");
      temp = document.getElementById("icd9codes");	
      temp.setAttribute("class", "searchnav"); 
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("equipment");	
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("hospitals");	
      temp.setAttribute("class", "searchnav");	  
	  temp.setAttribute("className", "searchnav");	  
      temp = document.getElementById("other");	
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("drugs");	
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
	  searchbox.setAttribute("name", "s");
	  var url = "/medicaldictionary.php";
	  searchform.setAttribute("method", "post");
	  searchform.setAttribute("target", "_self");
	  searchform.setAttribute("action", url);
      resetSearchBoxes();
      
      document.topsearch.search_box.focus();
      
	  return false;
    }	
	
    function searchIcd9Codes() {
		functionbool = 3;
		icd9laststate = 1;
		resetSearchBoxes();
		var searchform = document.getElementById("search_form");
	    var searchbox = document.getElementById("search_box");
		var bool = document.getElementById("icd9_select");
		
		if (bool == null){
      		var temp = document.getElementById("abbreviations");	
      		temp.setAttribute("class", "searchnav");
			temp.setAttribute("className", "searchnav");
      		temp = document.getElementById("definitions");	  
      		temp.setAttribute("class", "searchnav");
			temp.setAttribute("className", "searchnav");
      		temp = document.getElementById("dictionary");	
      		temp.setAttribute("class", "searchnav");
			temp.setAttribute("className", "searchnav");
      		var newselect = document.getElementById("icd9codes");	  
      		newselect.setAttribute("class", "searchnav_selector");
			newselect.setAttribute("className", "searchnav_selector");
			newselect.setAttribute("href", "#");
      		temp = document.getElementById("equipment");	
      		temp.setAttribute("class", "searchnav");
			temp.setAttribute("className", "searchnav");
      		temp = document.getElementById("hospitals");	
      		temp.setAttribute("class", "searchnav");	  
	  		temp.setAttribute("className", "searchnav");			
      		temp = document.getElementById("other");	
      		temp.setAttribute("class", "searchnav"); 
			temp.setAttribute("className", "searchnav");
      		temp = document.getElementById("drugs");	
      		temp.setAttribute("class", "searchnav"); 
			temp.setAttribute("className", "searchnav");

      		var box = document.getElementById("search_box");	
      		box.setAttribute("style", "width:375px;");  
			box.style.width = "375px";
	  		var button = document.getElementById("search_button");	  	   
      		button.setAttribute("value", "ICD9 Codes Search");		
	  
	  		var icd9select = document.createElement("select");
	  		icd9select.setAttribute("style", "width:150px;");
	  		icd9select.setAttribute("id", "icd9_select");
			icd9select.setAttribute("name", "searchtype");
	  		var icd9option = document.createElement("option");
	  		//icd9option.setAttribute("id", "icd9_option");
			icd9option.setAttribute("value", "procs");
	  		var newText = document.createTextNode("by procedure"); 	  
	  		icd9option.appendChild(newText);	  
	  		icd9select.appendChild(icd9option);				
	  		icd9option = document.createElement("option");
			icd9option.setAttribute("value", "diseases");
	  		newText = document.createTextNode("by disease/injury");	  
	  		icd9option.appendChild(newText);	  
	  		icd9select.appendChild(icd9option);	
	  		icd9option = document.createElement("option");
			icd9option.setAttribute("value", "drugs");
	  		newText = document.createTextNode("by drug/chemical");	  
	  		icd9option.appendChild(newText);	  
	  		icd9select.appendChild(icd9option);		  
	  		var icd9form = document.getElementById("search_form");
	  		icd9form.appendChild(icd9select);
    		icd9form.insertBefore(icd9select, button);
			

			if(!document.getElementById("spaceid")){
				var space = document.createElement("space");
				space.setAttribute("id", "spaceid");
				space.setAttribute("style", "padding-right:5px");
				space.style.padding = "0px 5px 0px 0px";
				var spacetextnode = document.createTextNode(String.fromCharCode(160));
				space.appendChild(spacetextnode);			
				icd9form.appendChild(space);
				icd9form.insertBefore(space, button);	
			}
					
			searchbox.setAttribute("name", "keywords");
			var url = "/searches/icd9.php";	
			searchform.setAttribute("method", "post");
			searchform.setAttribute("target", "_blank");
	  		searchform.setAttribute("action", url);	
			
			//icd9bool = true;
			
	  		document.topsearch.search_box.focus();
	  		
			return false;
		}
		
    }

    function searchEquipment() {
	  functionbool = 4;
	  var searchform = document.getElementById("search_form");	
	  var searchbox = document.getElementById("search_box");
      var temp = document.getElementById("abbreviations");	
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("definitions");	  
      temp.setAttribute("class", "searchnav");	
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("dictionary");	
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("icd9codes");	
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
      var newselect = document.getElementById("equipment");	  
      newselect.setAttribute("class", "searchnav_selector");
	  newselect.setAttribute("className", "searchnav_selector");
	  newselect.setAttribute("href", "#");
      var button = document.getElementById("search_button");	  	   
      button.setAttribute("value", "Equipment Search"); 
      temp = document.getElementById("hospitals");	
      temp.setAttribute("class", "searchnav");	  
	  temp.setAttribute("className", "searchnav");	  
      temp = document.getElementById("other");	
      temp.setAttribute("class", "searchnav");	
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("drugs");	
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
	  searchbox.setAttribute("name", "keywords");
	  var url = "/medicalequipment.php";	
	  searchform.setAttribute("method", "post");
	  searchform.setAttribute("target", "_self");
	  searchform.setAttribute("action", url);
	  resetSearchBoxes();
	  
	  document.topsearch.search_box.focus();
	  
	  return false;
    }


    //function searchOther(optionselected) {
	function searchOther(optionselected) {
		
		functionbool = 5;
		otherlaststate = 1;
		resetSearchBoxes();
		var searchform = document.getElementById("search_form");	
	    var searchbox = document.getElementById("search_box");
		var bool = document.getElementById("other_select");
		
		if (bool == null){
      		var temp = document.getElementById("abbreviations");
      		temp.setAttribute("class", "searchnav");
			temp.setAttribute("className", "searchnav");
      		temp = document.getElementById("definitions");	  
      		temp.setAttribute("class", "searchnav");
			temp.setAttribute("className", "searchnav");
      		temp = document.getElementById("dictionary");	
      		temp.setAttribute("class", "searchnav");
			temp.setAttribute("className", "searchnav");
      		temp = document.getElementById("icd9codes");	
      		temp.setAttribute("class", "searchnav"); 
			temp.setAttribute("className", "searchnav");
      		temp = document.getElementById("equipment");	
      		temp.setAttribute("class", "searchnav");
			temp.setAttribute("className", "searchnav");
      		temp = document.getElementById("hospitals");	
      		temp.setAttribute("class", "searchnav");	  
	  		temp.setAttribute("className", "searchnav");			
      		var newselect = document.getElementById("other");	  
      		newselect.setAttribute("class", "searchnav_selector");
			newselect.setAttribute("className", "searchnav_selector");
			newselect.setAttribute("href", "#");			
      		temp = document.getElementById("drugs");	
      		temp.setAttribute("class", "searchnav"); 
			temp.setAttribute("className", "searchnav");

      		var box = document.getElementById("search_box");	
      		box.setAttribute("style", "width:375px;");  
			box.style.width = "375px";
	  		var button = document.getElementById("search_button");	  	   
      		button.setAttribute("value", "Search (powered by google)");		
	  
	  		var otherselect = document.createElement("select");
	  		otherselect.setAttribute("style", "width:120px;");
	  		otherselect.setAttribute("id", "other_select");	
			otherselect.setAttribute("name", "sitesearch");	
	  		var otheroption = document.createElement("option");
			otheroption.setAttribute("value", "");
			if (optionselected == "web"){
				otheroption.setAttribute("selected", "selected");				
			}			
	  		var newText = document.createTextNode("web search");
	  		otheroption.appendChild(newText);	  
	  		otherselect.appendChild(otheroption);				
	  		otheroption = document.createElement("option");
			otheroption.setAttribute("value", "www.medicalnewstoday.com");
			if (optionselected == "medicalnewstoday"){
				otheroption.setAttribute("selected", "selected");				
			}
	  		newText = document.createTextNode("medical news");	  
	  		otheroption.appendChild(newText);	  
	  		otherselect.appendChild(otheroption);	
	  		otheroption = document.createElement("option");	
			otheroption.setAttribute("value", "en.wikipedia.org");
			if (optionselected == "wiki"){
				otheroption.setAttribute("selected", "selected");				
			}			
	  		newText = document.createTextNode("wikipedia");	  
	  		otheroption.appendChild(newText);	  
	  		otherselect.appendChild(otheroption);
	  		otheroption = document.createElement("option");
			otheroption.setAttribute("value", "www.ncbi.nlm.nih.gov/pubmed");
			if (optionselected == "pubmedarticles"){
				otheroption.setAttribute("selected", "selected");				
			}
	  		newText = document.createTextNode("pubmed");	  
	  		otheroption.appendChild(newText);	  
	  		otherselect.appendChild(otheroption);			
	  		var otherform = document.getElementById("search_form");
	  		otherform.appendChild(otherselect);
    		otherform.insertBefore(otherselect, button);
			

			if(!document.getElementById("otherspaceid")){
				var otherspace = document.createElement("otherspace");
				otherspace.setAttribute("id", "otherspaceid");
				otherspace.setAttribute("style", "padding-right:5px");
				otherspace.style.padding = "0px 5px 0px 0px";
				var spacetextnode = document.createTextNode(String.fromCharCode(160));
				otherspace.appendChild(spacetextnode);			
				otherform.appendChild(otherspace);
				otherform.insertBefore(otherspace, button);	
			}
			
			hiddensearchtype = document.getElementById("hiddensearchtype");
			hiddensearchtype.setAttribute("value", "");
					
			searchbox.setAttribute("name", "q"); 
			var url = "/mlsearch.php";
			searchform.setAttribute("method", "get");
			searchform.setAttribute("target", "_self");
	  		searchform.setAttribute("action", url);	

	  		document.topsearch.search_box.focus();
	  		
			return false;
		}

    }
	

    function searchDrugs() {
	  functionbool = 6;
	  var searchform = document.getElementById("search_form");	
	  var searchbox = document.getElementById("search_box");
      var temp = document.getElementById("abbreviations");	
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("definitions");	  
      temp.setAttribute("class", "searchnav");	
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("dictionary");	
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("icd9codes");
      temp.setAttribute("class", "searchnav");	
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("equipment");	
      temp.setAttribute("class", "searchnav");	  
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("hospitals");	
      temp.setAttribute("class", "searchnav");	  
	  temp.setAttribute("className", "searchnav");	  
      temp = document.getElementById("other");	
      temp.setAttribute("class", "searchnav"); 
	  temp.setAttribute("className", "searchnav");
      var newselect = document.getElementById("drugs");
      newselect.setAttribute("class", "searchnav_selector");
	  newselect.setAttribute("className", "searchnav_selector");
	  newselect.setAttribute("href", "#");  
      var button = document.getElementById("search_button");
      button.setAttribute("value", "Drugs Search");
	  //searchbox.setAttribute("name", "drug");
	  searchbox.setAttribute("name", "s");
	  var url = "/drugsearch.php";
	  searchform.setAttribute("method", "get");
	  searchform.setAttribute("target", "_self");  
	  searchform.setAttribute("action", url);
	  resetSearchBoxes();
	  
	  document.topsearch.search_box.focus();
	  
	  return false;
    }
	
	
    function searchHospitals() {
	  functionbool = 7;
	  var searchform = document.getElementById("search_form");	
	  var searchbox = document.getElementById("search_box");
      var temp = document.getElementById("abbreviations");	
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("definitions");	  
      temp.setAttribute("class", "searchnav");	
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("dictionary");	
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("icd9codes");	
      temp.setAttribute("class", "searchnav"); 
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("equipment");	
	  temp.setAttribute("className", "searchnav");
      temp.setAttribute("class", "searchnav");	  
      var newselect = document.getElementById("hospitals");	  
      newselect.setAttribute("class", "searchnav_selector");
	  newselect.setAttribute("className", "searchnav_selector");
	  newselect.setAttribute("href", "#");
      var button = document.getElementById("search_button");	  	   
      button.setAttribute("value", "Hospitals Search"); 
      temp = document.getElementById("drugs");	
      temp.setAttribute("class", "searchnav");
	  temp.setAttribute("className", "searchnav");
      temp = document.getElementById("other");	
      temp.setAttribute("class", "searchnav"); 
	  temp.setAttribute("className", "searchnav");	  
	  searchbox.setAttribute("name", "keywords");
	  var url = "/hospitalsdirectory.php";
	  searchform.setAttribute("target", "_self");
	  searchform.setAttribute("action", url);
	  resetSearchBoxes();
	  
	  document.topsearch.search_box.focus();
	  
	  return false;
    }		


		/*
		if (searchform.hasChildNodes()){
			alert("hasChildNodes");
			for(var i=0; i<searchform.length; i++){
				searchform.childNodes.item(i);
				alert("<form> child: " + searchform.childNodes.item(i));
				
				if (searchform.childNodes.item(i).getElementById("icd9_select") == null){
					alert("icd9_select = null");
				}
				else {
					alert("icd9_select != null");
				}
			}
		}
		else {
			alert("no children");
		}
		*/




/*
	// create an XMLHttpRequest(), test it works on all browsers
   var request = false;
   try {
     request = new XMLHttpRequest();
   } catch (trymicrosoft) {
     try {
       request = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (othermicrosoft) {
       try {
         request = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (failed) {
         request = false;
       }  
     }
   }

   if (!request)
     alert("Error initializing XMLHttpRequest!");	 	


	function executeSearch(){
		// value of search entered
		var searchbox = document.getElementById("search_box").value;	
		var searchform = document.getElementById("search_form");
				
		// if there is only one search box i.e. it is not an icd9 search
		if (document.getElementById("icd9_select") == null){
			alert("icd9select == null");
			if (){
				var url = "/medicaldictionary.php?s=" + escape(searchbox);			
			}
			else if (){
				
			}
			request.open("GET", url, true);
			alert("URL = " + url);
			serverCallBack();
			request.send(null);
			
		}
		else{
			var icd9select = document.getElementById("icd9_select").value;
			alert("else");
		}		
	}

	function serverCallBack(){
	
	}
*/