/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
var sponsorItemWidth=221;
var sponsorCurLeft;
var sponsorIniLeft;
var sponsorSpeed;

$(document).ready(function(){
    i=$('body').attr('id');
    $('body#'+i+' #opc_'+i+'>a').addClass('cur');

    $('.infoMenu a').corner('round top 5px');

    var sponsorSize=$('#divPatrocinadores li').size() * sponsorItemWidth;

    if($('#divPatrocinadores ul').size()!=0) {
        $('#divPatrocinadores ul').css({'width':sponsorSize+'px'})
        sponsorIniLeft = $('#divPatrocinadores ul').css('left');
        sponsorIniLeft = sponsorIniLeft.substr(0, sponsorIniLeft.length-2);
        sponsorCurLeft = sponsorIniLeft;
        sponsorInterval = setInterval(function(){
            sponsorCurLeft -= sponsorItemWidth;
            sponsorSpeed = 1500;
            if (Math.abs(sponsorCurLeft)+sponsorItemWidth>$('#divPatrocinadores ul').width()) {
                sponsorCurLeft=sponsorIniLeft;
                sponsorSpeed=750;
            }
            $('#divPatrocinadores ul').animate({'left':sponsorCurLeft},sponsorSpeed,'swing');
        }, 3000);
    }
    if ($('body').attr('id')=='competicoes' && $('body').hasClass('calendario')==true) {
        $('a[rel='+activeTab+']').addClass('cur');
        $('.tab').show();
    } else {
        initTabs();
    }
    initTables();
});

function initTabs() {
    $('.tab:first').show();
    $('.infoMenu a:first').addClass('cur');
    
    $('.infoMenu a').click(function() {
        var target=$(this).attr('href').substr(1);

        $('div.tab').hide();
        $('div#'+target).show();

        $('.infoMenu a').removeClass('cur');
        $(this).addClass('cur');

        $(this).blur();
        return false;
    });
}

function initTables() {
    $('table.classificacoes th').wrapInner('<div>')
    $('table.classificacoes th div').slice(1).append('<div style="position:absolute;bottom:-5px;left:-10px;background-color:#333;width:1px;height:10px"></div>');
}
