var offsetxpoint = -60; // Position x de l'aide
var offsetypoint = 20; // Position y de l'aide
var ie = document.all;
var w3c = document.getElementById && !document.all;
var enabletip = false;

if (ie || w3c)
{
	var tipobj;
	var tipobj2;
}

function ietruebody()
{
	return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body;
}

function ViewHelp(HelpText, HelpTitle)
{
	if (w3c || ie)
	{
		var tableau = '<table class="help"><tr><td width="100%" height="22" style="background-image:url(' + _rootPath + 'res/images/bulle_haut.gif);"><strong>' + ((HelpTitle != undefined) ? HelpTitle : 'Information') + '</strong></td></tr>';
		tableau = tableau + '<tr><td width="100%" height="22" style="background-image:url(' + _rootPath + 'res/images/bulle_fondmain.gif);">';
		tableau = tableau + '<p>' + HelpText + '</p></td></tr>';
		tableau = tableau + '<tr><td width="100%" height="22" style="background-image:url(' + _rootPath + 'res/images/bulle_bas.gif);">&nbsp;</td></tr></table>';
		tipobj = document.getElementById('dhtmlHelp');
		tipobj.innerHTML = tableau;
		enabletip = true;
		return false;
	}
}

function ViewNotif(NotifText, NotifUrl)
{
	if (w3c || ie)
	{
		var tableau = '<table class="help"><tr><td width="100%" height="22" style="background-image:url(' + _rootPath + 'res/images/bulle_haut.gif);"><strong>Notification</strong></td></tr>';
		tableau = tableau + '<tr><td width="100%" height="22" style="background-image:url(' + _rootPath + 'res/images/bulle_fondmain.gif);">';
		tableau = tableau + '<p><a href="' + NotifUrl + '">' + NotifText + '</a></p></td></tr>';
		tableau = tableau + '<tr><td width="100%" height="22" style="background-image:url(' + _rootPath + 'res/images/bulle_bas.gif);">&nbsp;</td></tr></table>';
		tipobj2 = document.getElementById('notification');
		tipobj2.innerHTML = tableau;
		tipobj2.style.display = 'none';
		
		$('#notification').fadeIn(1000);
		//Effect.Appear('notification', {from: 0.0, to: 1.0, queue: {position: 'end', scope: 'notif'}});

		return false;
	}
}

function MoveHelp(e)
{
	if (enabletip)
	{
		var curX = (w3c) ? e.pageX : event.x+ietruebody().scrollLeft;
		var curY = (w3c) ? e.pageY : event.y+ietruebody().scrollTop;

		var rightedge = (ie && !window.opera) ? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20;
		var bottomedge = (ie && !window.opera) ? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20;

		var leftedge = (offsetxpoint < 0) ? offsetxpoint*(-1) : -1000;

		// Déplacer vers la gauche
		if (rightedge < tipobj.offsetWidth)
			tipobj.style.left = (ie) ? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px";
		else if (curX<leftedge)
			tipobj.style.left = "5px";
		// Mettre la position horizontale à celle où se trouve la souris
		else
			tipobj.style.left = curX+offsetxpoint+"px";

		// Idem avec la position verticale
		if (bottomedge < tipobj.offsetHeight)
			tipobj.style.top = (ie) ? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px";
		else
			tipobj.style.top = curY+offsetypoint+"px";
	}
}

function HideHelp()
{
	if (w3c || ie)
	{
		enabletip = false;
		tipobj.style.left = "-1000px";
		tipobj.style.backgroundColor = '';
		tipobj.style.width = '';
	}
}

function HideNotif()
{
	$('#notification').fadeOut(1000);
	//Effect.Fade('notification', {from: 1.0, to: 0.0, queue: {position: 'front', scope: 'notif'}});
}

document.onmousemove = MoveHelp;

