
function CRTL_MyFirstChild(oObject, sTag) {
    oFirstChild = oObject.firstChild;
    while (oFirstChild && oFirstChild.nodeName != sTag) {
        oFirstChild = oFirstChild.nextSibling;
    }

    return oFirstChild;
}

function CRTL_MyLastChild(oObject, sTag) {

    oLastChild = oObject.lastChild;
    while (oLastChild && oLastChild.nodeName != sTag) {
        oLastChild = oLastChild.previousSibling;
    }

    return oLastChild;
}

function CRTL_DoOnMouseOver(oObject) {
    if (CRTL_oTimer != null) window.clearTimeout(CRTL_oTimer);
    CRTL_oTimer = null;

    oSubMenu = CRTL_MyLastChild(oObject, 'UL');

    oParent = oObject.parentNode;

    if (oParent) {
        oNode = CRTL_MyFirstChild(oParent, 'LI');
        while (oNode) {
            if (oNode != oObject) {
                oNode.className = null;
            }
            oNode = oNode.nextSibling;
        }
    }
}

var CRTL_oTimer = null;
var CRTL_oDefaultLi = null;

function CRTL_BackToDefault() {
    CRTL_oTimer = null;
    CRTL_oDefaultLi.className = CRTL_oDefaultLi.getAttribute('DefaultClass');
}

function CRTL_DoOnMouseOut(oObject) {
    oParent = window.event ? window.event.toElement : null;
    while (oParent != null) {
        if (oParent == oObject) return false;
        oParent = oParent.parentNode;
    }

    oSubMenu = CRTL_MyLastChild(oObject, 'UL');

    oParent = oObject.parentNode;

    if (oParent) {
        oNode = CRTL_MyFirstChild(oParent, 'LI');
        while (oNode) {
            //	if (oNode != oObject)
            {
                if (oNode.getAttribute('DefaultClass')) {
                    CRTL_oDefaultLi = oNode;

                    if (CRTL_oTimer != null) window.clearTimeout(CRTL_oTimer);
                    CRTL_oTimer = window.setTimeout(CRTL_BackToDefault, 10);
                }
            }
            oNode = oNode.nextSibling;
        }
    }
}

function CRTL_InitTopMenuLoisirs() {
    document.write('<link rel="stylesheet" type="text/css" href="http://common.rtl.be/css/loisirs/topmenu.css" media="all" />');
    document.write('<div id="CRTL_TopMenuLoisirsContainer"></div><div id="CRTL_Meteo_AB23"></div>');

    CRTL_HttpRequestTopMenuLoisirs('http://www.rtl.be/meteo/jsw10/prototype.php', 'CRTL_Meteo_AB23');

    script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'http://common.rtl.be/page/54.aspx?tab=' + CRTL_TopmenuTabSelected + '&bNoLog=1&js=document.getElementById(\'CRTL_TopMenuLoisirsContainer\').innerHTML=\'{0}\';';
    document.getElementsByTagName('head')[0].appendChild(script);
}

function CRTL_HttpRequestTopMenuLoisirs(sURL, sTarget) {
    script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = sURL + '?bNoLog=1&js=document.getElementById(\'' + sTarget + '\').innerHTML=\'{0}\';';
    document.getElementsByTagName('head')[0].appendChild(script);
}

CRTL_InitTopMenuLoisirs();
