var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12064986-1']);
_gaq.push(['_setDomainName', 'massageking.com']);
_gaq.push(['_trackPageview']);

(function() {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
  
$(document).ready(function(){ 
	
	$('.add_to_cart').click(function(){
		_gaq.push(['_trackEvent', 'Cart', 'Add to Cart', $('.infobox h1').html()]);
	});
  
  $('#checkout_button').click(function(){
		_gaq.push(['_trackEvent', 'Cart', 'Checkout', 'Pushed Checkout Button']);
	});
  
  
   if ($("body").hasClass("order_receipt")) {
		_gaq.push(['_addTrans',
				$(".order_id").html(),            // order ID - required
				"",  // affiliation or store name
				$(".order_total").html(),           // total - required
				$(".order_taxes").html(),            // tax
				$(".order_shipping").html(),           // shipping
				$(".city").html(),        // city
				$(".state").html(),      // state or province
				""              // country
		]);


		$(".order_item").each(function(){
		   var order_item = $(this);
		   // add item might be called for every item in the shopping cart
		   // where your ecommerce engine loops through each item in the cart and
		   // prints out _addItem for each
		  _gaq.push(['_addItem',
					  $(".order_id").html(),    // order ID - necessary to associate item with transaction
			  order_item.find(".item_code").first().html(),           // SKU/code - required
			  order_item.find(".item_description").first().html(),        // product name
			  "",   // category or variation
			  order_item.find(".item_unit_price").first().html(),          // unit price - required
			  order_item.find(".item_quantity").first().html()               // quantity - required
		  ]);

		});

		_gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
	}
});
  
