// JavaScript Document

var decalage = new Array();


function $(id) { return document.getElementById(id); }


function addListener(el, evType, funct, capture) { /* Compatibilité MSIE */

    el.addEventListener ?         el.addEventListener(evType, funct, capture):
            el.attachEvent ? el.attachEvent("on" + evType, funct):
            el["on" + evType] = funct;

}

function removeListener(el, evType, funct, capture) { /* Compatibilité MSIE */

    el.removeEventListener ?         el.removeEventListener(evType, funct, capture):
            el.detachEvent ? el.detachEvent("on" + evType, funct):
            el["on" + evType] = "";

}



function showGp(url,titre,imgWidth,imgHeight) {

    var oEl = $("previewGp");
    decalage[0] = parseInt(imgWidth,10) + 15; // Bordure
    decalage[1] = parseInt(imgHeight,10) + 28; // Bordure + Hauteur Titre
    addListener(document,'mousemove',followMouse, false);
    oEl.style.display = 'block';
    oEl.innerHTML = "<h5>"+titre+"</h5><img src='"+url+"' width='"+imgWidth+"' + height='"+imgHeight+"' alt='' />";
}

function followMouse(e) {

var oEl = $("previewGp");
mouse_x = e.clientX || e.pageX;
mouse_y = e.clientY || e.pageY;
oEl.style.left = mouse_x - decalage[0] + 'px';
oEl.style.top = mouse_y - decalage[1] + 'px';
}

function hideGp() {
    
    var oEl = $("previewGp");
    oEl.style.display = 'none';
    removeListener(document,'mousemove',followMouse, false);

}
