var t;
 
$(document).ready(function() {  
    $("ul.topnav li span").hover(function() { //When trigger is clicked...
        //Following events are applied to the subnav itself (moving subnav up and down)
        $(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

        $(this).parent().hover(function() {
        }, function(){
            $(this).parent().find("ul.subnav").fadeOut('slow'); //When the mouse hovers out of the subnav, move it back up
        });
    //Following events are applied to the trigger (Hover events for the trigger)
    }).hover(function() {
        $(this).addClass("subhover"); //On hover over, add class "subhover"
    }, function(){    //On Hover Out
        $(this).removeClass("subhover"); //On hover out, remove class "subhover"
    });
    if($('#banner').length > 0) {
        t = setInterval('timer()', 15000);
    }
    $('a.external').click(function() {
        window.open($(this).attr('href'));
        return false;    
    });
    $('.more a').click(function() {
        $(this).parent().parent().parent().find('td').css('display', '');
        $(this).parent().remove('.more');    
    });
    $.tablesorter.addParser({
        id: "jDate",
        is: function(s) {
            return false;
        },
        format: function(s) {
            var dt = s.split('/');
            var s2 = dt[2]+'-'+dt[1]+'-'+dt[0];
            return $.tablesorter.formatFloat((s2 != "") ? new Date(s2.replace(new RegExp(/-/g),"/")).getTime() : "0");
        },
        type: "numeric" 
    });
    $.tablesorter.addParser({
        id: "jService",
        is: function(s) {
            return false;
        },
        format: function(s) {
            var dt = s.split('<br>');
            return dt[0];
        },
        type: "text" 
    });
    $("table.doms.pro").tablesorter({headers: { 0: {sorter: 'jService'}, 3: {sorter: 'jDate'} } }); 
    $("table.doms.fst").tablesorter({headers: { 0: {sorter: 'jDate'}, 2: {sorter: 'jDate'} } });
    $("table.doms.inv").tablesorter({headers: { 1: {sorter: 'jDate'}, 2: {sorter: 'jDate'}, 5: {sorter: false} } });
    $("table.doms.ema").tablesorter({headers: { 0: {sorter: 'jDate'} } });
    $("table.doms.sup").tablesorter({headers: { 0: {sorter: 'jDate'} } }); 
    $("table.doms.adon").tablesorter({headers: { 2: {sorter: 'jDate'} } });  
});

function timer() {
    if($('#banner #domains').css('display') != 'none') {
        $('#banner #domains').css('display', 'none');
        $('#banner #webhosting').css({
            'background' : 'url(\'images/web_hosting.jpg\') no-repeat',
            'display' : ''
        });     
    } else if($('#banner #webhosting').css('display') != 'none') {
        $('#banner #webhosting').css('display', 'none');
        $('#banner #sslcertificates').css({
            'background' : 'url(\'images/ssl.jpg\') no-repeat',
            'display' : ''
        });       
    } else if($('#banner #sslcertificates').css('display') != 'none') {
        $('#banner #sslcertificates').css('display', 'none');
        $('#banner #websitedesign').css({
            'background' : 'url(\'images/web_design.jpg\') no-repeat',
            'display' : ''
        });       
    } else if($('#banner #websitedesign').css('display') != 'none') {
        $('#banner #websitedesign').css('display', 'none');
        $('#banner #domains').css({
            'background' : 'url(\'images/domain_names.jpg\') no-repeat',
            'display' : ''
        });       
    }
}
