jQuery(document).ready(function(){
    /* Enquete */
    $('#EnqueteAddQuestao').click(function(){
        $('#novas_questoes').append('<span class="box-fino01">Questão Nova: <input type="text" name="data[Enquete_questao][][titulo]"> <a href="javascript:{}" class="EnqueteDelQuestao" onclick="EnqueteDelQuestao(this)"> Remover </a><br /></span>');
    });

    /* Galeria de Fotos */
    $('#FotosAddCampo').click(function(){
        $('#fotos_campo').append('<span><input type="file" name="data[arquivos][]"> Legenda: <input type="text" name="data[titulo][]"> <a href="javascript:{}" class="EnqueteDelQuestao" onclick="FotosDelCampo(this)"> Remover </a><br /></span>');
    });

    /* Validador */
    $(".validacao").validate();
    $(".validacao input,.validacao textarea").blur(function() {
        //$(this).valid();
        });

    $('#menu a ').animate({
        marginLeft:'10px'
    },1);
    $('#menu a').hover(
        function(){
            $(this).stop().animate({
                marginLeft:'0px'
            },50)
        },
        function(){
            $(this).stop().animate({
                marginLeft:'10px'
            },500)
        }
        );

    $('.img-preview').hover(
        function(){
            var imgWidth    = $(this).children('img').width();
            $(this).stop().animate({width: '740px'},200,false,function(){
                $(this).animate({width: imgWidth+'px'});
            });

        },
        function(){
            var imgWidth = $(this).children('img').width();
            $(this).stop().animate({width: '760px'});
        }
    );

});


function EnqueteDelQuestao(elemento){
    $(elemento).parents('span').remove();
}
function FotosDelCampo(elemento){
    $(elemento).parents('span').remove();
}

$(function(){
    $('#dialog_link, ul#icons li').hover(
        function() {
            $(this).addClass('ui-state-hover');
        },
        function() {
            $(this).removeClass('ui-state-hover');
        }
        );
    // Dialog
    $('#dialog').dialog({
        autoOpen: false,
        width: 600,
        buttons: {
            "Fechar": function() {
                $(this).dialog("close");
            }
        }
    });

    // Dialog Link
    $('.dialog_link').click(function(){
        $('#dialog').children('p').html($(this).attr('open'));

        $('#dialog').dialog('open');
        return false;
    });

});
