<!-- 

// The following functions are included in the script:
//      getTotal - main function executed when form is submitted
//      clearCredit - clear credit card info if NZ currency chosen
//      calcTotal - calculate cost and prepare info for order summary window
//      checkIndex - ensure necessary fields are completed
//      checkDate - ensure proper date range
//      checkForm - ensure main entries on form are completed


// GLOBAL VARIABLES

    var goodForm = false; // added 000611- indicates if form is correctly completed
    var billingNotice =""; // added 000611- to store billing info
    var goodYear = false; // check to see if year value is valid
    var lowYear = 1837; // earliest year for a certificate
    var highYear = 2001; // this year


// ***************** main function executed when form is submitted

function getTotal()	{
	alert ('Your order is about to be prepared.\nClick "OK" and wait for confirmation message.');
    //alert ("Function getTotal before calling calcTotal:\n\nVariable \'goodForm\' has value "+ goodForm + ".");
	calcTotal();
    //alert ("Function getTotal after calling calcTotal:\n\nVariable \'goodForm\' has value "+ goodForm + ".");
    if (goodForm == true){
        document.mainForm.submit();
    } 
}



// ***************** clear credit card info if NZ currency chosen
/*
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 = "";
	}
}
*/
// ***************** Check if Certificat type was chosen

function checkCerttype2(){
	if (document.mainForm.BMD_2.selectedIndex == 0) {
		alert ("Please select the type of certificate you would like (BMD?).");
	}
	document.mainForm.BMD_2.focus();
}

function checkCerttype3(){
	if (document.mainForm.BMD_3.selectedIndex == 0) {
		alert ("Please select the type of certificate you would like (BMD?).");
	}
	document.mainForm.BMD_3.focus();
}

function checkCerttype4(){
	if (document.mainForm.BMD_4.selectedIndex == 0) {
		alert ("Please select the type of certificate you would like (BMD?).");
	}
	document.mainForm.BMD_4.focus();
}

function checkCerttype5(){
	if (document.mainForm.BMD_5.selectedIndex == 0) {
		alert ("Please select the type of certificate you would like (BMD?).");
	}
	document.mainForm.BMD_5.focus();
}

function checkCerttype6(){
	if (document.mainForm.BMD_6.selectedIndex == 0) {
		alert ("Please select the type of certificate you would like (BMD?).");
	}
	document.mainForm.BMD_6.focus();
}
// ***************** CHECK FORM: ENSURE MAIN ENTRIES ON FORM ARE COMPLETED

function dNotice1() {
	if (document.mainForm.BMD_1.selectedIndex == 1) {
		alert ("Birth Certificates within the last 50 years require full details of both parents, date of birth and place of birth in order for the General Register Office to issue the certificate.");
	}
	if (document.mainForm.BMD_1.selectedIndex == 3) {
		alert ("If death occurred less than 50 years ago, it MUST be stated in comments box OR an index check requested. The age should be given in the comments box.");
	}
}

function dNotice2() {
	if (document.mainForm.BMD_2.selectedIndex == 1) {
		alert ("Birth Certificates within the last 50 years require full details of both parents, date of birth and place of birth in order for the General Register Office to issue the certificate.");
	}
	if (document.mainForm.BMD_2.selectedIndex == 3) {
		alert ("If death occurred less than 50 years ago, it MUST be stated in comments box OR an index check requested. The age should be given in the comments box.");
	}
}

function dNotice3() {
	if (document.mainForm.BMD_3.selectedIndex == 1) {
		alert ("Birth Certificates within the last 50 years require full details of both parents, date of birth and place of birth in order for the General Register Office to issue the certificate.");
	}
	if (document.mainForm.BMD_3.selectedIndex == 3) {
		alert ("If death occurred less than 50 years ago, it MUST be stated in comments box OR an index check requested. The age should be given in the comments box.");
	}
}

function dNotice4() {
	if (document.mainForm.BMD_4.selectedIndex == 1) {
		alert ("Birth Certificates within the last 50 years require full details of both parents, date of birth and place of birth in order for the General Register Office to issue the certificate.");
	}
	if (document.mainForm.BMD_4.selectedIndex == 3) {
		alert ("If death occurred less than 50 years ago, it MUST be stated in comments box OR an index check requested. The age should be given in the comments box.");
	}
}

function dNotice5() {
	if (document.mainForm.BMD_5.selectedIndex == 1) {
		alert ("Birth Certificates within the last 50 years require full details of both parents, date of birth and place of birth in order for the General Register Office to issue the certificate.");
	}
	if (document.mainForm.BMD_5.selectedIndex == 3) {
		alert ("If death occurred less than 50 years ago, it MUST be stated in comments box OR an index check requested. The age should be given in the comments box.");
	}
}

function dNotice6() {
	if (document.mainForm.BMD_6.selectedIndex == 1) {
		alert ("Birth Certificates within the last 50 years require full details of both parents, date of birth and place of birth in order for the General Register Office to issue the certificate.");
	}
	if (document.mainForm.BMD_6.selectedIndex == 3) {
		alert ("If death occurred less than 50 years ago, it MUST be stated in comments box OR an index check requested. The age should be given in the comments box.");
	}
}

function checkForm() {

// User identification

	var checkname = document.mainForm.Name.value;
	var checkemail = document.mainForm.email.value;

// Payment variables
/*    
	var checkcurrency = document.mainForm.Currency.selectedIndex;
	var cardtype = document.mainForm.CardType.selectedIndex;
	var cardholder = document.mainForm.NameOnCard.value;
	var cardname = "";
	var cardnum = document.mainForm.CardNumber.value;		
	var cardexp = document.mainForm.ExpiryDate.value;
*/    

// Notices to user

    var error = false; // if true, display errorNotice below
    var errorNotice = "ERROR(S) DETECTED.  Please correct before submitting:   \n"    // contains list of all errors detected

// Positioning variables

    var movetoCerts = false;
    var movetoContact = false;
    var movetoBilling = false;
    var movetoCurrency = false;

// Certificate variables

    // Certificate 1 
   	var bmd1 = document.mainForm.BMD_1.selectedIndex;	// BMD for cert # 1
    var surname1 = document.mainForm.Surname_1.value;  
    var given1 = document.mainForm.Given_1.value;  
    var year1 = document.mainForm.Year_1.value;
    var quarter1 = document.mainForm.Quarter_1.selectedIndex;
    var district1 = document.mainForm.District_1.value;
    var volume1 = document.mainForm.Volume_1.value;
    var page1 = document.mainForm.Page_1.value;
    // no variable for document.mainForm.Page_1.checked ... status is checked using long form

    // Certificate 2 
   	var bmd2 = document.mainForm.BMD_2.selectedIndex;	// null or BMD for cert # 2
    var surname2 = document.mainForm.Surname_2.value;  
    var given2 = document.mainForm.Given_2.value;  
    var year2 = document.mainForm.Year_2.value;
    var quarter2 = document.mainForm.Quarter_2.selectedIndex;
    var district2 = document.mainForm.District_2.value;
    var volume2 = document.mainForm.Volume_2.value;
    var page2 = document.mainForm.Page_2.value;
    // no variable for document.mainForm.Page_2.checked ... status is checked using long form

    // Certificate 3 
   	var bmd3 = document.mainForm.BMD_3.selectedIndex;	// null or BMD for cert # 3
    var surname3 = document.mainForm.Surname_3.value;  
    var given3 = document.mainForm.Given_3.value;  
    var year3 = document.mainForm.Year_3.value;
    var quarter3 = document.mainForm.Quarter_3.selectedIndex;
    var district3 = document.mainForm.District_3.value;
    var volume3 = document.mainForm.Volume_3.value;
    var page3 = document.mainForm.Page_3.value;
    // no variable for document.mainForm.Page_3.checked ... status is checked using long form
    
    // Certificate 4 
   	var bmd4 = document.mainForm.BMD_4.selectedIndex;	// null or BMD for cert # 4
    var surname4 = document.mainForm.Surname_4.value;  
    var given4 = document.mainForm.Given_4.value;  
    var year4 = document.mainForm.Year_4.value;
    var quarter4 = document.mainForm.Quarter_4.selectedIndex;
    var district4 = document.mainForm.District_4.value;
    var volume4 = document.mainForm.Volume_4.value;
    var page4 = document.mainForm.Page_4.value;
    // no variable for document.mainForm.Page_4.checked ... status is checked using long form
    
    // Certificate 5 
   	var bmd5 = document.mainForm.BMD_5.selectedIndex;	// null or BMD for cert # 5
    var surname5 = document.mainForm.Surname_5.value;  
    var given5 = document.mainForm.Given_5.value;  
    var year5 = document.mainForm.Year_5.value;
    var quarter5 = document.mainForm.Quarter_5.selectedIndex;
    var district5 = document.mainForm.District_5.value;
    var volume5 = document.mainForm.Volume_5.value;
    var page5 = document.mainForm.Page_5.value;
    // no variable for document.mainForm.Page_5.checked ... status is checked using long form

    // Certificate 6 
   	var bmd6 = document.mainForm.BMD_6.selectedIndex;	// null or BMD for cert # 6
    var surname6 = document.mainForm.Surname_6.value;  
    var given6 = document.mainForm.Given_6.value;  
    var year6 = document.mainForm.Year_6.value;
    var quarter6 = document.mainForm.Quarter_6.selectedIndex;
    var district6 = document.mainForm.District_6.value;
    var volume6 = document.mainForm.Volume_6.value;
    var page6 = document.mainForm.Page_6.value;
    // no variable for document.mainForm.Page_6.checked ... status is checked using long form


// ============== Check Certificate 1 ==============

    // Note: An entry in surname1 indicates user has started a valid certificate request.
    errorNotice += ("\n")
    if (surname1 == "") {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 1: Enter the surname.\n")
    }
    
    // Check for valid entry for Year
    
    if (isNaN (year1)) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 1: Invalid year format.\n");
    }
    else if (year1 == "" ) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 1: Please enter the \'Year\'.\n");
    } 
    else if (year1 < lowYear ) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 1: Certificates are not available before 1 Jul 1837.\n");
    } 

    else if (year1 > highYear) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 1: The year you have chosen is in the future!.\n");
    }

    // Check if Quarter is unknown
    
    if (quarter1 == 4) {
        document.mainForm.checkref_1.checked = true;
    }

    // Check for Registration District entry
    
    if (district1 == "") {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 1: Enter the \'Registration District\' name.\n")
    }

    // Check for Volume name
    
    if (volume1 == "") {
	document.mainForm.checkref_1.checked = true;
    }

    // Check for Page name
    
    if (page1 == "") {
        document.mainForm.checkref_1.checked = true;
    }

// ============== Check Certificate 2 ==============

    // Note: An entry in bmd2 indicates user has started a valid certificate request.
 
 if (bmd2 != 0) {
    errorNotice += ("\n")
    if (surname2 == "") {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 2: Enter the surname.\n")
    }

    // Check for valid entry for Year
    
    if (isNaN (year2)) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 2: Invalid year format.\n");
    }
    else if (year2 == "" ) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 2: Please enter the \'Year\'.\n");
    } 
    else if (year2 < lowYear ) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 2: Certificates are not available before 1 Jul 1837.\n");
    } 

    else if (year2 > highYear) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 2: The year you have chosen is in the future!.\n");
    }

    // Check if Quarter is unknown
    
    if (quarter2 == 4) {
        document.mainForm.checkref_2.checked = true;
    }

    // Check for Registration District entry
    
    if (district2 == "") {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 2: Enter the \'Registration District\' name.\n")
    }

    // Check for Volume name
    
    if (volume2 == "") {
        document.mainForm.checkref_2.checked = true;
    }

    // Check for Page name
    
    if (page2 == "") {
        document.mainForm.checkref_2.checked = true;
    }
 }   
    
    
// ============== Check Certificate 3 ==============

    // Note: An entry in bmd3 indicates user has started a valid certificate request.
 
 if (bmd3 != 0) {
    errorNotice += ("\n")
    if (surname3 == "") {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 3: Enter the surname.\n")
    }

    // Check for valid entry for Year
    
    if (isNaN (year3)) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 3: Invalid year format.\n");
    }
    else if (year3 == "" ) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 3: Please enter the \'Year\'.\n");
    } 
    else if (year3 < lowYear ) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 3: Certificates are not available before 1 Jul 1837.\n");
    } 

    else if (year3 > highYear) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 3: The year you have chosen is in the future!.\n");
    }

    // Check if Quarter is unknown
    
    if (quarter3 == 4) {
        document.mainForm.checkref_3.checked = true;
    }

    // Check for Registration District entry
    
    if (district3 == "") {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 3: Enter the \'Registration District\' name.\n")
    }

    // Check for Volume name
    
    if (volume3 == "") {
        document.mainForm.checkref_3.checked = true;
    }

    // Check for Page name
    
    if (page3 == "") {
        document.mainForm.checkref_3.checked = true;
    }
 }   
    
    
// ============== Check Certificate 4 ==============

    // Note: An entry in bmd4 indicates user has started a valid certificate request.
 
 if (bmd4 != 0) {
     errorNotice += ("\n")
    if (surname4 == "") {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 4: Enter the surname.\n")
    }

    // Check for valid entry for Year
    
    if (isNaN (year4)) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 4: Invalid year format.\n");
    }
    else if (year4 == "" ) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 4: Please enter the \'Year\'.\n");
    } 
    else if (year4 < lowYear ) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 4: Certificates are not available before 1 Jul 1847.\n");
    } 

    else if (year4 > highYear) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 4: The year you have chosen is in the future!.\n");
    }

    // Check if Quarter is unknown
    
    if (quarter4 == 4) {
        document.mainForm.checkref_4.checked = true;
    }

    // Check for Registration District entry
    
    if (district4 == "") {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 4: Enter the \'Registration District\' name.\n")
    }

    // Check for Volume name
    
    if (volume4 == "") {
        document.mainForm.checkref_4.checked = true;
    }

    // Check for Page name
    
    if (page4 == "") {
        document.mainForm.checkref_4.checked = true;
    }
 }   
    
   
// ============== Check Certificate 5 ==============

    // Note: An entry in bmd5 indicates user has started a valid certificate request.
 
 if (bmd5 != 0) {
    errorNotice += ("\n")
    if (surname5 == "") {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 5: Enter the surname.\n")
    }

    // Check for valid entry for Year
    
    if (isNaN (year5)) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 5: Invalid year format.\n");
    }
    else if (year5 == "" ) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 5: Please enter the \'Year\'.\n");
    } 
    else if (year5 < lowYear ) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 5: Certificates are not available before 1 Jul 1857.\n");
    } 

    else if (year5 > highYear) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 5: The year you have chosen is in the future!.\n");
    }

    // Check if Quarter is unknown
    
    if (quarter5 == 4) {
        document.mainForm.checkref_5.checked = true;
    }

    // Check for Registration District entry
    
    if (district5 == "") {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 5: Enter the \'Registration District\' name.\n")
    }

    // Check for Volume name
    
    if (volume5 == "") {
        document.mainForm.checkref_5.checked = true;
    }

    // Check for Page name
    
    if (page5 == "") {
        document.mainForm.checkref_5.checked = true;
    }
 }   
    
// ============== Check Certificate 6 ==============

    // Note: An entry in bmd6 indicates user has started a valid certificate request.
 
 if (bmd6 != 0) {
    errorNotice += ("\n")
    if (surname6 == "") {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 6: Enter the surname.\n")
    }

    // Check for valid entry for Year
    
    if (isNaN (year6)) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 6: Invalid year format.\n");
    }
    else if (year6 == "" ) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 6: Please enter the \'Year\'.\n");
    } 
    else if (year6 < lowYear ) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 6: Certificates are not available before 1 Jul 1867.\n");
    } 

    else if (year6 > highYear) {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 6: The year you have chosen is in the future!.\n");
    }

    // Check if Quarter is unknown
    
    if (quarter6 == 4) {
        document.mainForm.checkref_6.checked = true;
    }

    // Check for Registration District entry
    
    if (district6 == "") {
        error = true;
        movetoCerts = true;
        errorNotice += ("   - Certificate 6: Enter the \'Registration District\' name.\n")
    }

    // Check for Volume name
    
    if (volume6 == "") {
        document.mainForm.checkref_6.checked = true;
    }

    // Check for Page name
    
    if (page6 == "") {
        document.mainForm.checkref_6.checked = true;
    }
 }   
    
    
    
    
// ============ Check for Name, Email, and Currency ==============    
    
	if (checkname == "" ) {
        error = true;
        movetoContact = true;
  		goodForm = false;
        errorNotice += ("\n   - 'Contact Information': Enter your \'Name\'.\n")
		}

    if (checkemail == "" ) {
        error = true;
        movetoContact = true;
        goodForm = false;
        errorNotice += ("\n   - 'Contact Information': Enter your \'Email Address\'.\n")
		} 
	else {
        goodForm = true;
		}
    
    // Check for type of credit card
/*    
    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 (checkcurrency == 0) {
        error = true;
        movetoCurrency = true;
        goodForm = false;
        errorNotice += ("\n   - 'Select Currency': Enter the \'Currency of Payment\'.\n")
	} else if  (checkcurrency == 3) {			// for New Zealand customers
			billingNotice = ("Payment by cheque in New Zealand dollars.\n");
            goodForm = true;
	} else if (cardholder == "" || cardnum == "" || cardexp == "" || cardname == ""){
        if (cardholder == "") {
            error = true;
            movetoBilling = true;
            goodForm = false;
            errorNotice += ("\n   - Credit Card Order: Enter \'Name on Card\'.")
        } 
        if (cardname == "") {
            error = true;
            movetoBilling = true;
            goodForm = false;
            errorNotice += ("\n   - Credit Card Order: Enter \'Credit card type\'.")
        }
        if (cardexp == "") {
            error = true;
            movetoBilling = true;
            goodForm = false;
            errorNotice += ("\n   - Credit Card Order: Enter \'Expiry date\'.")
        } 
        if (cardnum == "") {
            error = true;
            movetoBilling = true;
            goodForm = false;
            errorNotice += ("\n   - Credit Card Order: Enter \'Card number\'.")
        } 
    } else {
        billingNotice = ("Bill to " + cardholder + "\n" + cardname + " #: " + cardnum + "\nExpiration date: "  + cardexp + "\n");
        goodForm = true;
}

*/

// Positioning - if an error occurs in a particular field, move the user to that area to make the amendments    

//alert ("movertoCerts is "  + movetoCerts + "\nmovetoContact is " + movetoContact + "\nmovetoBilling is " + movetoBilling +"\nmovetoCurrency is "+ movetoCurrency + ".");

if ((movetoCerts == false) && (movetoContact == false) && (movetoBilling == false) && (movetoCurrency == true)) {
    window.location="#currency";
    } else if ((movetoCerts == false) && (movetoContact == false) && (movetoBilling == true)) {
    window.location="#billing";
    } else if ((movetoCerts == false) && (movetoContact == true)) {
    window.location="#contact";
    } else if (movetoCerts == true) {
    window.location="#certs";
    } else {
    window.location = "#review";
    }

// Display the error notices if there are any

    if (error) {
    alert (errorNotice);
	goodForm = false;
    }
       
    
} // end checkForm()


// ***************** CALC-TOTAL: CALCULATE COST AND PREPARE INFO FOR ORDER SUMMARY

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 = "";				// whether transcription or certificate
	var nocert = "Not 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 = 2.00;			// cost of index check in NZ dollars ***
	var refcheckvalUS = 1.00;	// cost of index check in US dollars ***
	var refcheckvalCAD = 2.00;	// cost of index check in CDN dollars ***
	var refcheckvalAUD = 2.00;	// cost of index check in AU dollars ***
	var currency = "NZD";
	var USD = 21;
	var CAD = 25;
	var NZD = 29;
	var surcharge = 2.00; // $2 added if transcript by email or transcript by email and paper for each certificate
	var AUD = 26.5;
//	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
	var checkrefyes = "   Check index.";	// for status window output

//Diagnostic
//alert ("Function calcTotal before calling checkForm:\n\nVariable \'goodForm\' has value "+ goodForm + ".");

checkForm();

//Diagnostic
//alert ("Function calcTotal after calling checkForm:\n\nVariable \'goodForm\' has value "+ goodForm + ".");

// OPENING STATUS

	if (document.mainForm.Certificate_Type.selectedIndex == 0)	{
		certtype = document.mainForm.Certificate_Type.options[0].value;  //Mod10
	} 
	else if (document.mainForm.Certificate_Type.selectedIndex == 1)	{
		certtype = document.mainForm.Certificate_Type.options[1].value;  //Mod10
	}
	else if (document.mainForm.Certificate_Type.selectedIndex == 2)	{
		certtype = document.mainForm.Certificate_Type.options[2].value;
    }
	document.mainForm.OrderStatus.value = ("England and Wales Order: " + certtype + " \n\n");


// DETERMINE CURRENCY OF PAYMENT
/*
curtype = document.mainForm.Currency.selectedIndex;

	if (curtype == 1)	{		// Australian
		currency = document.mainForm.Currency.options[1].value;
	}
	else if (curtype == 2){		// Canadian
		currency = document.mainForm.Currency.options[2].value;
	}
	else if (curtype == 3) {		// New Zealand
		currency = document.mainForm.Currency.options[3].value;
	}
	else if (curtype == 4) {		// American
		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 = "First";
	}
	else if (document.mainForm.Quarter_2.selectedIndex == 1) {
		qtr2 = "Second";
	}
	else if (document.mainForm.Quarter_2.selectedIndex == 2) {
		qtr2 = "Third";
	}
	else if (document.mainForm.Quarter_2.selectedIndex == 3) {
		qtr2 = "Fourth";
	}
	else if (document.mainForm.Quarter_2.selectedIndex == 4) {
		qtr2 = "Unknown";
	}


	if (document.mainForm.Quarter_3.selectedIndex == 0) {
		qtr3 = "First";
	}
	else if (document.mainForm.Quarter_3.selectedIndex == 1) {
		qtr3 = "Second";
	}
	else if (document.mainForm.Quarter_3.selectedIndex == 2) {
		qtr3 = "Third";
	}
	else if (document.mainForm.Quarter_3.selectedIndex == 3) {
		qtr3 = "Fourth";
	}
	else if (document.mainForm.Quarter_3.selectedIndex == 4) {
		qtr3 = "Unknown";
	}
	

	if (document.mainForm.Quarter_4.selectedIndex == 0) {
		qtr4 = "First";
	}
	else if (document.mainForm.Quarter_4.selectedIndex == 1) {
		qtr4 = "Second";
	}
	else if (document.mainForm.Quarter_4.selectedIndex == 2) {
		qtr4 = "Third";
	}
	else if (document.mainForm.Quarter_4.selectedIndex == 3) {
		qtr4 = "Fourth";
	}
	else if (document.mainForm.Quarter_4.selectedIndex == 4) {
		qtr4 = "Unknown";
	}


	if (document.mainForm.Quarter_5.selectedIndex == 0) {
		qtr5 = "First";
	}
	else if (document.mainForm.Quarter_5.selectedIndex == 1) {
		qtr5 = "Second";
	}
	else if (document.mainForm.Quarter_5.selectedIndex == 2) {
		qtr5 = "Third";
	}
	else if (document.mainForm.Quarter_5.selectedIndex == 3) {
		qtr5 = "Fourth";
	}
	else if (document.mainForm.Quarter_5.selectedIndex == 4) {
		qtr5 = "Unknown";
	}


	if (document.mainForm.Quarter_6.selectedIndex == 0) {
		qtr6 = "First";
	}
	else if (document.mainForm.Quarter_6.selectedIndex == 1) {
		qtr6 = "Second";
	}
	else if (document.mainForm.Quarter_6.selectedIndex == 2) {
		qtr6 = "Third";
	}
	else if (document.mainForm.Quarter_6.selectedIndex == 3) {
		qtr6 = "Fourth";
	}
	else if (document.mainForm.Quarter_6.selectedIndex == 4) {
		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 += ("   Year: " + document.mainForm.Year_1.value);
		document.mainForm.OrderStatus.value += ("   Quarter: " + qtr1 + "\n");
		document.mainForm.OrderStatus.value += ("   Registration District: " + document.mainForm.District_1.value + "\n");
		document.mainForm.OrderStatus.value += ("   Volume: " + document.mainForm.Volume_1.value);
		document.mainForm.OrderStatus.value += ("   Page: " + 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 += ("   Year: " + document.mainForm.Year_2.value);
		document.mainForm.OrderStatus.value += ("   Quarter: " + qtr2 + "\n");
		document.mainForm.OrderStatus.value += ("   Registration District: " + document.mainForm.District_2.value + "\n");
		document.mainForm.OrderStatus.value += ("   Volume: " + document.mainForm.Volume_2.value);
		document.mainForm.OrderStatus.value += ("   Page: " + 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 += ("   Year: " + document.mainForm.Year_3.value);
		document.mainForm.OrderStatus.value += ("   Quarter: " + qtr3 + "\n");
		document.mainForm.OrderStatus.value += ("   Registration District: " + document.mainForm.District_3.value + "\n");
		document.mainForm.OrderStatus.value += ("   Volume: " + document.mainForm.Volume_3.value);
		document.mainForm.OrderStatus.value += ("   Page: " + 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 += ("   Year: " + document.mainForm.Year_4.value);
		document.mainForm.OrderStatus.value += ("   Quarter: " + qtr4 + "\n");
		document.mainForm.OrderStatus.value += ("   Registration District: " + document.mainForm.District_4.value + "\n");
		document.mainForm.OrderStatus.value += ("   Volume: " + document.mainForm.Volume_4.value);
		document.mainForm.OrderStatus.value += ("   Page: " + 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 += ("   Year: " + document.mainForm.Year_5.value);
		document.mainForm.OrderStatus.value += ("   Quarter: " + qtr5 + "\n");
		document.mainForm.OrderStatus.value += ("   Registration District: " + document.mainForm.District_5.value + "\n");
		document.mainForm.OrderStatus.value += ("   Volume: " + document.mainForm.Volume_5.value);
		document.mainForm.OrderStatus.value += ("   Page: " + 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 += ("   Year: " + document.mainForm.Year_6.value);
		document.mainForm.OrderStatus.value += ("   Quarter: " + qtr6 + "\n");
		document.mainForm.OrderStatus.value += ("   Registration District: " + document.mainForm.District_6.value + "\n");
		document.mainForm.OrderStatus.value += ("   Volume: " + document.mainForm.Volume_6.value);
		document.mainForm.OrderStatus.value += ("   Page: " + 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");


// xxxxxxxxxxxxxxxxxxxxxxxxxx CHECK FREE BMD xxxxxxxxxxxxxxxxxxxxxxx
//
//	if (document.mainForm.FreeBMD[0].checked) {
//		document.mainForm.OrderStatus.value += (" - Free BMD Checked: No\n\n");
//	}
//	else if (document.mainForm.FreeBMD[1].checked) {
//		document.mainForm.OrderStatus.value += (" - Free BMD Checked: Yes\n\n");
//	}
// removed 25 Jun 2005

// ADD COMMENTS TO ORDER STATUS WINDOW

	if (document.mainForm.Comments.value != "") {
		document.mainForm.OrderStatus.value += (" - Comments: " + document.mainForm.Comments.value + "\n\n");
	}

//CHANGES TOTAL BILLED TO CURRENCY FUNCTION ... Mod14

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 
	}
}
	

// ADD BILLING INFORMATION

document.mainForm.OrderStatus.value += (billingNotice + "\n");


	
// CALCULATE TOTAL TO BE BILLED

if (currency == "USD") {
		total = ((cert_qty * USD) + (checkref * refcheckvalUS)); 		//Mod10
        if (document.mainForm.Certificate_Type.selectedIndex == 1) {
        total += (cert_qty * surcharge);
        }
		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
        if (document.mainForm.Certificate_Type.selectedIndex == 1) {
        total += (cert_qty * surcharge);
        }
		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
		if (document.mainForm.Certificate_Type.selectedIndex == 1) {
        total += (cert_qty * surcharge);
        }
        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
        if (document.mainForm.Certificate_Type.selectedIndex == 1) {
        total += (cert_qty * surcharge);
        }
        currencyFormat(); //Mod114
		document.mainForm.TotalPayable.value = ("$" + total + " CAD");
		document.mainForm.OrderStatus.value += ("Total: $" + total + " CAD");
	}

}

// -->