
/* Page initialisation scripts */
$().ready(function() {

    // ie Hack for rollover event
	if($.browser.msie && /6.0/.test(navigator.userAgent)){
        $('.hoverable').hover(
            function() { $(this).addClass('hovered'); },
            function() { $(this).removeClass('hovered'); }
        );

        $('.combo').hover(
            function() { $(this).find('ul').css('display','block'); },
            function() { $(this).find('ul').css('display','none'); }
        );

    }

    // Popup initalisation
    Popup.init();

    // Menu page projet
    $('#content .aide-menu-bloc li').mouseover(
        function() { $('#content .aide-menu-bloc li'). removeClass('sel'); $(this).addClass('sel'); }
    );

    // Extend hyperlink contained in a class='onclick' to onclick event
    $('.onclick').click(function(){
        window.location = $(this).find('a').attr("href");
    });

    jQuery.preloadImages = function() { for(var i = 0; i<arguments.length; i++) { jQuery("<img>").attr("src", arguments[i]); } };

});

// Event when clic on flash logo
function clicLogo() {
    //openHelpBox('help/projet');
    document.location='help/projet';
}

/// Utilities
function openHelpBox(url) {
    $.ajax({type: "GET",  url: url, dataType: "html", scriptCharset: "utf-8", contentType: "text/html; charset=utf-8", success: function(data){$("#helpbox").html(data);}});
    $('#helpbox').height($('div.content').height()+20); // 40 correspond au padding
    Popup.openBox("#helpbox","#dark");
}

function setFullScreen(layer)
{
    var y = 0;
    var x = 0;
    if (self.innerHeight) {
        y = self.innerHeight;
        x = self.innerWidth;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        y = document.documentElement.clientHeight;
        x = document.documentElement.clientWidth;
    } else if (document.body) {
        y = document.body.clientHeight;
        x = document.body.clientWidth;
    }

    if (y<$('#container').height()) {
        $(layer).css('height',$('#container').height());
    } else {
        $(layer).css('height','100%');
    }

    if (x<$('#container').width()) {
        $(layer).css('width',$('#container').width()+30); // 30 correspond au padding
    } else {
        $(layer).css('width','100%');
    }
}

