$(document).ready(function(){
    corBgCompromisso();
    tootipCompromisso();
    manipulador();
    config = configGloabl;
});
function corBgCompromisso(){
    //cor dos dias com compromisso
    $("div#calendario #cal a.eventDay").parent().css({
        backgroundColor: "#b0c8ec",
        border: "1px solid #9fbce8"
    });
}

/*
 *Plugin TooTip
 **/
function tootipCompromisso(){
    //mostra um tootip para os compromissos
    /* $('#calendario table a').tooltip({
     track: true,
     delay: 0,
     showURL: false,
     extraClass: "right",
     positionRight: true
     });*/
    // initialize tooltip
	
    $("#calendario table a[title]").tooltip({
    
        // tweak the position
        offset: [10, 2],
        
        // use the "slide" effect
        effect: 'slide'
    
        // add dynamic plugin with optional configuration for bottom edge
    }).dynamic({
        bottom: {
            direction: 'down',
            bounce: true
        }
    });
}

//var dadosS;
function loadAgenda(dadosS){
    $.ajax({
        type: "POST",
        url: config + "index/agenda/rand=" + Math.floor(Math.random() * 100),
        data: dadosS,
        success: function(ret){
            $('div#calendario div table').remove();
            $('div#calendario div').html(ret);
            //recarregar
            manipulador();
            tootipCompromisso();
            corBgCompromisso();
        }
    }); //fim ajax
}

function manipulador(){
    $('a.mudarMes').click(function(e){
        e.preventDefault();//tira o infame do som (qando clicado no IE)
        $('div#calendario div table').fadeTo('fast', 0.6);
        $('div#calendario div table').loading(true, {
            img: config + 'public/site/imgs/loading.gif',
            align: 'center'
        });
        dadosS = $(this).attr('rel');
        // alert(dadosS);
        loadAgenda(dadosS);
    });
}
