/**
 * Fonctions pour la navigation
 */
function goInternal(_url)
{
    location.href = document.getElementsByTagName('base')[0].href + _url;
}

function goAnchor(_id)
{
    location.href = location.href.split('#')[0] + '#' + _id;
}

/**
 * Gestionnaire des fonctions d'initialisation
 */
var initFunctions = new Array;

function registerInitFunction(_function)
{
    initFunctions[initFunctions.length] = _function;
}

function fireInitFunctions()
{
    for(i = 0; i < initFunctions.length; i++)
    {
        initFunctions[i]();
    }
}

window.onload = fireInitFunctions;

/**
 * Fonctions utilitaires pour les images
 */
var swappedImg = new Array;

function imgPreload()
{
    var d = document;
    if(d.images){
        var i, j = 0, p = new Array, a = imgPreload.arguments;
        for(i = 0; i < a.length; i++)
        {
            p[j] = new Image;
            p[j++].src = a[i];
        }
    }
}

function imgSwap()
{
    var i, j = swappedImg.length, x, a = imgSwap.arguments;
    for(i = 0; i < a.length - 1; i += 2)
    {
        x = document.getElementById(a[i]);
        if(x != null){
            swappedImg[j++] = x;
            if(!x.o) x.o = x.src;
            x.src = a[i + 1];
        }
    }
}

function imgRestore()
{
    var i, x, a = swappedImg;
    for(i = 0; i < a.length; i++)
    {
        x = a[i];
        if(x.o) x.src = x.o;
    }
}

/**
 * Préchargement des images du menu
 */
function preLoadMenu()
{
    imgPreload('img/menu/fr/decolletage_on.png',
               'img/menu/fr/membres_on.png',
               'img/menu/fr/profil_on.png',
               'img/menu_background.png');
}

registerInitFunction(preLoadMenu);