




//<meta name="decorator" content="none"/>

var uptodate = {

	addWindowOnload: function(onloadFunc) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = onloadFunc;
		} 
		else {
			window.onload = function() {
	    						oldonload();
	    						onloadFunc();
	    					}
		}
	},
	
	doSearch: function() {
		var objSearch = document.getElementById("txtSearch");
		if (objSearch) {
		   var searchTerm = objSearch.value;
		   if (objSearch.defaultValue != searchTerm && searchTerm != "") {
		     var url = document.getElementById("searchUrlBase").value;
		     url += '?source=' + document.getElementById("utdSource").value;
		     url += '&utm_campaign=' + document.getElementById("_CAMPAIGN").value;
		     url += '&utm_medium=' + document.getElementById("_MEDIUM").value;
		     url += '&utm_source=' + document.getElementById("_SOURCE").value;
		     url += '&referer=' + escape(document.getElementById("_REFERER").value);
		     if (document.getElementById("widgetClientId")) {
		       url += '&widgetClientId=' + document.getElementById("widgetClientId").value;
		     }
		     url += '&search=' + encodeURIComponent(searchTerm);
		     window.open(url, '_blank');	   
		   }
		}
		return false;
	},
	
	clearSearchText: function() {
	  var objSearch = document.getElementById("txtSearch");
		if (objSearch.defaultValue == objSearch.value) {
			objSearch.value = '';
		}
		else if (objSearch.value == '') {
			objSearch.value = objSearch.defaultValue;
		}
	},
		
	installWidget: function() {
		var jsonObj = {"widgetCode":"\r\n\r\n\r\n<div style=\"width:138px; height:51px; background-image: url(http://www.uptodate.com/images/logo.gif); background-repeat:no-repeat;\" title=\"UpToDate\">\r\n  <div style=\"font-size: 7pt; font-family: Verdana; font-weight: bold; width: 108px; padding:35px 0px 10px 60px;\"><b style=\"font-family: Helvetica; font-size: 9px;\">FOR&nbsp;PATIENTS</b></div>\r\n</div>\r\n<p style=\"font-family: Helvetica; font-size: 11px; line-height: 14px;\"><b>Answer your medical questions with <a href=\"http://www.uptodate.com/patients/index.html\" target=\"_blank\">UpToDate</a>, the source doctors trust</b></p>\r\n<input name=\"search\" type=\"text\" id=\"txtSearch\" \r\n\tonfocus=\"uptodate.clearSearchText();\" onblur=\"uptodate.clearSearchText();\" \r\n\tstyle=\"width:104px; background-color: #ffffcc; font-family: Arial, Helvetica, sans-serif; font-size: 9px; margin-bottom: 5px; padding: 2px; color: #666666;\"\r\n\tvalue=\"Enter your search here\" />&nbsp;\r\n<input type=\"button\" value=\"Go\" id=\"go\" style=\"font-family: Arial, Helvetica, sans-serif; font-size: 9px; margin-bottom: 5px; color: #666666; height:18px;\" onclick=\"uptodate.doSearch();\"/>\r\n\r\n<input type=\"hidden\" id=\"widgetClientId\" name=\"widgetClientId\" value=\"119D625FD72DEC06\"/>\r\n\r\n<input type=\"hidden\" id=\"utdSource\" name=\"source\" value=\"PATIENT_SEARCHBOX\"/>\r\n<input type=\"hidden\" id=\"_REFERER\" name=\"referer\" value=\"\"/>\r\n<input type=\"hidden\" id=\"_CAMPAIGN\" name=\"utm_campaign\" value=\"widget1\"/>\r\n<input type=\"hidden\" id=\"_MEDIUM\" name=\"utm_medium\" value=\"widget\"/>\r\n<input type=\"hidden\" id=\"_SOURCE\" name=\"utm_source\" value=\"widget\"/> \r\n<input type=\"hidden\" id=\"searchUrlBase\" value=\"http://www.uptodate.com/patients/contents/search\"/>\r\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"border:0px; padding:0px; margin:0px;\">\r\n<tr>\r\n  <td valign=\"top\" style=\"border:0px; padding:0px; margin:0px;\"><img src=\"http://www.uptodate.com/images/orange_arrow.gif\" width=\"16\" height=\"16\" border=\"0\" align=\"texttop\"/></td>\r\n  <td style=\"border:0px; padding:0px; margin:0px; width:5px;\"></td>\r\n  <td style=\"border:0px; padding:0px; margin:0px;\">\r\n    <a href=\"http://www.uptodate.com/patients/toc.do?tocKey=table_of_contents/12\" target=\"_blank\" onmouseover=\"this.style.color = '#D7833D'; return false;\" onmouseout=\"this.style.color = '#336633'; return false;\" style=\"font-family: Helvetica; color:#336633; text-decoration:none; font-size: 11px; font-weight: bold;\">\r\n    View health topics<br/>by category\r\n    </a>\r\n  </td>\r\n</tr></table>\r\n"};
	
		try {
			if (jsonObj.widgetCode) {
				var objContainer = document.getElementById("uptodatesearchcontainer");
				if (objContainer) {
					objContainer.innerHTML = jsonObj.widgetCode;
				}
	  	}
		} catch (e) {
			//ignore
		}
		
	  var objReferer = document.getElementById("_REFERER");
	  if (objReferer) {
	    objReferer.value = window.location.href;
	  }
	}

};

uptodate.addWindowOnload(uptodate.installWidget);
