//

var posx;
var posy;
var docHeight;
var docWidth;

function tooltip(theObj,content)
{
	document.getElementById('ttcontent').innerHTML=content;
	var tt_div=document.getElementById('tt');
	posy=findPosY(theObj);
	posx=findPosX(theObj);
	if (posy<200)
    {
		tt_div.className="flipped";
    	tt_div.style.top=(posy+(theObj.offsetHeight))+"px"
	}
    else
    {
		tt_div.className="normal";
		tt_div.style.top=posy-tt_div.offsetHeight+"px"

    }
  		tt_div.style.left=posx-35+"px";
    tt_div.style.visibility="visible"
}
function createShell()
{
    newTTDiv = document.createElement("DIV");
    newTTDiv.setAttribute("id","tt");
	newTTDiv.style.position="absolute";
	newTTDiv.style.zIndex="1000";
	newTTDiv.style.overflow="hidden";
	newTTDiv.style.left="100px";
	newTTDiv.style.top="100px";

	newTTDiv.innerHTML='<table id="ttwrapper" ><tr><td class="tt_top_left">&nbsp;</td><td class="tt_top">&nbsp;</td><td  class="tt_top_right">&nbsp;</td></tr><tr><td class="tt_left">&nbsp;</td><td class="ttmiddle" id="ttcontent">&nbsp;</td><td class="tt_right">&nbsp;</td></tr><tr><td class="tt_bot_left">&nbsp;</td><td class="tt_bot">&nbsp;</td><td  class="tt_bot_right">&nbsp;</td></tr></table>';
	newTTDiv.style.visibility="hidden";
    document.getElementsByTagName('BODY')[0].appendChild(newTTDiv);
    preloadBorderImages();
}
function clearTT()
{
	document.getElementById('tt').style.visibility="hidden";
}
function findPosY(obj)
{
    var curtop = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curtop += obj.offsetTop;
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
        return curtop;
}
function findPosX(obj)
{
    var curtop = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curtop += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curtop += obj.x;
        return curtop;
}

function preloadImages(){
	var pics = new Array();
	for(var i=0;i<arguments.length;i++){
        pics[i]=new Image();
        pics[i].src=arguments[i];
	}
 }

function preloadBorderImages(){
    preloadImages(
  				'http://www.zapawho.com/images/tooltip/tt_bg.png',
  				'http://www.zapawho.com/images/tooltip/tt_bg_left.png',
  				'http://www.zapawho.com/images/tooltip/tt_bg_right.png',
  				'http://www.zapawho.com/images/tooltip/tt_bot.png',
  				'http://www.zapawho.com/images/tooltip/tt_bot_left.png',
  				'http://www.zapawho.com/images/tooltip/tt_bot_right.png',
  				'http://www.zapawho.com/images/tooltip/tt_fl_bot_bg.png',
  				'http://www.zapawho.com/images/tooltip/tt_fl_bot_left.png',
  				'http://www.zapawho.com/images/tooltip/tt_fl_bot_right.png',
  				'http://www.zapawho.com/images/tooltip/tt_fl_left.png',
  				'http://www.zapawho.com/images/tooltip/tt_fl_right.png',
  				'http://www.zapawho.com/images/tooltip/tt_fl_top.png',
  				'http://www.zapawho.com/images/tooltip/tt_fl_top_left.png',
  				'http://www.zapawho.com/images/tooltip/tt_fl_top_right.png',
  				'http://www.zapawho.com/images/tooltip/tt_left.jpg',
  				'http://www.zapawho.com/images/tooltip/tt_left.png',
  				'http://www.zapawho.com/images/tooltip/tt_right.png',
  				'http://www.zapawho.com/images/tooltip/tt_top_bg.jpg',
  				'http://www.zapawho.com/images/tooltip/tt_top_left.png',
  				'http://www.zapawho.com/images/tooltip/tt_top_right.png' );
}

onloadEvent(createShell);

