
$(document).ready(function() {
	$("#quickQuoteButton").click(function() {

		//hide form while we process and show loading graphic
		$('#quickQuoteForm').hide(0);
		$('#uspsWait').show(500);
		$('#quickQuoteReturn').text('').hide(0);

		//send the request to get our quote
		$.ajax({
			type: 'POST',
			url: baseDir + 'modules/uspsquickquote/uspsgetquote.php',
			//async: true,
			dataType: "json",
			data: {
				weight : $('#uspsweight').val(),
				zip : $('#uspszip').val(),
				method : $("input[@name='uspsmethod']:checked").val(),
				idProduct : $("#uspsidProduct").val()
			},

			success : function(quote) {
				$('#uspsWait').hide(500);
				$("#quickQuoteReturn").removeClass();
					if (quote.error === true) {
						$('#quickQuoteReturn').addClass('QQerror').text('Error:  ' + quote.msg).fadeIn(500);
					}else{
						$('#quickQuoteReturn').addClass('QQsuccess').text('Price:  $' + quote.rate).fadeIn(500);
					}
				$('#quickQuoteForm').slideDown(500);
			},

			error : function(XMLHttpRequest,textStatus,errorThrown) {
				alert("USPS Quick Quote error:\n\n Error Thrown:  " + XMLHttpRequest + "\n Text Status:  " + textStatus);
			}
		});
	return false;
	});

});
