<!--
  /*  Your are permitted to reuse this code as long as the following copyright
      notice is not removed:

      This HTML tip handling is copyright 1998 by insideDHTML.com, LLC. More information about this
      code can be found at Inside Dynamic HTML: HTTP://www.insideDHTML.com
  */
  // Support for all collection
  var allSupport = document.all!=null;
  var MeSH="no";
  // today is global because used in setcookies and startup
  var today = new Date();
  var msg;

  
  function setupEventObject(e) {
    // Map NS event object to IEs
    if (e==null) return // IE returns
    window.event = e
    window.event.fromElement = e.target
    window.event.toElement = e.target
    window.event.srcElement = e.target
    window.event.x = e.x
    window.event.y = e.y
    // Route the event to the original element
    // Necessary to make sure _tip is set.
    window.event.srcElement.handleEvent(e);
  }


  function checkName(src) {
    // Look for tooltip in IE
    while ((src!=null) && (src._tip==null))
      src = src.parentElement
    return src
  }

  function getElement(elName) {
    // Get an element from its ID
    if (allSupport)
      return document.all[elName]
    else
      return document.layers[elName]
  }

  function writeContents(el, tip) {
    // Replace the contents of the tooltip
    if (allSupport)
      el.innerHTML = tip
    else {
      // In NS, insert a table to work around
      // stylesheet rendering bug.
      // NS fails to apply style sheets when writing
      // contents into a positioned element.
      el.document.open()
      if (tip.indexOf("subscriptions")>0)
      	{el.document.write("<TABLE WIDTH=400 BORDER=1 bordercolor=black><TR><TD WIDTH=100% BGCOLOR=yellow>")}
      else 
      	{el.document.write("<TABLE WIDTH=350 BORDER=1 bordercolor=black><TR><TD WIDTH=100% BGCOLOR=yellow>")}
      el.document.write("<FONT SIZE=-1>")
      el.document.write(tip)
      el.document.write("</FONT>")
      el.document.write("</TD></TR></TABLE>")
      el.document.close()
    }
  }

  function getOffset(el, which) {
    // Function for IE to calculate position 
    // of an element.
    var amount = el["offset"+which] 
    if (which=="Top")
      amount+=el.offsetHeight
    el = el.offsetParent
    while (el!=null) {
      amount+=el["offset"+which]
      el = el.offsetParent
    }
    return amount
  }
  

  function setPosition(el) {
    // Set the position of an element
    src = window.event.srcElement
    if (allSupport) {
      el.style.pixelTop = getOffset(src, "Top")
      el.style.pixelLeft = getOffset(src, "Left")-25
      if (self.location.toString().indexOf("espanol")>0){el.style.pixelLeft+=25}
    } else
    {
      el.top = src.y + 20 //window.event.y + 15
      el.left = src.x //window.event.x
    }
  }
      
  function setVisibility(el, bDisplay) {
    // Hide or show to tip
    if (bDisplay)
      if (allSupport)
        el.style.visibility = "visible" 
      else
        el.visibility = "show";
    else
      if (allSupport)
        el.style.visibility = "hidden"
      else
        el.visibility = "hidden"
  }


  function displayContents(tip) {
    // Display the tooltip. 
    var el = getElement("tipBox")
    writeContents(el, tip)
    setPosition(el)
    setVisibility(el, true)
  }


  function doMouseOver(e) {
    // Mouse moves over an element
    setupEventObject(e)
    var el, tip
    if ((el = checkName(window.event.srcElement))!=null)
      if  (!el._display) {
        displayContents(el._tip)
        el._display = true
      }
  }

  function doMouseOut(e) {
    // Mouse leaves an element
    setupEventObject(e)
    el = checkName(window.event.srcElement)
    var el, tip
    if ((el = checkName(window.event.srcElement))!=null)
      if (el._display)
        if ((el.contains==null) || (!el.contains(window.event.toElement))) {
          setVisibility(getElement("tipBox"), false)
          el._display = false
        }
  }

  function doLoad() {
    // Do Loading
    //if ((window.document.captureEvents==null) && (!allSupport))
    if (navigator.appVersion.substring(0,1)==3)
      return // Not IE4 or NS4
    if (window.document.captureEvents!=null)  // NS - capture events
      window.document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)
    window.document.onmouseover = doMouseOver;
    window.document.onmouseout = doMouseOut;
    window.status='Enter search terms...';
  }

  window.onload = doLoad

//Cookies, code borrowed from Netscape
function GetCookie(Name)
{
   var search = Name + "="
   if (document.cookie.length > 0) { // if there are any cookies
      offset = document.cookie.indexOf(search) 
      if (offset != -1) { // if cookie exists 
         offset += search.length 
         // set index of beginning of value
         end = document.cookie.indexOf(";", offset) 
         // set index of end of cookie value
         if (end == -1) 
            end = document.cookie.length
         return unescape(document.cookie.substring(offset, end))
      }}
}
function SetCookie(name, value, days)
{
   var expires = new Date();
   expires.setTime(today.getTime() + 1000*60*60*24*days);
   document.cookie = name + "=" + escape(value)
   + ((days == 0) ? "" : ("; expires=" + expires.toGMTString()))
   + ("localhost","");
}

function OpenNewWindow(URL,name,dfault)
{
if (name=="MeSH")
	{
	var msg="Digita il termine da cercare. ";
	msg+="Se ciò porta ad un termine con la virgola, riscrivi:\n";
	msg+="     'anemia, sickle cell' -> in -> 'sickle cell anemia'";
	dfault=document.SEARCHFORM.SearchString.select()
	dfault=prompt(msg,ParseTerms("MeSH"));
	URL+="term="+Replacer(dfault," ","+");
	document.SEARCHFORM.MESH.value+=dfault+"+";
	MeSH="yes";
	}
if (name=="traducir")
	{
	var msg="Intraduzca palabra español.";
	dfault=document.SEARCHFORM.SearchString.select()
	dfault=prompt(msg,ParseTerms("MeSH"));
	URL+="urltext="+Replacer(dfault," ","+");
	document.SEARCHFORM.TRADUCIR.value+=dfault+"+";
	}
if (dfault==null && (name=="MeSH" || name=="traducir"))
	{
	//eg do nothing if they entered nothing in the prompt
	return;
	}
else
	{
	var WindowFeatures;
	if (navigator.appName.substring(0,1)=="N")
		{
		WindowFeatures="scrollbars=yes,menubar=yes,toolbar=yes,location=yes,resizable=yes,width=640,height=480"
		}
	else
		{
		WindowFeatures="scrollbars=yes,menubar=yes,toolbar=yes,resizable=yes,width=640,height=480"
		}
	NWindow=window.open(URL,name,WindowFeatures);
	}
//if(NWindow==null) {return;};
}
// Fix NS4 resize bug
if(navigator.appVersion.substring(0,1)>3)
	{
	if (document.layers)
		{
		origWidth=innerWidth;
		origHeight=innerHeight;
		window.onresize=NS4Resize
		}
	}
function NS4Resize()
	{
	if(innerWidth!=origWidth||innerHeight!=origHeight)
		{
		location.reload()
		}
	}
// end hiding from old browsers-->
