function getReference()
{
document.refConv.elements[1].value = document.refConv.elements[1].value.toUpperCase()
var refno = document.refConv.elements[0].value + "A001" + document.refConv.elements[1].value
var mod11 = 11 
weighting  = new Array(13)
weighting[0] = 6;	weighting[1] = 7;	weighting[2] = 8;	weighting[3] = 9
weighting[4] = 10;	weighting[5] = 5;	weighting[6] = 4;	weighting[7] = 3;	weighting[8] = 2;	
checkDigits = new Array(11)
checkDigits[0] = 2;	checkDigits[1] = 1;	checkDigits[2] = 9;	checkDigits[3] = 8
checkDigits[4] = 7;	checkDigits[5] = 6;	checkDigits[6] = 5;	checkDigits[7] = 4
checkDigits[8] = 3;	checkDigits[9] = 2;	checkDigits[10] = 1
var msgTxt = ""
reg = /\d{10}A001\d{2}[A-Z]/
var refno = refno.toUpperCase()
error_count = 0
if (reg.test(refno) == false) {
	// alert("Cotax Reference format invalid. The eleventh character is always 'A' and characters 12-14 are always '001'")
	error_count = error_count + 1
}
else {
	var total = 0
	for (var i = 1; i < 10; i++) {
		var j = i - 1;		hold = "" + refno.substring(i, i + 1);		total = total + hold * weighting[j]
	}	
	var remainder = total%mod11
	if(checkDigits[remainder] == refno.substring(0,1)) {
		 // alert("Cotax Reference is correct")
		error_count = 0
	}
	else {
		// alert("Cotax Reference format invalid. Calculated check digit does not match actual check digit " + refno.substring(0,1))
		error_count = error_count + 1
	}
}
  if (error_count == 0) {alert("Your Reference number is correct.")} 
  else {
	var response = confirm("The reference number is incorrect. Press 'OK' for help or 'Cancel' to try again.")
	if (response) {window.location="/tools/payinghmrc/help/ct-help.htm"}
}

}



/******************/
function clearForm()
/*******************

   File        clearForm.jsm
   Copyright   Crown Copyright 2001

   Date        Author        Changes
   04-Jan-01   Chris Lowe    Created

   Purpose:
        To clear values from form fields. 

   Strategy:
        1. On clicking a button:
        2. Reset field values to null

   Input:
        none

   Output:
        none
--------------------------------------------------------------------- */
{


  document.refConv.elements[0].value = ""               // clear values
  document.refConv.elements[1].value = ""
  

  return
}