var pd_name = new Array("mglaunch", "mgswitch", "mgwindow_plus");
var pd_price = new Array(29.95, 19.95, 24.95);
var pd_disc = new Array(0, 0.10, 0.20);

function addOne(index)
{
	if (index < pd_name.length)
	{
		var fd = document.getElementById(pd_name[index]);
		if (isNaN(parseInt(fd.value)))
			fd.value = 0;
		fd.value = parseInt(fd.value) + 1;
	}
	
	updateTotal();
	
	return false; 	
}

function updateTotal()
{	
	total = 0;
	volume = 0;
	discount = 0;
	pds = 0;
	
	for (n = 0; n < pd_name.length; n++)
	{
		var fd = document.getElementById(pd_name[n]);
		volume = parseInt(fd.value);
		
		if (isNaN(volume))
			volume = 0;
			
		if (volume > 0)
			pds++;
			
		total += volume * parseFloat(pd_price[n]);
	}
		
	
	if (pds > 0)
	{
		pds--;
		discount = total * parseFloat(pd_disc[pds]);
		
		total -= discount;
	}
		
	document.getElementById('pc_discount').childNodes[0].nodeValue = discount.toFixed(2);
	document.getElementById('pc_total').childNodes[0].nodeValue = total.toFixed(2);
}