$(document).ready(function(){
    if($('#citation'))
    {
        $('#citation').html('<img src="/uploads/home/animation/' + tabImage[0] + '" alt="" >');
        setInterval( changeImage, 5000);
    }


    if($('#gallery a'))
        $('#gallery a').lightBox();
    
    if($('#en_savoir_plus'))
        $('#en_savoir_plus').click(function(){
            var t = "En savoir plus" || this.innerHTML || this.href;
            GB_show(t,this.href,470,600);
            return false;
        });

    if($('#mentions_legales'))
        $('#mentions_legales').click(function(){
            var t = "En savoir plus" || this.innerHTML || this.href;
            GB_show(t,this.href,470,600);
            return false;
        });

    if($('#carrieres'))
        $('#carrieres').click(function(){
            var t = "En savoir plus" || this.innerHTML || this.href;
            GB_show(t,this.href,470,600);
            return false;
        });

    if($('#contacts'))
        $('#contacts').click(function(){
            var t = "Contacts" || this.innerHTML || this.href;
            GB_show(t,this.href,300, 300);
            return false;
        });

    Popup.init();
    
});

var tabImage = [];
var currentImage = 0;
function changeImage()
{
    currentImage++;

    if(currentImage == tabImage.length)
        currentImage = 0;

    $('#citation').fadeOut(800, function(){
        $(this).html('<img src="/uploads/home/animation/' + tabImage[currentImage] + '" alt="" >');
        $(this).fadeIn(800);
    });
}

Popup = {

    init : function () {
        $('a.action_print').bind('click', Popup.printIt);
    },

    printIt : function () {
        var win = window.open('', 'Image', 'resizable=yes,...');
        if (win.document) {
            win.document.writeln('<img src="'+ $(this).attr('href') +'" alt="image" />');
            win.document.close();
            win.focus();
            win.print();
        }
        return false;
    }
}

