var CURRENT_NICE_TITLE;
var delay;


function showNiceTitleTest(note,header,lnk,imagePath)
{
    if (CURRENT_NICE_TITLE) hideNiceTitle(CURRENT_NICE_TITLE);
    if (!document.getElementsByTagName) return;

    nicetitle = note;

    var d = document.createElement('div');
    d.className = 'clientchk';
    d.id="divPopup";
    d.style.position="absolute";
    d.style.border="solid 1px black";
    d.style.padding="4px";
    d.style.backgroundColor="#ffffe1";    
    
    tnt = document.createTextNode(header);
    pat = document.createElement('p');
    pat.style.color="#e29545";
    
    pattext = document.createElement('u');
    pattext.appendChild(tnt);
    pat.appendChild(pattext);
    
    pat.className = 'clientchk';
    d.appendChild(pat);
    
    tnt = document.createTextNode(nicetitle);
    pat = document.createElement('p');
    // COMMENTED BY ANJANA ON 19JAN2010 - TO APPLY STYLE CLASS FROM CSS FILE
    //pat.style.color="#049135";
    pat.className = 'clientchksamll';
    
    pat.appendChild(tnt);    
    d.appendChild(pat);
    
    if (imagePath!=undefined)
    {
        pat=document.createElement('p');
        pat.innerHTML="<br /><img src='" + imagePath + "'><br /><font color='#ffffe1'>`</font>";
        d.appendChild(pat);
    }
    
    STD_WIDTH = 300;

    h=50;// txt.lenght; 
    t=50;//txt.lenght;    

    h_pixels = h*6;
    t_pixels = t*10;

    if (h_pixels > STD_WIDTH)
    {
        w = h_pixels;
    }
    else
    {
        w = STD_WIDTH;
    }
        
    d.style.width = w + 'px';    

    mpos = findPosition(lnk);
    mx = mpos[0];
    my = mpos[1];

    d.style.left = (mx) + 'px';
    d.style.top = (my+35) + 'px';

    if (window.innerWidth && ((mx+w) > window.innerWidth))
    {
        d.style.left = (window.innerWidth - w - 25) + 'px';
    }
    if (document.body.scrollWidth && ((mx+w) > document.body.scrollWidth))
    {
        d.style.left = (document.body.scrollWidth - w - 25) + 'px';
    }
    
    document.getElementsByTagName('body')[0].appendChild(d);    
    CURRENT_NICE_TITLE = d;    
}

function hideNiceTitle(e)
	{	    
	// 2003-11-19 sidesh0w
	// clearTimeout 
	    if (delay) clearTimeout(delay);
	    if (!document.getElementsByTagName) return;
	    if (CURRENT_NICE_TITLE)
		    {
		    document.getElementsByTagName('body')[0].removeChild(CURRENT_NICE_TITLE);		    
		    CURRENT_NICE_TITLE = null;
		    }
	    }

    window.onload = function(e) {
    //makeNiceTitles();
    }


function findPosition(oLink)
	{
	if (oLink.offsetParent)
		{
		for (var posX = 0, posY = 0; oLink.offsetParent; oLink = oLink.offsetParent)
			{
			posX += oLink.offsetLeft;
			posY += oLink.offsetTop;
			}
		return [posX, posY];
		}
	else
		{
		return [oLink.x, oLink.y];
		}
	}
