function verifica_sendinfo(){
	if (document.frmImageUp.nome.value==""){
		window.alert ("You need to fill in the NAME field." + "\n");
		document.frmImageUp.nome.focus(); 
		return false;
	}
	if (document.frmImageUp.assunto.value==""){
		window.alert ("You need to fill in the SUBJECT field." + "\n");
		document.frmImageUp.assunto.focus(); 
		return false;
	}
	if (document.frmImageUp.msg.value==""){
		window.alert ("You need to fill in the MESSAGE field." + "\n");
		document.frmImageUp.msg.focus(); 
		return false;
	}
	msg= "Your message will be sent." + "\n" ;
	window.alert (msg);

	return true
}

function verifica_search(){
	
	if (document.procura.t_name.value==""){
		msg= "You need to fill in the SEARCH field." + "\n" ;
		window.alert (msg);
		document.procura.t_name.focus(); 
		return false;
	}		
	return true
}

function verifica_search_es(){
	
	if (document.procura.t_name.value==""){
		msg= "Debe rellenar el campo de búsqueda." + "\n" ;
		window.alert (msg);
		document.procura.t_name.focus(); 
		return false;
	}		
	return true
}


function verifica_login(){
	
	if (document.login.idu.value==""){
		msg= "You need to fill in the NAME field." + "\n" ;
		window.alert (msg);
		document.login.idu.focus(); 
		return false;
	}	
	
	if (document.login.pw.value==""){
		msg= "You need to fill in the PASSWORD field." + "\n" ;
		window.alert (msg); 
		document.login.pw.focus(); 
		return false;
	}
	
	return true
}




function verifica_join(){
	
	if (document.members.association.value==""){
		msg= "You need to fill in the Name of Association field." + "\n" ;
		window.alert (msg);
		document.members.association.focus(); 
		return false;
	}
	
	if (document.members.person.value==""){
		msg= "You need to fill in the Name of Contact Person field." + "\n" ;
		window.alert (msg);
		document.members.person.focus(); 
		return false;
	}
	
	if (document.members.adress.value==""){
		msg= "You need to fill in the Adress field." + "\n" ;
		window.alert (msg);
		document.members.adress.focus(); 
		return false;
	} else if (document.members.adress.value.length<4){
		msg= "The Adress must have at least 4 digits." + "\n" ;
		window.alert (msg);
		document.members.adress.focus(); 
		return false;
	}	
	
	if (document.members.telephone.value==""){
			msg= "You need to fill in the TELEPHONE field." + "\n" ;
			window.alert (msg);
			document.members.telephone.focus(); 
			return false;	
	  }else if (isNaN(document.members.telephone.value)){
			msg= "The field TELEPHONE must be numeric." + "\n" ;
			window.alert (msg);
			document.members.telephone.focus(); 
			return false;		
		}		
	
	if (document.members.fax.value!=""){
		if (isNaN(document.members.fax.value)){
			msg= "The field FAX must be numeric." + "\n" ;
			window.alert (msg);
			document.members.fax.focus(); 
			return false;		
		}		
	}
	
	if (document.members.date.value==""){
		msg= "You need to fill in the FOUNDATION DATE field." + "\n" ;
		window.alert (msg);
		document.members.date.focus(); 
		return false;
	}
	
		if (document.members.n_associates.value==""){
		msg= "You need to fill in the Number of Associates field." + "\n" ;
		window.alert (msg);
		document.members.n_associates.focus(); 
		return false;
	}
	
	if (document.members.production.value==""){
		msg= "You need to fill in the Annual Tobacco Production field." + "\n" ;
		window.alert (msg);
		document.members.production.focus(); 
		return false;
	}
	
	if (document.members.b_ImageField_comp.value != document.members.b_ImageField.value) {
 		alert('The validation Code is not correct!');
		return false;
 	}
	
	return true
}



function verifica_send_info(){
	
	if (document.info.nome.value==""){
		msg= "You need to fill in the Name field." + "\n" ;
		window.alert (msg);
		document.info.nome.focus(); 
		return false;
	}
	
	if (document.info.assunto.value==""){
		msg= "You need to fill in the SUBJECT field." + "\n" ;
		window.alert (msg);
		document.info.assunto.focus(); 
		return false;
	}
	
	if (document.info.msg.value==""){
		msg= "You need to fill in the INFO field." + "\n" ;
		window.alert (msg);
		document.info.msg.focus(); 
		return false;
	}	
	
	return true
}



function verifica_login_pw(){
	
	if (document.login.t_email.value==""){
		msg= "You need to fill in the E-MAIL field." + "\n" ;
		window.alert (msg);
		document.login.t_email.focus(); 
		return false;
	}else if (document.login.t_email.value!=""){
		if (!(valida_email(document.login.t_email.value))){
		document.login.t_email.focus(); 
		return false;
		}	
	}		
	return true
}





function verifica_meeting(){
	
	if (document.meeting.nome1.value==""){
		msg= "You need to fill in the LAST NAME field." + "\n" ;
		window.alert (msg);
		document.meeting.nome1.focus(); 
		return false;
	}
	
	if (document.meeting.nome2.value==""){
		msg= "You need to fill in the FIRST NAME field." + "\n" ;
		window.alert (msg);
		document.meeting.nome2.focus(); 
		return false;
	}
	
	if (document.meeting.association.value==""){
		msg= "You need to fill in the Name of Association field." + "\n" ;
		window.alert (msg);
		document.meeting.association.focus(); 
		return false;
	}
	
	if (document.meeting.adress.value==""){
		msg= "You need to fill in the Adress field." + "\n" ;
		window.alert (msg);
		document.meeting.adress.focus(); 
		return false;
	} else if (document.meeting.adress.value.length<4){
		msg= "The Adress must have at least 4 digits." + "\n" ;
		window.alert (msg);
		document.meeting.adress.focus(); 
		return false;
	}	
	
	
	if (document.meeting.cidade.value==""){
		msg= "You need to fill in the City field." + "\n" ;
		window.alert (msg);
		document.meeting.cidade.focus(); 
		return false;
	}
	
	if (document.meeting.pais.value==""){
		msg= "You need to fill in the COUNTRY field." + "\n" ;
		window.alert (msg);
		document.meeting.pais.focus(); 
		return false;
	}
	
	if (document.meeting.cpostal.value==""){
			msg= "You need to fill in the ZIP CODE field." + "\n" ;
			window.alert (msg);
			document.meeting.cpostal.focus(); 
			return false;	
	  }else if (isNaN(document.meeting.cpostal.value)){
			msg= "The field ZIP CODE must be numeric." + "\n" ;
			window.alert (msg);
			document.meeting.cpostal.focus(); 
			return false;		
		}		
	
	if (document.meeting.telephone.value==""){
			msg= "You need to fill in the TELEPHONE field." + "\n" ;
			window.alert (msg);
			document.meeting.telephone.focus(); 
			return false;	
	  }else if (isNaN(document.meeting.telephone.value)){
			msg= "The field TELEPHONE must be numeric." + "\n" ;
			window.alert (msg);
			document.meeting.telephone.focus(); 
			return false;		
		}		
	
	
	
	if (document.meeting.fax.value!=""){			
	 if (isNaN(document.meeting.fax.value)){
			msg= "The field FAX must be numeric." + "\n" ;
			window.alert (msg);
			document.meeting.fax.focus(); 
			return false;		
		}		
	}
	
	
	if (document.meeting.email.value!=""){
		if (!(valida_email(document.meeting.email.value))){
		document.meeting.t_email.focus(); 
		return false;
		}	
	}
	
	
	if (document.meeting.adate.value==""){
		msg= "You need to fill in the ARRIVAL DATE field." + "\n" ;
		window.alert (msg);
		document.meeting.adate.focus(); 
		return false;
	}
	
	if (document.meeting.ddate.value==""){
		msg= "You need to fill in the DEPARTURE DATE field." + "\n" ;
		window.alert (msg);
		document.meeting.ddate.focus(); 
		return false;
	}
	
	if (document.meeting.atime.value==""){
		msg= "You need to fill in the ARRIVAL TIME field." + "\n" ;
		document.meeting.atime.focus(); 
		window.alert (msg);
		return false;
	}else if (!(IsValidTime(document.meeting.atime.value))){			
		document.meeting.atime.focus();
		return false;
		}
		
	if (document.meeting.dtime.value==""){
		msg= "You need to fill in the DEPARTURE TIME field." + "\n" ;
		document.meeting.dtime.focus(); 
		window.alert (msg);
		return false;
	}else if (!(IsValidTime(document.meeting.dtime.value))){			
		document.meeting.dtime.focus();
		return false;
		}
		
	if (document.meeting.nnoites.value==""){
		msg= "You need to fill in the NUMBER OF NIGHTS field." + "\n" ;
		window.alert (msg);
		document.meeting.nnoites.focus(); 
		return false;
	}
	
	if (document.meeting.nvoo1.value==""){
		msg= "You need to fill in the FLIGHT NUMBER field." + "\n" ;
		window.alert (msg);
		document.meeting.nvoo1.focus(); 
		return false;
	}
	
	return true
}

function verifica_AGM(){
	
	if (document.Registo_AGM.nome1.value==""){
		msg= "You need to fill in the LAST NAME field." + "\n" ;
		window.alert (msg);
		document.Registo_AGM.nome1.focus(); 
		return false;
	}
	
	if (document.Registo_AGM.nome2.value==""){
		msg= "You need to fill in the FIRST NAME field." + "\n" ;
		window.alert (msg);
		document.Registo_AGM.nome2.focus(); 
		return false;
	}
	
	if (document.Registo_AGM.empresa.value==""){
		msg= "You need to fill in the Name of Association field." + "\n" ;
		window.alert (msg);
		document.Registo_AGM.empresa.focus(); 
		return false;
	}
	
	if (document.Registo_AGM.morada.value==""){
		msg= "You need to fill in the Adress field." + "\n" ;
		window.alert (msg);
		document.Registo_AGM.morada.focus(); 
		return false;
	} else if (document.Registo_AGM.morada.value.length<4){
		msg= "The Adress must have at least 4 digits." + "\n" ;
		window.alert (msg);
		document.Registo_AGM.morada.focus(); 
		return false;
	}	
	
	
	if (document.Registo_AGM.cidade.value==""){
		msg= "You need to fill in the City field." + "\n" ;
		window.alert (msg);
		document.Registo_AGM.cidade.focus(); 
		return false;
	}
	
	if (document.Registo_AGM.pais.value==""){
		msg= "You need to fill in the COUNTRY field." + "\n" ;
		window.alert (msg);
		document.Registo_AGM.pais.focus(); 
		return false;
	}
	
	if (document.Registo_AGM.cpostal.value==""){
			msg= "You need to fill in the ZIP CODE field." + "\n" ;
			window.alert (msg);
			document.Registo_AGM.cpostal.focus(); 
			return false;	
	  }	
	
	if (document.Registo_AGM.tel.value==""){
			msg= "You need to fill in the TELEPHONE field." + "\n" ;
			window.alert (msg);
			document.Registo_AGM.tel.focus(); 
			return false;	
	  }
	  
	if (document.Registo_AGM.fax.value==""){			
	 	msg= "You need to fill in the FAX field." + "\n" ;
			window.alert (msg);
			document.Registo_AGM.fax.focus(); 
			return false;	
	}
	
	if (document.Registo_AGM.email.value==""){			
	 	msg= "You need to fill in the EMAIL field." + "\n" ;
			window.alert (msg);
			document.Registo_AGM.email.focus(); 
			return false;	
	} else if (document.Registo_AGM.email.value!=""){
		if (!(valida_email(document.Registo_AGM.email.value))){
		document.Registo_AGM.email.focus(); 
		return false;
		}	
	}
	
	if ((document.Registo_AGM.spouse.value=="1") && (document.Registo_AGM.nome1a.value=="")){
		msg= "You need to fill in the LAST NAME (SPOUSE) field." + "\n" ;
		window.alert (msg);
		document.Registo_AGM.nome1a.focus(); 
		return false;
	}
	
	if ((document.Registo_AGM.spouse.value=="1") && (document.Registo_AGM.nome2a.value=="")){
		msg= "You need to fill in the FIRST NAME (SPOUSE) field." + "\n" ;
		window.alert (msg);
		document.Registo_AGM.nome2a.focus(); 
		return false;
	}
	
	if (document.Registo_AGM.arrivdat.value==""){
		msg= "You need to fill in the ARRIVAL DATE field." + "\n" ;
		window.alert (msg);
		document.Registo_AGM.arrivdat.focus(); 
		return false;
	}
	
	if (document.Registo_AGM.depdat.value==""){
		msg= "You need to fill in the DEPARTURE DATE field." + "\n" ;
		window.alert (msg);
		document.Registo_AGM.depdat.focus(); 
		return false;
	}
	
		
	if (document.Registo_AGM.nnoites.value==""){
		msg= "You need to fill in the NUMBER OF NIGHTS field." + "\n" ;
		window.alert (msg);
		document.Registo_AGM.nnoites.focus(); 
		return false;
	}
	
	if (document.Registo_AGM.nvoo1.value==""){
		msg= "You need to fill in the FLIGHT NUMBER field." + "\n" ;
		window.alert (msg);
		document.Registo_AGM.nvoo1.focus(); 
		return false;
	}
	
		if (document.Registo_AGM.nvoo2.value==""){
		msg= "You need to fill in the FLIGHT NUMBER field." + "\n" ;
		window.alert (msg);
		document.Registo_AGM.nvoo2.focus(); 
		return false;
	}

	if (document.Registo_AGM.time1.value==""){
		msg= "You need to fill in the TIME ARRIVAL field." + "\n" ;
		window.alert (msg);
		document.Registo_AGM.time1.focus(); 
		return false;
	}

	if (document.Registo_AGM.time2.value==""){
		msg= "You need to fill in the TIME DEPARTURE field." + "\n" ;
		window.alert (msg);
		document.Registo_AGM.time2.focus(); 
		return false;
	}
	
	return true
}


function IsValidTime(timeStr) {

var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;

var matchArray = timeStr.match(timePat);	
	if (matchArray == null) {
		alert("Time is not in a valid format (hh:mm).");
		return false;
	}
hour = matchArray[1];
minute = matchArray[2];
second = matchArray[4];
ampm = matchArray[6];


	if (second=="") { second = null; }
	if (ampm=="") { ampm = null }

	if (hour < 0  || hour > 23) {
		alert("Hour must be between 0 and 23.");
		return false;
	}

	if  (hour > 12 && ampm != null) {
		alert("You can't specify AM or PM for military time.");
		return false;
	}

	if (minute<0 || minute > 59) {
		alert ("Minute must be between 0 and 59.");
		return false;
	}

	if (second != null && (second < 0 || second > 59)) {
		alert ("Second must be between 0 and 59.");
		return false;
	}
return true;
}





function valida_email(email)
{
	var result = /^.+\@.+\..+$/ ;

	if ((email == null) || (email.length == 0)) {
       	if (valida_email.arguments.length == 1) {
       		alert("You need to fill a valid E_MAIL.");
       		return false ;
       	} else {
       		if (!(valida_email.arguments[1] == true)) {
       			alert("You need to fill a valid E_MAIL.");
       		}
       		return (valida_email.arguments[1] == true);
       	}
    } else {
		if (!(result.test(email))) {
			alert("You need to fill a valid E_MAIL.");
		}
       return result.test(email);
    }
}