jQuery(document).ready(function(){
	jQuery("#order_items").click(function () {
		// Grab the HTML and get it ready for emailing as an order
		var your_name=jQuery(".your_name").attr('value');
		var your_phone=jQuery(".your_phone").attr('value');
		var your_email=jQuery(".your_email").attr('value');
		var item_order_form='';
		jQuery("input.aps_orderitem").each(function(i){
			var item_sku = jQuery(this).attr('sku');
			var item_quantity = jQuery(this).attr('value');
			
			item_order_form = item_order_form + "SKU: \t " + item_sku + "\t Quantity: \t " + item_quantity + "\n";
		});
		// Get ready to send it along
		jQuery.post("/post_order.php", { name: your_name, email: your_email, subject: "APS Parts Order - " + your_name, message: item_order_form, phone: your_phone },
  		function(data){
    		alert("Your order has been sent. We will call you shortly to verify your order.");
  		});
	});
	jQuery("#price_enquiry").click(function () {
		// Grab the HTML and get it ready for emailing as a price enquiry
		var your_name=jQuery(".your_name").attr('value');
		var your_phone=jQuery(".your_phone").attr('value');
		var your_email=jQuery(".your_email").attr('value');
		var item_order_form='';
		jQuery("input.aps_orderitem").each(function(i){
			var item_sku = jQuery(this).attr('sku');
			var item_quantity = jQuery(this).attr('value');
			
			item_order_form = item_order_form + "SKU: \t " + item_sku + "\t Quantity: \t " + item_quantity + "\n";
		});
		// Get ready to send it along
		jQuery.post("/post_order.php", { name: your_name, email: your_email, subject: "APS Parts Enquiry - " + your_name, message: item_order_form, phone: your_phone },
  		function(data){
    		alert("Your parts enquiry has been sent. We will call you shortly to verify your request.");
  		});
	});
	jQuery("#child_products").tablesorter({sortList: [[0,0]]});
});
