/*************************************************************************
  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 = 80;  
Tooltip.offY = 0;
Tooltip.followMouse = false;  // must be turned off for hover-tip
	
function doTooltip(e, uID, judged, judgement, extoll1, extoll2, extoll3, judger, imageType, defaultImage, date) {
	//if ((type == "") || (msg == "")) {
	judgement = judgement.toUpperCase();
	if (judger == '') { judger = "Blacklegs' minion"; }
	if (defaultImage == 'true') { uID = "blacklegs"; imageType = "gif"; }
	if ((extoll1) || (extoll2) || (extoll3)) { message = "<td align='center'><i>"+extoll1+"<br>"+extoll2+"<br>"+extoll3+"</i></td></tr>"; } else { message = ''; }
	if (!message) { imageAlign = "center"; } else { imageAlign = "left"; }
	msg = "<div id='summary'>";
	msg = msg+"<table width='300' border='0'>";
	msg = msg+"<tr><td colspan='2' align='center' class='style3'>"+judged+" will "+judgement+"!</td></tr>";
	msg = msg+"<tr valign='middle'><td width='150' align='"+imageAlign+"' ><img src='../userPics/"+uID+"."+imageType+"'></td>";
	msg = msg+message;
	msg = msg+"<tr><td colspan='2'><hr></td></tr>";
	msg = msg+"<tr><td colspan='2' align='center'>submitted for judgement by "+judger+"</td></tr>";
	msg = msg+"<tr><td colspan='2' align='center'>"+date+"</td></tr>";
	msg = msg+"</table>";
	msg = msg+"</div>";
	//msg = "<div class='divlink' style='width:300px;' align='left'><img src='../userPics/"+uID+"."+imageType+"'><div style='width:150px; position: absolute; top:0px; display:inline; background-color: #EE22AA;' align='center'><b>"+judged+"</b><br><br><i>"+message+"</i></div></div>";
	//msg = msg + "<div style='width:300px; position:absolute; top:-5px; left:10px;' align='right'><b class='closer'><a href='#' onClick='hideTip();'>x</a></b></div>";
	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;
	}
	Tooltip.show(e, msg);
}

function hideTip() {
  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
  Tooltip.timerId = setTimeout("Tooltip.hide()", 0);
}

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);
