/*!
 * Copyright (c) 2007-2010 Bractus, Inc.
 * 10538 Eastborne Ave #102, Los Angeles, California, 90024, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of Bractus ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Bractus.
 */
$j(document).ready(function(){
    $j('#pickupTime').timeEntry({spinnerImage: 'images/spinnerDefault.png',defaultTime: '+30m',show24Hours: true});
    $j('#pickupDate').datepicker({
      minDate: 0
    });
    $j('#deliveryTime').timeEntry({spinnerImage: 'images/spinnerDefault.png',defaultTime: '+90m',show24Hours: true});
    $j('#deliveryDate').datepicker({
      minDate: 0
    });
    $j('#package_info').click(function(){
        $j('#package_area').toggle("slow");
        $j('#package_area input').each(function(){$j(this).val('')});
        return null;
    });
    var oQuoteButton = new YAHOO.widget.Button("get_quote_btn");
        oQuoteButton.on("click", quote);
        var oResetButton = new YAHOO.widget.Button("reset_btn");
        oResetButton.on("click", function(){ $j('#quote_result').hide('slow');  });


});
 var quote = function(e){
       $j('#wait_image_ajax').show();
          $j('#pickup_time').val(jQuery.trim( $j('#pickupTime').val()+  ' ' + $j('#pickupDate').val()));
          $j('#delivery_time').val(jQuery.trim( $j('#deliveryTime').val()+  ' ' + $j('#deliveryDate').val()));

           $j.post("quote.html?action=quote", $j("#quote_form").serialize(), viewQuote, "json");
        }

var viewQuote =  function(data){
      $j('#wait_image_ajax').hide();
      if (data.message){
        $j('#quote_message').html(data.message).css({'color':'red'}).show();
        $j('#basePrice').html('');
      }else{
        $j('#quote_result').show('slow');
        $j('#quote_message').html('');
            $j('#basePrice').html(data.totalPrice).effect("highlight", {}, 3000);
          }
};
