function AddText(text,numerocampo)
{
	var tarea = document.getElementById("cont_testo"+numerocampo);
	if (typeof tarea.selectionStart != 'undefined')
	{ // if it supports DOM2
		start = tarea.selectionStart;
		end = tarea.selectionEnd;
		tarea.value = tarea.value.substr(0,tarea.selectionStart) + text + tarea.value.substr(tarea.selectionEnd);
		tarea.focus();
		tarea.selectionStart = ((start - end) == 0) ? start + text.length : start;
		tarea.selectionEnd = start + text.length;
	}
	else
	{
		if (tarea.createTextRange && tarea.caretPos)
		{
			var caretPos = tarea.caretPos;
			caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?   text + ' ' : text;
		}
		else
			tarea.value += text;
		tarea.focus(caretPos);
	}
}

function storeCaret(ftext) {
	if (ftext.createTextRange) {
		ftext.caretPos = document.selection.createRange().duplicate();
	}
}

function getText(numerocampo) {
	var tarea = document.getElementById("cont_testo"+numerocampo);
	if (tarea.createTextRange && tarea.caretPos) {
		return tarea.caretPos.text;
	} else if (typeof tarea.selectionStart != 'undefined'){
		return tarea.value.substr(tarea.selectionStart,tarea.selectionEnd-tarea.selectionStart)
	}
	return '';
}

function left(numerocampo) {
	var text = getText(numerocampo);
	AddTxt="<div align=left>" + text + "</div>";
	AddText(AddTxt,numerocampo);
}

function center(numerocampo) {
	var text = getText(numerocampo);
	AddTxt="<center>" + text + "</center>";
	AddText(AddTxt,numerocampo);
}

function right(numerocampo) {
	var text = getText(numerocampo);
	AddTxt="<div align=right>" + text + "</div>";
	AddText(AddTxt,numerocampo);
}

function grassetto(numerocampo) {
	var text = getText(numerocampo);
	AddTxt="<b>" + text + "</b>";
	AddText(AddTxt,numerocampo);
}

function corsivo(numerocampo) {
	var text = getText(numerocampo);
	AddTxt="<i>" + text + "</i>";
	AddText(AddTxt,numerocampo);
}

function url(numerocampo) {
	var text = getText(numerocampo);
	txt2 = prompt("Testo da visualizzare.\nLasciare vuoto se si vuole che sia visualizzato l\'URL.","");
	if (txt2!=null) {
		txt = prompt("URL del link.\nInserire l'indirizzo SENZA http://","");
		if (txt!=null) {
			if (txt2=="") {
				AddTxt="<a href=http://" + txt + " target=_blank>" + txt + "</a>";
				AddText(AddTxt,numerocampo);
			} else {
				AddTxt="<a href=http://" + txt + " target=_blank>" + txt2 + "</a>";
				AddText(AddTxt,numerocampo);
			}
		}
	}
}

function mail(numerocampo) {
	var text = getText(numerocampo);
	txt2 = prompt("Testo da visualizzare.\nLasciare vuoto se si vuole che sia visualizzato l\'indirizzo e-mail.","");
	if (txt2!=null) {
		txt = prompt("Indirizzo e-mail","");
		if (txt!=null) {
			if (txt2=="") {
				AddTxt="<a href=mailto:" + txt + " target=_blank>" + txt + "</a>";
				AddText(AddTxt,numerocampo);
			} else {
				AddTxt="<a href=mailto:" + txt + " target=_blank>" + txt2 + "</a>";
				AddText(AddTxt,numerocampo);
			}
		}
	}
}

function OpenPopup(pagina,nome,altezza,larghezza)
{
	var h = altezza;
	var w = larghezza;
	var pw = Math.floor((screen.width-w)/2);
	var ph = Math.floor((screen.height-h)/2);
	window.open(pagina,nome,"width=" + w + ",height=" + h + ",top=" + ph + ",left=" + pw );
}
//-->


//	#####   UTILIZZO GLOBALE   #####
function Popup(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function verEmail(stringa)
{
   if (stringa.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
   return true;
   else return false;
}

function Wait(azione)
{
	window.location.href='bo_popwait.asp?a='+azione;
}


//	#####   UTILIZZO AREA PUBBLICA   #####
function CheckContatti(f)
{
	var errMsg = '';
	var nome=f.nome;
	var cognome = f.cognome;
	var mail=f.mail;
	var messaggio=f.messaggio;
	var datipersonali = f.datipersonali;
	
	if ( (nome.value=="") || (nome.value.replace(/\s*/gi,'') == '') || (nome.value.replace(/\x13\x10*/gi,'') == '') )
		errMsg += "- Name is required.\n";

	if ( (cognome.value=="") || (cognome.value.replace(/\s*/gi,'') == '') || (cognome.value.replace(/\x13\x10*/gi,'') == '') )
		errMsg += "- Surname is required.\n";

	if (!verEmail(mail.value))
		errMsg += "- Insert a valid e-mail address.\n";

	if ( (messaggio.value=="") || (messaggio.value.replace(/\s*/gi,'') == '') || (messaggio.value.replace(/\x13\x10*/gi,'') == '') )
		errMsg += "- Message is required.\n";
	
	if (!datipersonali[0].checked)
		errMsg+="- Personal data\’s treatment is required.\n";
  
  	if (errMsg != '')
	{
		errMsg = "The following errors occurred:\n\n" + errMsg;
		alert(errMsg);
		return false;
	}
	//return true;
}


//	#####   UTILIZZO CONDIVISO   #####
function CheckLogin(f,lingua)
{
	var errMsg = '';
	var user=f.user;
	var pass=f.pass;

	switch (lingua)
	{
		case 'ita':
			errore0 = "Si sono verificati i seguenti errori:\n\n";
			errore1 = "- Username deve essere di 4-12 caratteri alfanumerici (a-z, A-Z, 0-9).\n";
			errore2 = "- Password deve essere di 4-12 caratteri alfanumerici (a-z, A-Z, 0-9).\n";
			break;
		case 'eng':
			errore0 = "The following errors occurred:\n\n";
			errore1 = "- Username must be of 4-12 alphanumeric characters (a-z, A-Z, 0-9).\n";
			errore2 = "- Password must be of 4-12 alphanumeric characters (a-z, A-Z, 0-9).\n";
			break;
	}
	
	if (!user.value.match(/^[a-zA-Z0-9]{4,12}$/))
		errMsg += errore1;

	if (!pass.value.match(/^[a-zA-Z0-9]{4,12}$/))
		errMsg += errore2;
	
	if (errMsg != '')
	{
		errMsg = errore0 + errMsg;
		alert(errMsg);
		return false;
	}
	return true;
}

function CheckAccount(f,tipoazione,tipoaccount,tipolingua)
{
	var errMsg = '';
	var nome = f.nome;
	var cognome = f.cognome;
	if (tipoaccount == 'c')
		var ditta = f.ditta;
		var telefono = f.telefono;
		var cellulare = f.cellulare;
		var citta = f.citta;
		var nazione = f.nazione;
		var sitoweb = f.sitoweb;
	var mail=f.mail;
	var user = f.user;
	var pass = f.pass;
	var pass1 = f.confpass;
	var randompw = f.randompw;
	var azione = tipoazione;
//	1 = modifica
//	2 = inserimento
	
	switch (tipolingua)
	{
		case 'ita':
			errore0 = "Si sono verificati i seguenti errori:\n\n";
			errore1 = "- Nome è obbligatorio e non può essere vuoto.\n";
			errore2 = "- Cognome è obbligatorio e non può essere vuoto.\n";
			errroe3 = "- Ditta non può essere vuoto.\n";
			errore4 = "- Telefono non può essere vuoto.\n";
			errore5 = "- Cellulare non può essere vuoto.\n";
			errore6 = "- Città non può essere vuoto.\n";
			errore7 = "- Nazione non può essere vuoto.\n";
			errore8 = "- Sito Web non può essere vuoto.\n";
			errore9 = "- Username deve essere di 4-12 caratteri alfanumerici (a-z, A-Z, 0-9).\n";
			errore10 = "- Inserire un indirizzo e-mail corretto.\n"
			errore11 = "- Nuova password deve essere di 4-12 caratteri alfanumerici (a-z, A-Z, 0-9).\n";
			errore12 = "- Conferma nuova password deve essere di 4-12 caratteri alfanumerici (a-z, A-Z, 0-9).\n";
			errore13 = "- Password deve essere di 4-12 caratteri alfanumerici (a-z, A-Z, 0-9).\n";
			errore14 = "- Conferma password deve essere di 4-12 caratteri alfanumerici (a-z, A-Z, 0-9).\n";
			errore15 = "- Nuova Password e Conferma Nuova Password devono coincidere.\n";
			break;
		case 'eng':
			errore0 = "The following errors occurred:\n\n";
			errore1 = "- Name is required and can\’t be empty.\n";
			errore2 = "- Surname is required and can\’t be empty.\n";
			errore3 = "- Company can\’t be empty.\n";
			errore4 = "- Telephone can\’t be empty.\n";
			errore5 = "- Mobile can\’t be empty.\n";
			errore6 = "- City can\’t be empty.\n";
			errore7 = "- Country can\’t be empty.\n";
			errore8 = "- Web site can\’t be empty.\n";
			errore9 = "- Username must be of 4-12 alphanumeric characters (a-z, A-Z, 0-9).\n";
			errore10 = "- Insert a valid e-mail address.\n"
			errore11 = "- New password must be of 4-12 alphanumeric characters (a-z, A-Z, 0-9).\n";
			errore12 = "- Repeat new password must be of 4-12 alphanumeric characters (a-z, A-Z, 0-9).\n";
			errore13 = "- Password must be of 4-12 alphanumeric characters (a-z, A-Z, 0-9).\n";
			errore14 = "- Password confirm must be of 4-12 alphanumeric characters (a-z, A-Z, 0-9).\n";
			errore15 = "- Password and password confirm must coincide.\n";
			break;
	}
	
	if ( (nome.value == "") || (nome.value.replace(/\s*/gi,'') == '') || (nome.value.replace(/\x13\x10*/gi,'') == '') )
		errMsg += errore1;
	
	if ( (cognome.value == "") || (cognome.value.replace(/\s*/gi,'') == '') || (cognome.value.replace(/\x13\x10*/gi,'') == '') )
		errMsg += errore2;
	
	if (tipoaccount == 'c')
	{
		if ( (ditta.value != "") && ((ditta.value.replace(/\s*/gi,'') == '') || (ditta.value.replace(/\x13\x10*/gi,'') == '')) )
			errMsg += errore3;
		if ( (telefono.value != "") && ((telefono.value.replace(/\s*/gi,'') == '') || (telefono.value.replace(/\x13\x10*/gi,'') == '')) )
			errMsg += errore4;
		if ( (cellulare.value != "") && ((cellulare.value.replace(/\s*/gi,'') == '') || (cellulare.value.replace(/\x13\x10*/gi,'') == '')) )
			errMsg += errore5;
		if ( (citta.value != "") && ((citta.value.replace(/\s*/gi,'') == '') || (citta.value.replace(/\x13\x10*/gi,'') == '')) )
			errMsg += errore6;
		if ( (nazione.value != "") && ((nazione.value.replace(/\s*/gi,'') == '') || (nazione.value.replace(/\x13\x10*/gi,'') == '')) )
			errMsg += errore7;
		if ( (sitoweb.value != "") && ((sitoweb.value.replace(/\s*/gi,'') == '') || (sitoweb.value.replace(/\x13\x10*/gi,'') == '')) )
			errMsg += errore8;
	}

	if (!user.value.match(/^[a-zA-Z0-9]{4,12}$/))
		errMsg += errore9;

	if (!verEmail(mail.value))
		errMsg += errore10;

	if (!randompw[0].checked)
	{
		switch (azione)
		{
			case 1:
				if (pass.value != "" || pass1.value != "")
				{
					if (!pass.value.match(/^[a-zA-Z0-9]{4,12}$/))
						errMsg += errore11;
					if (!pass1.value.match(/^[a-zA-Z0-9]{4,12}$/))
						errMsg += errore12;
				}
				break;
			case 2:
				if (!pass.value.match(/^[a-zA-Z0-9]{4,12}$/))
					errMsg += errore13;
				if (!pass1.value.match(/^[a-zA-Z0-9]{4,12}$/))
					errMsg += errore14;
				break;
		}
		if (!(pass.value == pass1.value) && pass.value != "" && pass1.value!= "")
			errMsg += errore15;
	}
	
  
  	if (errMsg != '')
	{
		errMsg = errore0 + errMsg;
		alert(errMsg);
		return false;
	}
	else
		return true;
}

function CheckRecupero(f,lingua)
{
	var errMsg = '';
	var valore = f.valore;
	var tipodato = f.tipodato;
	switch (lingua)
	{
		case 'ita':
			errore0 = "Si sono verificati i seguenti errori:\n\n";
			errore1 = "- Username deve essere di 4-12 caratteri alfanumerici (a-z, A-Z, 0-9).\n";
			errore2 = "- Inserire un indirizzo e-mail corretto.\n";
			break;
		case 'eng':
			errore0 = "The following errors occurred:\n\n";
			errore1 = "- Username must be of 4-12 alphanumeric characters (a-z, A-Z, 0-9).\n";
			errore2 = "- Insert a valid e-mail address.\n";
			break;
	}

	if (tipodato[0].checked)
	{
		if (!valore.value.match(/^[a-zA-Z0-9]{4,12}$/))
			errMsg += errore1;	
	}
	else if (tipodato[1].checked)
	{
		if (!verEmail(valore.value))
			errMsg += errore2;	
	}

	if (errMsg != '')
	{
		errMsg = errore0 + errMsg;
		alert(errMsg);
		return false;
	}
	else
	{
		if (lingua == 'ita')
		{
			f.submit()
			Wait(1);
		}
	}
}


//	#####   UTILIZZO BACK OFFICE   #####
function CheckContenuti(f)
{
	var errMsg = '';
	var errMsgLayout = '';
	var titolo = f.cont_titolo;
	var layout = f.cont_layout;
	var testo1 = f.cont_testo1;
	var testo2 = f.cont_testo2;
	var testo3 = f.cont_testo3;
	var img1 = f.cont_new_img1;
	var img2 = f.cont_new_img2;
	var img3 = f.cont_new_img3;
	var img4 = f.cont_new_img4;
	var img5 = f.cont_new_img5;

	if ( (titolo.value == "") || (titolo.value.replace(/\s*/gi,'') == '') || (titolo.value.replace(/\x13\x10*/gi,'') == '') )
		errMsg += "- Titolo è obbligatorio e non può essere vuoto.\n";
	
	switch (layout.value)
	{
		case '1':
			if ( (testo1.value == "") || (testo1.value.replace(/\s*/gi,'') == '') || (testo1.value.replace(/\x13\x10*/gi,'') == '') )
				errMsgLayout += "Testo #1 è obbligatorio e non può essere vuoto.\n";
			if ( (testo2.value == "") || (testo2.value.replace(/\s*/gi,'') == '') || (testo2.value.replace(/\x13\x10*/gi,'') == '') )
				errMsgLayout += "Testo #2 è obbligatorio e non può essere vuoto.\n";
			if ( (testo3.value == "") || (testo3.value.replace(/\s*/gi,'') == '') || (testo3.value.replace(/\x13\x10*/gi,'') == '') )
				errMsgLayout += "Testo #3 è obbligatorio e non può essere vuoto.\n";
			break;
		case '2':
		case '3':
			if ( (testo1.value == "") || (testo1.value.replace(/\s*/gi,'') == '') || (testo1.value.replace(/\x13\x10*/gi,'') == '') )
				errMsgLayout += "Testo #1 è obbligatorio e non può essere vuoto.\n";
			break;
		case '4':
		case '5':
			if ( (testo1.value == "") || (testo1.value.replace(/\s*/gi,'') == '') || (testo1.value.replace(/\x13\x10*/gi,'') == '') )
				errMsgLayout += "Testo #1 è obbligatorio e non può essere vuoto.\n";
			if ( (testo2.value == "") || (testo2.value.replace(/\s*/gi,'') == '') || (testo2.value.replace(/\x13\x10*/gi,'') == '') )
				errMsgLayout += "Testo #2 è obbligatorio e non può essere vuoto.\n";
			break;
		case '6':
			if ( ( (img1.value == "") || (img1.value.replace(/\s*/gi,'') == '') || (img1.value.replace(/\x13\x10*/gi,'') == '') ) && ( (img2.value == "") || (img2.value.replace(/\s*/gi,'') == '') || (img2.value.replace(/\x13\x10*/gi,'') == '') ) && ( (img3.value == "") || (img3.value.replace(/\s*/gi,'') == '') || (img3.value.replace(/\x13\x10*/gi,'') == '') ) && ( (img4.value == "") || (img4.value.replace(/\s*/gi,'') == '') || (img4.value.replace(/\x13\x10*/gi,'') == '') ) && ( (img5.value == "") || (img5.value.replace(/\s*/gi,'') == '') || (img5.value.replace(/\x13\x10*/gi,'') == '') ) )
				errMsgLayout += "E' necessario inserire almeno un\'immagine.\n";
			break;
	}
	
	if (errMsgLayout != '')
		errMsg += "- Layout #"+layout.value+":\n"+errMsgLayout;
  
  	if (errMsg != '')
	{
		errMsg = "Si sono verificati i seguenti errori:\n\n" + errMsg;
		alert(errMsg);
		return false;
	}
	else
		return true;
}

function CheckFilm(f)
{
	var errMsg = '';
	var titolo = f.film_titolo;
	var descrizione =f.film_descrizione;
	var idcasting = f.film_idcasting;
	var anno = f.film_anno;
	var cliente = f.film_cliente;
	var agenzia = f.film_agenzia;
	var produzione = f.film_produzione;
	var regista = f.film_regista;
	var video = f.film_new_video1;
	var conta_idcasting = 0;

	if ( (titolo.value == "") || (titolo.value.replace(/\s*/gi,'') == '') || (titolo.value.replace(/\x13\x10*/gi,'') == '') )
		errMsg += "- Titolo è obbligatorio e non può essere vuoto.\n";

	if ( (descrizione.value == "") || (descrizione.value.replace(/\s*/gi,'') == '') || (descrizione.value.replace(/\x13\x10*/gi,'') == '') )
		errMsg += "- Descrizione è obbligatorio e non può essere vuoto.\n";
	
	for(var i=0; i < idcasting.length; i++)
	{
    	if (idcasting.options[i].selected)
			conta_idcasting++;
	}
	if (conta_idcasting == 0)
		errMsg += "- Devi selezionare almeno un genere casting.\n";

	if ( (anno.value == "") || (anno.value.replace(/\s*/gi,'') == '') || (anno.value.replace(/\x13\x10*/gi,'') == '') )
		errMsg += "- Anno è obbligatorio e non può essere vuoto.\n";

	if ( (cliente.value == "") || (cliente.value.replace(/\s*/gi,'') == '') || (cliente.value.replace(/\x13\x10*/gi,'') == '') )
		errMsg += "- Cliente è obbligatorio e non può essere vuoto.\n";

	if ( (agenzia.value == "") || (agenzia.value.replace(/\s*/gi,'') == '') || (agenzia.value.replace(/\x13\x10*/gi,'') == '') )
		errMsg += "- Agenzia è obbligatorio e non può essere vuoto.\n";

	if ( (produzione.value == "") || (produzione.value.replace(/\s*/gi,'') == '') || (produzione.value.replace(/\x13\x10*/gi,'') == '') )
		errMsg += "- Produzione è obbligatorio e non può essere vuoto.\n";

	if ( (regista.value == "") || (regista.value.replace(/\s*/gi,'') == '') || (regista.value.replace(/\x13\x10*/gi,'') == '') )
		errMsg += "- Regista è obbligatorio e non può essere vuoto.\n";

	if ( (video.value == "") || (video.value.replace(/\s*/gi,'') == '') || (video.value.replace(/\x13\x10*/gi,'') == '') )
		errMsg += "- Video è obbligatorio.\n";

	if (errMsg != '')
	{
		errMsg = "Si sono verificati i seguenti errori:\n\n" + errMsg;
		alert(errMsg);
		return false;
	}
	//return true;
}

function CheckLocation(f)
{
	var errMsg = '';
	var titolo = f.loc_titolo;
	var idatmosfera = f.loc_idatmosfera;
	var idcategoria = f.loc_idcategoria;
	var immagine = f.loc_new_img3;
	var conta_idatmosfera = 0;
	var conta_idcategoria = 0;

	if ( (titolo.value == "") || (titolo.value.replace(/\s*/gi,'') == '') || (titolo.value.replace(/\x13\x10*/gi,'') == '') )
		errMsg += "- Titolo è obbligatorio e non può essere vuoto.\n";
	
	for(var i=0; i < idatmosfera.length; i++)
	{
    	if (idatmosfera.options[i].selected)
			conta_idatmosfera++;
	}
	if (conta_idatmosfera == 0)
		errMsg += "- Devi selezionare almeno un\'atmosfera.\n";

	for(var i=0; i < idcategoria.length; i++)
	{
    	if (idcategoria.options[i].selected)
			conta_idcategoria++;
	}
	if (conta_idcategoria == 0)
		errMsg += "- Devi selezionare almeno una categoria.\n";

	if ( (immagine.value == "") || (immagine.value.replace(/\s*/gi,'') == '') || (immagine.value.replace(/\x13\x10*/gi,'') == '') )
		errMsg += "- Immagine è obbligatorio.\n";

	if (errMsg != '')
	{
		errMsg = "Si sono verificati i seguenti errori:\n\n" + errMsg;
		alert(errMsg);
		return false;
	}
	//return true;
}

function CheckGenere(f,tipo_form,dapopup,wait)
{
	var errMsg = '';
	var genere = f.genere.value;
	
	var tipoform = tipo_form;
	// 1 = genere casting, 2 = genere film
	// 3 = atmosfera, 4 = categoria
	
	var popup = dapopup;
	// s = si - n = no

	if ( (genere == "") || (genere.replace(/\s*/gi,'') == '') || (genere.replace(/\x13\x10*/gi,'') == '') )
	{
		switch(tipoform)
		{
			case '1':
				errMsg += "- Genere Casting è obbligatorio e non può essere vuoto.\n";
				break;
			case '2':
				errMsg += "- Genere Film è obbligatorio e non può essere vuoto.\n";
				break;
			case '3':
				errMsg += "- Atmosfera è obbligatorio e non può essere vuoto.\n";
				break;
			case '4':
				errMsg += "- Categoria è obbligatorio e non può essere vuoto.\n";
				break;
		}
	}

	if (errMsg != '')
	{
		errMsg = "Si sono verificati i seguenti errori:\n\n" + errMsg;
		alert(errMsg);
		return false;
	}
	else
		f.submit()
		if (popup == 's')
			Wait(wait);
}

function CheckPass(f)
{
	var errMsg = '';
	var pass = f.pass;
	
	if (pass.value != "")
	{
		if (!pass.value.match(/^[a-zA-Z0-9]{4,12}$/))
			errMsg += "- Nuova password deve essere di 4,12 caratteri alfanumerici (a-z, A-Z, 0-9).\n";
	}

	
	if (errMsg != '')
	{
		errMsg = "Si sono verificati i seguenti errori:\n\n" + errMsg;
		alert(errMsg);
		return false;
	}
	else
		f.submit()
		Wait(2);
}

function EliminaFile(f)
{
	var errMsg = '';
	var elimina = f.elements;
	var conta_chek = 0;

	for (i=0; i<elimina.length ; i++)
		if (elimina[i].type=="checkbox" && elimina[i].checked)
			conta_chek++;
	
   	if (conta_chek == 0)
		errMsg += "- Devi selezionare almeno un elemento da eliminare";
		
	if (errMsg != '')
	{
		errMsg = "Si sono verificati i seguenti errori:\n\n" + errMsg;
		alert(errMsg);
		return false;
	}
	else
		if (confirm("Confermi l\'eliminazione dei file selezionati?"))
			return true;
		else
			return false;
}

function CheckAzienda(f,accesso)
{
	var errMsg = '';
	var errAzienda = '';
	var errCast = '';
	var errLoc = '';
	var errWeb = '';
	var errDev = '';
	var ragionesociale = f.ragionesociale;
	var indirizzo = f.indirizzo;
	var numerocivico = f.numerocivico;
	var cap = f.cap;
	var citta = f.citta;
	var telefono = f.telefono;
	var fax = f.fax;
	var mail = f.mail;
	var castnome = f.castnome;
	var castcognome = f.castcognome;
	var castmail = f.castmail;
	var castmobile = f.castmobile;
	var locnome = f.locnome;
	var loccognome = f.loccognome;
	var locmail = f.locmail;
	var locmobile = f.locmobile;
	
	if (accesso == 1)
	{
		var webnome = f.webnome;
		var webcognome = f.webcognome;
		var webmail = f.webmail;
		var webfrom = f.webfrom;
		var devnome = f.devnome;
		var devcognome = f.devcognome;
		var devmail = f.devmail;
		var devfrom = f.devfrom;
	}
	
	//   DATI DITTA
	if ( (ragionesociale.value=="") || (ragionesociale.value.replace(/\s*/gi,'') == '') || (ragionesociale.value.replace(/\x13\x10*/gi,'') == '') )
		errAzienda += "- Ragione Sociale è obbligatorio e non può essere vuoto.\n";
	
	if ( (indirizzo.value=="") || (indirizzo.value.replace(/\s*/gi,'') == '') || (indirizzo.value.replace(/\x13\x10*/gi,'') == '') )
		errAzienda += "- Indirizzo è obbligatorio e non può essere vuoto.\n";
	
	if ( (numerocivico.value!="") && ((numerocivico.value.replace(/\s*/gi,'') == '') || (numerocivico.value.replace(/\x13\x10*/gi,'') == '')) )
		errAzienda += "- Numero civico non può essere vuoto.\n";

	if ( (cap.value=="") || ((cap.value.replace(/\s*/gi,'') == '') || (cap.value.replace(/\x13\x10*/gi,'') == '')) )
		errAzienda += "- CAP è obbligatorio e non può essere vuoto.\n";

	if ( (citta.value=="") || ((citta.value.replace(/\s*/gi,'') == '') || (citta.value.replace(/\x13\x10*/gi,'') == '')) )
		errAzienda += "- Città è obbligatorio e non può essere vuoto.\n";

	if ( (telefono.value=="") || ((telefono.value.replace(/\s*/gi,'') == '') || (telefono.value.replace(/\x13\x10*/gi,'') == '')) )
		errAzienda += "- Telefono è obbligatorio e non può essere vuoto.\n";

	if ( (fax.value=="") || ((fax.value.replace(/\s*/gi,'') == '') || (fax.value.replace(/\x13\x10*/gi,'') == '')) )
		errAzienda += "- FAX è obbligatorio e non può essere vuoto.\n";

	if (mail.value == "")
		errAzienda += "- E-mail è obbligatorio.\n";
	else
	{
		if (!verEmail(mail.value))
			errAzienda += "- Inserire un indirizzo e-mail corretto.\n";
	}

	//   DATI CASTING
	if ( (castnome.value=="") || ((castnome.value.replace(/\s*/gi,'') == '') || (castnome.value.replace(/\x13\x10*/gi,'') == '')) )
		errCast += "- Nome è obbligatorio e non può essere vuoto.\n";

	if ( (castcognome.value=="") || ((castcognome.value.replace(/\s*/gi,'') == '') || (castcognome.value.replace(/\x13\x10*/gi,'') == '')) )
		errCast += "- Cognome è obbligatorio e non può essere vuoto.\n";

	if (castmail.value == "")
		errCast += "- E-mail è obbligatorio.\n";
	else
	{
		if (!verEmail(castmail.value))
			errCast += "- Inserire un indirizzo e-mail corretto.\n";
	}

	if ( (castmobile.value=="") || ((castmobile.value.replace(/\s*/gi,'') == '') || (castmobile.value.replace(/\x13\x10*/gi,'') == '')) )
		errCast += "- Cellulare è obbligatorio e non può essere vuoto.\n";

	//   DATI LOCATIONS
	if ( (locnome.value=="") || ((locnome.value.replace(/\s*/gi,'') == '') || (locnome.value.replace(/\x13\x10*/gi,'') == '')) )
		errLoc += "- Nome è obbligatorio e non può essere vuoto.\n";

	if ( (loccognome.value=="") || ((loccognome.value.replace(/\s*/gi,'') == '') || (loccognome.value.replace(/\x13\x10*/gi,'') == '')) )
		errLoc += "- Cognome è obbligatorio e non può essere vuoto.\n";

	if (locmail.value == "")
		errLoc += "- E-mail è obbligatorio.\n";
	else
	{
		if (!verEmail(locmail.value))
			errLoc += "- Inserire un indirizzo e-mail corretto.\n";
	}

	if ( (locmobile.value=="") || ((locmobile.value.replace(/\s*/gi,'') == '') || (locmobile.value.replace(/\x13\x10*/gi,'') == '')) )
		errLoc += "- Cellulare è obbligatorio e non può essere vuoto.\n";

	//   DATI WEBMASTER E SVILUPPATORE
	if (accesso == 1)
	{
		if ( (webnome.value=="") || ((webnome.value.replace(/\s*/gi,'') == '') || (webnome.value.replace(/\x13\x10*/gi,'') == '')) )
			errWeb += "- Nome è obbligatorio e non può essere vuoto.\n";
	
		if ( (webcognome.value=="") || ((webcognome.value.replace(/\s*/gi,'') == '') || (webcognome.value.replace(/\x13\x10*/gi,'') == '')) )
			errWeb += "- Cognome è obbligatorio e non può essere vuoto.\n";
	
		if (webmail.value == "")
			errWeb += "- E-mail è obbligatorio.\n";
		else
		{
			if (!verEmail(webmail.value))
				errWeb += "- Inserire un indirizzo e-mail corretto.\n";
		}
		if ( (webfrom.value!="") && ((webfrom.value.replace(/\s*/gi,'') == '') || (webfrom.value.replace(/\x13\x10*/gi,'') == '')) )
			errWeb += "- Località non può essere vuoto.\n";
	
		if ( (devnome.value=="") || ((devnome.value.replace(/\s*/gi,'') == '') || (devnome.value.replace(/\x13\x10*/gi,'') == '')) )
			errDev += "- Nome è obbligatorio e non può essere vuoto.\n";
	
		if ( (devcognome.value=="") || ((devcognome.value.replace(/\s*/gi,'') == '') || (devcognome.value.replace(/\x13\x10*/gi,'') == '')) )
			errDev += "- Cognome è obbligatorio e non può essere vuoto.\n";
	
		if (devmail.value == "")
			errDev += "- E-mail è obbligatorio.\n";
		else
		{
			if (!verEmail(devmail.value))
				errDev += "- Inserire un indirizzo e-mail corretto.\n";
		}
		if ( (devfrom.value!="") && ((devfrom.value.replace(/\s*/gi,'') == '') || (devfrom.value.replace(/\x13\x10*/gi,'') == '')) )
			errDev += "- Località non può essere vuoto.\n";
	}

	if (errAzienda != '')
		errMsg += "\nAzienda:\n"+errAzienda;
	if (errCast != '')
		errMsg += "\nResponsabile Casting:\n"+errCast;
	if (errLoc != '')
		errMsg += "\nResponsabile Locations:\n"+errLoc;
	if (accesso == 1)
	{
		if (errWeb != '')
			errMsg += "\Grafico:\n"+errWeb;
		if (errDev != '')
			errMsg += "\nSviluppatore:\n"+errDev;
	}

	//   STAMPA ERRORI
  	if (errMsg != '')
	{
		errMsg = "Si sono verificati i seguenti errori:\n"+errMsg;
		alert(errMsg);
		return false;
	}
	else
		return true;
}
