/*
	Autore: Sandro Ferretti
	Data: 30/01/2008
	Release: 0
	Descrizione: javascript di validazione
*/
// JavaScript Document

function valida_login(questo){
		if (questo.user.value == ''){
			alert("La user e' obbligatoria");
			questo.user.focus();
			return false;
		
		}
		
		if (questo.password.value == ''){
			alert("La Password e' obbligatoria");
			questo.password.focus();
			return false;
		
		}
	}

function valida_contatto(theForm){
//	if (theForm.nome.value == ''){	
//		alert("Il nome e' obbligatorio");
//		theForm.nome.focus();
//		return false;	
//	}
	
	if (theForm.email.value  == ''){		
		alert("L' email e' obbligatoria");
		theForm.email.focus();
		return false;
	} 
	else{		
	   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	   var address = theForm.email.value;
	   if(reg.test(address) == false) {
		  alert('Indirizzo email non valido');
		  return false;
	   }
	}
	
	if (theForm.email.value  != theForm.nome.value){		
		alert("Email non confermata correttamente");
		theForm.email.focus();
		return false;
	} 
	
		//if (theForm.oggetto.value == ''){
//		
//			alert("L'Oggetto del messaggio e' obbligatorio");
//			theForm.oggetto.focus();
//			return false;
//		
//		}
		
	if (theForm.messaggio.value == ''){
	
		alert("Il messaggio e' obbligatorio");
		theForm.messaggio.focus();
		return false;
	
	}
	return true
}

function valida_link(theForm){
	
	if (theForm.nome_link.value == ''){
		
			alert("Il nome del link e' obbligatorio");
			theForm.nome_link.focus();
			return false;
		
		}
		
	if (theForm._link.value  == ''){
		
			alert("Il link e' obbligatorio");
			theForm._link.focus();
			return false;

		}
		
	if (theForm._link.value  == 'http://'){
		
			alert("Il link e' obbligatorio");
			theForm._link.focus();
			return false;

		}
	}
	
function valida_utente(theForm){
	if (theForm.nome.value  == ''){
		
			alert("Il nome e' obbligatorio");
			theForm.nome.focus();
			return false;

		}
		
	if (theForm.cognome.value  == ''){
		
			alert("Il Cognome e' obbligatorio");
			theForm.cognome.focus();
			return false;

		}

	if (theForm.user.value  == ''){
		
			alert("La User e' obbligatoria");
			theForm.user.focus();
			return false;

		}
		
	if (theForm.password.value  == ''){
		
			alert("La Password e' obbligatoria");
			theForm.password.focus();
			return false;

		}
		
	if (theForm.email.value  == ''){
		
			alert("La Email e' obbligatoria");
			theForm.email.focus();
			return false;

		} else{
			
			   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
			   var address = theForm.email.value;
			   if(reg.test(address) == false) {
				  alert('Invalid Email Address');
				  return false;
			   }
		}/**/
		
	}

function valida_utente_mod(theForm){
	if (theForm.nome_mod.value  == ''){
		
			alert("Il nome e' obbligatorio");
			theForm.nome_mod.focus();
			return false;

		}
		
	if (theForm.cognome_mod.value  == ''){
		
			alert("Il Cognome e' obbligatorio");
			theForm.cognome_mod.focus();
			return false;

		}

	if (theForm.user_mod.value  == ''){
		
			alert("La User e' obbligatoria");
			theForm.user_mod.focus();
			return false;

		}
		
	if (theForm.password_mod.value  == ''){
		
			alert("La Password e' obbligatoria");
			theForm.password_mod.focus();
			return false;

		}
		
	if (theForm.email_mod.value  == ''){
		
			alert("La Email e' obbligatoria");
			theForm.email_mod.focus();
			return false;

		} else{
			
			   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
			   var address = theForm.email_mod.value;
			   if(reg.test(address) == false) {
				  alert('Invalid Email Address');
				  return false;
			   }
		}/**/
		
	}
	
function valida_galleria(theForm){
	
		if (theForm.nome_galleria.value  == ''){
		
			alert("Il nome della Galleria e' obbligatorio");
			theForm.nome_galleria.focus();
			return false;

		}
	
	}

function validateFileExtension(fld) {
	if(!/(\.jpg|\.jpeg)$/i.test(fld.value)) {
		alert("Attenzione valore nel campo immagine e' nullo o non valido.");
		fld.form.reset();
		fld.focus();
		return false;
	}
	return true;
}
