
var quote_selector = function() {
    var warningDiv = $('<div>');
    var dialog;
    var showWarning = function(message) {
        if(!dialog) {
            warningDiv.text(message);
            dialog = warningDiv.dialog({
                title: 'Error',
                autoOpen: false,
                resizeable: false,
                buttons: {
                    Ok: function() {
                        $( this ).dialog( "close" );
                    }
                },
                close: function() {
                    dialog.dialog('destroy');
                    dialog=null;
                }
            });
        }
        
        dialog.dialog('open');
    };

    var submitQuoteForm = function() {
        var zipCode = $("#zip").val();
        var insuranceType = $("#insuranceType").val();

        if (insuranceType == 'Type Of Insurance') {
                showWarning('Please Select Insurance Type');
                return;
        }
        
        if (jQuery.trim(zipCode).length != 5) {
                showWarning('Please Enter Zip Code');   
                return;
        }
        
        document.location = insuranceType + '&agtfnd=' + zipCode;
    };

    $('#quote_selector_next_button').click(function(e) {
        e.preventDefault();
        submitQuoteForm();
        return false;
    });
}
