<!--

//==============================================================================
	function round_decimals(num,bSign){
//==============================================================================
		num = num.toString().replace(/\£|\,| /g , '');
		if(isNaN(num))
			num = "0.00";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		pennies = num%100;
		num = Math.floor(num/100).toString();
		if(pennies<10)
			pennies = "0" + pennies;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
			num = num.substring(0,num.length-(4*i+3)) + ',' + num.substring(num.length-(4*i+3));
		return (((sign)?'':'-') + (bSign?'£':'') + num + '.' + pennies);
	}
//------------------------------------------------------------------------------

//==============================================================================
	function CheckNumeric(){
//==============================================================================
	
	   // Get ASCII value of key that user pressed
	   var key = window.event.keyCode;
	
	   // Was key that was pressed a numeric character (0-9)?
	   if ( key > 45 && key < 58 )
		  return; // if so, do nothing
	   else
		  window.event.returnValue = null; // otherwise, 
									   // discard character
	}
//------------------------------------------------------------------------------

//==============================================================================
	function ShowConflictingFormInputs(bDisplay,strExcept) {
//==============================================================================
		//alert("In ShowConflictingFormInputs");
		if ( navigator.appName.indexOf("MSIE") ) {
			//for ( var S = 0; S < document.forms.length; S++ ){
				for ( var R = 0; R < document.quoteform.length; R++ ) {
					if ( document.quoteform.elements[R].options ) {
						//alert(document.quoteform.elements[R].name);
						if (document.quoteform.elements[R].name != strExcept){
							if ( bDisplay ){
								document.quoteform.elements[R].style.visibility = 'visible';
							}else{
								document.quoteform.elements[R].style.visibility = 'hidden';
							}
						}
					}
				} 
			//}
		}
		//alert("Out ShowConflictingFormInputs");
	}
//------------------------------------------------------------------------------

//==============================================================================
function CheckPositiveInteger()
//==============================================================================
{
	// Get ASCII value of key that user pressed
	var key = window.event.keyCode;
	
	// Was key that was pressed a numeric character (0-9)?
	if (( key > 47 && key < 58 ) ){
		//alert("NO!!!");
		return; // if so, do nothing
	}else
		window.event.returnValue = null; // otherwise, 
	// discard character
}
//------------------------------------------------------------------------------
//==============================================================================
	function MugCost(){
//==============================================================================
	iMQuantity = 0;
	for (i = 1; i<=12; i++ ){
		if (document.getElementById("m"+i).value != ""){
			iMQuantity = iMQuantity + parseInt(document.getElementById("m"+i).value);
		}
	}
	document.getElementById("mugcost").value= round_decimals( iMQuantity*7 , false );
	DoTotals();
	
	}
//==============================================================================
	function RejigRow(oSelector,iRow){
//==============================================================================
	//alert(oSelector.name);

	// Generic initialisation (might not be used).
	strShirtColour = "<select name='shirtcolour"+iRow+"' id='shirtcolour"+iRow+"' class='shirtcolour' onChange='RejigRow(this,"+iRow+");' style='width: 80px; font-size: 0.9em;'>";

	strSize = "<select name='size"+iRow+"' id='size"+iRow+"' class='size' onChange='RejigRow(this,"+iRow+");' style='font-size: 0.9em; width: 80px;'>";
	var dItemCost = 0.0;

	switch (oSelector.name){
		case "style"+iRow:
			//alert("Style!"+oSelector.value);
			switch (oSelector.value){
				case "1":
					// Basic Adult
					strShirtColour = strShirtColour + "<option value='1'>White</option>";
					strShirtColour = strShirtColour + "<option value='2'>Natural</option>";
					strShirtColour = strShirtColour + "</select>";


					strSize = strSize + "<option value='1'>2XL - 45/46</option>";
					strSize = strSize + "<option value='2'>XL - 43/44</option>";
					strSize = strSize + "<option value='3'>L - 41/42</option>";
					strSize = strSize + "<option value='4'>M - 39/40</option>";
					strSize = strSize + "<option value='5'>S - 37/38</option>";
					strSize = strSize + "</select>";

					//dItemCost = dItemCost + 14.00;

					break
				case "2":
					// Ladies Fitted
					strShirtColour = strShirtColour + "<option value='1'>White</option>";
					strShirtColour = strShirtColour + "<option value='2'>Natural</option>";
					strShirtColour = strShirtColour + "</select>";

					strSize = strSize + "<option value='1'>XL - 40/42</option>";
					strSize = strSize + "<option value='2'>M/L - 36/38</option>";
					strSize = strSize + "<option value='3'>SM - 31/34</option>";
					strSize = strSize + "</select>";
					
					//dItemCost = dItemCost + 14.00;
			
					break
				case "3":
					// Kids
					strShirtColour = strShirtColour + "<option value='1'>White</option>";
					strShirtColour = strShirtColour + "<option value='2'>Natural</option>";
					strShirtColour = strShirtColour + "</select>";

					strSize = strSize + "<option value='1'>Age - 11/12</option>";
					strSize = strSize + "<option value='2'>Age - 8/10</option>";
					strSize = strSize + "<option value='3'>Age - 7/8</option>";
					strSize = strSize + "<option value='4'>Age - 5/6</option>";
					strSize = strSize + "<option value='5'>Age - 3/4</option>";
					strSize = strSize + "<option value='6'>Age - 1/2</option>";
					strSize = strSize + "</select>";
					
					//dItemCost = dItemCost + 10.0;

					break
				case "4":
					// Kids Fitted
					strShirtColour = "<input type='text' readonly='true' class='shirtcolour' value='Organic Natural'>";
					
					strSize = strSize + "<option value='1'>Age - 10/12</option>";
					strSize = strSize + "<option value='2'>Age - 7/9</option>";
					strSize = strSize + "<option value='3'>Age - 4/6</option>";
					strSize = strSize + "<option value='4'>Age - 2/3</option>";
					strSize = strSize + "</select>";
					
					//dItemCost = dItemCost + 11.0;

					break
			}
			//alert(dItemCost);
			document.getElementById("size"+iRow).innerHTML = strSize;
			document.getElementById("shirtcolour"+iRow).innerHTML = strShirtColour;


			break
		case "quantity"+iRow:
			//alert("quantity changed");
			//dItemCost = alert(document.getElementById("itemcost"+iRow).value);
			dItemCost = parseFloat(document.getElementById("itemcost"+iRow).value);
			//alert(dItemCost);
			//dItemCost = ParseFloat(round_decimals(document.getElementById("itemcost"+iRow).value,false));
			//alert(dItemCost);
			document.getElementById("cost"+iRow).value = round_decimals( dItemCost * parseInt(document.getElementById("quantity"+iRow).value),false);
			break
		case "camperdesign"+iRow:
			//alert("CAMPERDESIGN"+document.getElementById("camperdesign"+iRow).value);
			if (document.getElementById("camperdesign"+iRow).value=='"Not Just a Pretty Face"'){
				dItemCost = parseFloat(document.getElementById("itemcost"+iRow).value);
				alert(dItemCost);
				dItemCost = dItemCost + 3
				//document.getElementById("cost"+iRow).value = round_decimals( dItemCost * parseInt(document.getElementById("quantity"+iRow).value),false);
				document.getElementById("cost"+iRow).value = round_decimals( dItemCost * parseInt(document.getElementById("quantity"+iRow).value),false);
			}
			break
	}

	//alert(document.getElementById("style"+iRow).value);
	//alert("style"+iRow);
	switch (document.getElementById("style"+iRow).value){
		case "1":
			dItemCost = 14;
			break
		case "2":
			dItemCost = 14;
			break
		case "3":
			dItemCost = 10;
			break
		case "4":
			dItemCost = 11;
			break
	}
	//alert("dItemCost="+dItemCost);
	if (document.getElementById("camperdesign"+iRow).value == "4"){
		dItemCost = dItemCost+3;
	}
	//alert("dItemCost="+dItemCost);

	document.getElementById("itemcost"+iRow).value = round_decimals( dItemCost, false );
	
	document.getElementById("cost"+iRow).value = round_decimals( dItemCost * parseInt(document.getElementById("quantity"+iRow).value),false);

	DoTotals();

	}
//------------------------------------------------------------------------------
	
//==============================================================================
	function DoTotals(){
//==============================================================================
	dSubTotal = 0.0;
	dShirtSub = 0.0;
	dMugSub = 0.0;
	iShirtQuantity = 0;
	iMugQuantity = 0;
	dShirtDelivery = 0;
	dMugDelivery = 0;
	for (i = 1; i<=5; i++ ){
		dShirtSub = dShirtSub + parseFloat(document.getElementById("cost"+i).value);
		iShirtQuantity = iShirtQuantity + parseInt(document.getElementById("quantity"+i).value);
	}

	for (i = 1; i<=10; i++ ){
		if (document.getElementById("m"+i).value != ""){
			iMugQuantity = iMugQuantity + parseInt(document.getElementById("m"+i).value);
		}
	}
	dMugSub = iMugQuantity * 7;
	
	if (iShirtQuantity > 1 )	{
		dShirtDelivery = 2.95;
	}else if (iShirtQuantity == 1){	
		dShirtDelivery = 1.8;
	}
	if (iMugQuantity > 1 )	{
		dMugDelivery = 2.95;
	}else if (iMugQuantity == 1){	
		dMugDelivery = 1.8;
	}
	dSubTotal = dMugSub + dShirtSub;
	document.getElementById("subtotal").value = round_decimals(dSubTotal,false);
	dDelivery = dShirtDelivery+dMugDelivery
	document.getElementById("delivery").value = round_decimals(dDelivery,false);
	dGrandTotal = dDelivery + dSubTotal;
	document.getElementById("grandtotal").value = round_decimals(dGrandTotal,false);
	
	//if (this.name="style"+iRow) alert("Here!");
}				
//------------------------------------------------------------------------------

-->