var imageHeight = 250;
var imageWidth = 250;

function PopupImage(title, monImage, maLargeur, maHauteur)
{
	varLargeur = (screen.width - maLargeur) / 0;
	varHauteur = (screen.height - maHauteur) / 0;
	w=open("",'image','toolbar=no,scrollbars=no,resizable=no,width='+maLargeur+',height='+maHauteur+',top='+varHauteur+',left='+varLargeur); 
	w.document.write("<HTML><HEAD><TITLE>"+title+"</TITLE></HEAD>");
	w.document.write("<span style=\"font-size:12px;font-family:Verdana;text-align:center;width:100%;\">" + title+ "</span>");
	w.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+10,document.images[0].height+25); window.focus();} else { setTimeout('check()',250) } }</"+"SCRIPT>");
	w.document.write(" <body onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><A HREF='JavaScript:window.close();'><IMG SRC='"+monImage+"' border=0></A>");
	w.document.write("");
	w.document.write("</BODY></HTML>");
	w.document.close();
}

function getpopupimage()
{
	if (document.getElementById)
		return document.getElementById("popupimage")
	else if (document.all)
		return document.all.popupimage
}

function truebody()
{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function showpopupimage(imagename, title, text, width, height)
{

    if (width > 0)
        imageWidth = width;

    if (height > 0)
        imageHeight = height;

    document.onmousemove = followmouse;

    cameraHTML = '';

    newHTML = '<div>';
    newHTML = newHTML + '<br /><b style="text-decoration:none;text-align:center;">' + title + '</b>';
    newHTML = newHTML + '<div style="text-align:center;margin-top:5px;"><img src="' + imagename + '" style="border:2px solid #D7D7D7;" width="' + width + '" height="' + height + '"></div>';

    newHTML = newHTML + '</div>';

	if (!document.all)	popupimage = getpopupimage();
	
	popupimage.innerHTML = newHTML;
	popupimage.style.position="absolute";
	popupimage.style.zIndex="200";
	popupimage.style.visibility="visible";

}


function hidepopupimage()
{
    getpopupimage().style.visibility="hidden"
    document.onmousemove=""
    getpopupimage().style.left="-500px"

}

function followmouse(e)
{
    var xcoord=10
    var ycoord=10

    var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-20
    var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : window.innerHeight

    if (typeof e != "undefined")
    {
        if (docwidth - e.pageX < imageWidth)
        {
            xcoord = e.pageX - xcoord - imageWidth;
        } 
        else 
        {
            xcoord += e.pageX;
        }
        
        if (docheight - e.pageY < imageHeight)
        {
            //ycoord += e.pageY - ycoord - imageHeight;
            ycoord += e.pageY;
        }
        else
        {
            ycoord += e.pageY;
        }

    }
    else if (typeof window.event != "undefined")
    {
        if (docwidth - event.clientX < imageWidth)
        {
            xcoord = event.clientX + truebody().scrollLeft - xcoord - imageWidth;
        }
        else
        {
            xcoord += truebody().scrollLeft+event.clientX
        }
        if (docheight - event.clientY < imageHeight)
        {
            ycoord += event.clientY + truebody().scrollTop - ycoord - imageHeight;
        }
        else
        {
            ycoord += truebody().scrollTop + event.clientY;
        }
    }

    getpopupimage().style.left=xcoord-200+"px"
    getpopupimage().style.top=ycoord+"px"

}
