function validPhoneNumber(frmElement){
var check=/^[0-9]{10,11}$/;
var checkPrefix = /^[0]{1}[12]{1}/
frmElement.value=frmElement.value.replace(/\s+/g,"");
var phoneno = frmElement.value;
	if (phoneno == null || phoneno == ""){alert('Please enter your phone number');return false;}
	if (!isNumeric(phoneno)){alert("The phone number entered appears invalid.\nPlease do not enter any non numeric, spaces or + characters.");return false;}
	if (!phoneno.match(check)){alert("The phone number entered appears invalid.\nPlease check that it is numeric, and 10 and 11 digits long.");return false;}	
	if (phoneno.substring(0,1) != "0") {alert("The phone number entered appears invalid.\nPlease make sure that it starts with a 0.");return false;}	
	if (!phoneno.match(checkPrefix)){alert("The phone number entered does not appear to be a standard landline number.\nPlease check that it starts with the digits 01 or 02." );return false;}
	return true;
}
function isNumeric(str){ return ( ('1'+str) == parseInt('1'+str) );}
function replaceWS ( str ){return str.replace(/\s+/g,"");}

function validPostcode(frmElement){
/*
There are 6 possible valid UK postcodes: where L = letter and N = Number
LN NLL LLN NLL LNN NLL LNL NLL LLNN NLL LLNL NLL
*/
var pcode = frmElement.value;
var pcType1 = /^[A-Z]{1}\d{1}\s{1}\d{1}[A-Z]{2}/;
var pcType2 = /^[A-Z]{2}\d{1}\s{1}\d{1}[A-Z]{2}/;
var pcType3 = /^[A-Z]{1}\d{2}\s{1}\d{1}[A-Z]{2}/;
var pcType4 = /^[A-Z]{2}\d{2}\s{1}\d{1}[A-Z]{2}/;
var pcType5 = /^[A-Z]{2}\d{1}[A-Z]{1}\s{1}\d{1}[A-Z]{2}/;
var pcType6 = /^[A-Z]{1}\d{1}[A-Z]{1}\s{1}\d{1}[A-Z]{2}/;
var sAlertEmpty = "Please enter a valid UK post code.";
var sAlertLength = "Sorry, but the postcode you entered was too long or too short. " + sAlertEmpty;
var sAlertInvalid = "Sorry, the postcode [" + frmElement.value + "] is not valid. " + sAlertEmpty;
	if (pcode==null||pcode==""){alert(sAlertEmpty);return false;}
	pcode = formatPostcode(pcode);
	if (pcode.length<6||pcode.length>8){alert(sAlertLength);return false;}	
	if (pcode.match(pcType1)||pcode.match(pcType2)||pcode.match(pcType3)||pcode.match(pcType4)||pcode.match(pcType5)||pcode.match(pcType6)){
		frmElement.value = pcode; return true;
	}
	else {alert(sAlertInvalid);return false;}
}
function formatPostcode(xPC){
	xPC = xPC.toUpperCase();
// replace all spaces
	xRegExp = / /g;
	xPC = xPC.replace(xRegExp, "");
// replace all !
	xRegExp = /!/g;
	xPC = xPC.replace(xRegExp, "");
// now put the space back in the right place
	xLen = xPC.length;
	xLastStart = xLen - 3;
	xPart1 = xPC.substr(0, xLastStart);
	xPart2 = xPC.substr(xLastStart, 3);
	xPC = xPart1 + " " + xPart2;
	return xPC;
}
function ValMaxInput ( objText, Val ){
var msg = "The maximum number of characters allowed is " + Val + ", please remove some."
if (objText.value.length >= Val){alert(msg);return false;objText.focus();}else{return true;}
}

function fChk( Obj, ObjCnt, iVal )
{if (Obj.value.length > iVal) Obj.value = Obj.value.substring(0, iVal);else ObjCnt.value = iVal - Obj.value.length;}
