/* Offset position of tooltip */
var x_offset_tooltip = 5;
var y_offset_tooltip = 0;

/* Don't change anything below here */
var iClose = false;
var ajax_tooltipObj = false;
var ajax_tooltipObj_iframe = false;
var orgLeftPos;
var orgTopPos;
var ajax_tooltip_MSIE = false;
var timerID = '';
var isMouse = false;
var isSetTime = true;
if(navigator.userAgent.indexOf('MSIE')>=0)ajax_tooltip_MSIE=true;

/**
*	This function creates the tooltip div if not created and displays it
**/
function ajax_showTooltip(externalFile,inputObj,isSetTimeNeeded,isContent)
{
	if(!ajax_tooltipObj)	/* Tooltip div not created yet ? */
	{
		ajax_tooltipObj = document.createElement('DIV');
		ajax_tooltipObj.style.position = 'absolute';
		ajax_tooltipObj.id = 'ajax_tooltipObj';		
		document.body.appendChild(ajax_tooltipObj);
		ajax_tooltipObj.onmousedown = dragHandler;
		ajax_tooltipObj.style.width="50%";
		ajax_tooltipObj.style.height="100px";
		ajax_tooltipObj.onmouseover=mouseOverDiv;
		ajax_tooltipObj.onmouseout=mouseOutDiv;
		if(ajax_tooltip_MSIE){	/* Create iframe object for MSIE in order to make the tooltip cover select boxes */
			ajax_tooltipObj_iframe = document.createElement('<IFRAME frameborder="0">');
			ajax_tooltipObj_iframe.style.position = 'absolute';
			ajax_tooltipObj_iframe.border='0';
			ajax_tooltipObj_iframe.frameborder=0;
			ajax_tooltipObj_iframe.style.backgroundColor='#CCFFFF';
			ajax_tooltipObj_iframe.src = 'about:blank';
			ajax_tooltipObj.appendChild(ajax_tooltipObj_iframe);
			ajax_tooltipObj_iframe.style.left = '0px';
			ajax_tooltipObj_iframe.style.top = '0px';
			ajax_tooltipObj_iframe.style.overflow = 'auto';
		}
	}
	// Find position of tooltip
	ajax_tooltipObj.style.display='block';
	if(isContent)
	{
		var divContent = "";
		divContent += "<div class=\"sidebox\" id='contentbox'>"
		divContent += "<div class=\"boxhead\"><h2><div style=\"align:right;border:0px solid red\"><table border='0' width='100%'>"
		divContent += "<tr><td align='left' class='body'><B><%=keyword%></B>&nbsp;&nbsp;</td><td valign='top' align='right'><a href=\"javascript:closeToolTip();\"><IMG border='0' alt='close' "
		divContent += "src=\"../ajax/images/bt_close_off.gif\" name=bt_close></a></td></tr></table></div></h2></div>"
		divContent += "<div class=\"boxbody\"   style=\"overflow:auto\">"
		divContent += externalFile;	
		divContent += "</div>"
		divContent += "</div>"
		ajax_tooltipObj.innerHTML = divContent;
	}
	else
		ajax_loadContent('ajax_tooltipObj',externalFile);
	if(ajax_tooltip_MSIE)
	{
		ajax_tooltipObj_iframe.style.width = ajax_tooltipObj.clientWidth+'px';
		ajax_tooltipObj_iframe.style.height = ajax_tooltipObj.clientHeight+'px';
	}
	isMouse = true;
	isSetTime = isSetTimeNeeded;
	ajax_positionTooltip(inputObj);
}
function mouseOverDiv()
{
	isMouse = true;
}
function mouseOutDiv()
{
	isMouse = false;
}

/**
*	This function creates the tooltip div if not created and displays it
**/
function ajax_positionTooltip(inputObj)
{
	var leftPos = (ajaxTooltip_getLeftPos(inputObj)+inputObj.offsetWidth);
	var topPos = ajaxTooltip_getTopPos(inputObj);
	var tooltipWidth = document.getElementById('ajax_tooltipObj').offsetWidth ;//+  document.getElementById('ajax_tooltip_arrow').offsetWidth; 
	orgLeftPos = leftPos;
	orgTopPos = topPos;
	topPos -= 60;
	//leftPos +=5;
	ajax_tooltipObj.style.left = leftPos + 'px';
	ajax_tooltipObj.style.top = topPos +'px';	
	if(ajax_tooltipObj.style.top < ajax_tooltipObj.style.height)
		ajax_tooltipObj.style.top = ajax_tooltipObj.style.height;
	if('' != timerID)
		clearTimeout(timerID);
	if(isSetTime)
		setTimeout("ajax_hideTooltip()",5000);
}
/**
*	This function hides the tooltip if it has been inactive for certain seconds
**/
function ajax_hideTooltip()
{
	var leftPos = ajax_tooltipObj.style.left;
	var topPos = ajax_tooltipObj.style.top;
	leftPos = leftPos.substring(0,leftPos.indexOf("px"));
	if(isSetTime)
	{
		if(leftPos != orgLeftPos || isMouse)
			timerID = setTimeout("ajax_hideTooltip()",5000);
		else
			ajax_tooltipObj.style.display='none';
	}
	orgLeftPos = leftPos;
}
/**
*	This function positions the tooltip
**/
function ajaxTooltip_getTopPos(inputObj)
{		
  var returnValue = inputObj.offsetTop;
  while(null != (inputObj = inputObj.offsetParent))
  {
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetTop;
  }
  return returnValue;
}
/**
*	This function gets the left position for the tooltip
**/
function ajaxTooltip_getLeftPos(inputObj)
{
  var returnValue = inputObj.offsetLeft;
  while(null != (inputObj = inputObj.offsetParent))
  {
  	if(inputObj.tagName!='HTML')returnValue += inputObj.offsetLeft;
  }
  return returnValue;
}
function close()
{
	document.getElementById("ajax_tooltipObj").style.display ='none';
}
function hideToolTip()
{
//	setTimeout("document.getElementById('ajax_tooltipObj').style.display ='none';",1000);
}
function closeThis()
{
}
function whatsThis()
{
}
function whatsThisContent()
{
	window.open('http://www.claritas.com/claritas/Default.jsp?ci=6' );
}

var selObj = null;
var orgCursor=null;   // The original Cursor (mouse) Style so we can restore it
var dragOK=false;     // True if we're allowed to move the element under mouse
var dragXoffset=0;    // How much we've moved the element on the horozontal
var dragYoffset=0;    // How much we've moved the element on the verticle

/**
*	The moveHandler is the mousemove handler for the tooltip div
**/
function moveHandler(e)
{
	if (null == e) { e = window.event } 
	if (e.button<=1 && dragOK)
	{ 
		selObj.style.left = e.clientX-dragXoffset+'px';
		selObj.style.top = e.clientY-dragYoffset+'px';
		return false;
	}
}
/**
*	The cleanup is the mouseup handler for the tooltip div
**/
function cleanup(e) 
{
  document.onmousemove = null;
  document.onmouseup = null;
  selObj.style.cursor = orgCursor;
  dragOK=false;
}
/**
*	The dragHandler is the onmousedown event for the tooltip div
**/
function dragHandler(e)
{
	var htype='-moz-grabbing';
	if (null == e) { e = window.event; htype='move';} 
	var target = document.getElementById("ajax_tooltipObj");
	selObj = target;
	orgCursor = target.style.cursor;
	target.style.cursor = htype;
	dragOK = true;
	dragXoffset = e.clientX-parseInt(selObj.style.left);
	dragYoffset = e.clientY-parseInt(selObj.style.top);
	document.onmousemove = moveHandler;
	document.onmouseup = cleanup;
	return false;
}