// JavaScript Document

		function getFieldValue(field)
		{
			var val = field.value;
			if(String(val).length == 0)
				val = 0;
				
			if(isNaN(val))
				val = 0;
			
			if(val == 0)
				field.value = 0;
				
			return val;
		}
		
		function getPrice(measureNo)
		{
			var field = null;
			if(document.forms[0]["price" + measureNo])
				field = document.forms[0]["price" + measureNo];
			
			else
				return 0;
				
			return getFieldValue(field);
		}
		
		function getQuantity(measureNo)
		{
			var field = null;
			
			if(document.forms[0]["qty" + measureNo])
				field = document.forms[0]["qty" + measureNo];
				
			else
				return 0;
				
			return getFieldValue(field);
		}
		
		function displayAll()
		{
			if(getPrice(2) > 0)
			{				
				var obj = getObject("price2Row");
				if(obj && IE)
					obj.style.display = "block";
					
				else if(obj)
					obj.style.visibility = "visible";
			}
			if(getPrice(3) > 0)
			{
				var obj = getObject("price3Row");
				if(obj && IE)
					obj.style.display = "block";
					
				else if(obj)
					obj.style.visibility = "visible";
			}
		}

		function calculate(measureNo)
		{			
			if(arguments.length == 0)
			{
				for(var i = 1; i <= 3; i++)
					calculate(i);
					
				return;
			}
			
			var price = getPrice(measureNo);			
			if(price == 0)
				return;
			
			var qty = getQuantity(measureNo);
				
			var total = Math.round(price * qty * 100).toString();	
			total = total.substring(0,total.length - 2) + "." + total.substring(total.length - 2);	

			while(total.indexOf(".") != total.length - 3)
			total += "0";
		
			var totalField = document.forms[0]["total" + measureNo];
			totalField.value = pound + total;
		}

		function buyThis(id, name, measureNo)
		{
			calculate(measureNo);
	
			var qty = getQuantity(measureNo);
						
			if(qty == 0)
				return;

			addToCart(id, qty, measureNo);

			var startStr = " \n\nThis item has ";
			startStr = qty > 1 ? " \n\nThese items have " : startStr;

			var totalVal = document.forms[0]["total" + measureNo].value.toString();
			
			alert(name + "  " + totalVal + startStr + "been added to your shopping basket.\nClick the \"View Basket\" button to check your order and make any changes.");
		}
		
		var pound = String.fromCharCode(163);
