$(document).ready(function(){
    $('#nav_termite_show').hover(function(){
        $('#nav_termite').show();
        $('#nav_termite_show').css({
            'background-color': '#87B701',
            'color': '#000'
        });
        $('#nav_fume_show').attr('css', '');
    });
    $('#nav_fume_show').hover(function(){
        $('#nav_fume').show();
        $('#nav_fume_show').css({
            'background-color': '#FFF',
            'color': '#000'
        });
        $('#nav_fume_show span').css('color', '#000');
    });
    $('#nav').mouseleave(function(){
        $('#nav_termite, #nav_fume').hide();
        $('#nav_termite_show').attr('style', ' ');
        $('#nav_fume_show').attr('style', ' ');
        $('#nav_fume_show span').attr('style', ' ');
    })
    $('#nav_fume').mouseleave(function(){
        $('#nav_fume').hide();
        $('#nav_fume_show').attr('style', ' ');
        $('#nav_fume_show span').attr('style', ' ');
    });
    $('#nav > a').hover(function(){
        if($(this).attr('id') != 'nav_termite_show'){
            $('#nav_termite').hide();
            $('#nav_fume').hide();
            $('#nav_termite_show').attr('style', ' ');
            $('#nav_fume_show span').attr('style', ' ');
        }
    });
    $('#nav_termite a').hover(function(){
        if($(this).attr('id') != 'nav_fume_show'){
            $('#nav_fume').hide();
            $('#nav_fume_show').attr('style', ' ');
            $('#nav_fume_show span').attr('style', ' ');
        }
    });

    //safari fix
    if ( $.browser.webkit && !$.browser.opera && !$.browser.msie && !$.browser.mozilla ) {
        var userAgent = navigator.userAgent.toLowerCase();
        if ( userAgent.indexOf("chrome") === -1 ) {

            $('#nav_termite').css({
                'top': '32px',
                'left':'0'
            });
            $('#nav_fume').css({
                'left': '277px',
                'top': '-68px'
            });
        }
    }
    
    if($('.trustedby img').length > 0){
        setInterval('trustedBy();', 6000);
        setInterval('resetTB();', 90000);
    }

});
function trustedBy(){
    $('.trustedby img').animate({
        'margin-top': '-=100px'
    },1500);
    return 1;
}
function resetTB(){
    $('.trustedby img').css({'margin-top': '0'});
}
