function checksms(){
var a = document.getmail.sms.value;
var reg = /^([+]{1}447[0-9]{9}|[+]{1}306[0-9]{9})$/;
if (a != ""){
 if (! reg.test(a)){
   alert("Your phone number is not in the correct format. It should be +44... for UK numbers and +30... for Greek numbers");
	document.getmail.sms.focus();
   return false;
}
return true;
}
return true;
}
function checkmail(){
//  var reg = /^[a-zA-Z0-9-]{1,}\.?[a-zA-Z0-9-]*@[a-zA-Z0-9-]*\.[a-zA-Z]{2,}\.?[a-zA-Z]{0,3}$/;
var a = document.getmail.mail.value;
var checkTLD=0; 
var knownDomsPat=/ ^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|uk|me)$/; 
var emailPat=/^(.+)@(.+)$/; 
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]"; 
var validChars="\[^\\s" + specialChars + "\]"; 
var quotedUser="(\"[^\"]*\")"; 
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/; 
var atom=validChars + '+'; 
var word="(" + atom + "|" + quotedUser + ")"; 
var userPat=new RegExp("^" + word + "(\\." + word + ")*$"); 
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$"); 
var matchArray=a.match(emailPat); 

//check there is an email address
if (matchArray==null) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.getmail.mail.focus();
	return false; 
} 
//check the username doesn't contain invalid characters
var user=matchArray[1]; 
var domain=matchArray[2]; 
for (i=0; i<user.length; i++) { 
if (user.charCodeAt(i)>127) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.getmail.mail.focus();
	return false; 
} 
} 
//check the domain name doesn't contain invalid characters
for (i=0; i<domain.length; i++) { 
if (domain.charCodeAt(i)>127) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.getmail.mail.focus();
	return false; 
} 
} 
//check username is not invalid
if (user.match(userPat)==null) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.getmail.mail.focus();
	return false; 
} 
//check destination IP is not invalid if email is IP address format
var IPArray=domain.match(ipDomainPat); 
if (IPArray!=null) { 
	for (var i=1;i<=4;i++) { 
		if (IPArray>255) { 
			alert("Your e-mail address is not in the right format, please check and re-enter!");
		 	document.getmail.mail.focus();
			return false; 
} 
} 
} 
//check domain name is not invalid
var atomPat=new RegExp("^" + atom + "$"); 
var domArr=domain.split("."); 
var len=domArr.length; 
for (i=0;i<len;i++) { 
	if (domArr[i].search(atomPat)==-1) { 
		alert("Your e-mail address is not in the right format, please check and re-enter!");
 		document.getmail.mail.focus();
		return false; 
} 
} 
//check TLD is not invalid
if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.getmail.mail.focus();
	return false; 
} 
if (len<2) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.getmail.mail.focus();
	return false; 
}
//if we get this far everything is OK so we return true
return true;
}
function checkname(){
var a = document.getmail.namesurname.value;
  var reg = /^([a-zA-Z][.][a-zA-Z][.]\ *[a-zA-Z]{3,})| ([a-zA-Z]{3,}\ *[a-zA-Z][.]\ *[a-zA-Z]{3,})|([a-zA-Z]{3,}[-][a-zA-Z]{3,}\ *[a-zA-Z]{3,})|([a-zA-Z]{3,}[-][a-zA-Z]{3,}\ *[a-zA-Z]{3,}[-][a-zA-Z]{3,})|([a-zA-Z]{3,}\ *[a-zA-Z]{3,})$/;
//  var reg = /^[a-zA-Z]{1,}\.?\ ?[a-zA-Z]\ [a-zA-Z]{1,}\-?[a-zA-Z]*$/;
 if (! reg.test(a)){
 alert("Please check the form entry for your name - only Latin characters are allowed");
 document.getmail.namesurname.focus();
  return false;
}
return true;
}
function checkall(){
if (! checkmail() || ! checksms() || ! checkname()) {
	return false;
	}
else
{
	return true;
	}
}

function checkukmobile(){
var a = document.webapplicationform.sms.value;
var reg = /^[+]{1}447[0-9]{9}$/;
 if (! reg.test(a)){
   alert("Your phone number is not in the correct format. It should be +44... for UK numbers");
   document.webapplicationform.sms.focus();
   return false;
}
return true;
}
function checkgrmobile(){
var a = document.webapplicationform.sms.value;
var reg = /^[+]{1}306[0-9]{9}$/;
 if (! reg.test(a)){
   alert("Your phone number is not in the correct format. It should be +30... for GR numbers");
   document.webapplicationform.sms.focus();
	return false;
}
return true;
}
function checkmail2(){
//  var reg = /^[a-zA-Z0-9-]{1,}\.?[a-zA-Z0-9-]*@[a-zA-Z0-9-]*\.[a-zA-Z]{2,}\.?[a-zA-Z]{0,3}$/;
var a = document.webapplicationform.email.value;
var checkTLD=0; 
var knownDomsPat=/ ^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|uk|me)$/; 
var emailPat=/^(.+)@(.+)$/; 
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]"; 
var validChars="\[^\\s" + specialChars + "\]"; 
var quotedUser="(\"[^\"]*\")"; 
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/; 
var atom=validChars + '+'; 
var word="(" + atom + "|" + quotedUser + ")"; 
var userPat=new RegExp("^" + word + "(\\." + word + ")*$"); 
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$"); 
var matchArray=a.match(emailPat); 

//check there is an email address
if (matchArray==null) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.webapplicationform.email.focus();
	return false; 
} 
//check the username doesn't contain invalid characters
var user=matchArray[1]; 
var domain=matchArray[2]; 
for (i=0; i<user.length; i++) { 
if (user.charCodeAt(i)>127) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.webapplicationform.email.focus();
	return false; 
} 
} 
//check the domain name doesn't contain invalid characters
for (i=0; i<domain.length; i++) { 
if (domain.charCodeAt(i)>127) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.webapplicationform.email.focus();
	return false; 
} 
} 
//check username is not invalid
if (user.match(userPat)==null) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.webapplicationform.email.focus();
	return false; 
} 
//check destination IP is not invalid if email is IP address format
var IPArray=domain.match(ipDomainPat); 
if (IPArray!=null) { 
	for (var i=1;i<=4;i++) { 
		if (IPArray>255) { 
			alert("Your e-mail address is not in the right format, please check and re-enter!");
		 	document.webapplicationform.email.focus();
			return false; 
} 
} 
} 
//check domain name is not invalid
var atomPat=new RegExp("^" + atom + "$"); 
var domArr=domain.split("."); 
var len=domArr.length; 
for (i=0;i<len;i++) { 
	if (domArr[i].search(atomPat)==-1) { 
		alert("Your e-mail address is not in the right format, please check and re-enter!");
 		document.webapplicationform.email.focus();
		return false; 
} 
} 
//check TLD is not invalid
if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.webapplicationform.email.focus();
	return false; 
} 
if (len<2) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.webapplicationform.email.focus();
	return false; 
}
//if we get this far everything is OK so we return true
return true;
}
function checkfirstname2(){
var a = document.webapplicationform.firstname.value;
 var reg = /^([a-zA-Z]{3,}\ *[a-zA-Z][.]\ *)|([a-zA-Z]{3,}[-][a-zA-Z]{3,}\ *)|([a-zA-Z]{3,}[-][a-zA-Z]{3,}\ *)|([a-zA-Z]{3,}\ *)$/;
 // var reg = /^[a-zA-Z]{1,}\.?\ ?[a-zA-Z]\ [a-zA-Z]{1,}\-?[a-zA-Z]*$/;
 if (! reg.test(a)){
 alert("Please check the form entry for your first name");
document.webapplicationform.firstname.focus();  
return false;
}
return true;
}

function checkfirstname5(){
var a = document.webcomapplicationform.firstname.value;
 var reg = /^([a-zA-Z]{3,}\ *[a-zA-Z][.]\ *)|([a-zA-Z]{3,}[-][a-zA-Z]{3,}\ *)|([a-zA-Z]{3,}[-][a-zA-Z]{3,}\ *)|([a-zA-Z]{3,}\ *)$/;
 // var reg = /^[a-zA-Z]{1,}\.?\ ?[a-zA-Z]\ [a-zA-Z]{1,}\-?[a-zA-Z]*$/;
 if (! reg.test(a)){
 alert("Please check the form entry for your first name");
document.webapplicationform.firstname.focus();  
return false;
}
return true;
}

function checksurname2(){
var a = document.webapplicationform.surname.value;
  var reg = /^([a-zA-Z]{3,})|([a-zA-Z]{3,}[-][a-zA-Z]{3,})$/;
 // var reg = /^[a-zA-Z]{1,}\.?\ ?[a-zA-Z]\ [a-zA-Z]{1,}\-?[a-zA-Z]*$/;
 if (! reg.test(a)){
 alert("Please check the form entry for your last name");
document.webapplicationform.surname.focus();  
return false;
}
return true;
}

function checksurname5(){
var a = document.webcomapplicationform.surname.value;
  var reg = /^([a-zA-Z]{3,})|([a-zA-Z]{3,}[-][a-zA-Z]{3,})$/;
 // var reg = /^[a-zA-Z]{1,}\.?\ ?[a-zA-Z]\ [a-zA-Z]{1,}\-?[a-zA-Z]*$/;
 if (! reg.test(a)){
 alert("Please check the form entry for your last name");
document.webapplicationform.surname.focus();  
return false;
}
return true;
}

function checkdob(){
var a = document.webapplicationform.dob.value;
var reg = /^[0-9]{2}\/[0-9]{2}\/[0-9]{2}$/;
 if (! reg.test(a)){
   alert("Your date of birth is not in the correct format. It should be in the format 01/01/01");
	document.webapplicationform.dob.focus();
   return false;
}
return true;
}
function checkadt(){
var a = document.webapplicationform.adt.value;
var reg = /^[A-Za-z]{1}[0-9]{6}$/;
 if (! reg.test(a)){
   alert("Your National Identity Number is not in the correct format!");
document.webapplicationform.adt.focus();
   return false;
}
return true;
}

function checkfathername(){
var a = document.webapplicationform.fathername.value;
var reg = /^[A-Za-z]{4,}$/;
 if (! reg.test(a)){
   alert("Your father's name seems not to be long enough!");
document.webapplicationform.fathername.focus();   
return false;
}
return true;
}
function checkmothername(){
var a = document.webapplicationform.mothername.value;
var reg = /^[A-Za-z]{4,}$/;
 if (! reg.test(a)){
   alert("Your mother's name seems not to be long enough!");
document.webapplicationform.mothername.focus();   
return false;
}
return true;
}

function checkall2(){
if (! checkmail2() ||  ! checkukmobile() ||  ! checkfirstname2() || ! checksurname2()  ) {
	return false;
	}
else
{
	return true;
	}
}


function checkall3(){
if (! checkmail3() || ! checkukmobile3() || ! checkname3() || ! checkfilename()||! radio_button_checker()  ) {
	return false;
	}
else
{
	return true;
	}
}

function checkall5(){
if (! checkmail5() ||  ! checkukmobile() ||  ! checkfirstname5() || ! checksurname5()  ) {
	return false;
	}
else
{
	return true;
	}
}
function checkmail3(){
var a = document.yoursay.email.value;
 var reg = /^[a-zA-Z0-9-]{1,}\.?[a-zA-Z0-9-]*@[a-zA-Z0-9-]*\.[a-zA-Z]{2,}\.?[a-zA-Z]{0,3}$/;
 if (! reg.test(a)){
 alert("Your e-mail address is not in the right format, please check and re-enter!");
document.yoursay.email.focus();  
return false;
}
return true;
}

function checkukmobile2(){
var a = document.yoursay.ukmobile.value;
var reg = /^[+]{1}44[0-9]{10}$/;
 if (! reg.test(a)){
   alert("Your phone number is not in the correct format. It should be +44... for UK numbers");
document.yoursay.ukmobile.focus();
   return false;
}
return true;
}

function radio_button_checker()
{
// set var radio_choice to false
var radio_choice = false;

// Loop from zero to the one minus the number of radio button selections
for (counter = 0; counter < document.yoursay.ndorgmember.length; counter++)
{
// If a radio button has been selected it will return true
// (If not it will return false)
if (document.yoursay.ndorgmember[counter].checked)
{
radio_choice = true; 
return true;
}
}

// If there were no selections made display an alert box 
alert("Please select whether you are a member of an ND organisation or not.")
return (false);
}

function checkname3(){
var a = document.yoursay.namesurname.value;
// var reg = /^[a-zA-Z]{1,}\.?\ ?[a-zA-Z]\ [a-zA-Z]{1,}\-?[a-zA-Z]*$/;
  var reg = /^([a-zA-Z][.][a-zA-Z][.]\ *[a-zA-Z]{3,})| ([a-zA-Z]{3,}\ *[a-zA-Z][.]\ *[a-zA-Z]{3,})|([a-zA-Z]{3,}[-][a-zA-Z]{3,}\ *[a-zA-Z]{3,})|([a-zA-Z]{3,}[-][a-zA-Z]{3,}\ *[a-zA-Z]{3,}[-][a-zA-Z]{3,})|([a-zA-Z]{3,}\ *[a-zA-Z]{3,})$/;
 if (! reg.test(a)){
 alert("Please check the form entry for your name");
document.yoursay.namesurname.focus();
  return false;
}
return true;
}

function checkfilename(){
if (document.yoursay.userfile.value == "" && document.yoursay.morecomments.value == "") {
	alert("Please specify the file name you want to send us or write some comments!");
	return false;
	}
return true;
}


function checkverifyid(){
var a = document.memberidentry.partyid.value;
var reg = /^[0-9]{8}$/;
 if (! reg.test(a)){
   alert("Your party id is not in the correct format. It should be eight digits long.");
document.memberidentry.partyid.focus();
   return false;
}
return true;
}


function checkpaypalfn(){
var a = document.searchid.paypalfirstname.value;
var reg = /^[A-Za-z]{3,}\s*-?\s*[a-zA-Z]*$/;
 if (! reg.test(a)){
   alert("Your first name entry seems to be containing illegal characters. Please check and re-enter!");
document.searchid.paypalfirstname.focus();
   return false;
}
return true;
}

function checkpaypalln(){
var a = document.searchid.paypallastname.value;
var reg = /^[A-Za-z]{3,}\s*-?\s*[a-zA-Z]*$/;
 if (! reg.test(a)){
   alert("Your last name entry seems to be containing illegal characters. Please check and re-enter!");
document.searchid.paypallastname.focus();
   return false;
}
return true;
}

function checkpaypalfn2(){
var a = document.searchid.paypalfathername.value;
var reg = /^[A-Za-z]{3,}\s*-?\s*[a-zA-Z]*$/;
 if (! reg.test(a)){
   alert("Your father's first name entry seems to be containing illegal characters. Please check and re-enter!");
document.searchid.paypalfathername.focus();
   return false;
}
return true;
}

function checkpaypaladt(){
var a = document.searchid.paypaladt.value;
var reg = /^[A-Za-z]{1}[0-9]{6}|[A-Za-z]{2}[0-9]{7}|[A-Za-z]{1}[0-9]{5}$/;
 if (! reg.test(a)){
   alert("Your Passport number or your National Identity number seem not to be in the right format. Please check and re-enter!");
document.searchid.paypaladt.focus();
   return false;
}
return true;
}

function checkpaypalsearch(){
if (! checkpaypalfn() || ! checkpaypalln() || ! checkpaypalfn2() || ! checkpaypaladt()){
	return false;
}
return true;
}  

function runcheck(){
if (! checkpaypalpc() || ! checkpaypaladdress1() || ! checkpaypalsubscription() || ! checkpaypalamount()) {
	return false;
}
return true;
}

function checkpaypalpc(){
//  (GIR 0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]|[A-HK-Y][0-9]([0-9]|[ABEHMNPRV-Y]))|[0-9][A-HJKS-UW]) [0-9][ABD-HJLNP-UW-Z]{2})
var a = document.paypalform.zip.value;
var reg = /^[A-Za-z]{1,2}[0-9]{1,2}[ ]?[0-9]{1,2}[A-Za-z]{2}$/;
 if (! reg.test(a)){
   alert("Your postcode entry seems not to be valid. Please check and re-enter!");
document.paypalform.zip.focus();
   return false;
}
return true;
}

function checkpaypaladdress1(){
var a = document.paypalform.address1.value;
// var reg = /^\d{1,}[ ]*[a-zA-Z]{1,}[.]?[ ]*[a-zA-Z]{1,}$/;
var reg= /^[ ]*\d{1,}[-]\d{1,}[ ]*[a-zA-Z]{1,}[.]?[ ]*[a-zA-Z]{1,}[']?[a-zA-Z]*[ ]*[a-zA-Z]*[ ]*$/;
var reg2 = /^\d{1,}[ ]*[a-zA-Z]{1,}[.]?[ ]*[a-zA-Z]{1,}[']?[a-zA-Z]?[ ]*[a-zA-Z]?[ ]*$/; 
var reg3 = /^[ ]*[a-zA-Z][ ]*[a-zA-Z][ ]*[,]?[ ]*[a-zA-Z][.]?[ ]*[a-zA-Z][']?[a-zA-Z][ ]*[a-zA-Z][ ]*$/;
// var reg = /^[0-9]{1,4}[ ]*[A-Za-z]{1,}['. ]?[A-Za-z ]*$/;
 if (! reg.test(a) && ! reg2.test(a) && ! reg3.test(a)){
   alert("Your address format seems not to be valid. It has to be (line 1) Example Building, Flat 12 (line 2) 12 High Street or (line) 12 Example Building - please only fill in the second line if your first line is of the first form");
document.paypalform.address1.focus();
   return false;
}
return true;
}

function checkpaypalsubscription(){
var a = document.paypalform.os0.selectedIndex;
 if ( a == 0){
   alert("You must select a subscription type!");
document.paypalform.os0.focus();
   return false;
}
return true;
}

function checkpaypalamount(){
var a = document.paypalform.amount.value;
 if ( a >= 150){
   alert("We can not process payments more than a hundred and fifty pounds - please revise the amount or get in touch on 070 90 80 10 80!");
document.paypalform.amount.focus();
   return false;
}
return true;
}

function updateos0(){
document.paypalform.amount.value = document.paypalform.os0.options[document.paypalform.os0.selectedIndex].value;
}

function updateyoursayform() {
if (document.yoursay.ndorgmember[1].checked)
{
	document.yoursay.ukmember.disabled = true;
	document.yoursay.ndorg.disabled = true;
}

if (document.yoursay.ndorgmember[0].checked)
{
	document.yoursay.ukmember.disabled = false;
	document.yoursay.ndorg.disabled = false;
}
}

function updateyoursayform1(){
	if (document.yoursay.ukmember[document.yoursay.ukmember.selectedIndex].value != "other")
	{
		document.yoursay.ndorg.disabled = true;
	}
	else {
		document.yoursay.ndorg.disabled = false;
	}
}

function checkname4(){
var a = document.volunteer.namesurname.value;
// var reg = /^[a-zA-Z]{1,}\.?\ ?[a-zA-Z]\ [a-zA-Z]{1,}\-?[a-zA-Z]*$/;
  var reg = /^([a-zA-Z][.][a-zA-Z][.]\ *[a-zA-Z]{3,})| ([a-zA-Z]{3,}\ *[a-zA-Z][.]\ *[a-zA-Z]{3,})|([a-zA-Z]{3,}[-][a-zA-Z]{3,}\ *[a-zA-Z]{3,})|([a-zA-Z]{3,}[-][a-zA-Z]{3,}\ *[a-zA-Z]{3,}[-][a-zA-Z]{3,})|([a-zA-Z]{3,}\ *[a-zA-Z]{3,})$/;
 if (! reg.test(a)){
 alert("Please check the form entry for your name");
document.volunteer.namesurname.focus();
  return false;
}
return true;
}

function checkukmobile3(){
var a = document.yoursay.ukmobile.value;
var reg = /^[+]{1}44[0-9]{10}$/;
 if (! reg.test(a)){
   alert("Your phone number is not in the correct format. It should be +44... for UK numbers");
document.yoursay.ukmobile.focus();
   return false;
}
return true;
}

function checkukaddress(){
var a = document.volunteer.ukpostaladdress.value;
var reg = /^(\s*\d{1,}\s*\w[.]?\s*\w[']?\w\s*\w\s*|\s*\d{1,}[-]\d{1,}\s*\w[.]?\s*\w[']?\w\s*\w\s*|\s*\w\s*\w\s*[,]?\s*\w[.]?\s*\w[']?\w\s*\w\s*)$/;
// var reg = /^[0-9]{1,4}[ ]*[A-Za-z]{1,}['. ]?[A-Za-z ]*$/;
 if (! reg.test(a)){
   alert("Your address format seems not to be valid. It has to be (line 1) Example Building, Flat 12 (line 2) 12 High Street or (line) 12 Example Building - please only fill in the second line if your first line is of the first form");
document.volunteer.ukpostaladdress.focus();
   return false;
}
return true;
}

function checkage(){
var a = document.volunteer.age.value;
var reg = /^[1-9][0-9]$/;
 if (! reg.test(a)){
   alert("Your entry for the age field should contain only numbers and nothing else!");
document.volunteer.age.focus();
   return false;
}
return true;
}

function checkukmobile3(){
var a = document.volunteer.ukmobile.value;
var reg = /^[+]{1}44[0-9]{10}$/;
 if (! reg.test(a)){
   alert("Your phone number is not in the correct format. It should be +44... for UK numbers");
document.volunteer.ukmobile.focus();
   return false;
}
return true;
}

function checkprofession(){
var a = document.volunteer.profession.value;
 if (a == ""){
   alert("Please tell us what your profession is!");
document.volunteer.profession.focus();
   return false;
}
return true;
}

function checkintsectors(){
var a = document.volunteer.intsectors.value;
 if (a == ""){
   alert("Please tell us what sectors are of interest to you!");
document.volunteer.intsectors.focus();
   return false;
}
return true;
}

function checkvotingarea(){
var a = document.volunteer.votingarea.value;
 if (a == ""){
   alert("Please tell us where you vote in Greece!");
document.volunteer.votingarea.focus();
   return false;
}
return true;
}

function checkqualifications(){
var a = document.volunteer.qualifications.value;
 if (a == ""){
   alert("Please tell us about your qualifications!");
document.volunteer.qualifications.focus();
   return false;
}
return true;
}

function checkall4(){
if (! checkname4() || ! checkukmobile3() || ! checkukaddress() || ! checkage() ||! checkprofession() ||! checkintsectors() ||! checkvotingarea() || ! checkqualifications()) {
	return false;
}
return true;
}
function checkmail5(){
//  var reg = /^[a-zA-Z0-9-]{1,}\.?[a-zA-Z0-9-]*@[a-zA-Z0-9-]*\.[a-zA-Z]{2,}\.?[a-zA-Z]{0,3}$/;
var a = document.webcomapplicationform.email.value;
var checkTLD=0; 
var knownDomsPat=/ ^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|uk|me)$/; 
var emailPat=/^(.+)@(.+)$/; 
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]"; 
var validChars="\[^\\s" + specialChars + "\]"; 
var quotedUser="(\"[^\"]*\")"; 
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/; 
var atom=validChars + '+'; 
var word="(" + atom + "|" + quotedUser + ")"; 
var userPat=new RegExp("^" + word + "(\\." + word + ")*$"); 
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$"); 
var matchArray=a.match(emailPat); 

//check there is an email address
if (matchArray==null) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.webapplicationform.email.focus();
	return false; 
} 
//check the username doesn't contain invalid characters
var user=matchArray[1]; 
var domain=matchArray[2]; 
for (i=0; i<user.length; i++) { 
if (user.charCodeAt(i)>127) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.webapplicationform.email.focus();
	return false; 
} 
} 
//check the domain name doesn't contain invalid characters
for (i=0; i<domain.length; i++) { 
if (domain.charCodeAt(i)>127) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.webapplicationform.email.focus();
	return false; 
} 
} 
//check username is not invalid
if (user.match(userPat)==null) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.webapplicationform.email.focus();
	return false; 
} 
//check destination IP is not invalid if email is IP address format
var IPArray=domain.match(ipDomainPat); 
if (IPArray!=null) { 
	for (var i=1;i<=4;i++) { 
		if (IPArray>255) { 
			alert("Your e-mail address is not in the right format, please check and re-enter!");
		 	document.webapplicationform.email.focus();
			return false; 
} 
} 
} 
//check domain name is not invalid
var atomPat=new RegExp("^" + atom + "$"); 
var domArr=domain.split("."); 
var len=domArr.length; 
for (i=0;i<len;i++) { 
	if (domArr[i].search(atomPat)==-1) { 
		alert("Your e-mail address is not in the right format, please check and re-enter!");
 		document.webapplicationform.email.focus();
		return false; 
} 
} 
//check TLD is not invalid
if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.webapplicationform.email.focus();
	return false; 
} 
if (len<2) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.webapplicationform.email.focus();
	return false; 
}
//if we get this far everything is OK so we return true
return true;
}
function checkeuroel(){
if (! checkeuroelname() || ! checkeuroelmobile() || ! checkeuroeltransferfrom()) {
	return false;
}
return true;
}
function checkeuroelmobile(){
var a = document.euroelections.euroelmobile.value;
var reg = /^[+]{1}44[0-9]{10}$/;
 if (! reg.test(a)){
   alert("Your mobile phone number is not in the correct format. It should be +44...");
document.euroelections.euroelmobile.focus();
   return false;
}
return true;
}
function checkeuroelname(){
var a = document.euroelections.euroelname.value;
// var reg = /^[a-zA-Z]{1,}\.?\ ?[a-zA-Z]\ [a-zA-Z]{1,}\-?[a-zA-Z]*$/;
  var reg = /^([a-zA-Z][.][a-zA-Z][.]\ *[a-zA-Z]{3,})| ([a-zA-Z]{3,}\ *[a-zA-Z][.]\ *[a-zA-Z]{3,})|([a-zA-Z]{3,}[-][a-zA-Z]{3,}\ *[a-zA-Z]{3,})|([a-zA-Z]{3,}[-][a-zA-Z]{3,}\ *[a-zA-Z]{3,}[-][a-zA-Z]{3,})|([a-zA-Z]{3,}\ *[a-zA-Z]{3,})$/;
 if (! reg.test(a)){
 alert("Please check the form entry for your name");
document.euroelections.euroelname.focus();
  return false;
}
return true;
}
function checkeuroelland(){
var a = document.euroelections.euroelland.value;
var reg = /^[+]{1}44[0-9]{10}$/;
 if (! reg.test(a)){
   alert("Your landline phone number is not in the correct format. It should be +44...");
document.euroelections.euroelland.focus();
   return false;
}
return true;
}
function checkeuroeltransferfrom(){
var a = document.euroelections.euroeltransferfrom.value;
if (a == ""){
	alert("You haven't completed the town you want to be transfered from!");
	document.euroelections.euroeltransferfrom.focus();
	return false;
}
return true;
}
function checkeuroelemail(){
//  var reg = /^[a-zA-Z0-9-]{1,}\.?[a-zA-Z0-9-]*@[a-zA-Z0-9-]*\.[a-zA-Z]{2,}\.?[a-zA-Z]{0,3}$/;
var a = document.euroelections.euroelemail.value;
var checkTLD=0; 
var knownDomsPat=/ ^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|uk|me)$/; 
var emailPat=/^(.+)@(.+)$/; 
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]"; 
var validChars="\[^\\s" + specialChars + "\]"; 
var quotedUser="(\"[^\"]*\")"; 
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/; 
var atom=validChars + '+'; 
var word="(" + atom + "|" + quotedUser + ")"; 
var userPat=new RegExp("^" + word + "(\\." + word + ")*$"); 
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$"); 
var matchArray=a.match(emailPat); 

//check there is an email address
if (matchArray==null) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.euroelections.euroelemail.focus();
	return false; 
} 
//check the username doesn't contain invalid characters
var user=matchArray[1]; 
var domain=matchArray[2]; 
for (i=0; i<user.length; i++) { 
if (user.charCodeAt(i)>127) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.euroelections.euroelemail.focus();
	return false; 
} 
} 
//check the domain name doesn't contain invalid characters
for (i=0; i<domain.length; i++) { 
if (domain.charCodeAt(i)>127) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.euroelections.euroelemail.focus();
	return false; 
} 
} 
//check username is not invalid
if (user.match(userPat)==null) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.euroelections.euroelemail.focus();
	return false; 
} 
//check destination IP is not invalid if email is IP address format
var IPArray=domain.match(ipDomainPat); 
if (IPArray!=null) { 
	for (var i=1;i<=4;i++) { 
		if (IPArray>255) { 
			alert("Your e-mail address is not in the right format, please check and re-enter!");
		 	document.euroelections.euroelemail.focus();
			return false; 
} 
} 
} 
//check domain name is not invalid
var atomPat=new RegExp("^" + atom + "$"); 
var domArr=domain.split("."); 
var len=domArr.length; 
for (i=0;i<len;i++) { 
	if (domArr[i].search(atomPat)==-1) { 
		alert("Your e-mail address is not in the right format, please check and re-enter!");
 		document.euroelections.euroelemail.focus();
		return false; 
} 
} 
//check TLD is not invalid
if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.euroelections.euroelemail.focus();
	return false; 
} 
if (len<2) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.euroelections.euroelemail.focus();
	return false; 
}
//if we get this far everything is OK so we return true
return true;
}
function checkelections(){
if ( ! checkelectionemail() || ! checkelectionmobile() || ! checkelectionfrom() || ! checkelectionto() || ! checkelectionfn() || ! checkelectionln() || !checkdeparturedate() || !checkdeparturecon() || !checknonLatinfirstname() || !checknonLatinlastname() || !checknonLatinflyFrom() || !checknonLatinesoteriki() || !checknonLatingcomments()) 
{
	
	return false;
}
	return true;
}
function checkelectionemail(){
//  var reg = /^[a-zA-Z0-9-]{1,}\.?[a-zA-Z0-9-]*@[a-zA-Z0-9-]*\.[a-zA-Z]{2,}\.?[a-zA-Z]{0,3}$/;
var a = document.webelectionform.email.value;
var checkTLD=0; 
var knownDomsPat=/ ^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|uk|me)$/; 
var emailPat=/^(.+)@(.+)$/; 
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]"; 
var validChars="\[^\\s" + specialChars + "\]"; 
var quotedUser="(\"[^\"]*\")"; 
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/; 
var atom=validChars + '+'; 
var word="(" + atom + "|" + quotedUser + ")"; 
var userPat=new RegExp("^" + word + "(\\." + word + ")*$"); 
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$"); 
var matchArray=a.match(emailPat); 

//check there is an email address
if (matchArray==null) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.webelectionform.email.focus();
	return false; 
} 
//check the username doesn't contain invalid characters
var user=matchArray[1]; 
var domain=matchArray[2]; 
for (i=0; i<user.length; i++) { 
if (user.charCodeAt(i)>127) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.webelectionform.email.focus();
	return false; 
} 
} 
//check the domain name doesn't contain invalid characters
for (i=0; i<domain.length; i++) { 
if (domain.charCodeAt(i)>127) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.webelectionform.email.focus();
	return false; 
} 
} 
//check username is not invalid
if (user.match(userPat)==null) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.webelectionform.email.focus();
	return false; 
} 
//check destination IP is not invalid if email is IP address format
var IPArray=domain.match(ipDomainPat); 
if (IPArray!=null) { 
	for (var i=1;i<=4;i++) { 
		if (IPArray>255) { 
			alert("Your e-mail address is not in the right format, please check and re-enter!");
		 	document.webelectionform.email.focus();
			return false; 
} 
} 
} 
//check domain name is not invalid
var atomPat=new RegExp("^" + atom + "$"); 
var domArr=domain.split("."); 
var len=domArr.length; 
for (i=0;i<len;i++) { 
	if (domArr[i].search(atomPat)==-1) { 
		alert("Your e-mail address is not in the right format, please check and re-enter!");
 		document.webelectionform.email.focus();
		return false; 
} 
} 
//check TLD is not invalid
if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.webelectionform.email.focus();
	return false; 
} 
if (len<2) { 
	alert("Your e-mail address is not in the right format, please check and re-enter!");
 	document.webelectionform.email.focus();
	return false; 
}
//if we get this far everything is OK so we return true
return true;
}
function checkelectionmobile(){
var a = document.webelectionform.ukmobile.value;
var reg = /^[+]{1}44[0-9]{10}$/;
 if (! reg.test(a)){
   alert("Your phone number is not in the correct format. It should be +44... for UK numbers");
   document.webelectionform.ukmobile.focus();
   return false;
}
return true;
}
function checkelectionfrom(){
var a = document.webelectionform.flyfrom.value;
if (a == ""){
	alert("You did not specify where you want to fly out from!");
	document.webelectionform.flyfrom.focus();
	return false;
}
return true;
}
function checkelectionto(){
var a = document.webelectionform.flyto.value;
if (a == ""){
	alert("You did not specify where you want to fly out to!");
	document.webelectionform.flyto.focus();
	return false;
}
return true;
}
function checkelectionfn(){
var a = document.webelectionform.firstname.value;
if (a == ""){
	alert("You did not specify your first name!");
	document.webelectionform.firstname.focus();
	return false;
}
return true;
}
function checkelectionln(){
var a = document.webelectionform.surname.value;
if (a == ""){
	alert("You did not specify your last  name!");
	document.webelectionform.surname.focus();
	return false;
}
return true;
}
function checkdeparturedate(){
if ((document.webelectionform.fromday[document.webelectionform.fromday.selectedIndex].value == "" && document.webelectionform.frommonth[document.webelectionform.frommonth.selectedIndex].value != "") || (document.webelectionform.fromday[document.webelectionform.fromday.selectedIndex].value     != "" && document.webelectionform.frommonth[document.webelectionform.frommonth.selectedIndex].value == "")){
	alert("You need to specify both the day and the month you want to fly out from!");
	return false;
}
return true;
}
function checkdeparturecon(){
if ((document.webelectionform.fromday[document.webelectionform.fromday.selectedIndex].value >24 && document.webelectionform.fromday[document.webelectionform.fromday.selectedIndex].value <30) && (document.webelectionform.frommonth[document.webelectionform.frommonth.selectedIndex].value == "" || document.webelectionform.frommonth[document.webelectionform.frommonth.selectedIndex].value  == "10")) {
	alert("These are not valid days for travel, please select others!");
	return false;   
}
if ((document.webelectionform.fromday[document.webelectionform.fromday.selectedIndex].value < 3 ) && (document.webelectionform.frommonth[document.webelectionform.frommonth.selectedIndex].value == "" || document.webelectionform.frommonth[document.webelectionform.frommonth.selectedIndex].value  == "09")) {
	alert("These are not valid days for travel, please select others!");
	return false;   
}
return true;
}
function checknonLatinfirstname(){
	var ls = "abcdefghijklmnopqrstuvywxyz-";
	var ud = document.webelectionform.firstname.value;
	var char;
	for (i = 0; i < ud.length ; i++ )
	{
		char = ud.charAt(i);
		if (ls.indexOf(char.toLowerCase()) == -1)
		{
			alert("Your first name should only contain Latin characters - please re-enter");
			return false;
		}
	}
	return true;
}
function checknonLatinlastname(){
	var ls = "abcdefghijklmnopqrstuvywxyz-";
	var ud = document.webelectionform.surname.value;
	var char;
	for (i = 0; i < ud.length ; i++ )
	{
		char = ud.charAt(i);
		if (ls.indexOf(char.toLowerCase()) == -1)
		{
			alert("Your surname should only contain Latin characters - please re-enter");
			return false;
		}
	}
	return true;
}
function checknonLatinflyFrom(){
	var ls = "abcdefghijklmnopqrstuvywxyz";
	var ud = document.webelectionform.flyfrom.value;
	var char;
	for (i = 0; i < ud.length ; i++ )
	{
		char = ud.charAt(i);
		if (ls.indexOf(char.toLowerCase()) == -1)
		{
			alert("The city you are flying from should only contain Latin characters - please re-enter");
			return false;
		}
	}
	return true;
}
function checknonLatinesoteriki(){
	var ls = "abcdefghijklmnopqrstuvywxyz";
	var ud = document.webelectionform.esoteriki.value;
	if ( ud == "") {
		return true;
	}
	var char;
	for (i = 0; i < ud.length ; i++ )
	{
		char = ud.charAt(i);
		if (ls.indexOf(char.toLowerCase()) == -1)
		{
			alert("The value for your final destination in Greece should only contain Latin characters - please re-enter");
			return false;
		}
}
}
function checknonLatingcomments(){
	var ls = "abcdefghijklmnopqrstuvywxyz./- 0123456789";
	var ud = document.webelectionform.gcomments.value;
	var char;
	for (i = 0; i < ud.length ; i++ )
	{
		char = ud.charAt(i);
		if (ls.indexOf(char.toLowerCase()) == -1)
		{
			alert("Your comments should be in Latin and not contain commas - please re-enter");
			return false;
		}
	}
	return true;
}
function checkelections2(){
if ( ! checkelectionemail() || ! checkelectionmobile() || ! checkelectionfn() || ! checkelectionln() || !checknonLatinfirstname() || !checknonLatinlastname()  || !checknonLatinesoteriki()) 
{
	
	return false;
}
	return true;
}
