// JavaScript Document
// Santachiara a chiesto di invertire i colori di onMouseover da verde a bianco, cambiando il colore iniziale del testo del menu
// da bianco a verde
function linea_bianca(){
	document.getElementById('verde').style.display = "none";
	document.getElementById('bianca').style.display = "inline";
	document.getElementById('menu_chisiamo').style.display ='none';
	document.getElementById('chisiamo').style.color='#168D7C';	
}
function linea_verde(){
	document.getElementById('verde').style.display = "inline";
	document.getElementById('bianca').style.display = "none";
	document.getElementById('menu_chisiamo').style.display ='inline';
	document.getElementById('chisiamo').style.color='#ffffff';
}

function linea_bianca1(){
	document.getElementById('verde').style.display = "none";
	document.getElementById('bianca').style.display = "inline";
	document.getElementById('verde1').style.display = "none";
	document.getElementById('bianca1').style.display = "inline";
	document.getElementById('servizi').style.color='#168D7C';
}
function linea_verde1(){
	document.getElementById('verde').style.display = "inline";
	document.getElementById('bianca').style.display = "none";	
	document.getElementById('verde1').style.display = "inline";
	document.getElementById('bianca1').style.display = "none";
	document.getElementById('servizi').style.color='#ffffff';	
}

function linea_bianca2(){
	document.getElementById('verde2').style.display = "none";
	document.getElementById('bianca2').style.display = "inline";
	document.getElementById('verde1').style.display = "none";
	document.getElementById('bianca1').style.display = "inline";
	document.getElementById('altri_servizi2').style.display ='none';
	document.getElementById('altriservizi').style.color='#168D7C';	
}
function linea_verde2(){
	document.getElementById('verde2').style.display = "inline";
	document.getElementById('bianca2').style.display = "none";	
	document.getElementById('verde1').style.display = "inline";
	document.getElementById('bianca1').style.display = "none";
	document.getElementById('altri_servizi2').style.display ='inline';
	document.getElementById('altriservizi').style.color='#ffffff';
}

function linea_bianca3(){
	document.getElementById('verde2').style.display = "none";
	document.getElementById('bianca2').style.display = "inline";
	document.getElementById('verde3').style.display = "none";
	document.getElementById('bianca3').style.display = "inline";
	document.getElementById('link').style.color='#168D7C';	
}
function linea_verde3(){
	document.getElementById('verde2').style.display = "inline";
	document.getElementById('bianca2').style.display = "none";	
	document.getElementById('verde3').style.display = "inline";
	document.getElementById('bianca3').style.display = "none";
	document.getElementById('link').style.color='#ffffff';	
}

function linea_bianca4(){
	document.getElementById('verde3').style.display = "none";
	document.getElementById('bianca3').style.display = "inline";
	document.getElementById('vetrina').style.color='#168D7C';	
}
function linea_verde4(){
	document.getElementById('verde3').style.display = "inline";
	document.getElementById('bianca3').style.display = "none";
	document.getElementById('vetrina').style.color='#ffffff';
}

function controllo_radio_password(){
	if( !document.cambiopsw.cambio[0].checked && !document.cambiopsw.cambio[0].checked){
		alert("Attenzione! Selezionare quale password vuoi cambiare");
		return false;
	}
	if( document.cambiopsw.psw1.value=="" ){
		alert("Attenzione! La password è obbligatoria");
		document.cambiopsw.psw1.focus();
		return false;
	}
	if( document.cambiopsw.psw2.value=="" ){
		alert("Attenzione! La seconda password è obbligatoria, e deve essere identica alla precedente");
		document.cambiopsw.psw2.focus();
		return false;
	}
	
	if(document.cambiopsw.psw1.value.length == document.cambiopsw.psw2.value.length){
		//alert(document.registrazione.password.value.length);
		for(i=0; i<document.cambiopsw.psw1.value.length; i++){
			if(document.cambiopsw.psw1.value.charAt(i+1) !== document.cambiopsw.psw2.value.charAt(i+1) ){
				alert("Attenzione! Le password devono essere identiche");
				document.cambiopsw.psw1.value="";
				document.cambiopsw.psw1.focus();
				return false;
			}
		}
	}
	else{
		alert("Attenzione! Le password devono essere identiche");
		return false;
	}
}

function Controllo_admin_file(){
	if(document.cambiopsw.categoria.value ==""){
		alert("Selezionare una categoria");
		document.cambiopsw.categoria.focus();
		return false;
	}
	if(document.cambiopsw.didascalia.value ==""){
		alert("Inserire una didascalia");
		document.cambiopsw.didascalia.focus();
		return false;
	}	
}

function Controllo_ins_file(){
		var stringa = document.frmSend.attach1.value; 
		var estensione = (stringa.substring(stringa.length-3, stringa.length));
		
		if (document.frmSend.attach1.value == ""){
			alert("Il campo File da caricare è obbligatorio");
			document.frmSend.attach1.focus();
			return false;
		}			

		if( (estensione !== "PDF") && (estensione !== "pdf") ){
			alert(" ATTENZIONE: il file selezionato non ha estensione .pdf");
		 	document.frmSend.attach1.focus();
			return false;
		}

}

function confermi(){
	var a=window.confirm("Sei sicuro di volere eliminare questo file");
	if(a){
		return true;
	}
	else{
		return false;
	}
}




 function Controllodati(){
//---------------------cognome-------------------------------------
	if(document.modulo.cognome.value==""){
		alert("Il campo Cognome è obbligatorio");
		document.modulo.cognome.focus();
		return false;
	}
	if( !isNaN(document.modulo.cognome.value) ){
		alert("Il campo Cognome non può essere numerico");
		document.modulo.cognome.focus();
		return false;
	}	
//---------------------fine cognome-------------------------------------



//---------------------nome-------------------------------------	 
	if(document.modulo.nome.value==""){
		alert("Il campo Nome è obbligatorio");
		document.modulo.nome.focus();
		return false;
	}
	if( !isNaN(document.modulo.nome.value) ){
		alert("Il campo Nome non può essere numerico");
		document.modulo.nome.focus();
		return false;
	}
//---------------------fine nome-------------------------------------



//---------------------Indirizzo-------------------------------------
	if(document.modulo.indirizzo.value){
		if( !isNaN(document.modulo.indirizzo.value) ){
			alert("Il campo Indirizzo non può essere numerico");
			document.modulo.indirizzo.focus();
			return false;
		}
	}
//---------------------fine indirizzo-------------------------------------

//---------------------Citta-------------------------------------
	if(document.modulo.citta.value){
		if( !isNaN(document.modulo.citta.value) ){
			alert("Il campo Città non può essere numerico");
			document.modulo.citta.focus();
			return false;
		}
	}
//---------------------fine citta-------------------------------------

//---------------------cap-------------------------------------
	if(document.modulo.cap.value){
		if( isNaN(document.modulo.cap.value) ){
			alert("Il campo Cap deve essere numerico");
			document.modulo.cap.focus();
			return false;
		}
	}
//---------------------fine cap-------------------------------------

//---------------------telefono-------------------------------------	
	if(document.modulo.tel.value==""){
		alert("Il campo Telefono è obbligatorio");
		document.modulo.tel.focus();
		return false;
	}
	if( isNaN(document.modulo.tel.value) ){
		alert("Il campo Telefono deve essere numerico");
		document.modulo.tel.focus();
		return false;
	}
//---------------------fine telefono-------------------------------------

//---------------------cellulare-------------------------------------
	if(document.modulo.cel.value==""){
		alert("Il campo Cellulare è obbligatorio");
		document.modulo.cel.focus();
		return false;
	}
	if( isNaN(document.modulo.cel.value) ){
		alert("Il campo Cellulare deve essere numerico");
		document.modulo.cel.focus();
		return false;
	}
//---------------------fine cellulare-------------------------------------	

	
//---------------------Fax-------------------------------------
	if(document.modulo.fax.value){
		if( isNaN(document.modulo.fax.value) ){
			alert("Il campo Fax deve essere numerico");
			document.modulo.fax.focus();
			return false;
		}
	}
//---------------------fine Fax-------------------------------------

//---------------------mail-------------------------------------	
	if(document.modulo.mail.value){	
		if (document.modulo.mail.value.indexOf ('@',0) == -1 ||
			document.modulo.mail.value.indexOf ('.',0) == -1) {
			alert ("\n INDIRIZZO E-MAIL non corretto. Inserire un indirizzo e-mail valido.")
			document.modulo.mail.focus();
			return false;
		}
	}
//---------------------fine mail-------------------------------------



//---------------------sito web-------------------------------------
	if(document.modulo.SitoWeb.value){
		if( !isNaN(document.modulo.SitoWeb.value) ){
			alert("Il campo Sito Web non può essere numerico");
			document.modulo.SitoWeb.focus();
			return false;
		}
	}
//---------------------fine sito web------------------------------



//--------------settore, Zona operativa, Canale di vendità---------------	
	if(document.modulo.settore.value==""){
		alert("Il campo Settore è obbligatorio");
		document.modulo.settore.focus();
		return false;
	}
	if( !isNaN(document.modulo.settore.value) ){
		alert("Il campo Settore non può essere numerico");
		document.modulo.settore.focus();
		return false;
	}
	
	if(document.modulo.ZonaOperativa.value==""){
		alert("Il campo Zona Operativa è obbligatorio");
		document.modulo.ZonaOperativa.focus();
		return false;
	}
	if( !isNaN(document.modulo.ZonaOperativa.value) ){
		alert("Il campo Zona Operativa non può essere numerico");
		document.modulo.ZonaOperativa.focus();
		return false;
	}
		
	if(document.modulo.CanaleVendita.value==""){
		alert("Il campo Canale di Vendita è obbligatorio");
		document.modulo.CanaleVendita.focus();
		return false;
	}
	if( !isNaN(document.modulo.CanaleVendita.value) ){
		alert("Il campo Canale di Vendita non può essere numerico");
		document.modulo.CanaleVendita.focus();
		return false;
	}	
//--------------fine settore, Zona operativa, Canale di vendità---------------	
	
	
	
}


function Controllodati2(){
//---------------------nome-------------------------------------	 
	if(document.modulo.categoria.value==""){
		alert("Il campo Categoria è obbligatorio");
		document.modulo.categoria.focus();
		return false;
	}
	if( !isNaN(document.modulo.categoria.value) ){
		alert("Il campo Categoria non può essere numerico");
		document.modulo.categoria.focus();
		return false;
	}
//---------------------fine nome-------------------------------------	
}

function Visualizza(valore){
	document.getElementById(valore).style.display ="inline"
	document.getElementById(valore+"espandi").style.display ="none"
	document.getElementById(valore+"comprimi").style.display ="inline"	
}
function Nascondi(valore){
	document.getElementById(valore).style.display ="none"
	document.getElementById(valore+"espandi").style.display ="inline"
	document.getElementById(valore+"comprimi").style.display ="none"	
	
}
