

function showImage(imagesrc,imagetitle,width,height)
{
	imagewindow = window.open('image_detail.php?imagesrc=' + imagesrc + '&title=' + imagetitle,
				'','width=' + width + ',height=' + height +
				',location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
	
	//imagewindow.document.write('<html><head><title>' + imagetitle + '</title></head>');
	//imagewindow.document.write('<body topmargin=0 leftmargin=0><center><img src="' + imagename + '"></center></body></html>');
	imagewindow.focus();
}


function calcTotal(theForm, quantityField, priceField, totalField) {
	
	var quantity = quantityField.value;
	var price = getNum(priceField);
	var total = quantity*price;
	
	totalField.value = fixDecimal("$" + total);
	
	calcGrandTotal(theForm);
	return true;
	
}

function calcGrandTotal(theForm) {
	var subtotal = 0;
	subtotal = getNum(theForm.Total_MugShelf) + getNum(theForm.Total_CollectibleShelf) +
				   getNum(theForm.Total_FoyerPiece) + getNum(theForm.Total_CoffeeTable);
	theForm.MerchandiseTotal.value = fixDecimal("$" + subtotal);
	
	var tax = subtotal * .08;
	theForm.SalesTax.value = fixDecimal("$" + tax);
	
	theForm.GrandTotal.value = fixDecimal("$" + (subtotal+tax+getNum(theForm.ShippingAndHandling)));
}

function getNum(theField) {
	return Number(theField.value.substring(1));
}

function fixDecimal(theString) {
	
	var decimalPos = theString.indexOf(".");
	if (decimalPos != -1) {
		var newString = theString.substring(0,decimalPos+3);
		if (newString.length < decimalPos+3) 
			newString = newString + "0";
		return newString;
	}
	else
		return theString + ".00";
}
	