jQuery(function() {    
    //==================== Search With all plugins =================================================
    // Unbind form submit
    $('.livesearch').bind('submit', function() {return false;} ) ;
    
    // Set autosuggest options with all plugins activated
    var options = {
        script: "/professors/search/?",
        varname: "input",
        json: true,                        // Returned response type
        shownoresults: true,                // If disable, display nothing if no results
        noresults: "No Results",            // String displayed when no results
        maxresults: 8,                    // Max num results displayed
        cache: false,                    // To enable cache
        minchars: 2,                        // Start AJAX request with at leat 2 chars
        timeout: 100000,                    // AutoHide in XX ms
        offsety: 2,
        callback: function (obj) {         // Callback after click or selection
            // For example use :
                        
            // Build HTML
            var html = "ID : " + obj.id + "<br>Main Text : " + obj.value + "<br>Info : " + obj.info;
            //$('#input_search_all_response').html(html).show() ;
            //alert(obj.id);
            // => TO submit form (general use)
            $('#search_all_value').val(obj.id); 
            //$('#professor_search').submit(); 
            window.location = obj.id;
        }
    };
    // Init autosuggest
    var as_json = new bsn.AutoSuggest('input_search_all', options);
    
    // Display a little watermak    
    $("#s").Watermark("Search");
    $("#input_search_all").Watermark("Search for a professor...");
    $("#search_book").Watermark("Find a book...");
    
    $('.calendar').Calendar();
    
});