/* 
 * file: search.js

 * Powers AJAX search of records in the CMC Sales System.
 *
 * 
 */

$(function() {

    $("#ajaxLoading").hide();


    $("#ajaxLoading").bind("ajaxSend", function() {
        $(this).show();
    }).bind("ajaxComplete", function() {
        $(this).hide();
    });



  
    $("#dialogDiv").hide();


   
    $("#dialogDiv").dialog({
        autoOpen: false,
        width: 900,
        modal: true

    });


    $("#searchLink").click(function() {

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

    $("#searchButton").button().click(function() {

        doSearch();
        return false;

    });
    


    $("#dialogDiv").bind("dialogclose", function() {
        $("#results").empty();
    })
    
});




function doSearch() {
    $.post("/enquiries/doSearch", $("#searchString").serialize(), function(data) {
        $("#results").html(data);
    });
}

