// global_subtotal = 0.00;

function dollars_to_number (dollarstr)
{
	var sign = dollarstr.indexOf('$') + 1;
	var new_string = dollarstr.substring(sign,(dollarstr.length));
	if (new_string.indexOf(',') > 0)
	{
		var comma = new_string.indexOf(',');
		var first_part = new_string.substring(0, comma);
		var second_part = new_string.substr(comma+1, new_string.length);
		// alert(first_part+'/'+second_part);
		
		new_string = first_part + second_part;
	}
	return (new_string * 1);
}

function update_subtotal (qty_field, price_id, subtotal_id)
{
	var qty = qty_field.value;
	var price = dollars_to_number(document.getElementById(price_id).innerHTML);
	var subtotal = document.getElementById(subtotal_id).value;
	var global_subtotal = dollars_to_number(document.getElementById('total_price_this_page').innerHTML);

	var new_subtotal = (qty * price);
	var diff = new_subtotal - subtotal;
	// alert('Price: '+price+', Sub: '+subtotal+', Global: '+global_subtotal+', Diff: '+diff);
	global_subtotal = global_subtotal + diff;
	document.getElementById(subtotal_id).value = new_subtotal;
	document.getElementById('total_price_this_page').innerHTML = '$'+new NumberFormat(global_subtotal).toFormatted();
}