/* $Id: nm_bubble.js,v 1.1.1.1 2010/10/06 04:45:22 parishesh Exp $ */

/* Detect if the browser is IE or not. If it is not IE, we assume that the browser is NS. */
var IEbbl = document.all?true:false;

var IEbblBody = ietruebody();

function displayBubble(bblId,e,contEmail)
{
	var musX = getMouseX(e);
	var musY = getMouseY(e);
    var contEmail;

	/* Absolute bottom position (including scroll value) of browser-window (viewport) */
	var wndwHeight = getWinHeight();

	document.getElementById(bblId).style.display = 'inline';

	var bblWidth = document.getElementById(bblId).offsetWidth;
	var bblHeight = document.getElementById(bblId).offsetHeight + 30;

	/* vertical distance between musY and bottom edge of browser-window (viewport) */
	var bottomDist = wndwHeight - musY;

	if(bottomDist < bblHeight)
	{
		var bblY = musY - bblHeight;
	}
	else
	{
		var bblY = musY + 30;
	}

    if(contEmail == 1)
	{
		document.getElementById(bblId).style.top = (musY - bblHeight) + "px";
		document.getElementById(bblId).style.left = (musX - 220) + "px";
	}
	else
	{
		document.getElementById(bblId).style.top = bblY + "px";
		document.getElementById(bblId).style.left = (getMouseX(e) - 100) + "px";
		// 	document.getElementById(bblId).style.left = '145' + "px";
	}
}

function hideBubble(bblId)
{
	document.getElementById(bblId).style.display = 'none';
}

function getMouseX(e)
{
	var tempX = 0;

	if (IEbbl)
	{
		/* Get the x pos.s if browser is IE */
		tempX = event.clientX + IEbblBody.scrollLeft;
	}
	else
	{
		/* Get the x pos.s if browser is NS */
		tempX = e.pageX;
	}

	/* catch possible negative values in NS4 */
	if (tempX < 0)
	{
		tempX = 0;
	}

	return tempX;
}

function getMouseY(e)
{
	var tempY = 0;

	if (IEbbl)
	{
		/* Get the y pos.s if browser is IE */
		tempY = event.clientY + IEbblBody.scrollTop;
	}
	else
	{
		/* Get the y pos.s if browser is NS */
		tempY = e.pageY;
	}

	/* catch possible negative values in NS4 */
	if (tempY < 0)
	{
		tempY = 0;
	}

	return tempY;
}

/* Gives absolute bottom position (Including scroll value) of bottom edge of browser visible window (viewport) */
function getWinHeight()
{
	/* Default value for old browser if(parseInt(navigator.appVersion)<3) */
	/*	var winW = 630, winH = 460;	*/

	/* We can also use if(navigator.appName.indexOf("Microsoft")!=-1) for the following */
	if(IEbbl && !window.opera)	/* For IE */
	{
// 		var winW = IEbblBody.offsetWidth + IEbblBody.scrollLeft;
// 		var winH = (IEbblBody.offsetHeight - 1222) + IEbblBody.scrollTop;
// 		var winW = IEbblBody.clientWidth + IEbblBody.scrollLeft;
		var winH = IEbblBody.clientHeight + IEbblBody.scrollTop;
	}
	else	/* For Netscape if(navigator.appName=="Netscape") */
	{
// 		var winW = window.innerWidth + window.pageXOffset;
		var winH = window.innerHeight + window.pageYOffset;
	}

	return winH;
}

function ietruebody()
{
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
