// Copyright 2002-2006 ExpoCharger International, Inc. 
// All rights reserverd. 

//modeled after macromedia boilerplate tooltip
var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;
var ns7 = (ns6==true) && (typeof (document.body.clientWidth) != "undefined");
offsetX = 5;
offsetY = 20;
var toolTipSTYLE="";
var CssClassName="toolTip";
var freezePosition=false;
function initToolTips(cssClassName)
{
  if(ns4||ns6||ie4)
  {
	if(cssClassName) CssClassName=cssClassName;
    if(ns4) toolTipSTYLE = document.toolTipLayer;
    else if(ns6) toolTipSTYLE = document.getElementById("toolTipLayer").style;
    else if(ie4) toolTipSTYLE = document.all.toolTipLayer.style;
    if(ns4) document.captureEvents(Event.MOUSEMOVE);
    else
    {
      toolTipSTYLE.visibility = "visible";
      toolTipSTYLE.display = "none";
    }
    document.onmousemove = moveToMouseLoc;
  }
}
function toolTip(msg)
{
  if(toolTip.arguments.length < 1) // hide
  {
    if(ns4) toolTipSTYLE.visibility = "hidden";
		//already hidden
    else 
		toolTipSTYLE.display = "none";
    freezePosition=false;
  }
  else // show
  {
	//freezePosition=true;
	if(msg=="")
		msg = "&nbsp\;";
    var content = '<table border="0" cellspacing="0" cellpadding="1" >' + 
	'<td align="left"  class="' + CssClassName + '" NOWRAP>' + msg +  '</td></table>';
    if(ns4)
    {
      toolTipSTYLE.document.write(content);
      toolTipSTYLE.document.close();
      toolTipSTYLE.visibility = "visible";
    }
    if(ns6)
    {
      document.getElementById("toolTipLayer").innerHTML = content;
      toolTipSTYLE.display='block';
    }
    if(ie4)
    {
      document.all("toolTipLayer").innerHTML=content;
      toolTipSTYLE.display='block';	
    }
  }
}
//tooltip for exhibitor list
function toolTipExhibList(imgFolderUrl,imgFileName,imgWidth,imgHeight,coName,coProfile,level,boothNumbers,productNames,pinToTop)
{
	var tipContent = "";
	var imgDimensionString = "";
	var tdWidth = imgWidth;
	if (imgFileName.length > 0)
	{
		if( (parseInt(imgWidth) > 150) || (parseInt(imgHeight) > 150) )
		{
			if( parseInt(imgWidth) > parseInt(imgHeight) )
			{
				imgDimensionString = "width=150";
				tdWidth = 150;
			}
			else {
				imgDimensionString = "height=150";
				tdWidth = Math.ceil(imgWidth/imgHeight * 150);
			}
		}
		tipContent = "<table border=1 cellspacing=0 cellpadding=0 width=400>"
				+ "<tr><td class=#0#><table border=0 cellspacing=0 cellpadding=0 width=100%>"
				+ "<tr><td valign=middle width=#5#><img src=#1# #2# border=0 /></td>"
				+ "<td valign=top class=#6#><b>#3#</b><br /><br />#4#</td></tr><table>"
				+ "</td></tr></table>";
	} 
	else 
	{
		tipContent = "<table border=1 cellspacing=0 cellpadding=0 width=400>"
				+ "<tr><td class=#0#><table border=0 cellspacing=0 cellpadding=0 width=100%>"
				+ "<tr><td class=#6#><b>#3#</b>"
				+ "<br /><br />#4#</td></tr><table>"
				+ "</td></tr></table>";
	}
	
	if(coProfile.length > 250)
	{
		//find a word break
		var cutoff = Math.max(coProfile.indexOf(" ",249),240);
		//trim the profile
		coProfile = coProfile.substr(0,cutoff) + " ...";
	}
	
	var cssClassBg="attListBgFlyOver"; //background
	var cssClassFg="attListFgFlyOver"; //foreground
	
	tipContent = tipContent.replace(/#0#/g,cssClassBg);
	tipContent = tipContent.replace(/#6#/g,cssClassFg);
	tipContent = tipContent.replace(/#1#/g,imgFolderUrl + imgFileName);
	tipContent = tipContent.replace(/#2#/g,imgDimensionString);
	tipContent = tipContent.replace(/#3#/g,coName);
	tipContent = tipContent.replace(/#4#/g,coProfile);
	tipContent = tipContent.replace(/#5#/g,tdWidth);
	
	freezePosition=true;
	offsetX=25;
	offsetY=-20;
	
	if(ns4)
    {
      toolTipSTYLE.document.write(tipContent);
      toolTipSTYLE.document.close();
      toolTipSTYLE.visibility = "visible";
    }
    else if(document.getElementById)
    {
      document.getElementById("toolTipLayer").innerHTML = tipContent;
      toolTipSTYLE.display='block'
    }
    else if(document.all)
    {
      document.all("toolTipLayer").innerHTML=tipContent;
      toolTipSTYLE.display='block'	
    }
}
function moveToMouseLoc(e)
{
	var x,y;
	if(ns4||ns6)
	{
		x = e.pageX;
		y = e.pageY;
	}
	else 
	{
		x = event.x + document.body.scrollLeft;
		y = event.y + document.body.scrollTop;
	}
	var saveX = x;
	var saveY = y;
	if (ie4 || ns7)
	{
		var div = document.getElementById("toolTipLayer");
		var flyWidth = div.scrollWidth + offsetX;
		var flyHeight = div.scrollHeight + offsetY;
		
		if (x+flyWidth>document.body.clientWidth + document.body.scrollLeft)
		{
			x=x-flyWidth-offsetX/2;
		}
		if (y+flyHeight-10>document.body.clientHeight + document.body.scrollTop)
		{
			y=y-flyHeight-offsetY/2;
		}
		if (x+10<document.body.scrollLeft)
			x=document.body.scrollLeft-offsetX;
		if (y+10<document.body.scrollTop)
			y=document.body.scrollTop-offsetY;		
		//don't cover up the cursor (prevents clicking on the booth)
		if(x<saveX && (x+flyWidth)>saveX && y<saveY && (y+flyHeight)>saveY)
		{
			x = saveX + offsetX;
		}
			
	}
	  
	if (freezePosition==false)
	{
		toolTipSTYLE.left = x + offsetX;
		toolTipSTYLE.top = y + offsetY;

		
	}
  return true;
}