function getReference()
{
var mod23 = 11
var refno = document.refConv.elements[0].value
var refno = refno.toUpperCase()
  weighting  = new Array(17)
  weighting[0]   = 8;  weighting[1]   = 4;  weighting[2]   = 6;  weighting[3]   = 3
  weighting[4]   = 5;  weighting[5]   = 2;  weighting[6]   = 1;  weighting[7]   = 9;  weighting[8]   = 10
  weighting[9]   = 7;  weighting[10]  = 8;  weighting[11]  = 4;  weighting[12]  = 6;
  weighting[13]   = 3;  weighting[14]  = 5;  weighting[15]  = 2;  weighting[16]  = 1

var chkchr = -999
reg = /\d{18}/
var error_count = 0
if (reg.test(refno) == false) {
	error_count = error_count + 1
	
}
else {
	if(refno.substring(0,2) != "11" && refno.substring(0,2) != "60") {	error_count = error_count + 1 } 
	else {
	
		var prod = 0 ; var total = 0
		for (var i = 0; i < 17; i++) {
			hold = "" + refno.substring(i, i + 1)
			prod = hold * weighting[i]
			
			total = total + prod
		}
		
			var chkchr = refno.substring(17,18)
		}  
		var remainder = total%mod23
		
		var calc_chkchr = mod23 - remainder
		
		if(calc_chkchr == chkchr) {
			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/c2c3-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

  

  return
}