<!-- 
/*
function clearCredit (){
	if (document.mainForm.Currency.selectedIndex == 3) {
	alert ("You have chosen to pay using New Zealand Dollars.  This payment can only be made by cheque.  Credit card information should remain blank.");
	document.mainForm.NameOnCard.value = "";
	document.mainForm.CardType.selectedIndex = 0;
	document.mainForm.CardNumber.value = "";
	document.mainForm.ExpiryDate.value = "";
	}
}

function nzcredit (){
	alert("New Zealand residents wishing to pay by credit card must make prior arrangement.  If you have already done so, please note there will be a 3.9% bank fee added to your order.");
	document.mainForm.Currency.options[3].selected =true;
}
*/

function checkDate(year)	{
    var today = new Date();
    var thisYear = today.getFullYear();
    var year = year.value;
    var goodYear = true;
    //alert ("The year chosen is " + year + ".\n\nThis year is " + thisYear + "."); //diagnostic
	if (isNaN (year)) {
		alert ("Invalid year format.\n\nForm cannot be submitted with an invalid year.");
        goodYear = false;
	} else if (year < 1922 ) {
		alert ("Certificates are not available before 1922.\n\nForm cannot be submitted with an invalid year.");
        goodYear = false;
	} else if (year > thisYear ){
		alert ("The year you have chosen is in the future! \n\nForm cannot be submitted with an invalid year.");
        goodYear = false;
	}    
}

function checkDate(year)	{
	var year = year.value;
	if (isNaN (year)) {
		alert ("Invalid year format.");
	} else if (year < 1922 ) {
		alert ("Certificates are not available before 1922.");
	} else if (year > 1999 ){
		alert ("Year is out of range.");
	}	
}


function getTotal()	{
	alert ('Your order is about to be prepared.\nClick "OK" and wait for confirmation message.');
	calcTotal();
}


function calcTotal()	{

//	VARIABLES

	var bmd1 = "";					// birth, marriage or death for certificate #1
	var bmd2 = "";					//  " #2
	var bmd3 = "";					//  " #3
	var bmd4 = "";					//  " #4
	var bmd5 = "";					//  " #5
	var bmd6 = "";					//  " #6
	
	var qtr1 = "";					// quarter for certificate #1
	var qtr2 = "";					//  " #2
	var qtr3 = "";					//  " #3
	var qtr4 = "";					//  " #4
	var qtr5 = "";					//  " #5
	var qtr6 = "";					//  " #6
	
	var cert_qty = 0;				// total quantity of certificates
	var certtype = "Certificate by post";	// only certificate availble for N. Ireland
	var nocert = "No specified";	// if no BMD is selected, this is the value given to the blank field
	var checkref = 0;				// will the index be checked?
	var refcheckval = 0.00;			// cost of index check in NZ dollars ***
	var refcheckvalUS = 2.50;	// cost of index check in US dollars ***
	var refcheckvalCAD = 4.00;	// cost of index check in CDN dollars ***
	var refcheckvalAUD = 4.50;	// cost of index check in AU dollars ***
	var currency = "NZD";
	var USD = 28;
	var CAD = 33;
	var NZD = 50;
	var AUD = 37;
//	var cardholder = document.mainForm.NameOnCard.value;	// persons's name on card
//	var cardname = "";										// visa-mc etc.
//	var cardnum = document.mainForm.CardNumber.value;		
//	var cardexp = document.mainForm.ExpiryDate.value;
	total = 0;						// set inital amount payable to zero
	suffix = ".00";					// add cents to amount payable
	var checkrefyes = "\tCheck index.";	// for status window output

	
// OPENING STATUS

	document.mainForm.OrderStatus.value = ("Northern Ireland Order: " + certtype + " \n\n");



// DETERMINE CURRENCY OF PAYMENT
/*
	if (document.mainForm.Currency.selectedIndex == 0){
		currency = document.mainForm.Currency.options[0].value;
	}
	else if (document.mainForm.Currency.selectedIndex == 1)	{
		currency = document.mainForm.Currency.options[1].value;
	}
	else if (document.mainForm.Currency.selectedIndex == 2){
		currency = document.mainForm.Currency.options[2].value;
	}
	else if (document.mainForm.Currency.selectedIndex == 3) {
		currency = document.mainForm.Currency.options[3].value;
	}
	else if (document.mainForm.Currency.selectedIndex == 4) {
		currency = document.mainForm.Currency.options[4].value;
	}
*/


// DETERMINE WHETHER B, M, OR D

	if (document.mainForm.BMD_1.selectedIndex == 0) {
		bmd1 = document.mainForm.BMD_1.options[0].value;
	}
	else if (document.mainForm.BMD_1.selectedIndex == 1) {
		bmd1 = document.mainForm.BMD_1.options[1].value;
	}
	else if (document.mainForm.BMD_1.selectedIndex == 2) {
		bmd1 = document.mainForm.BMD_1.options[2].value;
	}
	else if (document.mainForm.BMD_1.selectedIndex == 3) {
		bmd1 = document.mainForm.BMD_1.options[3].value;
	}

	if (document.mainForm.BMD_2.selectedIndex == 0) {
		bmd2 = nocert;
	}
	else if (document.mainForm.BMD_2.selectedIndex == 1) {
		bmd2 = document.mainForm.BMD_2.options[1].value;
	}
	else if (document.mainForm.BMD_2.selectedIndex == 2) {
		bmd2 = document.mainForm.BMD_2.options[2].value;
	}
	else if (document.mainForm.BMD_2.selectedIndex == 3) {
		bmd2 = document.mainForm.BMD_2.options[3].value;
	}

	if (document.mainForm.BMD_3.selectedIndex == 0) {
		bmd3 = nocert;
	}
	else if (document.mainForm.BMD_3.selectedIndex == 1) {
		bmd3 = document.mainForm.BMD_3.options[1].value;
	}
	else if (document.mainForm.BMD_3.selectedIndex == 2) {
		bmd3 = document.mainForm.BMD_3.options[2].value;
	}
	else if (document.mainForm.BMD_3.selectedIndex == 3) {
		bmd3 = document.mainForm.BMD_3.options[3].value;
	}

	if (document.mainForm.BMD_4.selectedIndex == 0)	{
		bmd4 = nocert;
	}
	else if (document.mainForm.BMD_4.selectedIndex == 1) {
		bmd4 = document.mainForm.BMD_4.options[1].value;
	}
	else if (document.mainForm.BMD_4.selectedIndex == 2) {
		bmd4 = document.mainForm.BMD_4.options[2].value;
	}
	else if (document.mainForm.BMD_4.selectedIndex == 3)
		{bmd4 = document.mainForm.BMD_4.options[3].value;
	}

	if (document.mainForm.BMD_5.selectedIndex == 0)	{
		bmd5 = nocert;
	}
	else if (document.mainForm.BMD_5.selectedIndex == 1) {
		bmd5 = document.mainForm.BMD_5.options[1].value;
	}
	else if (document.mainForm.BMD_5.selectedIndex == 2) {
		bmd5 = document.mainForm.BMD_5.options[2].value;
	}
	else if (document.mainForm.BMD_5.selectedIndex == 3) {
		bmd5 = document.mainForm.BMD_5.options[3].value;
	}

	if (document.mainForm.BMD_6.selectedIndex == 0) {
		bmd6 = nocert;
	}
	else if (document.mainForm.BMD_6.selectedIndex == 1) {
		bmd6 = document.mainForm.BMD_6.options[1].value;
	}
	else if (document.mainForm.BMD_6.selectedIndex == 2) {
		bmd6 = document.mainForm.BMD_6.options[2].value;
	}
	else if (document.mainForm.BMD_6.selectedIndex == 3) {
		bmd6 = document.mainForm.BMD_6.options[3].value;
	}


// DETERMINE QUARTER

	if (document.mainForm.Quarter_1.selectedIndex == 0) {
		qtr1 = "First";
	}
	else if (document.mainForm.Quarter_1.selectedIndex == 1) {
		qtr1 = "Second";
	}
	else if (document.mainForm.Quarter_1.selectedIndex == 2) {
		qtr1 = "Third";
	}
	else if (document.mainForm.Quarter_1.selectedIndex == 3) {
		qtr1 = "Fourth";
	}
	else if (document.mainForm.Quarter_1.selectedIndex == 4) {
		qtr1 = "Unknown";
	}

	if (document.mainForm.Quarter_2.selectedIndex == 0) {
		qtr2 = "Not specified";
	}
	else if (document.mainForm.Quarter_2.selectedIndex == 1) {
		qtr2 = "First";
	}
	else if (document.mainForm.Quarter_2.selectedIndex == 2) {
		qtr2 = "Second";
	}
	else if (document.mainForm.Quarter_2.selectedIndex == 3) {
		qtr2 = "Third";
	}
	else if (document.mainForm.Quarter_2.selectedIndex == 4) {
		qtr2 = "Fourth";
	}
	else if (document.mainForm.Quarter_2.selectedIndex == 5) {
		qtr2 = "Unknown";
	}

	if (document.mainForm.Quarter_3.selectedIndex == 0) {
		qtr3 = "Not specified.";
	}
	else if (document.mainForm.Quarter_3.selectedIndex == 1) {
		qtr3 = "First";
	}
	else if (document.mainForm.Quarter_3.selectedIndex == 2) {
		qtr3 = "Second";
	}
	else if (document.mainForm.Quarter_3.selectedIndex == 3) {
		qtr3 = "Third";
	}
	else if (document.mainForm.Quarter_3.selectedIndex == 4) {
		qtr3 = "Fourth";
	}
	else if (document.mainForm.Quarter_3.selectedIndex == 5) {
		qtr3 = "Unknown";
	}
	

	if (document.mainForm.Quarter_4.selectedIndex == 0) {
		qtr4 = "Not specified.";
	}
	else if (document.mainForm.Quarter_4.selectedIndex == 1) {
		qtr4 = "First";
	}
	else if (document.mainForm.Quarter_4.selectedIndex == 2) {
		qtr4 = "Second";
	}
	else if (document.mainForm.Quarter_4.selectedIndex == 3) {
		qtr4 = "Third";
	}
	else if (document.mainForm.Quarter_4.selectedIndex == 4) {
		qtr4 = "Fourth";
	}
	else if (document.mainForm.Quarter_4.selectedIndex == 5) {
		qtr4 = "Unknown";
	}


	if (document.mainForm.Quarter_5.selectedIndex == 0) {
		qtr5 = "Not specified.";
	}
	else if (document.mainForm.Quarter_5.selectedIndex == 1) {
		qtr5 = "First";
	}
	else if (document.mainForm.Quarter_5.selectedIndex == 2) {
		qtr5 = "Second";
	}
	else if (document.mainForm.Quarter_5.selectedIndex == 3) {
		qtr5 = "Third";
	}
	else if (document.mainForm.Quarter_5.selectedIndex == 4) {
		qtr5 = "Fourth";
	}
	else if (document.mainForm.Quarter_5.selectedIndex == 5) {
		qtr5 = "Unknown";
	}


	if (document.mainForm.Quarter_6.selectedIndex == 0) {
		qtr6 = "Not specified.";
	}
	else if (document.mainForm.Quarter_6.selectedIndex == 1) {
		qtr6 = "First";
	}
	else if (document.mainForm.Quarter_6.selectedIndex == 2) {
		qtr6 = "Second";
	}
	else if (document.mainForm.Quarter_6.selectedIndex == 3) {
		qtr6 = "Third";
	}
	else if (document.mainForm.Quarter_6.selectedIndex == 4) {
		qtr6 = "Fourth";
	}
	else if (document.mainForm.Quarter_6.selectedIndex == 5) {
		qtr6 = "Unknown";
	}
	

//	FIRST CERTIFICATE

	if (document.mainForm.Surname_1.value != "") {
		cert_qty = cert_qty + 1;
		document.mainForm.OrderStatus.value += (" - " + bmd1 + " certificate for " + document.mainForm.Given_1.value + " " + document.mainForm.Surname_1.value + ".\n");
		document.mainForm.OrderStatus.value += ("\tYear: " + document.mainForm.Year_1.value);
		document.mainForm.OrderStatus.value += ("\tQuarter: " + qtr1 + "\n");
		document.mainForm.OrderStatus.value += ("\tRegistration District: " + document.mainForm.District_1.value + "\n");
		document.mainForm.OrderStatus.value += ("\tVolume: " + document.mainForm.Volume_1.value);
		document.mainForm.OrderStatus.value += ("\tPage: " + document.mainForm.Page_1.value);
		if (document.mainForm.checkref_1.checked) {
			document.mainForm.OrderStatus.value += (checkrefyes);
			checkref = checkref + 1;
		}
		document.mainForm.OrderStatus.value += ("\n\n");
	}


//	SECOND CERTIFICATE

	if (document.mainForm.Surname_2.value != "") {
		cert_qty = cert_qty + 1;
		document.mainForm.OrderStatus.value += (" - " + bmd2 + " certificate for " + document.mainForm.Given_2.value + " " + document.mainForm.Surname_2.value + ".\n");
		document.mainForm.OrderStatus.value += ("\tYear: " + document.mainForm.Year_2.value);
		document.mainForm.OrderStatus.value += ("\tQuarter: " + qtr2 + "\n");
		document.mainForm.OrderStatus.value += ("\tRegistration District: " + document.mainForm.District_2.value + "\n");
		document.mainForm.OrderStatus.value += ("\tVolume: " + document.mainForm.Volume_2.value);
		document.mainForm.OrderStatus.value += ("\tPage: " + document.mainForm.Page_2.value);
		if (document.mainForm.checkref_2.checked) {
			document.mainForm.OrderStatus.value += (checkrefyes);
			checkref = checkref + 1;
		}
		document.mainForm.OrderStatus.value += ("\n\n");
	}


//	THIRD CERTIFICATE

	if (document.mainForm.Surname_3.value != "") {
		cert_qty = cert_qty + 1;
		document.mainForm.OrderStatus.value += (" - " + bmd3 + " certificate for " + document.mainForm.Given_3.value + " " + document.mainForm.Surname_3.value + ".\n");
		document.mainForm.OrderStatus.value += ("\tYear: " + document.mainForm.Year_3.value);
		document.mainForm.OrderStatus.value += ("\tQuarter: " + qtr3 + "\n");
		document.mainForm.OrderStatus.value += ("\tRegistration District: " + document.mainForm.District_3.value + "\n");
		document.mainForm.OrderStatus.value += ("\tVolume: " + document.mainForm.Volume_3.value);
		document.mainForm.OrderStatus.value += ("\tPage: " + document.mainForm.Page_3.value);
		if (document.mainForm.checkref_3.checked) {
			document.mainForm.OrderStatus.value += (checkrefyes);
			checkref = checkref + 1;
		}
		document.mainForm.OrderStatus.value += ("\n\n");
	}


//	FOURTH CERTIFICATE

	if (document.mainForm.Surname_4.value != "") {
		cert_qty = cert_qty + 1;
		document.mainForm.OrderStatus.value += (" - " + bmd4 + " certificate for " + document.mainForm.Given_4.value + " " + document.mainForm.Surname_4.value + ".\n");
		document.mainForm.OrderStatus.value += ("\tYear: " + document.mainForm.Year_4.value);
		document.mainForm.OrderStatus.value += ("\tQuarter: " + qtr4 + "\n");
		document.mainForm.OrderStatus.value += ("\tRegistration District: " + document.mainForm.District_4.value + "\n");
		document.mainForm.OrderStatus.value += ("\tVolume: " + document.mainForm.Volume_4.value);
		document.mainForm.OrderStatus.value += ("\tPage: " + document.mainForm.Page_4.value);
		if (document.mainForm.checkref_4.checked) {
			document.mainForm.OrderStatus.value += (checkrefyes);
			checkref = checkref + 1;
		}
		document.mainForm.OrderStatus.value += ("\n\n");
	}


//	FIFTH CERTIFICATE

	if (document.mainForm.Surname_5.value != "") {
		cert_qty = cert_qty + 1;
		document.mainForm.OrderStatus.value += (" - " + bmd5 + " certificate for " + document.mainForm.Given_5.value + " " + document.mainForm.Surname_5.value + ".\n");
		document.mainForm.OrderStatus.value += ("\tYear: " + document.mainForm.Year_5.value);
		document.mainForm.OrderStatus.value += ("\tQuarter: " + qtr5 + "\n");
		document.mainForm.OrderStatus.value += ("\tRegistration District: " + document.mainForm.District_5.value + "\n");
		document.mainForm.OrderStatus.value += ("\tVolume: " + document.mainForm.Volume_5.value);
		document.mainForm.OrderStatus.value += ("\tPage: " + document.mainForm.Page_5.value);
		if (document.mainForm.checkref_5.checked) {
			document.mainForm.OrderStatus.value += (checkrefyes);
			checkref = checkref + 1;
		}
		document.mainForm.OrderStatus.value += ("\n\n");
	}


//	SIXTH CERTIFICATE

	if (document.mainForm.Surname_6.value != "") {
		cert_qty = cert_qty + 1;
		document.mainForm.OrderStatus.value += (" - " + bmd6 + " certificate for " + document.mainForm.Given_6.value + " " + document.mainForm.Surname_6.value + ".\n");
		document.mainForm.OrderStatus.value += ("\tYear: " + document.mainForm.Year_6.value);
		document.mainForm.OrderStatus.value += ("\tQuarter: " + qtr6 + "\n");
		document.mainForm.OrderStatus.value += ("\tRegistration District: " + document.mainForm.District_6.value + "\n");
		document.mainForm.OrderStatus.value += ("\tVolume: " + document.mainForm.Volume_6.value);
		document.mainForm.OrderStatus.value += ("\tPage: " + document.mainForm.Page_6.value);
		if (document.mainForm.checkref_6.checked) {
			document.mainForm.OrderStatus.value += (checkrefyes);
			checkref = checkref + 1;
		}
		document.mainForm.OrderStatus.value += ("\n\n");
	}

	document.mainForm.OrderStatus.value += ("\n");



// ADD COMMENTS TO ORDER STATUS WINDOW

	if (document.mainForm.Comments.value != "") {
		document.mainForm.OrderStatus.value += (" - Comments: " + document.mainForm.Comments.value + "\n\n");
	}



// GET RIGHT NUMBER OF ZEROS AFTER AMOUNT

	if (checkref == 1 || checkref == 3 || checkref == 5) {
		suffix = "0";
	}


// SUMAMRY OF BILLING INFORMATION
/*
	if (document.mainForm.CardType.selectedIndex == 1) {
		cardname = document.mainForm.CardType.options[1].value;     // card is Visa
	}
	
	if (document.mainForm.CardType.selectedIndex == 2)	{
	cardname = document.mainForm.CardType.options[2].value;     // card is MC
	}

	if  (document.mainForm.Currency.selectedIndex == 3) {			// for New Zealand customers
		document.mainForm.OrderStatus.value += ("Payment by cheque in New Zealand dollars.\n\n");
	} else {            // for non=New Zealand currencies
		if (cardholder == "" || cardnum == "" || cardexp == "" || cardname == "") {
			document.mainForm.OrderStatus.value += ("NOTE: Your billing information is incomplete.\n\n");
		} else {
		document.mainForm.OrderStatus.value += ("Bill to " + cardholder + "\n" + cardname + " #: " + cardnum + "\nExpiration date: "  + cardexp + "\n\n");
		} 
	}
*/

function currencyFormat () {
	total = (" " + total);	//converts integer to string for manipulation
	len = (total.length - 1);
	dotPosition = total.indexOf(".",0);
	centsDigits = (len - dotPosition);
	if (centsDigits == 1) {
		total = total + "0";	//add a trailing zero if cents are represented by only one digit
	} else if (centsDigits == 0){
		total = total + "00";	//add 2 trailing zeros if total is an integer and decimal point with no cents
	} else if (centsDigits << 0){
		total = total + ".00";	//add 2 trailing zeros plus decimal point 
	}
}
	
	
// CALCULATE TOTAL TO BE BILLED

if (currency == "USD") {
		total = ((cert_qty * USD) + (checkref * refcheckvalUS)); 		//Mod10
		currencyFormat();  //Mod14
		document.mainForm.TotalPayable.value = ("$" + total + " USD");
		document.mainForm.OrderStatus.value += ("TOTAL: $" + total + " USD");
	}
	else if (currency == "AUD") {
		total = ((cert_qty * AUD) + (checkref * refcheckvalAUD)); 		//Mod10
		currencyFormat();	//Mod14
		document.mainForm.TotalPayable.value = ("$" + total + " AUD");
		document.mainForm.OrderStatus.value += ("TOTAL: $" + total + " AUD");
	}
	else if (currency == "NZD") {
		total = ((cert_qty * NZD) + (checkref * refcheckval)); 		//Mod10
		currencyFormat(); //Mod14
		document.mainForm.TotalPayable.value = ("$" + total + " NZD");  //Mod14
		document.mainForm.OrderStatus.value += ("TOTAL: $" + total + " NZD");  //Mod14
	}
	else if (currency == "CAD")	{	
		total = ((cert_qty * CAD) + (checkref * refcheckvalCAD)); 		//Mod10
		currencyFormat(); //Mod114
		document.mainForm.TotalPayable.value = ("$" + total + " CAD");
		document.mainForm.OrderStatus.value += ("TOTAL: $" + total + " CAD");
	}

}

// -->