function jumpTo(path, confirmMessage) {
    var answer = confirm(confirmMessage);
    if (answer == 1) {
        location.href = path;
    }
}

$(document).ready(function() {
    $('.title').each(function() {
        var $this = $(this);
        if($this.val() === '') {
            $this.val($this.attr('title'));
        }

        $this.focus(function() {
            if($this.val() === $this.attr('title')) {
                $this.val('');
            }
        });

        $this.blur(function() {
            if($this.val() === '') {
                $this.val($this.attr('title'));
            }
        });
    });
});


$(function() {
    searchTrim = [];

    $("#termo").each(function(i){
        searchTrim[i] = $(this).val();
        $(this).focus(function(){
            if ($(this).val() == searchTrim[i]) {
                $(this).val("");
            }
        }).blur(function(){
            if ($.trim($(this).val()) == "") {
                $(this).val(searchTrim[i]);
            }
        });
    });
});

function Selecionar(campo){
    var objTextArea = document.getElementById(campo);
    objTextArea.select();
}

$(document).ready(function(){
    $(function(){
        // bind change event to select
        $('.dynamic_select').bind('change', function () {
            var url = $(this).val(); // get selected value
            if (url) { // require a URL
                window.location = url; // redirect
            }
            return false;
        });
    });
});

$(document).ready(function() {
    $(".msg").hide();
    $(".msg").fadeIn(2000);

    $(".msg").click(function(){
        $(".msg").slideUp();
    });
});

$(document).ready(function () {
    $('.headlink').click(function () {
	$('ul.the_menu').slideToggle('medium');
    });
});

// MOVEMENT
$(document).ready(function() {
    $('.the_menu li a').hover(function() { //mouse in
        $(this).animate({ paddingLeft: '20px' }, 200);
    }, function() { //mouse out
        $(this).animate({ paddingLeft: '10px' }, 200);
    });
});

// OPACITY IMAGE, LOGO
$(function() {
    $(".logo").css("opacity","1.0");
    $(".logo").hover(function () {
        $(this).stop().animate({
            opacity: 0.5
        }, "slow");
    },

    function () {
        $(this).stop().animate({
            opacity: 1.0
        }, "slow");
    });
});

$(document).ready(function(){
    $(document).keydown(function (e) {
        // Página anterior.
        if (e.keyCode == 37) {
            window.location = $(".pagAnt").attr("href");
        }
        // Proxima página.
        if (e.keyCode == 39) {
            window.location = $(".pagProx").attr("href");
        }
    });
});

$(document).ready(function(){
    $(".like").click(function(){
        var id=$(this).attr("id");
        var name=$(this).attr("name");
        var dataString = 'id='+ id + '&name='+ name;
        $("#votebox").slideDown("slow");
        $("#flash").fadeIn("slow");
        $.ajax({
            type: "POST",
            url: base_url + "voto/",
            data: dataString,
            cache: false,
            success: function(html){
                $("#flash").fadeOut("slow");
                $("#content").html(html);
            }
        });
    });

    // Close button action
    $(".close").click(function(){
        $("#votebox").slideUp("slow");
    });
});
