addLoadEvent(AdditionalOnLoad);

function addLoadEvent(func) {   
   var oldonload = window.onload;   
   if (typeof window.onload != 'function') {   
     window.onload = func;   
   } else {   
     window.onload = function() {   
       if (oldonload) {   
         oldonload();   
       }   
       func();   
     }   
   }   
}

function AdditionalOnLoad() {
    var listLeft = document.getElementById('mainNavigationLeft').getElementsByTagName('li');
    var li = null;
    for (var i = 0; i < listLeft.length; i++) {
        li = listLeft[i];
        if (li.getElementsByTagName('ul').item(0) == null) continue;
        li.onmouseover = function() {
            this.getElementsByTagName('ul').item(0).style.display = 'block';
            this.getElementsByTagName('ul').item(0).style.zIndex = '6000';
        }
        li.onmouseout = function() { this.getElementsByTagName('ul').item(0).style.display = 'none'; }
    }

    var listMiddle = document.getElementById('mainNavigationMiddle').getElementsByTagName('li');
    for (var i = 0; i < listMiddle.length; i++) {
        li = listMiddle[i];
        if (li.getElementsByTagName('ul').item(0) == null) continue;
        li.onmouseover = function() {
            this.getElementsByTagName('ul').item(0).style.display = 'block';
            this.getElementsByTagName('ul').item(0).style.zIndex = '6000';
        }
        li.onmouseout = function() { this.getElementsByTagName('ul').item(0).style.display = 'none'; }

        if (li.className == '2ndmenu') {
            li.onmouseover = function() { this.getElementsByTagName('ul').item(0).style.visibility = 'visible'; }
            li.onmouseout = function() { this.getElementsByTagName('ul').item(0).style.visibility = 'hidden'; }
        }
    }
}

$(document).ready(function() {
    if ($.cookie('LOGONSESSIONID') != null) {
        $('#header_top_username', this).css('display', 'block');
        $('#header_top_logout', this).css('display', 'block');
        $('#header_top_login', this).css('display', 'block');
    }
    else {
        //$('#header_top_username', this).css('display', 'none');
        //$('#header_top_login', this).css('display', 'none');
        //$('#header_top_logout', this).css('display', 'block');			
        $('#header_top_username', this).css('display', 'block');
        $('#header_top_login', this).css('display', 'block');
        $('#header_top_logout', this).css('display', 'block');
    }

    if ($.cookie('vlln') != null) {
        $("#hdr_username").text($.cookie('vlln'));
    }

    /* // doesn't work with Chrome, use javascript instead (see above) 11-15-2010
    $('#mainNavigationLeft li').hover(
			function() {
			    $('ul', this).css('display', 'block');
			    $('ul', this).css('z-index', '6000');
			},
			function() { $('ul', this).css('display', 'none'); });

    $('#mainNavigationMiddle li').hover(
			function() {
			    $('ul', this).css('display', 'block');
			    $('ul', this).css('z-index', '6000');
			},
			function() {
			    $('ul', this).css('display', 'none');
			}
    );

    $('#mainNavigationMiddle li.2ndmenu').hover(
			function() { $('ul', this).css('visibility', 'visible'); },
			function() { $('ul', this).css('visibility', 'hidden'); });
			
	*/

    /*
    $('#header_top_login').toggle(
    function() { $('ul', this).css('display', 'block'); },
    function() { $('ul', this).css('display', 'none'); }),
    function() { $('#headerdropdown', this).css('display', 'block') };
    */
});
