	// === Validation Functions === //
	function jfIsValid( sValue, strValidChars  ) {
		var isValid = new Boolean()
		isValid=true
		var myChar=""
		var myInt=0

		if (sValue!="" && typeof(sValue)=="string") {
			for (i=0;i<sValue.length;i++) {
				myChar=sValue.charAt(i)
				myInt=strValidChars.indexOf(myChar)

				if (myInt == -1) {
					isValid=false
					break;
				}
			}
		}
		else {
			isValid=false
		}

		return isValid
	}

	function jfIsDate(data,datename)
	{

	// function created : 31.12.03
	// created by 		: Farrakh Aslam
	// input paramaters : data     - the formname
	//datename - the fieldname specified when calling the vbscript date box function
	// description      : Can be used to validate any of the vbscript date box functions
	data = "document." + data + "."

	var day   = eval( data + datename + "_d.value")
	var month = eval( data + datename + "_m.value")
	var year  = eval( data + datename + "_y.value")

	var calcYear = (year % 4 == 0)
	if (!calcYear)
		{
		leapDays = 28
		}
	else
		{
		leapDays = 29
		}

	if (month == 02)
		{
		if (day > leapDays)
		   {
		   return false;
		   }


		}
	else if (month == 04 || month == 06 || month == 09 || month == 11)
		{
		if (day > 30)
		   {
		   return false;
		   }

		}
	return true;
	}


	function jfIsEmail(incoming) {
		var emailstring = incoming;
		var ampIndex = emailstring.indexOf("@");
		var afterAmp = emailstring.substring((ampIndex + 1), emailstring.length);
			// find a dot in the portion of the string after the ampersand only
		var dotIndex = afterAmp.indexOf(".");
			// determine dot position in entire string (not just after amp portion)
		dotIndex = dotIndex + ampIndex + 1;
			// afterAmp will be portion of string from ampersand to dot
		afterAmp = emailstring.substring((ampIndex + 1), dotIndex);
			// afterDot will be portion of string from dot to end of string
		var afterDot = emailstring.substring((dotIndex + 1), emailstring.length);
		var beforeAmp = emailstring.substring(0,(ampIndex));

		var email_regex = /^\w(?:\w|-|\.(?!\.|@))*@\w(?:\w|-|\.(?!\.))*\.\w{2,3}/
			// index of -1 means "not found"
		if ((emailstring.indexOf("@") != "-1") &&
			(emailstring.length > 5) &&
			(afterAmp.length > 0) &&
			(beforeAmp.length > 1) &&
			(afterDot.length > 1) &&
			(email_regex.test(emailstring)) ) {
			  return true;
		} else {
				return false;
		}
	}

	function jfIsPhoneNum( sValue ) {
		var isPhoneNum = new Boolean()
		isPhoneNum=true
		var myChar=""
		var myInt=0
		var strValidChars = "0123456789";

		if (sValue!="" && typeof(sValue)=="string") {
			for (i=0;i<sValue.length;i++) {
				myChar=sValue.charAt(i)
				myInt=strValidChars.indexOf(myChar)

				if (myInt == -1) {
					isPhoneNum=false
				}
			}

		} else {
			isPhoneNum=false
		}

		return isPhoneNum
	}

	function jIsMoney( sValue ) {
		var bMoney = new Boolean()
		bMoney=true
		var myChar=""
		var myInt=0
		var strValidChars = "0123456789.";

		if (sValue!="" && typeof(sValue)=="string") {
			for (i=0;i<sValue.length;i++) {
				myChar=sValue.charAt(i)
				myInt=strValidChars.indexOf(myChar)

				if (myInt == -1) {
					bMoney=false
				}
			}

		} else {
			bMoney=false
		}

		return bMoney
	}
	
	function jfIsInt( sValue ) {
		var isInteger = new Boolean()
		isInteger=true
		var myChar=""
		var myInt=0

		if (sValue!="" && typeof(sValue)=="string") {
			for (i=0;i<sValue.length;i++) {
				myChar=sValue.charAt(i)
				myInt=parseInt(myChar)

				if (isNaN(myInt)) {
					isInteger=false
				}
			}

		} else {
			isInteger=false
		}

		return isInteger
	}


	function jmenu( iMenu, sClassName )
	{
			t=document.getElementById("menu_"+iMenu) ;
			t.className=sClassName;
	}

	function jcallback(){
		frm = document.frmEmail

		if (frm.txtFirstName.value == ""){
			alert("Please enter your Foreame(s).")
			return;
		}
		else if (frm.txtLastName.value == ""){
			alert("Please enter your Surname.")
			return;
		}
		else if (frm.txtPhone.value == ""){
			alert("Please enter your contact telephone number.")
			return;
		}

		frm.submit()
	}
	
	function japply(){
	
		frm = document.frmApply

		if (frm.txtFirstName.value == ""){
			alert("Please enter your first name(s).")
			frm.txtFirstName.focus();
			return;
		}
		else if (frm.txtLastName.value == ""){
			alert("Please enter your last name.")
			frm.txtLastName.focus();
			return;
		}		
		else if (frm.txtAdd1.value == "" ){
			alert("Please enter your address.")
			frm.txtAdd1.focus();
			return;
		}
		else if (frm.optCity.value == 0 ){
			alert("Please enter your city.")
			frm.optCity.focus();
			return;
		}
		else if (frm.optCounty.value == 0 ){
			alert("Please enter your county.")
			frm.optCounty.focus();
			return;
		}		
		else if (frm.txtPostcode.value == "" ){
			alert("Please enter your postcode.")
			frm.txtPostcode.focus();
			return;
		}		
		else if (frm.txtTel1.value == "" ){
			alert("Please enter your home telephone number.")
			frm.txtTel1.focus();
			return;
		}
		else if (frm.txtEmail.value == "" ){
			alert("Please enter your e-mail.")
			frm.txtEmail.focus();
			return;
		}	
		else if (frm.txtQ1.value == "" ){
			alert("Please enter your property value.")
			frm.txtQ1.focus();
			return;
		}
		else if ( jIsMoney(frm.txtQ1.value) == false ){
			alert("Your property value must be a numeric value.")
			frm.txtQ1.focus();
			return;
		}
		else if ( frm.txtQ2.value != "" && jIsMoney(frm.txtQ2.value) == false ){
			alert("Your current mortgage must be a numeric value.")
			frm.txtQ2.focus();
			return;
		}
		else if ( frm.txtQ3.value != "" && jIsMoney(frm.txtQ3.value) == false ){
			alert("Your other loans must be a numeric value.")
			frm.txtQ3.focus();
			return;
		}		
		else if (frm.optDirection.value == 0){
			alert("Please select where did you saw us advertised?")
			frm.optDirection.focus();
			return;
		}
		frm.submit()
	}
	
	function jredraw(){
	
		frm = document.frmApply
		frm.action = "apply.asp"
		frm.submit()
	}	