$(function(){

        // Datepicker
        $.datepicker.setDefaults({
                minDate: +5,
                maxDate: +180,
                defaultDate: +5,
                dateFormat: 'mm-dd-yy'
        });
        $('#pickup_date').livequery('click', function() {
            $(this).datepicker({
                showOn: 'focus'
            }).focus();

        });

        $('#dropoff_date').livequery('click', function() {
            $(this).datepicker({
                showOn: 'focus'
            }).focus();

        });
                                                //hover states on the static widgets
        $('#dialog_link, ul#icons li').hover(
                function() { $(this).addClass('ui-state-hover'); },
                function() { $(this).removeClass('ui-state-hover'); }
        );

});

$(document).ready(function() {
    $('#cart_dropdown')
        .livequery('change', function() {

            var form_data = {
                    type_of_cart: $('#cart_dropdown').val(),
                    ajax: '1'
            };

            $.ajax({
                    url: "http://www.golf-cars.net/home/ajax_replace_picture",
                    dataType: 'html',
                    type: 'POST',
                    data: form_data,
                    success: function(msg) {
                            $('#type_picture').html(msg);
                    }
            });

            return false;
    });

       $("#reservation_start").validate({
       errorElement: "td",
       rules: {
           zipcode: {
           required: true,
           minlength: 5,
           maxlength: 5,
           remote: {
               url: "http://www.golf-cars.net/home/ajax_validate_zip",
               type: "post",
               data: {
                   zipcode: $("#zipcode").val()
               }
           }
           },
           pickup_date: "required",
           dropoff_date: "required"
       },
       messages: {
           zipcode: {
               required: "Our prices are based upon the delivery zipcode",
               maxlength: "Please enter a valid zipcode.",
               minlength: "Please enter a valid zipcode.",
               remote: "We are not setup for a quote to that zipcode, please call 555-555-5555 to see if we can accommodate your location."
           },
           pickup_date: "Please pick a delivery date",
           dropoff_date: "Please pick a pickup date."
       }
   });
});

