function createRequestObject() {
	var ro;
	var browser = navigator.appName;

	if(browser == "Microsoft Internet Explorer") {
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	} else {	
		ro = new XMLHttpRequest();
	}
	return ro;
}

var http = createRequestObject();

function checkOnline() {
	http.open("get", "checkOnline.php");
	http.send(null);
}

 // textarea counter on adverts form
  function textCounter(field, countfield) {
      {countfield.value =  field.value.length;}
  }

function Validate_FrmReports() {

  if (document.FrmReports.lstPeriod.selectedIndex == 0)
   {
               alert("Please enter a value for the \"Period\" field.");
               document.FrmReports.lstPeriod.focus();
               return (false);
   }
  if (document.FrmReports.lstYear.selectedIndex == 0)
   {
               alert("Please enter a value for the \"Year\" field.");
               document.FrmReports.lstYear.focus();
               return (false);
   }
   document.FrmReports.hdnyear.value=document.FrmReports.lstYear.value;
   document.FrmReports.hdnperiod.value=document.FrmReports.lstPeriod.value;
  return (true);
 }

 function Validate_FrmPersonal() {  if (document.FrmPersonal.lstPerson1.selectedIndex == 0)
    {
                alert("Please enter a value for the \"Personality\" field.");
                document.FrmPersonal.lstPerson1.focus();
                return (false);
    }  if (document.FrmPersonal.lstPhilos1.selectedIndex == 0)
    {
                alert("Please enter a value for the \"Philosophy\" field.");
                document.FrmPersonal.lstPhilos1.focus();
                return (false);
    }

   if (document.FrmPersonal.lstSocial1.selectedIndex == 0)
    {
                alert("Please enter a value for the \"Social Group\" field.");
                document.FrmPersonal.lstSocial1.focus();
                return (false);
    }

   if (document.FrmPersonal.lstGoal1.selectedIndex == 0)
    {
                alert("Please enter a value for the \"Goals\" field.");
                document.FrmPersonal.lstGoal1.focus();
                return (false);
    }

   if (document.FrmPersonal.lstHobby1.selectedIndex == 0)
    {
                alert("Please enter a value for the \"Hobbies\" field.");
                document.FrmPersonal.lstHobby1.focus();
                return (false);
    }

   if (document.FrmPersonal.lstSport1.selectedIndex == 0)
    {
                alert("Please enter a value for the \"Sports\" field.");
                document.FrmPersonal.lstSport1.focus();
                return (false);
    }

   if (document.FrmPersonal.lstMusic1.selectedIndex == 0)
    {
                alert("Please enter a value for the \"Music\" field.");
                document.FrmPersonal.lstMusic1.focus();
                return (false);
    }

   if (document.FrmPersonal.lstFood1.selectedIndex == 0)
    {
                alert("Please enter a value for the \"Food\" field.");
                document.FrmPersonal.lstFood1.focus();
                return (false);
    }

   return (true);
 }
function Validate_FrmSendMail() {
  if (document.FrmSendMail.txtSubject.value.length < 2)
  {
    alert("Please enter at least 2 characters in the  \"Subject\" field.");
    document.FrmSendMail.txtSubject.focus();
    return (false);
  }
  if (document.FrmSendMail.txtMessage.value.length < 20)
  {
    alert("Please enter at least 20 characters in the \"Message\" field.");
    document.FrmSendMail.txtMessage.focus();
    return (false);
  }

  return (true);
 }

 function Validate_FrmLogin() {

   if (document.FrmLogin.txtHandle.value.length < 6)
   {
     alert("Please enter at least 6 characters in the \"Username\" field.");
     document.FrmLogin.txtHandle.focus();
     return (false);
   }

   if (document.FrmLogin.txtHandle.value.length > 25)
   {
     alert("Please enter at most 25 characters in the \"Username\" field.");
     document.FrmLogin.txtHandle.focus();
     return (false);
   }

   if (document.FrmLogin.txtPassword.value.length < 5)
   {
     alert("Please enter at least 6 characters in the \"Password\" field.");
     document.FrmLogin.txtPassword.focus();
     return (false);
   }

   if (document.FrmLogin.txtPassword.value.length > 10)
   {
     alert("Please enter at most 10 characters in the \"Password\" field.");
     document.FrmLogin.txtPassword.focus();
     return (false);
   }

   return (true);
 }

function Validate_Style(fld, fldError) {
	alert(fldError);
	fld.style.border = '1px solid #df3737';
	fld.focus();
	return false;
}

var dublicatedUser;

function preValidate_FrmRegister() {
	username = document.FrmRegister.txtHandle.value;
	if (username != '') {
		new Ajax.Request('usercheck.php?username=' + username,
		{
			method:'get',
			asynchronous: false,
			onComplete: function(transport) {
				var response = transport.responseText || "no response text";
				if (response == "r|not") {
					dublicatedUser = true;					
				} else {
					dublicatedUser = false;
				}			
			//	return Validate_FrmRegister('create');
			}			
		});
	}	
	//return false;
	return Validate_FrmRegister('create');
}
 
function preValidateUserName() {
	$('register_loading').style.display = 'inline';
	myDiv = $("dublicatedUser");
	username = document.FrmRegister.txtHandle.value;
	if (username.length < 6) {
		myDiv.innerHTML = "'Please enter at least 6 letters'";
		$('register_loading').style.display = 'none';
		return;
	}
	new Ajax.Request('usercheck.php?username=' + username,
	{
		method:'get',
		asynchronous: true,
		onComplete: function(transport) {
			var response = transport.responseText || "no response text";			
			if (response == "r|not") {
				myDiv.innerHTML = "'Name Taken'";
				dublicatedUser = true;	
			} else {
				//$('dublicatedUser').update('ok');
				myDiv.innerHTML = "<span style='color:#239e46'>'Name Avaiable'</span>";
				dublicatedUser = false;
			}
			$('register_loading').style.display = 'none';
		}			
	});
	} 
 
function Validate_FrmRegister(mode) {
	var fld = "";	
   if (mode == 'create') {

			fld = document.FrmRegister.txtHandle;
			fld.style.border = '';			
           if (fld.value == "")
           {             			 
			 fldError = "Please enter at least 6 characters in the \"Username\" field.";
			 return Validate_Style(fld, fldError);             
           }
		   
           if (fld.value.length > 14)
           {
             fldError = "Please enter no more than 14 characters in the \"Username\" field.";			 
			 return Validate_Style(fld, fldError);
           }
		   
           if (fld.value.length < 6)
           {
             fldError = "Please enter at least 6 characters in the \"Username\" field.";
             return Validate_Style(fld, fldError);
           }
		   
           var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz����������������������������������������������������������������������1234567890-\t\r\n\f";
           var checkStr = document.FrmRegister.txtHandle.value;
           var allValid = true;
           for (i = 0;  i < checkStr.length;  i++)
           {
             ch = checkStr.charAt(i);
             for (j = 0;  j < checkOK.length;  j++)
               if (ch == checkOK.charAt(j))
                 break;
             if (j == checkOK.length)
             {
               allValid = false;
               break;
             }
           }
           if (!allValid)
           {
             fldError = "Please enter only letter, numbers and \"-\" characters in the \"Username\" field.";
             return Validate_Style(fld, fldError);
           }
		   
			if (dublicatedUser == true){
				fldError = "User name '" + fld.value +"' is already taken. Please enter another name.";
				dublicatedUser = false;
				return Validate_Style(fld, fldError);
			}	
   }
	
	fld = document.FrmRegister.txtPassword;
	fld.style.border = '';
   if (fld.value.length < 6)
   {
     fldError = "Please enter between 6-10 characters in the \"Password\" field.";
     return Validate_Style(fld, fldError);
   }

   var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz����������������������������������������������������������������������1234567890";
   var checkStr = document.FrmRegister.txtPassword.value;
   var allValid = true;
   for (i = 0;  i < checkStr.length;  i++)
   {
     ch = checkStr.charAt(i);
     for (j = 0;  j < checkOK.length;  j++)
       if (ch == checkOK.charAt(j))
         break;
     if (j == checkOK.length)
     {
       allValid = false;
       break;
     }
   }
   if (!allValid)
   {
     fldError = "Please enter only letters and numbers in the \"Password\" field.";
     return Validate_Style(fld, fldError);
   }

   if (fld.value.length > 10)
    {
      fldError = "Please enter no more than 10 characters in the \"Password\" field.";
      return Validate_Style(fld, fldError);
   }

	fld = document.FrmRegister.txtConfirm;
	fld.style.border = '';
	
   if (fld.value.length < 6)
   {
     fldError = "Please enter between 6-10 characters in the \"Confirm\" field.";
     return Validate_Style(fld, fldError);
   }

   var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz����������������������������������������������������������������������1234567890";
   var checkStr = document.FrmRegister.txtConfirm.value;
   var allValid = true;
   for (i = 0;  i < checkStr.length;  i++)
   {
     ch = checkStr.charAt(i);
     for (j = 0;  j < checkOK.length;  j++)
       if (ch == checkOK.charAt(j))
         break;
     if (j == checkOK.length)
     {
       allValid = false;
       break;
     }
   }
   if (!allValid)
   {
     fldError = "Please enter only letters and numbers in the \"Confirm\" field.";
     return Validate_Style(fld, fldError);
   }

   if (document.FrmRegister.txtConfirm.value.length > 10)
    {
      fldErorr = "Please enter no more than 10 characters in the \"Confirm\" field.";
      return Validate_Style(fld, fldError);
   }
   
   if (document.FrmRegister.txtPassword.value != document.FrmRegister.txtConfirm.value)
    {
      fldError = "Password confirmation does not match password - please re-enter";
      return Validate_Style(fld, fldError);
   }
   
   
	
	fld = document.FrmRegister.lstDay;
	fld.style.border = '';
	if (mode=='create' && fld.selectedIndex == 0) {
	   fldError = "Please select your Day of Birth.";
	   return Validate_Style(fld, fldError);
	}

	fld = document.FrmRegister.lstMonth;
	fld.style.border = '';
	if (mode=='create' && fld.selectedIndex == 0) {
	   fldError = "Please select your Month of Birth.";
	   return Validate_Style(fld, fldError);
	}

	fld = document.FrmRegister.txtYear;
	fld.style.border = '';
	if (fld.value.length < 2) {
		fldError = "Please enter 2 digits in the \"Year of Birth\" field.";
		return Validate_Style(fld, fldError);
	}

	if (document.FrmRegister.txtYear.value.length > 2) {
		fldError = "Please enter at most 2 digits in the \"Year of Birth\" field.";
		return Validate_Style(fld, fldError);
	}

	var checkOK = "0123456789";
	var checkStr = document.FrmRegister.txtYear.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
		if (j == checkOK.length) {
			allValid = false;
			break;
		}
    }
	if (!allValid) {
		fldError = "Please enter only digits in the \"Year of Birth\" field.";
		return Validate_Style(fld, fldError);
	}

	fld = document.FrmRegister.lstSex;
	fld.style.border = '';
	if (mode=='create' && fld.selectedIndex == 0) {
		fldError = "Please select your gender.";
		return Validate_Style(fld, fldError);
	}

	fld = document.FrmRegister.txtEmail;
	fld.style.border = '';
	if (fld.value.length < 5)	{
		fldError = "Please enter at least 5 characters in the \"Email\" field.";
		return Validate_Style(fld, fldError);
	}
    var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    str = fld.value;

    if(!str.match(emailRegEx)) {    
        fldError = "An invalid \"Email\" address has been supplied please re-enter.";
        return Validate_Style(fld, fldError);
    }
	
	tfld = document.FrmRegister.txtEmailConfirm;	
	if (tfld) {
		if (tfld.value != str) {
			fldError = "The confirm email address does not match.\n";
			return Validate_Style(tfld, fldError);
		} 
	}
	
	fld = document.FrmRegister.chkDisclaimer;
	fld.style.border = '';	
	if (fld.checked == false) {
		fldError = "You must read and approve the Disclaimer before registering.";
		return Validate_Style(fld, fldError);
	}

	fld = document.FrmRegister.lstCountry_;
	fld.style.border = '';	
	if (fld.value <= 0)	{
		fldError = "Please enter a value for the \"Country\" field.";		
		return Validate_Style(fld, fldError);
	}
	
	
	fld = document.FrmRegister.lstCity;
	fld.style.border = '';	
	if (document.FrmRegister.lstCity && fld.value <= 0) {		
		fldError = "Please enter a value for the \"In or Around\" field.";
		return Validate_Style(fld, fldError);	
	} 
	
	
	if (mode=='create' && document.FrmRegister.lstSeeking) {
		inarr=new Array(
			new Array("lstLstatus", "Living Status"),
			new Array("lstLanguages", "Languages"),
			new Array("lstReligion", "Religion"),
			new Array("lstEthnicity", "Ethnicity"),
			new Array("lstChildren", "Children"),
			new Array("lstNationality", "Nationality"),
			new Array("lstBodyType", "Body Type"),
			new Array("lstSeeking", "Relationship"),
			new Array("lstHeight", "Height"),				
			new Array("lstMarital",	"Marital Status"),		
			new Array("lstHaircolor", "Hair Colour"),		
			new Array("lstEducation", "Education"),
			new Array("lstEyecolor", "Eye Colour"),
			new Array("lstEmployment", "Employment"),
			new Array("lstDrink", "Drinker"),
			new Array("lstIncome", "Income"),		
			new Array("lstSmoke", "Smoker")
		);
		
		for(var i=0; i<inarr.length; i++) {
			fld = document.FrmRegister.elements[inarr[i][0]];
			fld.style.border = '';
			if (fld.selectedIndex == 0) {
				fldError = "Please enter a value for the \"" + inarr[i][1] +  "\" field.";
				return Validate_Style(fld, fldError);
			}
		}
		
		fld = document.FrmRegister.txtTitle;	
		fld.style.border = '';
		if (fld.value.length < 5 || fld.value.length > 40) {
			fldError = "Please enter at between 5 and 40 characters in the \"Message Title\" field.";
			return Validate_Style(fld, fldError);
		}

		fld = document.FrmRegister.txtComment;
		fld.style.border = '';
		if (fld.value.length < 5 || fld.value.length > 400) {
			fldError = "Please enter between 5 and 400 characters in the \"Message\" field.";
			return Validate_Style(fld, fldError);
		}
		
		fld = document.FrmRegister.chkSeekmen;
		fld.style.border = '';
		if (mode=='create' && document.FrmRegister.chkSeekmen.checked == false && document.FrmRegister.chkSeekwmn.checked == false) {
			fldError = "Please select the genders you are \"Seeking\".";
			return Validate_Style(fld, fldError);
		}
		
	}
	return true;
}

 function Validate_FrmAffiliate() {

   if (document.FrmAffiliate.txtUsername.value.length > 25)
   {
     alert("Please enter no more than 25 characters in the \"Username\" field.");
     document.FrmAffiliate.txtUsername.focus();
     return (false);
   }

   if (document.FrmAffiliate.txtUsername.value.length < 6)
   {
     alert("Please enter at least 6 characters in the \"Username\" field.");
     document.FrmAffiliate.txtUsername.focus();
     return (false);
   }

   var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz����������������������������������������������������������������������1234567890-\t\r\n\f";
   var checkStr = document.FrmAffiliate.txtUsername.value;
   var allValid = true;
   for (i = 0;  i < checkStr.length;  i++)
   {
     ch = checkStr.charAt(i);
     for (j = 0;  j < checkOK.length;  j++)
       if (ch == checkOK.charAt(j))
         break;
     if (j == checkOK.length)
     {
       allValid = false;
       break;
     }
   }
   if (!allValid)
   {
     alert("Please enter only letter, numbers and \"-\" characters in the \"Username\" field.");
     document.FrmAffiliate.txtUsername.focus();
     return (false);
   }

   if (document.FrmAffiliate.txtSurname.value.length < 2)
   {
     alert("Please enter at least 2 characters in the \"Last name\" field.");
     document.FrmAffiliate.txtSurname.focus();
     return (false);
   }

   var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz����������������������������������������������������������������������- \t\r\n\f";
   var checkStr = document.FrmAffiliate.txtSurname.value;
   var allValid = true;
   for (i = 0;  i < checkStr.length;  i++)
   {
     ch = checkStr.charAt(i);
     for (j = 0;  j < checkOK.length;  j++)
       if (ch == checkOK.charAt(j))
         break;
     if (j == checkOK.length)
     {
       allValid = false;
       break;
     }
   }
   if (!allValid)
   {
     alert("Please enter only letter, whitespace and \"-\" characters in the \"Last name\" field.");
     document.FrmAffiliate.txtSurname.focus();
     return (false);
   }

   if (document.FrmAffiliate.txtSurname.value.length > 25)
    {
      alert("Please enter no more than 25 characters in the \"Last name\" field.");
      document.FrmAffiliate.txtSurname.focus();
      return (false);
   }

   if (document.FrmAffiliate.txtForename.value.length > 25)
    {
      alert("Please enter no more than 25 characters in the \"First name\" field.");
      document.FrmAffiliate.txtForename.focus();
      return (false);
   }

   if (document.FrmAffiliate.txtForename.value.length < 2)
   {
     alert("Please enter at least 2 characters in the \"First name\" field.");
     document.FrmAffiliate.txtForename.focus();
     return (false);
   }

   var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz����������������������������������������������������������������������- \t\r\n\f";
   var checkStr = document.FrmAffiliate.txtForename.value;
   var allValid = true;
   for (i = 0;  i < checkStr.length;  i++)
   {
     ch = checkStr.charAt(i);
     for (j = 0;  j < checkOK.length;  j++)
       if (ch == checkOK.charAt(j))
         break;
     if (j == checkOK.length)
     {
       allValid = false;
       break;
     }
   }
   if (!allValid)
   {
     alert("Please enter only letter, whitespace and \"-\" characters in the \"First name\" field.");
     document.FrmAffiliate.txtForename.focus();
     return (false);
   }

   if (document.FrmAffiliate.txtBusiness.value == "")
   {
     alert("Please enter a value for the \"Business name\" field.");
     document.FrmAffiliate.txtBusiness.focus();
     return (false);
   }

   if (document.FrmAffiliate.txtAddress.value == "")
   {
     alert("Please enter a value for the \"Address\" field.");
     document.FrmAffiliate.txtAddress.focus();
     return (false);
   }

   if (document.FrmAffiliate.txtStreet.value == "")
   {
     alert("Please enter a value for the \"Street\" field.");
     document.FrmAffiliate.txtStreet.focus();
     return (false);
   }

   if (document.FrmAffiliate.txtTown.value == "")
   {
     alert("Please enter a value for the \"Town\" field.");
     document.FrmAffiliate.txtTown.focus();
     return (false);
   }

   if (document.FrmAffiliate.txtState.value == "")
   {
     alert("Please enter a value for the \"State\" field.");
     document.FrmAffiliate.txtState.focus();
     return (false);
   }

   if (document.FrmAffiliate.txtZip.value == "")
   {
     alert("Please enter a value for the \"Zip\" field.");
     document.FrmAffiliate.txtZip.focus();
     return (false);
   }

   if (document.FrmAffiliate.lstCountry.selectedIndex == 0)
    {
                alert("Please enter a value for the \"Country\" field.");
                document.FrmAffiliate.lstCountry.focus();
                return (false);
    }

   if (document.FrmAffiliate.txtEmail.value.length < 5)
   {
     alert("Please enter at least 5 characters in the \"Email\" field.");
     document.FrmAffiliate.txtEmail.focus();
     return (false);
   }

   if (document.FrmAffiliate.txtEmail.value.indexOf("@") < 0 || document.FrmAffiliate.txtEmail.value.indexOf(".") < 0)
   {
     alert("An invalid \"Email\" address has been supplied please re-enter.");
     document.FrmAffiliate.txtEmail.focus();
     return (false);
   }

    if (document.FrmAffiliate.txtWebsite.value == "http://")
    {
      alert("Please enter a value for the \"Website\" field.");
      document.FrmAffiliate.txtWebsite.focus();
      return (false);
    }


    if (document.FrmAffiliate.txtPayable.value == "")
    {
      alert("Please enter a value for the \"Payable\" field.");
      document.FrmAffiliate.txtPayable.focus();
      return (false);
    }


   return (true);
 }

 function Validate_FrmAdvert(mode) {
 
	fld = document.FrmAdvert.txtPassword;
	fld.style.border = '';
	if (fld.value.length < 6) {
		fldError = "Please enter between 6-10 characters in the \"Password\" field.";
		return Validate_Style(fld, fldError);
	}

   var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz����������������������������������������������������������������������1234567890";
   var checkStr = document.FrmAdvert.txtPassword.value;
   var allValid = true;
   for (i = 0;  i < checkStr.length;  i++)
   {
     ch = checkStr.charAt(i);
     for (j = 0;  j < checkOK.length;  j++)
       if (ch == checkOK.charAt(j))
         break;
     if (j == checkOK.length)
     {
       allValid = false;
       break;
     }
   }
   if (!allValid)
   {
     fldError = "Please enter only letters and numbers in the \"Password\" field.";
     return Validate_Style(fld, fldError);
   }

   if (fld.value.length > 10)
    {
      fldError = "Please enter no more than 10 characters in the \"Password\" field.";
      return Validate_Style(fld, fldError);
   }

	fld = document.FrmAdvert.txtConfirm;
	fld.style.border = '';
	
   if (fld.value.length < 6)
   {
     fldError = "Please enter between 6-10 characters in the \"Confirm\" field.";
     return Validate_Style(fld, fldError);
   }

   var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz����������������������������������������������������������������������1234567890";
   var checkStr = document.FrmAdvert.txtConfirm.value;
   var allValid = true;
   for (i = 0;  i < checkStr.length;  i++)
   {
     ch = checkStr.charAt(i);
     for (j = 0;  j < checkOK.length;  j++)
       if (ch == checkOK.charAt(j))
         break;
     if (j == checkOK.length)
     {
       allValid = false;
       break;
     }
   }
   if (!allValid)
   {
     fldError = "Please enter only letters and numbers in the \"Confirm\" field.";
     return Validate_Style(fld, fldError);
   }

   if (document.FrmAdvert.txtConfirm.value.length > 10)
    {
      fldErorr = "Please enter no more than 10 characters in the \"Confirm\" field.";
      return Validate_Style(fld, fldError);
   }
   
   if (document.FrmAdvert.txtPassword.value != document.FrmAdvert.txtConfirm.value)
    {
      fldError = "Password confirmation does not match password - please re-enter";
      return Validate_Style(fld, fldError);
   }
   
   
	
	fld = document.FrmAdvert.lstDay;
	fld.style.border = '';
	if (mode=='create' && fld.selectedIndex < 0) {
	   fldError = "Please select your Day of Birth.";
	   return Validate_Style(fld, fldError);
	}

	fld = document.FrmAdvert.lstMonth;
	fld.style.border = '';
	if (mode=='create' && fld.selectedIndex < 0) {
	   fldError = "Please select your Month of Birth.";
	   return Validate_Style(fld, fldError);
	}

	fld = document.FrmAdvert.txtYear;
	fld.style.border = '';
	if (fld.value.length < 2) {
		fldError = "Please enter 2 digits in the \"Year of Birth\" field.";
		return Validate_Style(fld, fldError);
	}

	if (document.FrmAdvert.txtYear.value.length > 2) {
		fldError = "Please enter at most 2 digits in the \"Year of Birth\" field.";
		return Validate_Style(fld, fldError);
	}

	var checkOK = "0123456789";
	var checkStr = document.FrmAdvert.txtYear.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)	{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
		if (j == checkOK.length) {
			allValid = false;
			break;
		}
    }
	if (!allValid) {
		fldError = "Please enter only digits in the \"Year of Birth\" field.";
		return Validate_Style(fld, fldError);
	}

	fld = document.FrmAdvert.lstSex;
	fld.style.border = '';
	if (mode=='create' && fld.selectedIndex < 0) {
		fldError = "Please select your gender.";
		return Validate_Style(fld, fldError);
	}

	fld = document.FrmAdvert.txtEmail;
	fld.style.border = '';
	if (fld.value.length < 5)	{
		fldError = "Please enter at least 5 characters in the \"Email\" field.";
		return Validate_Style(fld, fldError);
	}
    var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    str = fld.value;

    if(!str.match(emailRegEx)) {    
        fldError = "An invalid \"Email\" address has been supplied please re-enter.";
        return Validate_Style(fld, fldError);
    }
	
	tfld = document.FrmAdvert.txtEmailConfirm;	
	if (tfld) {
		if (tfld.value != str) {
			fldError = "The confirm email address does not match.\n";
			return Validate_Style(tfld, fldError);
		} 
	}

	fld = document.FrmAdvert.lstCountry_;
	fld.style.border = '';	
	if (fld.value <= 0)	{
		fldError = "Please enter a value for the \"Country\" field.";		
		return Validate_Style(fld, fldError);
	}
	
	
	fld = document.FrmAdvert.lstCity;
	fld.style.border = '';	
	if (document.FrmAdvert.lstCity && fld.value <= 0) {		
		fldError = "Please enter a value for the \"In or Around\" field.";
		return Validate_Style(fld, fldError);	
	} 
	
	inarr=new Array(
		new Array("lstLstatus", "Living Status"),
		new Array("lstReligion", "Religion"),
		new Array("lstLanguages", "Languages"),
		new Array("lstNationality", "Nationality"),
		new Array("lstBodyType", "Body Type"),
		new Array("lstSeeking", "Relationship"),
		new Array("lstHeight", "Height"),
		new Array("lstChildren", "Children"),
		new Array("lstEyecolor", "Eye Colour"),
		new Array("lstHaircolor", "Hair Colour"),
		new Array("lstMarital",	"Marital Status"),
		new Array("lstEthnicity", "Ethnicity"),
		new Array("lstEducation", "Education"),
		new Array("lstEmployment", "Employment"),
		new Array("lstIncome", "Income"),
		new Array("lstDrink", "Drinker"),
		new Array("lstSmoke", "Smoker")		
	);
	
	for(i in inarr) {
		fld = document.FrmAdvert.elements[inarr[i][0]];
		fld.style.border = '';
		if (fld.selectedIndex == 0) {
			fldError = "Please enter a value for the \"" + inarr[i][1] +  "\" field.";
			return Validate_Style(fld, fldError);
		}
	}	

	fld = document.FrmAdvert.txtTitle;
	fld.style.border = '';
	if (fld.value.length < 5 || fld.value.length > 40) {
		fldError = "Please enter at between 5 and 30 characters in the \"Message Title\" field.";
		return Validate_Style(fld, fldError);
	}

	fld = document.FrmAdvert.txtComment;
	fld.style.border = '';
	if (fld.value.length < 5 || fld.value.length > 400) {
		fldError = "Please enter between 5 and 400 characters in the \"Message\" field.";
		return Validate_Style(fld, fldError);
	}
	
	fld = document.FrmAdvert.chkSeekmen;
	fld.style.border = '';
	if (document.FrmAdvert.chkSeekmen.checked == false && document.FrmAdvert.chkSeekwmn.checked == false) {
		fldError = "Please select the genders you are \"Seeking\".";
		return Validate_Style(fld, fldError);
	}	
   return (true);
 }

function delete_alert() {
        if (window.confirm("This will remove you from the system, including any profiles, mail and hotlist. Are you sure?")) {
                return true;
        } else {
                return false;
        }
}
function delete_alert2() {
        if (window.confirm("This will remove your profile from the system. Are you sure?")) {
                return true;
        } else {
                return false;
        }
}
function delete_alert3() {
        if (window.confirm("This will remove the profile from the system. Are you sure?")) {
                return true;
        } else {
                return false;
        }
}
function delete_alert4() {
        if (window.confirm("This will remove the member from the system. Are you sure?")) {
                return true;
        } else {
                return false;
        }
}
function skip_alert() {
        if (window.confirm("Do you wish to skip this part of the profile?")) {
                return true;
        } else {
                return false;
        }
}
function MDM_openWindow(theURL,winName,features) {
//        features += ',location=yes,status=yes,resizeable=yes';
        var _W=window.open(theURL,winName,features);
        _W.focus();
        _W.moveTo(50,30);
}
function selected(oRow){ oRow.style.backgroundColor='#FFFFE6'; }
function deselected(oRow){ oRow.style.backgroundColor='#DCE8FC'; }

function cupid_alert() {
        if (window.confirm("Are you sure you wish to run this process? Please check the documentation if unsure.")) {
                return true;
        } else {
                return false;
        }
}

// MACROMEDIA JavaScript
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function getCookie(name){
   var result = null;
   var myCookie = " " + document.cookie + ";";
   var searchName = " " + name + "=";
   var startOfCookie = myCookie.indexOf(searchName);
   var endOfCookie;

   if (startOfCookie != -1){
      startOfCookie += searchName.length;
      endOfCookie = myCookie.indexOf(";",startOfCookie);
      result = unescape(myCookie.substring(startOfCookie,endOfCookie));
   }
   return result;
}

window.setInterval("checkOnline()", 120000);