// JavaScript Document

<!--


var ie5 = (document.getElementById && document.all);
var ns6 = (document.getElementById && !document.all);

var alpha = "abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ";
var numeric = "1234567890";
var dateMsg = "";
var dtCh= "/";
var minYear=1900;
var maxYear=2100;


function getObj(n, d) { 
  var p,i,x;  
  if(!d) {
		d=document; 
	}
	if((p=n.indexOf("?")) > 0 && parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; 
    n=n.substring(0,p);
  }
  if(!(x=d[n]) && d.all) {
		x=d.all[n]; 
	}
	for (i=0; !x && i<d.forms.length; i++) {
		x=d.forms[i][n];
	}
  for(i=0; !x&&d.layers && i<d.layers.length; i++) {
		x=getObj(n,d.layers[i].document);
	}
  if(!x && d.getElementById) {
		x=d.getElementById(n); 
	}
	return x;
}


// -----------------------------------------------------------------------------------------------------------
// sets the background colour of an element
// -----------------------------------------------------------------------------------------------------------

function setBGColor(elementName, colour) {
	element = getObj(elementName);
	try {
		element.style.backgroundColor = colour;
	} catch (e) {
		alert(e);
	}
}
/**
// -----------------------------------------------------------------------------------------------------------
//   TEMPLATE FOR VALIDATION FUNCTIONS
// -----------------------------------------------------------------------------------------------------------

function validateFunctionTemplate(normalColour, errorColour) {
	var msg = 'Please correct the following errors:\n';
	msg += '-------------------------------------------\n\n';
	
	var ok = true;
	
	// do this for every form element you are validating
	setBGColor("!!yourElementNameHere!!",normalColour);
	
	// use the functions listed below to check your form elements
	if (!isThere("!!yourElementNameHere!!")) {
		ok = false;
		msg += "Please enter yourElementNameHere\n";
		setBGColor("!!yourElementNameHere!!",errorColour);
	}


	// if ok submit, it not display the errors
	if (!ok) {
		alert(msg);
	} else {
		document.!!yourFormNameHere!!.submit();
	}		

}
**/


// -----------------------------------------------------------------------------------------------------------
// form validation functions
// -----------------------------------------------------------------------------------------------------------
function getObj(n, d) { 
  var p,i,x;  
  if(!d) {
		d=document; 
	}
	if((p=n.indexOf("?")) > 0 && parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; 
    n=n.substring(0,p);
  }
  if(!(x=d[n]) && d.all) {
		x=d.all[n]; 
	}
	for (i=0; !x && i<d.forms.length; i++) {
		x=d.forms[i][n];
	}
  for(i=0; !x&&d.layers && i<d.layers.length; i++) {
		x=getObj(n,d.layers[i].document);
	}
  if(!x && d.getElementById) {
		x=d.getElementById(n); 
	}
	return x;
}
// -----------------------------------------------------------------------------------------------------------
// checkes that a value has been entered
// -----------------------------------------------------------------------------------------------------------
function isThere(elementName) {
	var element = getObj(elementName);
	if (element.value == "") {
		return false;
	} else {
		return true;
	}
}

// -----------------------------------------------------------------------------------------------------------
// sets the background colour of an element
// -----------------------------------------------------------------------------------------------------------

function setBGColor(elementName, colour) {
	element = getObj(elementName);
	try {
		element.style.backgroundColor = colour;
	} catch (e) {
		alert(e);
	}
}

// -----------------------------------------------------------------------------------------------------------
// checks that a value has been entered and that it follows an email format.
// -----------------------------------------------------------------------------------------------------------
function emailCheck(elementName) 
{
	var email = getObj(elementName).value;
	invalidChars = " /:,;"

	if (email == "") {
		return false;
	}
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false;
		}
	}
	atPos = email.indexOf("@",1)
	if (atPos == -1) {
		return false;
	}
	if (email.indexOf("@",atPos+1) > -1) {
		return false;
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {
		return false;
	}
	//if (periodPos+3 > email.length)	{
		//return false;
	//}
	return true;
}

// -----------------------------------------------------------------------------------------------------------
// Validate Form function
// -----------------------------------------------------------------------------------------------------------

function validate_contact_form()
{
	//Check fields completed
	//Ensure email is valid and confirm_email is identical
	//var theForm = document.forms("fm_contact")
	//theForm.submit();

	var msg = ''	
	var ok = true;
	var sendmag = true;
	
	var normalColour = 'FFFFFF';	
	var errorColour = 'C7E0EF';
	
	var chk_terms = getObj('chk_terms');
	//var free_mag1 = getObj('free_mag1');
	//var free_mag2 = getObj('free_mag2');
	//var free_mag3 = getObj('free_mag3');
	
	// do this for every form element you are validating
	setBGColor("txt_first_name", normalColour);
	setBGColor("txt_last_name", normalColour);
	setBGColor("txt_email", normalColour);
	setBGColor("txt_tel", normalColour);
	setBGColor("txt_confirm_email", normalColour);
	setBGColor("txt_address1", normalColour);
	setBGColor("txt_address2", normalColour);
	setBGColor("txt_address3", normalColour);
	setBGColor("txt_address4", normalColour);
	setBGColor("txt_postcode", normalColour);
	setBGColor("chk_terms", normalColour);
	
	// use the functions listed below to check your form elements
	if (!isThere("txt_first_name")) {
		ok = false;
		msg += "Please enter your first name\n";
		setBGColor("txt_first_name",errorColour);
	}

	if (!isThere("txt_last_name")) {
		ok = false;
		msg += "Please enter your last name\n";
		setBGColor("txt_last_name",errorColour);
	}

	
	//if (!isThere("txt_tel")||!isNumeric("txt_tel") ) {
	//	ok = false;
		//msg += "Please enter your telephone number using numbers only\n";
		//setBGColor("txt_tel",errorColour);
	//}

	if (!isNumeric("txt_tel")) {
		ok = false;
		msg += "Please enter a telephone number (numbers only)\n";
		setBGColor("txt_tel",errorColour);
	}
	
	if (!emailCheck("txt_email")) {
		ok = false;
		msg += "Please enter a valid email address\n";
		setBGColor("txt_email",errorColour);
	}
	
	var strEmail, strConfirmEmail
	strEmail = getObj("txt_email").value;
	strConfirmEmail = getObj("txt_confirm_email").value;
	

	if (!emailCheck("txt_confirm_email") || strEmail != strConfirmEmail) {
		ok = false;
		msg += "Please ensure the two email addresses are identical\n";
		setBGColor("txt_confirm_email",errorColour);
		}
	
	if (!isThere("txt_address1")) {
		ok = false;
		msg += "Please enter the first line of your address\n";
		setBGColor("txt_address1",errorColour);
	}
	if (!isThere("txt_address2")) {
		ok = false;
		msg += "Please enter the second line of your address\n";
		setBGColor("txt_address2",errorColour);
	}
	if (!isThere("txt_address3")) {
		ok = false;
		msg += "Please enter the third line of your address\n";
		setBGColor("txt_address3",errorColour);
	}
	if (!isThere("txt_address4")) {
		ok = false;
		msg += "Please enter your country\n";
		setBGColor("txt_address4",errorColour);
	}
	if (!isThere("txt_postcode")) {
		ok = false;
		msg += "Please enter your postcode\n";
		setBGColor("txt_postcode",errorColour);
	}
	
	if(!chk_terms.checked)
	{
		ok = false;
		msg += 'Please tick the box to confirm you have read the Terms & Conditions.\n';
		setBGColor("chk_terms",normalColour);
	}

	//if(!free_mag1.checked){
	
		//if(!free_mag2.checked){
		
			//if(!free_mag3.checked){
		
				//ok = false;
				//msg += 'World of Property are happy to send you One Free Magazine.\n';
				//setBGColor("free_mag1",errorColour);
			//}
		//}	
	//}
	
	//if(free_mag1.checked)
	//{
		//if(free_mag2.checked || free_mag3.checked) 
			//sendmag = false;
			//setBGColor("free_mag1",errorColour);
	//}
	//if(free_mag2.checked)
	//{
		//if(free_mag1.checked || free_mag3.checked) 
			//sendmag = false;
			//setBGColor("free_mag2",errorColour);
	//}
	//if(free_mag3.checked)
	//{
		//if(free_mag1.checked || free_mag2.checked) 
			//sendmag = false;
			//setBGColor("free_mag3",errorColour);
	//}

	if (!ok) {
		if (!sendmag) {
			msg += 'You are entilted to ONE free magazine only';
			}
		alert(msg);
		return false;
	} else {
		document.fm_contact.submit();
	}
}


function validate_enquiry_form()
{
	//Check fields completed
	//Ensure email is valid and confirm_email is identical
	//var theForm = document.forms("fm_enquiry")
	//theForm.submit();

	var msg = ''
	var ok = true;
	var sendmag = true;
	
	var normalColour = 'FFFFFF';	
	var errorColour = 'C7E0EF';
	
	var chk_terms = getObj('chk_terms');
	
	var free_mag1 = getObj('free_mag1');
	var free_mag2 = getObj('free_mag2');
	var free_mag3 = getObj('free_mag3');
	

	// do this for every form element you are validating
	setBGColor("txt_first_name", normalColour);
	setBGColor("txt_last_name", normalColour);
	setBGColor("txt_email", normalColour);
	setBGColor("txt_tel", normalColour);
	setBGColor("txt_confirm_email", normalColour);
	setBGColor("txt_address1", normalColour);
	setBGColor("txt_address2", normalColour);
	setBGColor("txt_address3", normalColour);
	setBGColor("txt_address4", normalColour);
	setBGColor("txt_postcode", normalColour);
	setBGColor("chk_terms", normalColour);
	setBGColor("free_mag1", normalColour);
	//setBGColor("free_mag2", normalColour);
	setBGColor("free_mag3", normalColour);

	// use the functions listed below to check your form elements
	if (!isThere("txt_first_name")) {
		ok = false;
		msg += "Please enter your first name\n";
		setBGColor("txt_first_name",errorColour);
	}

	if (!isThere("txt_last_name")) {
		ok = false;
		msg += "Please enter your last name\n";
		setBGColor("txt_last_name",errorColour);
	}

	if (!emailCheck("txt_email")) {
		ok = false;
		msg += "Please enter a valid email address\n";
		setBGColor("txt_email",errorColour);
	}
	
	var strEmail, strConfirmEmail
	strEmail = getObj("txt_email").value;
	strConfirmEmail = getObj("txt_confirm_email").value;
	

	if (!emailCheck("txt_confirm_email") || strEmail != strConfirmEmail) {
		ok = false;
		msg += "Please ensure the two email addresses are identical\n";
		setBGColor("txt_confirm_email",errorColour);
		}
	if (!isThere("txt_tel")||!isNumeric("txt_tel") ) {
		ok = false;
		msg += "Please enter your telephone number using numbers only\n";
		setBGColor("txt_tel",errorColour);
	}
	
	if (!isThere("txt_address1")) {
		ok = false;
		msg += "Please enter the first line of your address\n";
		setBGColor("txt_address1",errorColour);
	}
	if (!isThere("txt_address2")) {
		ok = false;
		msg += "Please enter the second line of your address\n";
		setBGColor("txt_address2",errorColour);
	}
	if (!isThere("txt_address3")) {
		ok = false;
		msg += "Please enter the third line of your address\n";
		setBGColor("txt_address3",errorColour);
	}
	if (!isThere("txt_address4")) {
		ok = false;
		msg += "Please enter your country\n";
		setBGColor("txt_address4",errorColour);
	}
	if (!isThere("txt_postcode")) {
		ok = false;
		msg += "Please enter your postcode\n";
		setBGColor("txt_postcode",errorColour);
	}
	
	if(!chk_terms.checked)
	{
		ok = false;
		msg += 'Please tick the box to confirm you have read the Terms & Conditions.\n';
		setBGColor("chk_terms",normalColour);
	}
	
	//if(!free_mag1.checked){
	
		//if(!free_mag2.checked){
		
			//if(!free_mag3.checked){
		
				//ok = false;
				//msg += 'World of Property are happy to send you One Free Magazine.\n';
				//setBGColor("free_mag1",errorColour);
			//}
		//}	
	//}
	
	//if(free_mag1.checked)
	//{
		//if(free_mag2.checked || free_mag3.checked) 
			//sendmag = false;
			//setBGColor("free_mag1",errorColour);
	//}
	
	//if(free_mag2.checked)
	//{
		//if(free_mag1.checked || free_mag3.checked) 
			//sendmag = false;
			//setBGColor("free_mag2",errorColour);
	//}
	
	//if(free_mag3.checked)
	//{
		//if(free_mag1.checked || free_mag2.checked) 
			//sendmag = false;
			//setBGColor("free_mag3",errorColour);
	//}

	
	
	
	// if ok submit, if not display the errors
	if (!ok) {
		//if (!sendmag) {
			//msg += 'You are entilted to ONE free magazine only';
			//}
		alert(msg);
		return false;
	} else {
		document.fm_enquiry.submit();
	}
}




// -----------------------------------------------------------------------------------------------------------
// checkes that a value has been entered
// -----------------------------------------------------------------------------------------------------------
function isThere(elementName) {
	var element = getObj(elementName);
	if (element.value == "") {
		return false;
	} else {
		return true;
	}
}

// -----------------------------------------------------------------------------------------------------------
// sets the background colour of an element
// -----------------------------------------------------------------------------------------------------------

function setBGColor(elementName, colour) {
	element = getObj(elementName);
	try {
		element.style.backgroundColor = colour;
	} catch (e) {
		alert(e);
	}
}

// -----------------------------------------------------------------------------------------------------------
// check a form elements length agains the entered value
// -----------------------------------------------------------------------------------------------------------
function checkLength(elementName, length) {
	var element = getObj(elementName);
	if (element.value.length < length) {
		return false;
	} else {
		return true;
	}
}

// -----------------------------------------------------------------------------------------------------------
// checkes to see if a select drop box matches a particular value
// -----------------------------------------------------------------------------------------------------------
function selectMatches(elementName, value) {
	var element = getObj(elementName);
	var elementValue = element.options[element.selectedIndex].value;
	if (elementValue == value) {
		return true;
	} else {
		return false;
	}
}

function isSelected(elementName) {
	var element = getObj(elementName);
    if (element.selectedIndex==0)
    {
        return false;
    }
    else
    {
        return true;    
    }
}


// -----------------------------------------------------------------------------------------------------------
// checkes to see if a value has been entered and that it is numeric
// -----------------------------------------------------------------------------------------------------------
function isNumeric(elementName) {
	var element = getObj(elementName);
	var strString = element.value;
	if (strString == "") {
		return false;
	}
  var strValidChars = "0123456789.";
  var strChar;
  var blnResult = true;

  if (strString.length == 0) return false;

  //  test strString consists of valid characters listed above
  for (i = 0; i < strString.length && blnResult == true; i++)
     {
     strChar = strString.charAt(i);
     if (strValidChars.indexOf(strChar) == -1)
        {
        blnResult = false;
        }
     }
  return blnResult;

}

// -----------------------------------------------------------------------------------------------------------
// checkes to see if a value has been entered and that it matches a credit card (can include spaces)
// -----------------------------------------------------------------------------------------------------------
function isCC(elementName) {
	var element = getObj(elementName);
	var strString = element.value;
	if (strString == "") {
		return false;
	}
  var strValidChars = "0123456789 ";
  var strChar;
  var blnResult = true;

  if (strString.length == 0) return false;

  //  test strString consists of valid characters listed above
  for (i = 0; i < strString.length && blnResult == true; i++)
     {
     strChar = strString.charAt(i);
     if (strValidChars.indexOf(strChar) == -1)
        {
        blnResult = false;
        }
     }
  return blnResult;

}

// -----------------------------------------------------------------------------------------------------------
// checkes to see if a value has been entered and that it matches a phone number
// does not do format checking, only checks that the characters entered are
// valid for a phone number
// -----------------------------------------------------------------------------------------------------------
function isPhoneNumber(elementName) {
	var element = getObj(elementName);
	var strString = element.value;
	if (strString == "") {
		return false;
	}
  var strValidChars = "0123456789 ()+";
  var strChar;
  var blnResult = true;

  if (strString.length == 0) return false;

  //  test strString consists of valid characters listed above
  for (i = 0; i < strString.length && blnResult == true; i++)
     {
     strChar = strString.charAt(i);
     if (strValidChars.indexOf(strChar) == -1)
        {
        blnResult = false;
        }
     }
  return blnResult;

}

// -----------------------------------------------------------------------------------------------------------
// checks if two elements values match
// -----------------------------------------------------------------------------------------------------------
function valuesMatch(element1, element2) {
	var e1 = getObj(element1);
	var e2 = getObj(element2);
	if (e1.value == e2.value) {
		return true;
	} else {
		return false;
	}
}

// -----------------------------------------------------------------------------------------------------------
// checks that a value has been entered and that it follows an email format.
// -----------------------------------------------------------------------------------------------------------
function emailCheck(elementName) 
{
	var email = getObj(elementName).value;
	invalidChars = " /:,;"

	if (email == "") {
		return false;
	}
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false;
		}
	}
	atPos = email.indexOf("@",1)
	if (atPos == -1) {
		return false;
	}
	if (email.indexOf("@",atPos+1) > -1) {
		return false;
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {
		return false;
	}
	if (periodPos+3 > email.length)	{
		return false;
	}
	return true;
}

// -----------------------------------------------------------------------------------------------------------
// checks that a value has been entered and that it is a valid date
// -----------------------------------------------------------------------------------------------------------

function isDate(dtStr){
	var daysInMonth = DaysArray(12);
	var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);
	var strDay=dtStr.substring(0,pos1);
	var strMonth=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);
	strYr=strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1);
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1);
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1);
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	if (pos1==-1 || pos2==-1){
		dateMsg = "The date format should be : mm/dd/yyyy";
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12){
		dateMsg = "Please enter a valid month";
		return false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		dateMsg = "Please enter a valid day";
		return false;
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		dateMsg = "Please enter a valid 4 digit year between "+minYear+" and "+maxYear;
		return false;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		dateMsg = "Please enter a valid date"
		return false;
	}
	return true;
}

// -----------------------------------------------------------------------------------------------------------
// Utility function for isDate()
// -----------------------------------------------------------------------------------------------------------

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

// -----------------------------------------------------------------------------------------------------------
// Utility function for isDate()
// -----------------------------------------------------------------------------------------------------------

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

// -----------------------------------------------------------------------------------------------------------
// Utility function for isDate()
// -----------------------------------------------------------------------------------------------------------

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31;
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
		if (i==2) {this[i] = 29;}
   } 
   return this
}

// -----------------------------------------------------------------------------------------------------------
// Other functions
// -----------------------------------------------------------------------------------------------------------


// -----------------------------------------------------------------------------------------------------------
// formats a number to a particular number of decimals
// -----------------------------------------------------------------------------------------------------------
function formatNumber(expr, decplaces) {
	var str = "" + Math.round(eval(expr) * Math.pow(10, decplaces));
	while (str.length <= decplaces)
	{
		str += "0";
	}

	var decpoint = str.length - decplaces;

	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
}

function showhide(qid) {
	for (var x=1; x <= 50; x++) {
	
		if (getObj('answer-' + x) != null) {
			getObj('answer-' + x).style.display = 'none';
		}
	}
	getObj('answer-' + qid).style.display = 'block';
}





function typeit(){
	getObj('typing').insertAdjacentText("beforeEnd",". ")
	setTimeout("typeit()",100)
}

function golink() {
	var sel = getObj('quicklinks').options[getObj('quicklinks').selectedIndex].value;
	window.document.location = sel;
}

function displaydatetime() {
	dateVar = new Date();
	thisday = dateVar.getDate();
	thismonth = getCalendarMonth(dateVar.getMonth());
	thisyear = dateVar.getFullYear();
	thishrs = dateVar.getHours();
	thismins = String(dateVar.getMinutes());
	
	if (thismins.length < 2) {
		thismins = '0' + thismins;
	}
	
	document.write(thisday + ' ' + thismonth + ' ' + thisyear + ' ' + thishrs + ':' + thismins);
	
	function getCalendarMonth(monthNum) {
			
		var moy = new Array(12)
		moy[0] = "January" 
		moy[1] = "February" 
		moy[2] = "March" 
		moy[3] = "April" 
		moy[4] = "May" 
		moy[5] = "June" 
		moy[6] = "July" 
		moy[7] = "August" 
		moy[8] = "September" 
		moy[9] = "October" 
		moy[10] = "November" 
		moy[11] = "December" 
		return moy[monthNum] 
	}
}

function openWindow(theURL, winName, features) {
	newWin=window.open(theURL, winName, features);
	newWin.originalWindow=window; // keep a reference to this window
}

function setBGColour(element, colour){

	element.style.backgroundColor = colour;

}


function ValidateEnquiryForm(){
	var strMsg = 'Please correct the following...\n---------------------------------------\n';
	var blnCanSubmit = true;
	

	var frmTitle = document.getElementById('frmTitle');
	var frmFirstName = document.getElementById('frmFirstName');
	var frmLastName = document.getElementById('frmLastName');
	var frmEmailAddress = document.getElementById('frmEmailAddress');
	var frmEnquiry = document.getElementById('frmEnquiry');
	var frmComplete = document.getElementById('hdnfrmcomplete');

	var strPleaseCorrectColour;
	var strOKColour;
	
	strPleaseCorrectColour = 'C7E0EF';
	strOKColour = 'FFFFFF';	

		
	setBGColour(frmTitle,strOKColour);
	if (frmTitle.value == 0) {
		setBGColour(frmTitle,strPleaseCorrectColour);
		blnCanSubmit = false;
		strMsg += "Please select your Title \n";
	}
		
	setBGColour(frmFirstName,strOKColour);
	if(frmFirstName.value == ''){
		setBGColour(frmFirstName,strPleaseCorrectColour);
		blnCanSubmit = false;
		strMsg += 'Please enter your first name.\n';
	}
	
	setBGColour(frmLastName,strOKColour);
	if(frmLastName.value == ''){
		setBGColour(frmLastName,strPleaseCorrectColour);
		blnCanSubmit = false;
		strMsg += 'Please enter your last name.\n';
	}	

	setBGColour(frmEmailAddress,strOKColour);
	if(!emailCheck("frmEmailAddress")){
		setBGColour(frmEmailAddress,strPleaseCorrectColour);
		blnCanSubmit = false;
		strMsg += 'Please enter a valid email address.\n';
	}	

	setBGColour(frmEnquiry,strOKColour);
	if(frmEnquiry.value == ''){
		setBGColour(frmEnquiry,strPleaseCorrectColour);
		blnCanSubmit = false;
		strMsg += 'Please enter your enquiry.\n';
	}
		
	
	if(blnCanSubmit == false){
		alert(strMsg);
		return false;
	}else{
		frmComplete.value = 'query';
		document.EnquiryForm.submit();
	}

}

//-->

// this function gets the page number and submits the form

function submit_propertysearch_form(pageNo){
//alert ('in function');
	var pageNumber;
	pageNumber = pageNo;
	var frmpageid = document.getElementById('frmpageid');
	frmpageid.value = pageNo;
	document.propertySearch.submit();
	//alert('form sub');
	
}
function validate_competition_form()
{
	//Check fields completed
	//Ensure email is valid and confirm_email is identical
	//var theForm = document.forms("fm_contact")
	//theForm.submit();

	var msg = ''	
	var ok = true;
	var sendmag = true;
	
	var normalColour = 'FFFFFF';	
	var errorColour = 'C7E0EF';
	
	var chk_terms = getObj('chk_terms');
	
	// do this for every form element you are validating
	setBGColor("txt_first_name", normalColour);
	setBGColor("txt_last_name", normalColour);
	setBGColor("txt_email", normalColour);
	setBGColor("txt_tel", normalColour);
	setBGColor("txt_confirm_email", normalColour);
	setBGColor("txt_address1", normalColour);
	setBGColor("txt_address2", normalColour);
	setBGColor("txt_address3", normalColour);
	setBGColor("txt_address4", normalColour);
	setBGColor("txt_postcode", normalColour);
	setBGColor("chk_terms", normalColour);
	
	// use the functions listed below to check your form elements
	if (!isThere("txt_first_name")) {
		ok = false;
		msg += "Please enter your first name\n";
		setBGColor("txt_first_name",errorColour);
	}

	if (!isThere("txt_last_name")) {
		ok = false;
		msg += "Please enter your last name\n";
		setBGColor("txt_last_name",errorColour);
	}

	if (!emailCheck("txt_email")) {
		ok = false;
		msg += "Please enter a valid email address\n";
		setBGColor("txt_email",errorColour);
	}
	
	var strEmail, strConfirmEmail
	strEmail = getObj("txt_email").value;
	strConfirmEmail = getObj("txt_confirm_email").value;
	

	if (!emailCheck("txt_confirm_email") || strEmail != strConfirmEmail) {
		ok = false;
		msg += "Please ensure the two email addresses are identical\n";
		setBGColor("txt_confirm_email",errorColour);
		}
	
	if (!isThere("txt_address1")) {
		ok = false;
		msg += "Please enter the first line of your address\n";
		setBGColor("txt_address1",errorColour);
	}
	if (!isThere("txt_address2")) {
		ok = false;
		msg += "Please enter the second line of your address\n";
		setBGColor("txt_address2",errorColour);
	}
	if (!isThere("txt_address3")) {
		ok = false;
		msg += "Please enter the third line of your address\n";
		setBGColor("txt_address3",errorColour);
	}
	if (!isThere("txt_address4")) {
		ok = false;
		msg += "Please enter your country\n";
		setBGColor("txt_address4",errorColour);
	}
	if (!isThere("txt_postcode")) {
		ok = false;
		msg += "Please enter your postcode\n";
		setBGColor("txt_postcode",errorColour);
	}
	
	if(!chk_terms.checked)
	{
		ok = false;
		msg += 'Please tick the box to confirm you have read the Terms & Conditions.\n';
		setBGColor("chk_terms",normalColour);
	}

	
	if (!ok) {
		
		alert(msg);
		return false;
	} else {
		document.fm_competition.submit();
	}
}


function ValidateInterestForm()
{
	var msg = ''
	var ok = true;
	var sendmag = true;
	
	var normalColour = '#FFFFFF';	
	var errorColour = '#C7E0EF';

	// do this for every form element you are validating
	setBGColor("TradingName", normalColour);
	setBGColor("LegalName", normalColour);
	setBGColor("Address", normalColour);
	setBGColor("Postcode", normalColour);
	setBGColor("Country", normalColour);
	setBGColor("CompanyPhoneDialingCode", normalColour);
	setBGColor("CompanyPhoneNumber", normalColour);
	setBGColor("CompanyFaxDialingCode", normalColour);
	setBGColor("CompanyFaxNumber", normalColour);
	setBGColor("WebsiteURL", normalColour);
	setBGColor("Title", normalColour);
	setBGColor("FirstName", normalColour);
	setBGColor("LastName", normalColour);
	setBGColor("JobTitle", normalColour);
	setBGColor("Email1", normalColour);
	setBGColor("Email2", normalColour);
	setBGColor("PhoneDialingCode", normalColour);
	setBGColor("PhoneNumber", normalColour);
	setBGColor("MobileNumber", normalColour);
	setBGColor("HeardOnline", normalColour);
	setBGColor("HeardOffline", normalColour);
	setBGColor("HeardSearchEngine", normalColour);
	setBGColor("HeardRWCWebSiteLink", normalColour);
	setBGColor("HeardRTHCourtesyContact", normalColour);
	setBGColor("HeardPreviouslyWorked", normalColour);
	setBGColor("HeardOther", normalColour);

	// use the functions listed below to check your form elements
	if (!isThere("TradingName")) {ok = false;msg += "Please enter your company's trading name\n"; setBGColor("TradingName",errorColour);}
	if (!isThere("LegalName")) {ok = false;msg += "Please enter your company's legal name\n"; setBGColor("LegalName",errorColour);}
	if (!isThere("Address")) {ok = false;msg += "Please enter your company's address\n"; setBGColor("Address",errorColour);}
	if (!isThere("Postcode")) {ok = false;msg += "Please enter your company's postcode\n"; setBGColor("Postcode",errorColour);}
	if (!isSelected("Country")) {ok = false;msg += "Please enter your company's country\n"; setBGColor("Country",errorColour);}
	if ((!isThere("CompanyPhoneDialingCode")) || (!isThere("CompanyPhoneNumber"))) {ok = false;msg += "Please enter your company's phone number and dialing code\n"; setBGColor("CompanyPhoneDialingCode",errorColour);setBGColor("CompanyPhoneNumber",errorColour);}
	if ((!isThere("CompanyFaxDialingCode")) || (!isThere("CompanyFaxNumber"))) {ok = false;msg += "Please enter your company's fax number and dialing code\n"; setBGColor("CompanyFaxDialingCode",errorColour);setBGColor("CompanyFaxNumber",errorColour);}

	if (!isSelected("Title")) {ok = false;msg += "Please enter your title\n"; setBGColor("Title",errorColour);}
	if (!isThere("FirstName")) {ok = false;msg += "Please enter your first name\n"; setBGColor("FirstName",errorColour);}
	if (!isThere("LastName")) {ok = false;msg += "Please enter your last name\n"; setBGColor("LastName",errorColour);}
	if (!valuesMatch("Email1","Email2")) { 
	    ok = false;
	    msg += "Please enter a valid email address\n"; 
	    setBGColor("Email1",errorColour);
	    setBGColor("Email2",errorColour);
    } else {
        if (!emailCheck("Email1"))
        {
	        ok = false;
	        msg += "Please enter a valid email address\n"; 
	        setBGColor("Email1",errorColour);
	        setBGColor("Email2",errorColour);
        } else {
            //Copy Email1 => Email
            var email = getObj("Email1").value;
            var emailControl=getObj("Email");
            emailControl.value=email;
        }
    }
    var heardCount=0;
    heardCount+=getObj("HeardOnline").checked;
    heardCount+=getObj("HeardOffline").checked;
    heardCount+=getObj("HeardSearchEngine").checked;
    heardCount+=getObj("HeardRWCWebSiteLink").checked;
    heardCount+=getObj("HeardRTHCourtesyContact").checked;
    heardCount+=getObj("HeardPreviouslyWorked").checked;
    heardCount+=getObj("HeardOther").checked;

	if (heardCount==0) {
	    ok = false;
	    msg += "Please tell us at least one way you found out about us\n";
	    setBGColor("HeardOnline", errorColour);
	    setBGColor("HeardOffline", errorColour);
	    setBGColor("HeardSearchEngine", errorColour);
	    setBGColor("HeardRWCWebSiteLink", errorColour);
	    setBGColor("HeardRTHCourtesyContact", errorColour);
	    setBGColor("HeardPreviouslyWorked", errorColour);
	    setBGColor("HeardOther", errorColour);	
	}
	// if ok submit, if not display the errors
	if (!ok) {
		//if (!sendmag) {
			//msg += 'You are entilted to ONE free magazine only';
			//}
		alert(msg);
		return false;
	} else {
		document.fm_enquiry.submit();
	}    
}


function validate_login_form()
{
	//Check fields completed
	//Ensure email is valid and confirm_email is identical
	//var theForm = document.forms("fm_contact")
	//theForm.submit();

	var msg = ''	
	var ok = true;
	var sendmag = true;
	
	var normalColour = 'FFFFFF';	
	var errorColour = 'FBB5B5';
	
	
	// do this for every form element you are validating
	setBGColor("txt_email", normalColour);
	setBGColor("txt_password", normalColour);
	
	
	// use the functions listed below to check your form elements
	if (!isThere("txt_email")) {
		ok = false;
		msg += "Please enter your email address\n";
		setBGColor("txt_email",errorColour);
	}
	
	if (!emailCheck("txt_email")) {
		ok = false;
		msg += "Please enter a valid email address\n";
		setBGColor("txt_email",errorColour);
	}

	if (!isThere("txt_password")) {
		ok = false;
		msg += "Please enter your password\n";
		setBGColor("txt_password",errorColour);
	}

	if (!ok) {
		alert(msg);
		return false;
	} else {
		document.fm_login.submit();
	}
}
function validate_password_form()
{
	//Check fields completed
	//Ensure email is valid and confirm_email is identical
	//var theForm = document.forms("fm_contact")
	//theForm.submit();

	var msg = ''	
	var ok = true;
	var sendmag = true;
	
	var normalColour = 'FFFFFF';	
	var errorColour = 'FBB5B5';
	
	
	// do this for every form element you are validating
	setBGColor("txt_email", normalColour);
	
	// use the functions listed below to check your form elements
	if (!isThere("txt_email")) {
		ok = false;
		msg += "Please enter your email address\n";
		setBGColor("txt_email",errorColour);
	}
	
	if (!emailCheck("txt_email")) {
		ok = false;
		msg += "Please enter a valid email address\n";
		setBGColor("txt_email",errorColour);
	}

	if (!ok) {
		alert(msg);
		return false;
	} else {
		document.fm_password.submit();
	}
}


function validate_change_password()
{
    var msg = ''	
	var ok = true;
	
	var normalColour = 'FFFFFF';	
	var errorColour = 'FBB5B5';
	
	setBGColor("txt_current_pw", normalColour);
	setBGColor("txt_new_pw", normalColour);
	
	if (!isThere("txt_current_pw")) {
		ok = false;
		msg += "Please provide your current password.\n";
		setBGColor("txt_current_pw",errorColour);
	}
	
	if (!isThere("txt_new_pw")) {
		ok = false;
		msg += "Please provide your new password.\n";
		setBGColor("txt_new_pw",errorColour);
	}
	
	if (!checkFormLength('txt_new_pw', 10)) {
	    ok = false;
		msg += "Please make sure that the password in less or equal to 10 characters.\n";
		setBGColor("txt_new_pw",errorColour);
	}
	if (!ok) {
		alert(msg);
		return false;
	} else {
		document.fm_change_password.submit();
	}
	
}


function validate_update_form(action)
{
	var msg = ''	
	var ok = true;
	var sendmag = true;
	
	var normalColour = 'FFFFFF';	
	var errorColour = 'FBB5B5';
	
	
	//var chk_terms = getObj('chk_terms');
	//var chk_monthly_letters = getObj('chk_monthly_letters');

	
	// do this for every form element you are validating
	
	setBGColor("txt_first_name", normalColour);
	setBGColor("txt_last_name", normalColour);
	setBGColor("txt_contact_job", normalColour);
	setBGColor("txt_email", normalColour);
	setBGColor("txt_confirm_email", normalColour);
	setBGColor("txt_contact_tel", normalColour);
	setBGColor("txt_company_name", normalColour);
	setBGColor("txt_address1", normalColour);
	setBGColor("txt_tel", normalColour);
	setBGColor("txt_company_fax", normalColour);
	
	
	// use the functions listed below to check your form elements
	
    
    
	if (!isThere("txt_first_name")) {
		ok = false;
		msg += "Please provide the first name of the companies main contact.\n";
		setBGColor("txt_first_name",errorColour);
	}
	if (!isThere("txt_last_name")) {
		ok = false;
		msg += "Please provide the last name of the companies main contact.\n";
		setBGColor("txt_last_name",errorColour);
	}	
	if (!isThere("txt_contact_job")) {
		ok = false;
		msg += "Please provide the main contacts job title.\n";
		setBGColor("txt_contact_job",errorColour);
	}


	if (!emailCheck("txt_email")) {
		ok = false;
		msg += "Please enter a valid email address\n";
		setBGColor("txt_email",errorColour);
	}
	
	var strEmail, strConfirmEmail
	strEmail = getObj("txt_email").value;
	strConfirmEmail = getObj("txt_confirm_email").value;
	

	if (!emailCheck("txt_confirm_email") || strEmail != strConfirmEmail) {
		ok = false;
		msg += "Please ensure the two email addresses are identical\n";
		setBGColor("txt_confirm_email",errorColour);
		}
	
	if (!isThere("txt_company_name")) {
		ok = false;
		msg += "Please enter the company name\n";
		setBGColor("txt_company_name",errorColour);
	}
	
	
	if (!isThere("txt_address1")) {
		ok = false;
		msg += "Please enter the first line of your address\n";
		setBGColor("txt_address1",errorColour);
	}
	
	if (!isNumericOnlyorNull("txt_contact_tel")) {
		ok = false;
		msg += "The Main Contact Direct Telephone must be numbers only eg. +44 123456789\n";
		setBGColor("txt_contact_tel",errorColour);
	}
	
	if (!isNumericOnlyorNull("txt_tel")) {
		ok = false;
		msg += "The Company Telephone must be numbers only eg. +44 123456789\n";
		setBGColor("txt_tel",errorColour);
	}
	
	if (!isNumericOnlyorNull("txt_company_fax")) {
		ok = false;
		msg += "The Company Fax must be numbers only eg. +44 123456789\n";
		setBGColor("txt_company_fax",errorColour);
	}
	
	
	
	if (!ok) {
		alert(msg);
		return false;
	} else {
	    document.fm_update.hid_submitted_action.value = action;
	    //document.fm_update.hid_redirect_url.value = redirectionURL;
		document.fm_update.submit();
	}
}


function validate_step2(action)
{

	var msg = ''	
	var ok = true;
	var sendmag = true;
	
	var normalColour = 'FFFFFF';	
	var errorColour = 'FBB5B5';
	
	// do this for every form element you are validating
	setBGColor("txt_co_name", normalColour);
	setBGColor("txt_legal_name", normalColour);
	setBGColor("txt_trading_name", normalColour);
	setBGColor("txt_regno", normalColour);
	setBGColor("txt_sub_co", normalColour);
	setBGColor("txt_share_holders", normalColour);
	setBGColor("txt_hold_co", normalColour);
	setBGColor("txt_emp", normalColour);
	setBGColor("txt_cap_turnover", normalColour);
	setBGColor("txt_share_capital", normalColour);

	
	// use the functions listed below to check your form elements
	/*
	if (!isThere("txt_co_name")) {
		ok = false;
		msg += "Please enter your company name\n";
		setBGColor("txt_co_name",errorColour);
	}
	
	if (!isThere("txt_legal_name")) {
		ok = false;
		msg += "Please enter your legal name\n";
		setBGColor("txt_legal_name",errorColour);
	}
	
	if (!isThere("txt_trading_name")) {
		ok = false;
		msg += "Please enter your trading name\n";
		setBGColor("txt_trading_name",errorColour);
	}
	
	if (!isThere("txt_regno")) {
		ok = false;
		msg += "Please enter your company registration no.\n";
		setBGColor("txt_regno",errorColour);
	}
	
    
	if (!checkLengthorNull('txt_share_holders',500)) {
		ok = false;
		msg += "Please name the main shareholders (partners)in less then 500 characters.\n";
		setBGColor("txt_share_holders",errorColour);
	}
	
	if (!checkLengthorNull('txt_sub_co',500)) {
		ok = false;
		msg += "Please name the company subsidaries in less then 500 characters.\n";
		setBGColor("txt_sub_co",errorColour);
	}
	
	
	if (!isThere('txt_sub_co')) {
		ok = false;
		msg += "Please name any subsidiary companies in less then 500 characters.\n";
		setBGColor("txt_sub_co",errorColour);
	} 
	*/
	
	if (!checkFormLength('txt_sub_co', 500)) {
	    ok = false;
		msg += "Please name any subsidiary companies in less then 500 characters.\n";
		setBGColor("txt_sub_co",errorColour);
	}
	
	/*
	if (!isThere('txt_share_holders')) {
		ok = false;
		msg += "Please name the main shareholders (partners)in less then 500 characters.\n";
		setBGColor("txt_share_holders",errorColour);
	} 
	*/
	
	if (!checkFormLength('txt_share_holders', 500)) {
	    ok = false;
		msg += "Please name the main shareholders (partners)in less then 500 characters.\n";
		setBGColor("txt_share_holders",errorColour);
	}
	
	/*
	if (!isThere("txt_hold_co")) {
		ok = false;
		msg += "Please name the ultimate holding company.\n";
		setBGColor("txt_hold_co",errorColour);
	}
	
	if(!isThere("txt_emp"))
	{
	    ok = false;
	    msg += "Please provide the number of employees in numbers only.\n";
		setBGColor("txt_emp",errorColour);
	}
	else
	{
		
	}
	*/
	
	if (!isNumericOnlyorNull("txt_emp")) 
	{
	    ok = false;
	    msg += "Please provide the number of employees in numbers only.\n";
	    setBGColor("txt_emp",errorColour);
    }
    
    
    /*if (!isNumericOnlyorNull("txt_cap_turnover")) 
    {
	    ok = false;
	    msg += "Please provide the share capital turnover for last financial year in numbers only - For example no commas, symbols or letters.\n";
	    setBGColor("txt_cap_turnover",errorColour);
    }*/
    
    /*
    if (!isNumericOnlyorNull("txt_share_capital")) 
    {
	    ok = false;
	    msg += "Please provide the share capital.\n";
	    setBGColor("txt_share_capital",errorColour);
    }
	
	
	if(!isThere("txt_cap_turnover"))
	{
	    ok = false;
		msg += "Please provide the share capital turnover for last financial year in numbers only - For example no commas, symbols or letters.\n";
		setBGColor("txt_cap_turnover",errorColour);
	}
	else
	{
	    
	}
	
	
	
	if(!isThere("txt_share_capital"))
	{
	    ok = false;
		msg += "Please provide the share capital.\n";
		setBGColor("txt_share_capital",errorColour);
	}
	else
	{
	    
	}
	
	*/
	
	
	if (!ok) {
		alert(msg);
		return false;
	} else {
	    //document.fm_step2.hid_redirect_url.value = redirectionURL;
	    document.fm_step2.hid_submitted_action.value = action;
		document.fm_step2.submit();
	}
}
function validate_step3(action)
{

	var msg = ''	
	var ok = true;
	var sendmag = true;
	var action2 = action;
	
	var normalColour = 'FFFFFF';	
	var errorColour = 'FBB5B5';
	
	// do this for every form element you are validating
	setBGColor("txt_name", normalColour);
	//setBGColor("txt_address1", normalColour);
	//setBGColor("txt_address2", normalColour);
	//setBGColor("txt_address3", normalColour);
	//setBGColor("txt_address4", normalColour);
	setBGColor("txt_years", normalColour);
	setBGColor("txt_cv", normalColour);
	
	
	if (step3_saveRequired() || action == 'first_save')
	{
	    // use the functions listed below to check your form elements
	    if (!isThere("txt_name")) {
		    ok = false;
		    msg += "To save a director's details you must enter a name.\n";
		    setBGColor("txt_name",errorColour);
	    }
    	
	    if (!isNumericOnlyorNull("txt_years")) {
		    ok = false;
		    msg += "Please confirm the directors years in numbers only.\n";
		    setBGColor("txt_years",errorColour);
	    }
    	
	    if (!checkLengthorNull('txt_cv',800)) {
		    ok = false;
		    msg += "Please provide a top level CV (Max: 800 characters).\n";
		    setBGColor("txt_cv",errorColour);
	    }
	} 
	else
	{
	    if (action == "next_step")
	    {
	        action2 = "next_step_no_save"
	    }
	    
	    if (action == "save_logout")
	    {
	        action2 = "logout_no_save"
	    }
	    
	}
	

	if (!ok) {
		alert(msg);
	return false;
	} else {
	    //document.fm_step3.hid_redirect_url.value = redirectionURL;
	    document.fm_step3.hid_submitted_action.value = action2;
		document.fm_step3.submit();
	}
}

function step3_saveRequired()
{
    if (isThere("txt_name") || isThere("txt_address1") || isThere("txt_address2") || isThere("txt_address3") || isThere("txt_address4") || isThere("txt_years") || isThere("txt_cv") || document.getElementById('travel_exp').value != 0 || document.getElementById('hosp_exp').value != 0)
    {
        return true;
    }
    else
    {
        return false;
    }
}

function validate_step4(action)
{

	var msg = ''	
	var ok = true;
	var sendmag = true;
	var action2 = action;
	
	var normalColour = 'FFFFFF';	
	var errorColour = 'FBB5B5';
	
	// do this for every form element you are validating
	setBGColor("txt_name", normalColour);
	//setBGColor("txt_job_title", normalColour);
	setBGColor("txt_years_exp", normalColour);
	
	
	if (step4_saveRequired() || action == 'first_save')
	{
	    // use the functions listed below to check your form elements
	    if (!isThere("txt_name")) {
		    ok = false;
		    msg += "To save a senior staff memeber's details you must enter a name.\n";
		    setBGColor("txt_name",errorColour);
	    }
    	
	    //if (!isThere("txt_job_title")) {
		    //ok = false;
		    //msg += "Please provide a Job Title\n";
		    //setBGColor("txt_job_title",errorColour);
	    //}
	    if (!isNumericOnlyorNull("txt_years_exp")) {
		    ok = false;
		    msg += "Please confirm no. of years experience in numbers only.\n";
		    setBGColor("txt_years_exp",errorColour);
	    }
	}
	else
	{
	    if (action == "next_step")
	    {
	        action2 = "next_step_no_save"
	    }
	    
	    if (action == "save_logout")
	    {
	        action2 = "logout_no_save"
	    }
	}

	if (!ok) {
		alert(msg);
		return false;
	} else {
	    //document.fm_step4.hid_redirect_url.value = redirectionURL;
	    document.fm_step4.hid_submitted_action.value = action2;
		document.fm_step4.submit();
	}
}


function step4_saveRequired()
{
    if (isThere("txt_name") || isThere("txt_job_title") || isThere("txt_years_exp"))
    {
        return true;
    }
    else
    {
        return false;
    }
}


function validate_step5(action)
{

	var msg = ''	
	var ok = true;
	var sendmag = true;
	
	var normalColour = 'FFFFFF';	
	var errorColour = 'FBB5B5';
	
	// do this for every form element you are validating
	setBGColor("txt_Agency_Ex", normalColour);

	
	if (!checkLengthorNull('txt_Agency_Ex',2000)) {
		ok = false;
		msg += "Please provide Membership Experience (Max: 2000 characters).\n";
		setBGColor("txt_Agency_Ex",errorColour);
	}
	
			
	if (!ok) {
		alert(msg);
		return false;
	} else {
	    //document.fm_step5.hid_redirect_url.value = redirectionURL;
	    document.fm_step5.hid_submitted_action.value = action;
		document.fm_step5.submit();
	}
}

function validate_step7(action)
{

	var msg = ''	
	var ok = true;
	var sendmag = true;
	
	var normalColour = 'FFFFFF';	
	var errorColour = 'FBB5B5';
	
	// do this for every form element you are validating
	setBGColor("txt_fin_security", normalColour);

	
	if (!checkLengthorNull('txt_fin_security',2000)) {
		ok = false;
		msg += "Please provide details of Financial Security (Max: 2000 characters).\n";
		setBGColor("txt_fin_security",errorColour);
	}
	
			
	if (!ok) {
		alert(msg);
		return false;
	} else {
	    //document.fm_step7.hid_redirect_url.value = redirectionURL;
	    document.fm_step7.hid_submitted_action.value = action;
		document.fm_step7.submit();
	}
}


function validate_step6_nta(action)
{

	var msg = ''	
	var ok = true;
	var sendmag = true;
	
	
	var normalColour = 'FFFFFF';	
	var errorColour = 'FBB5B5';
	
	// do this for every form element you are validating
	setBGColor("txt_name", normalColour);
	setBGColor("txt_years", normalColour);
	//setBGColor("txt_mem_no", normalColour);
	//setBGColor("txt_bond_amount", normalColour);

	
	// use the functions listed below to check your form elements
	if (!isThere("txt_name")) {
		ok = false;
		msg += "Please provide the Association name.\n";
		setBGColor("txt_name",errorColour);
	}
	
	if (!isNumericOnlyorNull("txt_years")) {
		ok = false;
		msg += "Please provide the membership years in numbers only.\n";
		setBGColor("txt_years",errorColour);
	}
	//if (!isNumeric("txt_mem_no")) {
		//ok = false;
		//msg += "Please confirm membership no..\n";
		//setBGColor("txt_mem_no",errorColour);
	//}
	//	if (!isNumericOnlyorNull("txt_bond_amount")) {
		//ok = false;
		//msg += "Please confirm the bond amount in numbers only.\n";
		//setBGColor("txt_bond_amount",errorColour);
	//}
			
	if (!ok) {
		alert(msg);
		return false;
	} else {
	    document.fm_step6.hid_submitted_action.value=action
		document.fm_step6.submit();
	}
}
function validate_step6_iata(action)
{

	var msg = ''	
	var ok = true;
	var sendmag = true;
	
	var normalColour = 'FFFFFF';	
	var errorColour = 'FBB5B5';
	

	setBGColor("txt_iata_years", normalColour);

	
	if (!isNumericOnlyorNull("txt_iata_years")) {
		ok = false;
		msg += "Please provide the years in numbers only.\n";
		setBGColor("txt_iata_years",errorColour);
	}
	
			
	if (!ok) {
		alert(msg);
		return false;
	} else {
	    document.fm_step6.hid_submitted_action.value=action
		document.fm_step6.submit();
	}
}

function validate_step6(action)
{

	var msg = ''	
	var ok = true;
	var sendmag = true;
	var action2 = action;
	
	var normalColour = 'FFFFFF';	
	var errorColour = 'FBB5B5';
	

	setBGColor("txt_iata_years", normalColour);
	if (document.getElementById('txt_name') != null)
	{
	    setBGColor("txt_name", normalColour);
	    setBGColor("txt_years", normalColour);
	}
	

	
	if (!isNumericOnlyorNull("txt_iata_years")) {
		ok = false;
		msg += "Please provide the years in numbers only.\n";
		setBGColor("txt_iata_years",errorColour);
	}
	
	if (step6_saveRequired())
	{
	    if (document.getElementById('txt_name') != null)
	    {
	        if (!isThere("txt_name")) {
		        ok = false;
		        msg += "Please provide the Association name.\n";
		        setBGColor("txt_name",errorColour);
	        }
        	
	        if (!isNumericOnlyorNull("txt_years")) {
		        ok = false;
		        msg += "Please provide the membership years in numbers only.\n";
		        setBGColor("txt_years",errorColour);
	        }
	    }
	}
	else
	{
	    if (action == "next_step")
	    {
	        action2 = "next_step_no_save"
	    }
	    
	    if (action == "save_logout")
	    {
	        action2 = "logout_no_save"
	    }
	}
	
	
		
	if (!ok) {
		alert(msg);
		return false;
	} else {
	   // document.fm_step6.hid_redirect_url.value = redirectionURL;
	    document.fm_step6.hid_submitted_action.value=action2
		document.fm_step6.submit();
	}
}

function step6_saveRequired()
{
    if (isThere("txt_name") || isThere("txt_mem_no") || isThere("txt_years") || isThere("txt_bond_amount"))
    {
        return true;
    }
    else
    {
        return false;
    }
}

function confirmStep8()
{
    document.fm_step8.hid_confirm.value='true';
}

function showApplicationSummary()
{
    openWindow('applications_print.htm','','status = 1, height = 600, width = 600, resizable = 1, scrollbars = yes');
}


// -----------------------------------------------------------------------------------------------------------
// checkes to see if a value has been entered and that it is numeric
// -----------------------------------------------------------------------------------------------------------
function isNumericOnlyorNull(elementName) {
	var element = getObj(elementName);
	var strString = element.value;
	if (strString == "") {
		return true;
	}
  var strValidChars = "0123456789.+ ";
  var strChar;
  var blnResult = true;


  //  test strString consists of valid characters listed above
  for (i = 0; i < strString.length && blnResult == true; i++)
    {
    strChar = strString.charAt(i);
     if (strValidChars.indexOf(strChar) == -1)
        {
        blnResult = false;
        }
    }
    //blnResult = true;
  return blnResult;

}


// -----------------------------------------------------------------------------------------------------------
// check a form elements length agains the entered value
// -----------------------------------------------------------------------------------------------------------
function checkLengthorNull(elementName,length) {
	var element = getObj(elementName);
	var strString = element.value;

	//alert('Len=' + element.value.length);
	//alert('Size=' + length);
	if (strString == ""){
		 return true;		
	}
	
	if (element.value.length <= length || element.value == '' ){
		return true;
	}
	
}

function checkFormLength(elementName,length) {
	var element = getObj(elementName);
	var strString = element.value;
	
	if (element.value.length <= length){
		return true;
	}
	
}
