// JavaScript Document

<!--
var ie5 = (document.getElementById && document.all);
var ns6 = (document.getElementById && !document.all);

var alpha = "abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ";
var numeric = "1234567890";
var dateMsg = "";
var dtCh= "index.html";
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;
}



/**
// -----------------------------------------------------------------------------------------------------------
//   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;
}


function open_win(url,ref_page)
{

window.open(url);
document.location.href=ref_page;
}

// -----------------------------------------------------------------------------------------------------------
// Validate Form function
// -----------------------------------------------------------------------------------------------------------

function validate_Relocate2_contact_form()
{

	var msg = ''	
	var ok = true;
	var sendmag = true;
	
	var normalColour = 'FFFFFF';	
	var errorColour = 'E5DF49';
	
	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_email", normalColour);
	setBGColor("txt_confirm_email", normalColour);
	setBGColor("txt_tel", normalColour);
	setBGColor("txt_mobile", normalColour);
	setBGColor("txt_address1", normalColour);
	setBGColor("txt_address2", normalColour);
	setBGColor("txt_address3", normalColour);
	setBGColor("txt_address4", normalColour);
	setBGColor("txt_postcode", normalColour);
	//setBGColor("txt_password", normalColour);

	setBGColor("chk_terms", normalColour);
	//setBGColor("chk_monthly_letters", 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);
	}
	
	//var strpassword
	//strpassword = getObj("txt_password")
	
	
	//if (!isThere("txt_password")){
	//	ok = false;
	//	msg += "Please enter your password\n";
	//	setBGColor("txt_password",errorColour);
	//}
	//if (strpassword.value.length < 6 ) {
	///	ok = false;
	//	msg += "Please ensure that your password is greater then 6 characters\n";
	//	setBGColor("txt_password",errorColour);
	//}

	//if (!isThere("txt_confirm_password")) {
	//	ok = false;
	//	msg += "Please confirm your password\n";
	//	setBGColor("txt_confirm_password",errorColour);
	//}
	
	//var strpassword, strConfirmPassword
	//strpassword = getObj("txt_password").value;
	//strConfirmPassword = getObj("txt_confirm_password").value;


	//if (strpassword != strConfirmPassword){
	//	ok = false;
	//	msg += "Please ensure the two passwords are identical\n";
	//	setBGColor("txt_confirm_password",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_contact.submit();
	}
}

function validate_contact_form()
{

	var msg = ''	
	var ok = true;
	var sendmag = true;
	
	var normalColour = 'FFFFFF';	
	var errorColour = 'E5DF49';
	
	var chk_terms = getObj('chk_terms');
	var chk_monthly_letters = getObj('chk_monthly_letters');
    var select_country = document.getElementById('country_interest');
   // alert(select_country.value);

	
	// 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_confirm_email", normalColour);
	setBGColor("txt_tel", normalColour);
	setBGColor("txt_mobile", normalColour);
	setBGColor("txt_address1", normalColour);
	setBGColor("txt_address2", normalColour);
	setBGColor("txt_address3", normalColour);
	setBGColor("txt_address4", normalColour);
	setBGColor("txt_postcode", normalColour);
	setBGColor("txt_password", normalColour);
	setBGColor("txt_confirm_password", normalColour);
	setBGColor("chk_terms", normalColour);
	setBGColor("country_interest", normalColour);
	
		//alert (select_country);
	
	//setBGColor("chk_monthly_letters", normalColour);
	
	// use the functions listed below to check your form elements
	//if (select_country.value == 0) {
	
		//ok = false;
		//msg += "Please enter your country of interest\n";
		//setBGColor("country_interest",errorColour);
	
	//}
	
	
	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);
	}
	
	var strpassword
	strpassword = getObj("txt_password")
	
	
	if (!isThere("txt_password")){
		ok = false;
		msg += "Please enter your password\n";
		setBGColor("txt_password",errorColour);
	}
	if (strpassword.value.length < 6 ) {
		ok = false;
		msg += "Please ensure that your password is greater then 6 characters\n";
		setBGColor("txt_password",errorColour);
	}

	if (!isThere("txt_confirm_password")) {
		ok = false;
		msg += "Please confirm your password\n";
		setBGColor("txt_confirm_password",errorColour);
	}
	
	var strpassword, strConfirmPassword
	strpassword = getObj("txt_password").value;
	strConfirmPassword = getObj("txt_confirm_password").value;


	if (strpassword != strConfirmPassword){
		ok = false;
		msg += "Please ensure the two passwords are identical\n";
		setBGColor("txt_confirm_password",errorColour);
		}

	if (select_country.value == 0) {
	
		ok = false;
		msg += "Please enter your country of interest\n";
		setBGColor("country_interest",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_contact.submit();
	}
}


function validate_update_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 = 'E5DF49';
	
	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_email", normalColour);
	setBGColor("txt_confirm_email", normalColour);
	setBGColor("txt_tel", normalColour);
	setBGColor("txt_mobile", normalColour);
	setBGColor("txt_address1", normalColour);
	setBGColor("txt_address2", normalColour);
	setBGColor("txt_address3", normalColour);
	setBGColor("txt_address4", normalColour);
	setBGColor("txt_postcode", normalColour);
	setBGColor("txt_password", normalColour);
	setBGColor("chk_terms", normalColour);
	//setBGColor("chk_monthly_letters", 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 (!isThere("txt_password")) {
		ok = false;
		msg += "Please enter your password\n";
		setBGColor("txt_password",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_update.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 = 'E5DF49';
	
	
	// 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 = 'E5DF49';
	
	
	// 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_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_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;
	}
}

// -----------------------------------------------------------------------------------------------------------
// 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();
	}

}

//-->
function submit_tv_form() {
	var answer = confirm("You will now proceed to WorldPay")
	if (answer){
		document.fm_emigrate_tv.submit();
	}
	else{
		
	}
}
// this function gets the function variable and assigns it to the form

function set_flag_session(id){
//alert ('in function');
	
	var country_id = document.getElementById("flag_session");
	country_id.value = id;
	document.fm_flags.submit();

//alert('form sub');
	
}

function submit_country_id(){

var region_id = document.getElementById("frmRegion"); 
region_id.value = -1;
var city_id = document.getElementById("frmCity");
city_id.value =-1
document.weblinkSearch.submit();
}

function submit_region_id(){

var city_id = document.getElementById("frmCity");
city_id.value = -1;
document.weblinkSearch.submit();

}

function submit_form(){

//alert('hello - form submitted');
document.weblinkSearch.submit();

}

function submit_subscription_form(){
document.fm_newspaper.submit();
}

function NewsLetter(){
//alert('hello');
document.fm_newsEmail.submit();
}

function submit_shows_form(){
document.fm_shows.submit();
}

// -----------------------------------------------------------------------------------------------------------
// Validate News Paper Form function
// -----------------------------------------------------------------------------------------------------------

function validate_newspaper_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 = 'E5DF49';
	
	var chk_usa3 = getObj('chk_usa3');
	var chk_usa6 = getObj('chk_usa6');
	var chk_usa12 = getObj('chk_usa12');
	//var chk_aus = getObj('chk_AUS');
	//var chk_nz = getObj('chk_NZ');
	//var chk_sa = getObj('chk_SA');
	//var chk_can = getObj('chk_CAN');
	
	
	// do this for every form element you are validating
	setBGColor("chk_usa3", normalColour);
	setBGColor("chk_usa6", normalColour);
	setBGColor("chk_usa12", normalColour);
	//setBGColor("chk_AUS", normalColour);
	//setBGColor("chk_NZ", normalColour);
	//setBGColor("chk_SA", normalColour);
	//setBGColor("chk_CAN", normalColour);
	
	
	//if(!chk_usa3.checked)
	//{
		//ok = false;
		//msg += 'Please tick - deb need to validate.\n';
		//setBGColor("chk_usa3",normalColour);
	//}

	//if(!chk_usa6.checked)
	//{
		//ok = false;
		//msg += 'Please tick the box to confirm you have read the Terms & Conditions.\n';
		//setBGColor("chk_usa6",normalColour);
	//}
	//if(!chk_usa12.checked)
	//{
		//ok = false;
		//msg += 'Please tick the box to confirm you have read the Terms & Conditions.\n';
		//setBGColor("chk_usa12",normalColour);
	//}
	
	if (!ok) {
		alert(msg);
		return false;
	} else {
		document.fm_newspaper.submit();
	}
}


