// JavaScript Document

function bookmarksite(title,url){
	if (window.sidebar) { 							// firefox
		window.sidebar.addPanel(title, url, "");
	} else if( window.opera && window.print) { 		// opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} else if (document.all) { 						// ie
		window.external.AddFavorite(url, title);
	}
}


	  function validate_reg(option) {
		// Variabili associate ai campi del subscribe
		// var azienda = document.subscribe.azienda.value;
		 var cognome = document.subscribe.cognome.value;
		 var nome = document.subscribe.nome.value;
		// var p_iva = document.subscribe.p_iva.value;
		// var cf = document.subscribe.cf.value;
		 var indirizzo = document.subscribe.indirizzo.value;
		 var civico = document.subscribe.civico.value;
		 var cap = document.subscribe.cap.value;
		 var citta = document.subscribe.citta.value;
		 var prov = document.subscribe.prov.value;
		 var nazione = document.subscribe.nazione.value;
		 var tel = document.subscribe.tel.value;
		 var email = document.subscribe.email.value;
		 var email_conf = document.subscribe.email_conf.value;
		 var password = document.subscribe.password.value;
		 var pwd_conf = document.subscribe.pwd_conf.value;
		 //var checkcode = document.subscribe.checkcode.value;



			if (option=="subscribe" || option=="finale"){
				if (document.subscribe.elements['privacy'].checked){ var privacy="ok"; }
			}
	 
		 // Espressione regolare dell\'email
		 var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	
			var err="Inserire i Dati Mancanti:\n";
		/*	
			if ((azienda == "") || (azienda == "undefined")){
				   err+="Denominazione Completa dell'Azienda.\n";
				}
		*/
			if ((cognome == "") || (cognome == "undefined")){
				   err+="Cognome\n";
				}
			if ((nome == "") || (nome == "undefined")){
				   err+="Nome\n";
				}
		/*
			if ( (p_iva == "" || p_iva == "undefined") ){
				   err+="Partita IVA.\n";						   
				}
			if ( (cf == "" || cf == "undefined") ){
				   err+="Codice Fiscale.\n";						   
				}
		*/
			if ((indirizzo == "") || (indirizzo == "undefined")){
				   err+="Indirizzo\n";
				}
			if ((civico == "") || (civico == "undefined")){
				   err+="Numero civico (SN se Senza Numero)\n";
				}
			if ((cap == "") || (cap == "undefined")){
				   err+="Codice di avviamento postale\n";
				}
			if ((citta == "") || (citta == "undefined")){
				   err+="Località\n";
				}
			if ((prov == "") || (prov == "undefined")){
				   err+="Provincia\n";
				}
			if ((nazione == "") || (nazione == "undefined")){
				   err+="Nazione\n";
				}
			if ((tel == "") || (tel == "undefined")){
				   err+="Telefono\n";
				}
			if ((email == "") || (email == "undefined")){
				   err+="Indirizzo e-mail\n";
				}
			if (!email_reg_exp.test(email) && email!="") {
					err+="L'indirizzo e-mail inserito non è valido\n";
				}
			if ((email != email_conf)){
				   err+="L'indirizzo e-mail e quello di conferma sono diversi\n";
				}
			
					
					
			if (option=="finale"){
				if ((password == "") || (password == "undefined")){
					   err+="Scegliere una password\n";
					}
				
				if ((password != pwd_conf)){
					   err+="La password scelta e quella di conferma sono diverse\n";
					}
					
				/*	
				if ((checkcode == "")){
					   err+="Inserire codice di sicurezza.\n";
					}
				*/
				
				if (privacy != "ok"){
					   err+="Autorizzare il trattamento dei dati personali\n";
					}
					
			}
			
			
			
			
			
			if (option=="update"){
				if ((password !="" && password != pwd_conf)){
					   err+="La password scelta e quella di conferma sono diverse\n";
					}
			}
					
				
				
				
			if (err != "Inserire i Dati Mancanti:\n"){
				alert(err);
				return false;
			} else {
			   document.subscribe.action = "index.php?op="+option;
			   document.subscribe.submit();
			}
		  }





	  function validate_sped(option) {
		// Variabili associate ai campi del subscribe
		// var azienda = document.anagsped.azienda.value;
		 var cognome = document.anagsped.cognome.value;
		 var nome = document.anagsped.nome.value;
		// var p_iva = document.anagsped.p_iva.value;
		// var cf = document.anagsped.cf.value;
		 var indirizzo = document.anagsped.indirizzo.value;
		 var civico = document.anagsped.civico.value;
		 var cap = document.anagsped.cap.value;
		 var citta = document.anagsped.citta.value;
		 var prov = document.anagsped.prov.value;
		 var nazione = document.anagsped.nazione.value;
		 var tel = document.anagsped.tel.value;

		 //var email = document.anagsped.email.value;
		 //var email_conf = document.anagsped.email_conf.value;

	 
		 // Espressione regolare dell\'email
		 var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	
			var err="Inserire i Dati Mancanti:\n";
		/*	
			if ((azienda == "") || (azienda == "undefined")){
				   err+="Denominazione Completa dell'Azienda.\n";
				}
		*/
			if ((cognome == "") || (cognome == "undefined")){
				   err+="Cognome\n";
				}
			if ((nome == "") || (nome == "undefined")){
				   err+="Nome\n";
				}
		/*
			if ( (p_iva == "" || p_iva == "undefined") ){
				   err+="Partita IVA.\n";						   
				}
			if ( (cf == "" || cf == "undefined") ){
				   err+="Codice Fiscale.\n";						   
				}
		*/
			if ((indirizzo == "") || (indirizzo == "undefined")){
				   err+="Indirizzo\n";
				}
			if ((civico == "") || (civico == "undefined")){
				   err+="Numero civico (SN se Senza Numero)\n";
				}
			if ((cap == "") || (cap == "undefined")){
				   err+="Codice di avviamento postale\n";
				}
			if ((citta == "") || (citta == "undefined")){
				   err+="Località\n";
				}
			if ((prov == "") || (prov == "undefined")){
				   err+="Provincia\n";
				}
			if ((nazione == "") || (nazione == "undefined")){
				   err+="Nazione\n";
				}
			if ((tel == "") || (tel == "undefined")){
				   err+="Telefono\n";
				}
				
		/*		
			if ((email == "") || (email == "undefined")){
				   err+="Indirizzo e-mail\n";
				}
			if (!email_reg_exp.test(email) && email!="") {
					err+="L'indirizzo e-mail inserito non è valido\n";
				}
			if ((email != email_conf)){
				   err+="L'indirizzo e-mail e quello di conferma sono diversi\n";
				}
		*/
					
			
					
				
				
				
			if (err != "Inserire i Dati Mancanti:\n"){
				alert(err);
				return false;
			} else {
			   document.anagsped.action = "index.php?op="+option;
			   document.anagsped.submit();
			}
		  }

