/*************************************************************************
  This code is from Dynamic Web Coding at dyn-web.com
  Copyright 2003-5 by Sharon Paine 
  See Terms of Use at www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

// adjust horizontal and vertical offsets here
// (distance from mouseover event which activates tooltip)
Tooltip.offX = 4;  
Tooltip.offY = 4;
Tooltip.followMouse = false;  // must be turned off for hover-tip

// tooltip content variables
var msgTips = 'Get the latest information about the <a href="http://www.dyn-web.com/dhtml/tooltips/">tooltips</a> currently available at <a href="http://www.dyn-web.com">dyn-web.com</a>.';

var msgTerms = 'The code is free for <a href="http://www.dyn-web.com/bus/terms.html#personal">personal use</a> but all other uses require purchase of a <a href="http://www.dyn-web.com/bus/purchase.html">license</a>.';


function doTooltip(e) {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.clearTimer();
  var tip = document.getElementById? document.getElementById(Tooltip.tipID): null;
  if ( tip && tip.onmouseout == null ) {
      tip.onmouseout = Tooltip.tipOutCheck;
      tip.onmouseover = Tooltip.clearTimer;
  }
  var tg = (window.event) ? e.srcElement : e.target;
  if (tg.nodeName == 'TD' && tg.id != 'noshow'){
  //alert(tg.innerHTML);
  tg.style.background="#FFFFCC"; 
  var url;
  if (tg.id){
       if(tg.name =='Blast'){
	       url="http://www.ebi.ac.uk/cgi-bin/sumtab?tool=wublast&jobid=";
	 }
	 else{
      	 url="http://www.ebi.ac.uk/cgi-bin/iprscan/iprscan?tool=iprscan&cmd=check&view=Table&jobid=";
	 }
       Tooltip.show(e, '<font color="#CC6600">Find out about  </font><br><strong>'+ tg.innerHTML+'</strong><br> at <br><a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?CMD=search&DB=pubmed&term='+tg.innerHTML+'" target="_blank">Pubmed</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="http://www.google.com/search?q='+tg.innerHTML+'" target="_blank">Google </a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="http://scholar.google.com/scholar?q='+tg.innerHTML+'" target="_blank">Google Scholar</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="http://www.godatabase.org/cgi-bin/amigo/go.cgi?action=query&view=query&search_constraint=gp&query='+tg.innerHTML+'" target="_blank">Gene Ontology</a><hr><a href="'+url+tg.id+'" target="_blank">View Original '+tg.name+' Result</a>');
 }
  else{
	 Tooltip.show(e, '<font color="#CC6600">Find out about  </font><br><strong>'+ tg.innerHTML+'</strong><br> at <br><a href="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?CMD=search&DB=pubmed&term='+tg.innerHTML+'" target="_blank">Pubmed</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="http://www.google.com/search?q='+tg.innerHTML+'" target="_blank">Google </a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="http://scholar.google.com/scholar?q='+tg.innerHTML+'" target="_blank">Google Scholar</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="http://www.godatabase.org/cgi-bin/amigo/go.cgi?action=query&view=query&search_constraint=gp&query='+tg.innerHTML+'" target="_blank">Gene Ontology</a>');
  }
  }
}

function hideTip(e) {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  var tg1 = (window.event) ? e.srcElement : e.target;
  if (tg1.nodeName == 'TD'){
  //alert(tg1.innerHTML);
  tg1.style.background="#CEE7FF"; 
  }
  Tooltip.timerId = setTimeout("Tooltip.hide()", 50);
  //}
}

Tooltip.tipOutCheck = function(e) {
  e = dw_event.DOMit(e);
  // is element moused into contained by tooltip?
  var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
  if ( this != toEl && !contained(toEl, this) ) Tooltip.hide();
}

// returns true of oNode is contained by oCont (container)
function contained(oNode, oCont) {
  if (!oNode) return; // in case alt-tab away while hovering (prevent error)
  while ( oNode = oNode.parentNode ) if ( oNode == oCont ) return true;
  return false;
}

Tooltip.timerId = 0;
Tooltip.clearTimer = function() {
  if (Tooltip.timerId) { clearTimeout(Tooltip.timerId); Tooltip.timerId = 0; }
}

Tooltip.unHookHover = function () {
    var tip = document.getElementById? document.getElementById(Tooltip.tipID): null;
    if (tip) {
        tip.onmouseover = null; 
        tip.onmouseout = null;
        tip = null;
    }
}

dw_event.add(window, "unload", Tooltip.unHookHover, true);