var isIE = false;

$(document).ready(function(){
    // limpa campo de pesquisa
    $("#cx_input").focus(function() {
        if($(this).val() == "Digite o que procura")
            $(this).val("");
    });

    $("#cx_input").blur(function() {
        if($(this).val() == "")
            $(this).val("Digite o que procura");
    });

    $("li#loading-li").remove();

    $("#lista-de-videos li").each(function(i){
          if(i < 8)
              $(this).fadeIn('slow');
    });

    $("#more-videos").live('click',function(){
       var len = $("#lista-de-videos li:hidden").length;

       $("#lista-de-videos li:hidden").each(function(j){
          if(j < 8)
              $(this).fadeIn('slow');

          if($("#lista-de-videos li:hidden").length == 0)
              $("#more-videos").hide();
       });
    });

    $(".day-link").click(function(){
        var weekday = $(this).attr('rel');

        $("#box-table-programming").html('<img src="/css/images/facebook-loading.gif" valign="absmiddle" /> Carregando...');

        $.get('/programacao/get_daily_programming/'+weekday+'', function(data){

            $("#box-table-programming").html(data);
        });

        switch(weekday){
            case '0': $(".title-page h1").html("Programação de Domingo"); break;
            case '1': $(".title-page h1").html("Programação de Segunda-feira"); break;
            case '2': $(".title-page h1").html("Programação de Terça-feira"); break;
            case '3': $(".title-page h1").html("Programação de Quarta-feira"); break;
            case '4': $(".title-page h1").html("Programação de Quinta-feira"); break;
            case '5': $(".title-page h1").html("Programação de Sexta-feira"); break;
            case '6': $(".title-page h1").html("Programação de Sábado"); break;
        }
    });

    $("a[rel^='prettyPhoto']").prettyPhoto({
        show_title: false,
        allow_resize: true,
        default_width: 800,
        default_height: 400,
        flash_markup: '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{width}" height="{height}"><param name="wmode" value="{wmode}" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{path}&fs=1" /><embed src="{path}&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="{width}" height="{height}" wmode="{wmode}"></embed></object>',
        changepicturecallback: function(){
            $.each($.browser, function(i, val) {
                if(i == 'msie'){
                    $('body').css('overflow', 'hidden');
                    isIE = true;
                }

            });
        },
        callback: function(){
            if(isIE)
                $('body').css('overflow', '');
        }
    });
});



