var oHelpLayer;

function getToolText( sMsgID )
{
    var sText;
    
    if( sMsgID == "kleurwedstrijd" )
        sText = "tt_kleurwedstrijd";
    else if( sMsgID == "boekenvoordeel" )
        sText = "tt_boekenvoordeel";
    else if( sMsgID == "aanbiedingen" )
        sText = "tt_aanbiedingen";
    else if( sMsgID == "prijzenregen" )
        sText = "tt_prijzenregen";
    else if( sMsgID == "testproducten" )
        sText = "tt_testproducten";
    else if( sMsgID == "voorleestips" )
        sText = "tt_voorleestips";
        
    if( sText != "" )
        return sText;
}


function Help( sMsgID )
{
    if ( typeof oHelpLayer == "undefined" )
        oHelpLayer = new Tooltip();
    oHelpLayer.show( getToolText( sMsgID ) );
}

function hideHelp()
{
    oHelpLayer.hide();
}   


function Tooltip()
{
    this.init();
};
Tooltip.prototype.init = function()
{
    if ( document.createElement )
        this._tip = document.createElement( "div" );

    if ( this._tip )
    {                                                                    
        this._tip.id         = "jstooltip";
        this._tip.className  = "helplayer";    
        document._tooltip    = this;
        document.onmousemove = this._delegateMouseMove;
        document.body.appendChild( this._tip );
        this._tooltip = new klib3.dynamic( this._tip );
    }
    this._follow = false;
};
Tooltip.prototype.move = function( e )
{
    if ( this._follow )
    {
        if (!e) var e = window.event;
        if (e.pageX || e.pageY)     
        {
            this._xmouse = e.pageX;
            this._ymouse = e.pageY;
        }
        else if (e.clientX || e.clientY)     
        {
            this._xmouse = e.clientX + document.body.scrollLeft + 10; 
            this._ymouse = e.clientY + document.documentElement.scrollTop - 10;
        }

        
        this._tooltip.move( this._xmouse + 10, this._ymouse + 10);
    }
};
Tooltip.prototype.show = function( sText )
{   
	if (!this._tip)
	{
		this.init();
	}
    this._tip.style.display = "block";
    this._tip.className  = "helplayer " + sText;
	this._follow            = true;
};
Tooltip.prototype.hide = function()
{
	this._tip.parentNode.removeChild(this._tip) ;
	delete this._tip;
    this._follow            = false;
};
//  All of the delegate methods have the scope of the html element to which it is attached, this is NOT the Tooltip Object!
Tooltip.prototype._delegateMouseOver = function()
{
    if ( this._title != "" )
        this._tooltip.show( this._title );
};
Tooltip.prototype._delegateMouseOut = function()
{
    this._tooltip.hide();
};
Tooltip.prototype._delegateMouseMove = function( e )
{
    this._tooltip.move( e );
};