
function calcTotal()
{
	var quantities = $("select");	
	var total = 0;
	
	for(var i=0; i<quantities.size(); i++)
	{
		var item = quantities.get(i);
		
		if(!item.price)
		{
			item.price = item.getAttribute("price");
		}
		
		if(item.isValid() && item.value)	//only process items with valid integer data
		{
			total += parseFloat(item.price) * parseFloat(item.value);
		}		
	}
	
	//var gst = Math.round((total/11) * 100)/100;
	var gst;
	gst = GSTRate == 0 ? 0 : gst = total / GSTInclusiveDivider;  // Set GST to zero if the GSTRate is zero
	var displayGst = Math.round(gst*100) / 100;
	var displayTotal = Math.round(total * 100) / 100;

	$("#totalGST").html("$" + CurrencyFormatted(displayGst));
	$("#totalValue").html("$" + CurrencyFormatted(displayTotal));
}


//http://www.web-source.net/web_development/currency_formatting.htm
//Use JavaScript to Format Currency within Your Web Page
//By
//William Bontrager
function CurrencyFormatted(amount) {
	var i = parseFloat(amount);
	var minus = '';

	if (isNaN(i)) {
		i = 0.00;
	}
	if (i < 0) {
		minus = '-';
	}
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if (s.indexOf('.') < 0) {
		s += '.00';
	}
	if (s.indexOf('.') == (s.length - 2)) {
		s += '0';
	}
	s = minus + s;
	return s;
}
// end of function CurrencyFormatted()

//* (not necessary after full migration to async)
function printTicketsWindow(transactionID) 
{
	listWindow = window.open('/Ticketing/user/PrintableTickets.aspx?tid=' + transactionID, 'ticketsWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=830,height=630');
}
function taxInvoiceWindow(transactionID) 
{
	listWindow = window.open('/Ticketing/user/receipt.aspx?tid=' + transactionID, 'taxReceipt', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=880,height=850,top=100,left=100')
}
