<!-- hide it

// price values

//var blueBook = 50.00;
//var safetyCode = 25.00;
//var travelZone_akl = 165.00;
//var travelZone_wgtn = 165.00;
//var post_nz = 8.00;
var post_aus = 45.00;
var post_us = 90.00;
var packaging;
var gstVal = 0.15;

// START checkAndAdd
// triggered by an  onBlur="checkAndAdd(this);" on a form field, it checks the field for numeric and calls 'addAndSetTotals' to add up everything
function checkAndAdd(field) 
{
// calls addAndSetTotal if the field is numerical
fieldValue = field.value;
//if (field.name == "document.form2.packaging") 
if (isNaN(fieldValue) && field.name!="rad_packaging" || fieldValue=="" ) 
	{
	alert(fieldValue + " is not a number or empty");
	}
	else
		{
		addAndSetTotals();
		}
}
// END checkAndAdd

// START getRadio
// gets the price value for the radio that is selected
function getRadio() 
{
var post_nz = 8.00;
var post_aus = 45.00;
var post_us = 90.00;
//alert("chk: " + document.form2.rad_packaging[0].checked);


if (document.form2.rad_packaging[0].checked) {
	packaging = post_nz;
	}
if (document.form2.rad_packaging[1].checked) {
	packaging = post_aus;
	}	
if (document.form2.rad_packaging[2].checked) {
	packaging = post_us;
	}
		

return packaging;
}

// START addAndSetTotals
function addAndSetTotals()
{
packaging = post_nz; 
//alert(document.form2.test_me.value) ;
pubsTotal = parseInt(document.form2.blue_book.value)*blueBook + parseInt(document.form2.safety_code.value)*safetyCode + parseInt(document.form2.akl_map.value)*travelZone_akl + parseInt(document.form2.wgtn_map.value)*travelZone_wgtn + parseInt(packaging);
pubsTotal = decimalise(pubsTotal, 3);

//alert(pubsTotal.toFixed(2));
gst = decimalise((pubsTotal * gstVal), 2);

finalTotal = decimalise(parseFloat(pubsTotal) + parseFloat(gst), 2);
document.form2.gst.value = gst;
document.form2.total.value = finalTotal;
}
// END addAndSetTotals

function decimalise(temp, places) {
// first check if the number has no decimal point (is an integer) - if so, convert to string and add the two decimal places as a string. If not, use the multiply, chop, divide method
temp1=temp.toString();

if (temp1.indexOf(".") == -1) {
temp = (temp1 + ".00");
}
//else if (temp1.indexOf(".") == 1) {
//temp = (temp1 + "0");
//}
else {
temp = temp.toFixed(2);
//temp *= Math.pow(10, places);
//temp = Math.floor(temp);
//temp /= Math.pow(10, places);
}
return temp;

}
// -->

