$(document).ready(function() {
    
    if($('.welcometext').length > 0)
        $('.welcometext').scroller();
    
    if ($('.welcome #navMain').length > 0)
        createNavHoverFX($('.welcome #navMain li'));
        
    if ($('#navMain').length > 0 && $.browser.msie && parseInt($.browser.version) < 8)
        $('#navMain li').hover(
            function() {
                $(this).addClass('hover');
            },
            function() {
                $(this).removeClass('hover');
            }
        );
        
    $('a.external').attr('target', '_blank');
    
    $('a.top').click(function(e) {
        e.preventDefault();
        $('html,body').animate({ scrollTop: 0 }, 500); 
    });
})

function createNavHoverFX($el) {
    var duration = 350;
    $el.hover(
        function(e) {
            e.preventDefault();
            var sub = $(this).find('.subLevel');
            sub.css({ width: 0, display: 'block' });
            sub.stop(true, true).animate({ width: 234, right: -232 }, duration);
        },
        function(e) {
            e.preventDefault();
            var sub = $(this).find('.subLevel');
            sub.stop(true, true).animate({ width: 0, right: -20 }, duration);
        }
    );
}
