
function Start(){
    
    var obj = $('ul#Menu');
    
    var fadeInTime = 200; // in milliseconds
    var fadeOutTime = 300; // in milliseconds
    
    $(obj).find('li ul li:has(ul) > a').prepend('<span class="menu-sub-indicator"> &raquo;</span>');
    
    $(obj).find('li ul').attr('fadeState','none');
    $(obj).find('li').hover(
        function() {
            if($(this.getElementsByTagName('ul')[0]).attr('fadeState') =='fadeOut') {
                $(this.getElementsByTagName('ul')[0]).stop(true,true);
                $(this.getElementsByTagName('ul')[0]).attr('fadeState','none')
            } 
            
            if ($(this.getElementsByTagName('ul')[0]).attr('fadeState') =='none') {
                $(this.getElementsByTagName('ul')[0]).attr('fadeState','fadeIn');
                $(this.getElementsByTagName('ul')[0]).fadeIn(fadeInTime, function(){
                    $(this).attr('fadeState','none')
                });
            }
            $(this).addClass('over');
        },
        function() {
            if($(this.getElementsByTagName('ul')[0]).attr('fadeState') =='fadeIn') {
                $(this.getElementsByTagName('ul')[0]).stop(true,true);
                $(this.getElementsByTagName('ul')[0]).attr('fadeState','none');
            }
            
            if ($(this.getElementsByTagName('ul')[0]).attr('fadeState') =='none') {
                $(this.getElementsByTagName('ul')[0]).attr('fadeState','fadeOut');
                $(this.getElementsByTagName('ul')[0]).fadeOut(fadeOutTime, function(){
                    $(this).attr('fadeState','none')
                });
            }
            $(this).removeClass('over');
        }
    );
    
    $(obj).find('li.item ul').each(function() {
        $(this).find('li:last > a').css('border-bottom','0px');
    });
    
    $(obj).find('li ul:empty').css('visibility','hidden');
    
}

$(document).ready(function() {
    pixelsilk.renderSkin('[' + '[Menu1]' + ']', function(html) {
        $('#subNavigation').html(html);
        var sections = $('#subNavigation div');
        var topElements = $('#Menu li.item');
        for (z = 0; z < sections.length; z++) {
            var li = topElements[z];
            var lihtml = li.innerHTML;
            li.innerHTML = lihtml + sections[z].innerHTML;
        }
        Start();
    });
});