function getReference()
{
var mod23 = 23
document.refConv.elements[1].value = document.refConv.elements[1].value.toUpperCase()
var refno = document.refConv.elements[0].value + "M" + document.refConv.elements[1].value
var refno = refno.toUpperCase()
  weighting  = new Array(9)
  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(23)
  checkDigits[0] = "A";  checkDigits[1] = "B";  checkDigits[2] = "C";  checkDigits[3] = "D"
  checkDigits[4] = "E";  checkDigits[5] = "F";  checkDigits[6] = "G";  checkDigits[7] = "H"
  checkDigits[8] = "X";  checkDigits[9] = "J";  checkDigits[10] = "K";  checkDigits[11] = "L"
  checkDigits[12] = "M";  checkDigits[13] = "N";  checkDigits[14] = "Y";  checkDigits[15] = "P"
  checkDigits[16] = "Q";  checkDigits[17] = "R";  checkDigits[18] = "S";  checkDigits[19] = "T"
  checkDigits[20] = "Z";  checkDigits[21] = "V";  checkDigits[22] = "W"

var msgTxt = ""
var chkchr = -999
reg = /\d{9}M[A-Z]/
var error_count = 0
if (reg.test(refno) == false) {
	error_count = error_count + 1
}
else {
	var prod = 0 ; var total = 0
	for (var i = 0; i < 9; i++) {
		hold = "" + refno.substring(i, i + 1)
		prod = hold * weighting[i]
		total = total + prod
	}
	var chkchr = refno.substring(10,11)   // always 11th char

}
var remainder = total%mod23
if(checkDigits[remainder] == chkchr) {
	//alert("SDLT Reference is correct")
	error_count = 0
}
else {
	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/sdlt-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
}