$(function() {
    var set = $('div#top-nav div img').not('.sp-active-nav').not('.sp-social-icon');
    set.css({opacity: 0, display: 'block'});
    set.hover(
        function() {
            $(this).fadeTo(300, 1);
        },
        function() {
            $(this).fadeTo(300, 0);
        }
    );

    if (is_admin) {
        if (hostreq_pending > 0) {
            $.gritter.add({
                // (string | mandatory) the heading of the notification
                title: '<strong>'+hostreq_pending+'</strong> Hostrequest'+(hostreq_pending > 1 ? 's' : '')+' pending!',
                // (string | mandatory) the text inside the notification
                text: 'Click <a href="'+hostreq_link+'">HERE</a> to approve or reject the request'+(hostreq_pending > 1 ? 's' : '')+'.',
                sticky: true
            });
        }
    }

    if ($('#reconfig_time').length > 0) {
        function show_reconfig() {
            var rem = 3600-(parseInt(new Date().getTime()/1000)%3600);
            var mins = Math.floor(rem/60);
            mins = (mins < 10) ? '0'+mins : mins;
            var secs = rem%60;
            secs = (secs < 10) ? '0'+secs : secs;

            $('#reconfig_time').html(mins+':'+secs);

            window.setTimeout(show_reconfig, 1000);
        }

        show_reconfig();
    }
    
});
