//
// Medical Term Search
//

function processKey(e) 
{

var evtobj=window.event? event : e //distinguish between IE's explicit event object (window.event) and Firefox's implicit.
var unicode=evtobj.charCode? evtobj.charCode : evtobj.keyCode
var actualkey=String.fromCharCode(unicode)

//alert("Key Pressed: " + unicode + " - " + actualkey);

if (unicode=="13") 
{
    	if (document.getSelection) 
{
	var str = document.getSelection();
	//alert("First: " + str);
} 
		else if (document.selection && document.selection.createRange) 
{
		//alert("Second: " + str);
		var range = document.selection.createRange();
		var str = range.text;
} 
			else if (window.getSelection) 
{
			//alert("Third: " + str);
			var str = window.getSelection();
} 
				else 
{
				var str = "";
				alert("The browser you are using is incompatible with the Medical Dictionary Search feature. Please try using another browser.");
}

//alert("String: " + str);

if (str.length >= 1 && str.length <= 25) 
{
var r=prompt("Would you like to search the MedlinePlus® medical dictionary for...",  str.toUpperCase())
if (r!= null)
{
var webaddress = new String("http://www2.merriam-webster.com/cgi-bin/mwmednlm?book=Medical&va=" + r);
window.location = webaddress
}
}
	else if (str.length > 25)
{
	alert("Please Select A Shorter Search Term.  \n\n This feature only supports search terms up to 25 characters in length.");	
}
}
}


document.onkeypress=processKey
