﻿function Menu(){
    var childnodes;
    try{
        childnodes = $('mainnav').getElementsByTagName('li');
    }
    catch (e){
        //alert(childnodes);
        //alert(e);
    }
    for(var i=0; i<childnodes.length; i++){
        var ulList = childnodes[i].getElementsByTagName('ul');
        if (ulList.length > 0){
            var ul = ulList[0];
            ul.onmouseover = function(){HighLight(this)};
            ul.onmouseout = function(){RemoveHighLight(this)};
        }
    }
}

function HighLight(ul){
    try{
        var a = $(ul).previous();
        var image = $(a).getStyle('backgroundImage');

        if(image != 'url(Images/P_RightActiveLink_BG.gif)'){
            a.style.backgroundImage = "url('Images/P_RightActiveLink2_BG.gif')";
            a.style.color = "#312e2c";
            a.style.backgroundRepeat = "no-repeat";
            a.style.backgroundPosition = "right center";
        }
    }
    catch (e) {
        //alert(e);
    }
}

function RemoveHighLight(ul){
    try{
        var a = $(ul).previous();
        var image = $(a).getStyle('backgroundImage');
        
        if(image == 'url(Images/P_RightActiveLink_BG.gif)'){
            a.style.backgroundImage = "url('Images/P_RightActiveLink_BG.gif')";
            a.style.color = "#312e2c";
        }else{
            a.style.backgroundImage = "";
            a.style.color = "";
        }
    }
    catch (e) {
        //alert(e);
    }
}