$( function(){

    // inicializando o placeholder
    initPlaceholder();

    // inicializando maskaras para inputs
    initMasks();

    //Validacao de formularios
    $('form.validacao').validationEngine();

    //Inicializando prettyPhoto
    if($.prettyPhoto){
        $("a[rel^='prettyPhoto']").prettyPhoto({
            deeplinking:false
        });
    }

    //iniciando prettyLoader
    $.prettyLoader({
            animation_speed: 'fast', /* fast/normal/slow/integer */
            bind_to_ajax: true, /* true/false */
            delay: false, /* false OR time in milliseconds (ms) */
            loader: window.root_path + '/images/prettyLoader/ajax-loader.gif', /* Path to your loader gif */
            offset_top: 13, /* integer */
            offset_left: 10 /* integer */
    });


    //AUTO COMPLETE---------------------------------------------------------
    $("#form-busca input.busca-produto").blur(function(){
        $(this).find('.suggestions').fadeOut();
    });

    $("#form-busca input.busca-produto").keyup(function(){
        getSugestions($(this));
    });

    function getSugestions($input) {
        var $divSug = $('#busca-sugestiva');
        if($input.val().length == 0) {
            $divSug.fadeOut(); // Hide the suggestions box
        } else {
            $.post(window.root_path + "/ajax/autocomplete/", {
                queryString: "" + $input.val() + ""
                }, function(data) { // Do an AJAX call
                $divSug.fadeIn(); // Show the suggestions box
                $divSug.html(data); // Fill the suggestions box
            });
        }
    }




});
