/**
 * file: add_enquiry.js
 */

$(function() {
   
 
    $("#customer_autocomplete").autocomplete({
        source: "/customers/completeCustomer",
        minLength: 2,
        select: function( event, ui ) {
            $("#customer_id").val(ui.item.id);
          
          
            $.ajax({
                url: '/customers/customerContacts/'+ui.item.id,
                cache: false,
                success: function(data) {
                    $(".customer_id").attr('id', ui.item.id); 
                    $("#contacts").html(data);
                }
               
            });
          
        /*$.get('/addresses/customerAddresses/'+ui.item.id, function(data) {
                $("#address").html(data);
                $(".selectAddress", data).button();
            });*/
            
            

        }
    });


    $("#addContact").live('click', function(event) {
        event.preventDefault();
        $("#contacts").html("<h1>ADD CONTACT</h1>");
        return false;
    });

   
   
});