function price_format(price)
{
	price = '$'+Math.round(price*100)/100;
	var sp = price.split('.');
	if (sp[1])
	{
		if (sp[1].length == 1)
		{
			price = price+'0';
		}
	} else
	{
		price = price+'.00';
	}
	
	return price;
}

window.addEvent('domready', function(){
	$$('input.qty').each(function(el1){
		el1.addEvent('keyup', function(){
			var subtotal = 0;
			$$('input.qty').each(function(el){
				var qty = el.value;
				var price = el.getParent().getPrevious().getElement('strong').getText();
				price = price.replace('$','');
				price = price.toInt();
				if (el.hasClass('cents') == true)
				{
					price = price/100;
				}
				var check = Math.round((price * qty)*100)/100;
				if (isNaN(check) == false)
				{
					subtotal += check;
				} else
				{
					el.value = '';
				}
			});
			subtotal = subtotal;
			$('subtotal').getElement('strong').setText(price_format(subtotal));
			//console.log('subtotal: '+subtotal);
			var gst = (subtotal/100)*12.5;
			//$('gst').getElement('strong').setText(price_format(gst));
			//console.log('gst: '+gst);
			var total = subtotal + gst;
			//$('total').getElement('strong').setText(price_format(total));
			//console.log('total: '+total);
		});
	});
});