/* ariane software - menu axialfinance.com - configuration du javascript */

function initMenuListeners() {
    var menu = document.getElementById("menu");
    var children = menu.childNodes;
    for (var i = 0; i < children.length; i++) {
        var node = children[i];
        if (node.nodeName == "LI") {
            node.onmouseover = showMenu;
            node.onmouseout  = hideMenu;
            node.onfocus = showMenu;
            node.onblur = hideMenu;
        }
    }
}

function showMenu() {
    var menuElement = this;

    var sousMenu = getSousMenu(menuElement);
    if (sousMenu != null) {
        sousMenu.style.zIndex = 100;
        sousMenu.style.top = menuElement.offsetHeight + "px";
        sousMenu.style.display = "block";
    }
}

function hideMenu() {
    var menuElement = this;
    var sousMenu = getSousMenu(menuElement);
    if (sousMenu != null) {
        sousMenu.style.display = "none";
    }
}

function getSousMenu(element) {
    var children = element.childNodes;
    for (var i = 0; i < children.length; i++) {
        var node = children[i];
        if (node.nodeName == "UL") {
            return node;
        }
    }

    return null;
}


function ouvreImage(nomImage, dimX, dimY)
{
    var maxWidth = screen.availWidth;
    var maxHeight = screen.availHeight;

    var x = (maxWidth - dimX) / 2;
    var y = (maxHeight - dimY) / 2;
    var options = "toolbar=no,location=no,status=no,menubar=no,"
            + "scrollbars=no,resizable=no,width=" + dimX + ",height=" + dimY + ",left=" + x + ",top=" + y;
    window.open("photos/" + nomImage + ".png", "_blank", options);
}

function openWindow(url, width, height) {
    var maxWidth = screen.availWidth;
    var maxHeight = screen.availHeight;
    var x = (maxWidth - width) / 2;
    var y = (maxHeight - height) / 2;
    var options = "toolbar=no,location=no,status=no,menubar=no,"
            + "scrollbars=no,resizable=no,width=" + width + ",height=" + height + ",left=" + x + ",top=" + y;
    window.open(url, "_blank", options);
}

/**
 * Change le cookie déterminant la locale et recharge la page.
 */
function changeLocale(locale) {
    // expiration dans 1 an
    var expires = new Date();
    expires.setTime(expires.getTime() + 365 * 24 * 3600 * 1000);

    document.cookie = 'lang=' + escape(locale) + '; expires=' + expires.toGMTString() + '; path=/'

    document.location.reload();
}
