function genMail()
{
    var nom = "contact";
    var domaine = "lespointscardinaux.com"; 
    document.write('<a class="contact" href=\"mailto:' + nom + '@' + domaine + '\">');
    document.write(nom + '@' + domaine + '</a>'); 
}

var _fadeFinished = false;
var _lightboxImage = null;

function _setLightboxImage()
{
    var d = document.getElementById("lightboxImage");
    d.appendChild(_lightboxImage);
    
    // alert("doc H/2 " + document.body.scrollHeight/2 + "doc W/2 "+ document.body.scrollWidth/2 + " img H " + _lightboxImage.naturalHeight + " img W " +_lightboxImage.naturalWidth );
    d.style.top =  document.body.scrollHeight/2 - _lightboxImage.naturalHeight/2 + "px";
    d.style.left = document.body.scrollWidth/2 - _lightboxImage.naturalWidth/2 + "px";
    if (document.all) 
        d.filter = "alpha(opacity=100)";
    d.style.MozOpacity = 1;
    d.style.opacity = 1;
    d.style.display = "block";
}

function lightboxFade(){
    
    document.getElementById("lightbox").style.display = "block";

    bgfade = new Animator({
                          duration: 250,
                          onComplete: function() {
                          _fadeFinished = true ;
                          _setLightboxImage();
                          }
                          });
    
    bgfade.addSubject(new NumericalStyleSubject( document.getElementById("lightbox"), 'opacity', 0, .98, 4) );

    if(!_fadeFinished){
        bgfade.play();
    }
}


function lightboxHideBack() {
    document.getElementById("lightbox").style.display = "none";
}

/* Fond de la lightbox pour toute la fenetre */
function lightboxResizeBack() {
    var back = document.getElementById("lightbox");
    if (back) {
        back.style.height = document.body.scrollHeight + "px";
        back.style.width = document.body.scrollWidth + "px";
        back.style.top = "0px";
        back.style.left = "0px";

        if (document.all) 
            back.filter = "alpha(opacity=0)";
        back.style.MozOpacity = 0;
        back.style.opacity = 0;
    }
}

function LPCLightbox(src, lgd)
{
    if (_lightboxImage == null)
    {
        _lightboxImage = document.createElement('img');
    }
    _lightboxImage.src = src;
        
    lightboxResizeBack();
    lightboxFade();
}

function LPCHideLightbox()
{
    var i = document.getElementById("lightboxImage");
    while (i.hasChildNodes())
        i.removeChild(i.childNodes[0]);
    i.style.display = "none";
    
    bgfade = new Animator({
                          duration: 200,
                          onComplete: function() { 
                          document.getElementById("lightbox").style.display = "none";
                          _fadeFinished = false;
                          }
                          });

    bgfade.addSubject(new NumericalStyleSubject(document.getElementById("lightbox"), 'opacity', .95, 0, 4));

    if(_fadeFinished){
        bgfade.play();
    }
}

