var version = 0;

//ON RECUPERE LA VERSION D'IE
if (navigator.appVersion.indexOf("MSIE") != -1)
{
	temp = navigator.appVersion.split("MSIE");
	version = parseFloat(temp[1]);
}

if(navigator.appName=="Microsoft Internet Explorer" && version == 7)
{
	decal_x = 5;
	decal_y = 5;
}
else
{
	decal_x = 5;
	decal_y = 5;
}

//APPEL DE LA FONCTION QUI SUIT LA SOURIS
document.onmousemove = suivre_souris;
var contenu = "";

//FONCTION QUI AFFICHE L'IMAGE ET LE TEXTE DU CONTENEUR SUR SURVOL DE LA SOURIS
function survol_image_texte(urlImage,texte,bordure,color,p_width,p_height)
{
	window.document.getElementById("image_grand").style.display = "block";
	window.document.getElementById("image_grand").style.border = bordure + "px solid " + color;
	window.document.getElementById("image_grand").style.background = "white";
	window.document.getElementById("image_grand").style.position = "absolute";
	window.document.getElementById("image_grand").style.zIndex = 900;
	window.document.getElementById("image_grand").style.width = p_width + "px";
	window.document.getElementById("image_grand").style.margin = "0px";
	window.document.getElementById("image_grand").style.padding = "0px";
	window.document.getElementById("image_grand").style.fontSize = "13px";
	window.document.getElementById("image_grand").innerHTML = "<img src='" + urlImage + "'>";
	window.document.getElementById("image_grand").innerHTML+= "<br />";
	window.document.getElementById("image_grand").innerHTML+= texte;
}

//FONCTION QUI AFFICHE L'IMAGE SUR SURVOL DE LA SOURIS
function survol_image(contenu,bordure,color,p_width,p_height)
{
	if(p_width < 400)
	{
		width = p_width;
		height = p_height;
	}
	else
	{
		width = 400;
		height = (width * p_height) / p_width;
	}

	window.document.getElementById("image_grand").style.display = "block";
	window.document.getElementById("image_grand").style.border = bordure + "px solid " + color;
	window.document.getElementById("image_grand").style.background = "white";
	window.document.getElementById("image_grand").style.position = "absolute";
	window.document.getElementById("image_grand").style.zIndex = 900;
	window.document.getElementById("image_grand").style.width = width + "px";
	window.document.getElementById("image_grand").style.height = height + "px";
	window.document.getElementById("image_grand").style.margin = "0px";
	window.document.getElementById("image_grand").style.padding = "0px";
	window.document.getElementById("image_grand").innerHTML = "<img width='"+width+"' src=" + contenu;
}

function suivre_souris(e)
{
	var isEnHaut = false;
	var isAGauche = false;
	var width = window.document.getElementById("image_grand").clientWidth;
	var height = window.document.getElementById("image_grand").clientHeight;

	if (navigator.appName == "Microsoft Internet Explorer")
	{
		if(version != 7)
		{
			var x = event.x + document.body.scrollLeft;
			var y = event.y +  document.body.scrollTop;
		}
		else
		{
			var x = event.x + document.documentElement.scrollLeft;
			var y = event.y +  document.documentElement.scrollTop;
		}
	}
	else
	{
		var x =  e.pageX;
		var y =  e.pageY;
	}

	if(navigator.appName != "Microsoft Internet Explorer")
	{
		xmax = window.innerWidth + window.pageXOffset - 15;
		ymax = window.innerHeight + window.pageYOffset - 15;
	}
	else
	{
		xmax = document.documentElement.clientWidth+document.documentElement.scrollLeft;

		if(version < 7)
		{
			ymax = document.documentElement.clientHeight+document.documentElement.scrollTop - 150;
		}
		else
		{
			ymax = document.documentElement.clientHeight+document.documentElement.scrollTop;
		}
	}

	if (x + width > xmax)
	{
		isAGauche = true;
		 x = x - width;
	}

	if (y + height > ymax)
	{
		isEnHaut = true;
		 y = y - height;
	}

	if(isAGauche == false)
	{
		window.document.getElementById("image_grand").style.left = x + decal_x + "px";
	}
	else
	{
		window.document.getElementById("image_grand").style.left = x - decal_x + "px";
	}

	if(isEnHaut == false)
	{
		window.document.getElementById("image_grand").style.top  = y + decal_y + "px";
	}
	else
	{
		window.document.getElementById("image_grand").style.top  = y - decal_y + "px";
	}
}

function enlever_image()
{
	document.getElementById("image_grand").innerHTML = '';
	document.getElementById("image_grand").style.display = "none";
}