/*
************************   ELENCO FUNZIONI  **************************


CheckUpload(form)       :     controlla che il nome di un file selezionato per l'upload non contenga spazi biancbi
cambianome(nID,nLANG,nIDp)	:	server per cambiare al volo il nome di un menu


**********************************************************************
*/
function navigoIE(){
	var ie
	ie = (navigator.appName == "Microsoft Internet Explorer");	// true o false a seconda del browser
	return ie;
}
/*
function usoIE(){
	
  var browser=navigator.appName;
   if ((browser != "Microsoft Internet Explorer")||(ie7 == true)) {
		return false;
		
   }
   else
   {
		return true;
   }
}
*/

function openPopup(ind){
	Xdimens=(screen.availWidth/4)*3;		// dimensioni del popup: 3/4 dello schermo
	Ydimens=(screen.availHeight/4)*3;		// a qualsiasi risoluzione
	x=(screen.availWidth/2)-(Xdimens/2);
	y=(screen.availHeight/2)-(Ydimens/2);
	window.open(ind,'','scrollbars=yes,resizable=no,width='+Xdimens+',height='+Ydimens+',status=no,location=no,toolbar=no,menubar=no,top='+y+',left='+x+',screenY=0,screenX=0');
}

function openPopupResize(ind){
	Xdimens=(screen.availWidth/4)*3;		// dimensioni del popup: 3/4 dello schermo, ridimensionabile
	Ydimens=(screen.availHeight/4)*3;		// a qualsiasi risoluzione
	x=(screen.availWidth/2)-(Xdimens/2);
	y=(screen.availHeight/2)-(Ydimens/2);
	window.open(ind,'','scrollbars=yes,titlebar=no,resizable=yes,width='+Xdimens+',height='+Ydimens+',status=no,location=no,toolbar=no,menubar=no,top='+y+',left='+x+',screenY=0,screenX=0');
}

function openPopupDim(ind, dimWidth, dimHeight){
	// popup di dimensioni variabili
	if (navigator.appName == "Netscape"){
		alt = window.innerHeight;
//		alert (alt);
		Hdim = 613;		// altezza della finestra senza i menu
	} else{
		alt = window.screen.height;
		Hdim = 768;
	}
	barScroll = "yes";
	if (alt < Hdim){
		dimHeight = (screen.availHeight/4)*3;
		barScroll = "yes";
	}
	x=(screen.availWidth/2)-(dimWidth/2);
	y=((screen.availHeight/2)-(dimHeight/2)-14);
	window.open(ind,'','scrollbars='+barScroll+',resizable=no,width='+ (dimWidth + 20) +',height='+dimHeight+',status=no,location=no,toolbar=no,menubar=no,top='+y+',left='+x+',screenY=0,screenX=0');
}

function mlFormCheck(form){
	var ffocus, Char, Char2;
	var theForm = eval ("document." + form);
	var msgErr = "";
	var IsNumber=true;
	var ValidChars = "0123456789+.";
	for (i = 0; i < theForm.email.value.length; i++){
		Char = theForm.email.value.charAt(i);
		Char2 = theForm.email.value.charAt(i + 1);
		if (Char == "@"){
			if (Char2 != ""){
				msgErr = "";
				break;
			} else {
				msgErr = theForm.msgemailwrong.value;
				ffocus = eval("document." + form + ".email");
			}
		} else {
			msgErr = theForm.msgemailwrong.value;
			ffocus = eval("document." + form + ".email");
		}
	}
	if (theForm.email.value == ""){
		msgErr = theForm.msgemail.value;
		ffocus = eval("document." + form + ".email");
	}
	if (theForm.tel.value == ""){
		msgErr = theForm.msgtel.value;
		ffocus = eval("document." + form + ".tel");
	}
	if (theForm.stato.value == ""){
		msgErr = theForm.msgstato.value;
		ffocus = eval("document." + form + ".stato");
	}
	if (theForm.prov.value == ""){
		msgErr = theForm.msgprov.value;
		ffocus = eval("document." + form + ".prov");
	}
	if (theForm.cap.value == ""){
		msgErr = theForm.msgcap.value;
		ffocus = eval("document." + form + ".cap");
	}
	for (i = 0; i < theForm.cap.value.length && IsNumber == true; i++){
		Char = theForm.cap.value.charAt(i);
		if (ValidChars.indexOf(Char) == -1){
			msgErr = theForm.msgcapwrong.value;
			ffocus = eval("document." + form + ".cap");
		}
	}
	if (theForm.localit.value == ""){
		msgErr = theForm.msglocalit.value;
		ffocus = eval("document." + form + ".localit");
	}
	if (theForm.indirizzo.value == ""){
		msgErr = theForm.msgindirizzo.value;
		ffocus = eval("document." + form + ".indirizzo");
	}
	if (theForm.azienda.value == ""){
		msgErr = theForm.msgazienda.value;
		ffocus = eval("document." + form + ".azienda");
	}
	if (theForm.cognome.value == ""){
		msgErr = theForm.msgcognome.value;
		ffocus = eval("document." + form + ".cognome");
	}
	if (theForm.nome.value == "") {
		msgErr = theForm.msgnome.value;
		ffocus = eval("document." + form + ".nome");
	}
	if (theForm.serial.value == ""){
		msgErr = theForm.msgserial.value;
		ffocus = eval("document." + form + ".serial");
	}
	if (!theForm.autor.checked) {
		msgErr = theForm.msgautor.value;
	}
	if (msgErr == "") {
		theForm.submit();
	} else {
		alert (msgErr);
		ffocus.focus();
	}
}

function mlGetLang(){
	var mlBrow = navigator.appName;
	if (mlBrow == "Netscape"){
		var mlVar = navigator.language;
	} else {
		var mlVar = window.navigator.systemLanguage;
	}
//	alert (mlBrow + " - " + mlVar);
}

function mlSendActivation(form){
	var theForm = eval ("document." + form);
	theForm.submit();
}

function plOk(txt){
	alert(txt);
	window.location = "default.asp";
//	window.location = "index.asp";
}

function plSales(ID, source){
//	alert (source);
	document.getElementById(ID).src=source;
}

function daIframe(page){
	parent.location = page;
}

function mlPager(source){
	// cambia la pagina con quella indicata da SOURCE
	// all'interno di un Iframe chiamato MAIN
	document.getElementById('main').src = source;
}

function mlDiv(id){
	if (document.layers){
	miomenu = "document.layers." + substring(id, 4);
	alert (miomenu);
		if (miomenu.visibility =='hidden'){
			miomenu.visibility = 'show';
		}		
	} else {
	miomenu = document.all[id];
		if (miomenu.style.display =='none'){
			miomenu.style.display ='inline';
		}
	}
}

function mlClose(tot, menuOpen){
//	alert (tot);
	for (i=0; i<=(eval(tot) + 1); i++){
		mnu = "premenu" + i;
		if (document.layers){
			miomenu = document.layer[i];
		}else{
			miomenu = document.all[mnu];
		}
		if (miomenu != null){
			if (i<=tot){
				if (i == menuOpen){
					i++;	// lascia aperto il menu relativo alla pagina visualizzata
				} else {
					miomenu.style.display ='none';
				}
			}
		}
	}
}

function mlBrowser(){
	if (document.layers){
		document.layers.menu0.visibility = 'show';
	} else {
		document.all['premenu0'].style.display = 'none';
		document.all['premenu1'].style.display = 'none';
		document.all['premenu2'].style.display = 'none';
		document.all['premenu3'].style.display = 'none';
		document.all['premenu4'].style.display = 'none';
	}
}

function getBrowser(){
// Identifico il Browser e la versione con cui l'utente naviga
	var sBrowser, sVers, result;
	sBrowser = navigator.appName;
	sVers = navigator.appVersion;
	result = true;
	if (sBrowser == 'Netscape'){
		if (sVers.substring(0, 4) == '4.79'){
			result = false;
		}
	}
	return result;
}

function showLayer(id, menuOpen, totMenu){
	alert ("HERE");
/*
	//var totMenu => si trova nel file plConn.asp
	result = getBrowser();
	if (result){
		for (i=0; i<=totMenu; i++){
			if (i < totMenu){
				// lascia aperto il submenu relativo alla pagina visualizzata
				if (i == menuOpen) i++;
			}
			premenu = "menu" + i;
			document.all[premenu].style.display ='none';
			document.all[premenu].style.visibility ='hidden';
			if (i == totMenu && i == menuOpen){
				// controllo sull'ultimo submenu
				document.all[premenu].style.display ='inline';
				document.all[premenu].style.visibility ='visible';
			}
		}
		//hideLayer(id);
		if (id <= totMenu) hideLayer(id);
	}
	return result;
*/
}

function hideLayer(id){
	premenu = "menu" + id;
	if (result){
		document.all[premenu].style.display ='inline';
		document.all[premenu].style.visibility ='visible';
	}
}

function HideLayerGeneric(layer){
	document.all[layer].style.display = 'none';
}

function confirmDelete(ID, IDLang){
//	alert("Attenzione! Questo comando permette di cancellare tutti i dati in tutte le lingue!");
	var myPage = "myMenu.asp";
	var agree = confirm("Premere OK per cancellare tutti i menu con ID:" + ID +".\nPremere Cancel per eliminare solo il menu selezionato");
	if (agree) {
		myPage += "?cmd=del&id=" + ID;
		var agree2 = confirm("Sicuro di voler procedere?");
		if (agree2)	myPage += "&bVal=1";
	} else {
		myPage += "?cmd=del&id=" + ID;
		var agree2 = confirm("Sicuro di voler procedere?");
		if (agree2) myPage += "&idLang=" + IDLang + "&bVal=0";
	}
	window.location.href = myPage;
//	alert (myPage);
}

function getHref(){
	var myHref = "";
	myHref = window.location.href;
	alert (myHref);
}


function NewFormCheck(form){
// funzione necessaria per la verifica dei dati provenienti da un FORM
// inserire nel FORM il campo <input type="button" onClick="NewFormCheck('nomeForm');">
// senza questo valore il controllo non funziona correttamente
	var ffocus, Char;
	var theForm = eval ("document." + form);
	var msgErr = "";
	//var ore = theForm.ore.value;
	//var minuti = theForm.minuti.value;
	var giorno = theForm.giorno.value;
	var mese = theForm.mese.value;
	var anno = theForm.anno.value;

/*
	if (theForm.ore.value == ""){
		msgErr = "Non hai inserito l'ora!";
		ffocus = eval("document." + form + ".ore");
	}
	if(isNaN(ore)){
		msgErr = "L'ora che hai inserito non è un numero!";
		ffocus = eval("document." + form + ".ore");
	}
	if(isNaN(minuti)){
		msgErr = "L'ora che hai inserito non è un numero!";
		ffocus = eval("document." + form + ".minuti");
	}
	if(ore > 23){
		msgErr = "Hai inserito un'ora non corretta!";
		ffocus = eval("document." + form + ".ore");
	}
	if(minuti > 59){
		msgErr = "Hai inserito un'ora non corretta!";
		ffocus = eval("document." + form + ".minuti");
	}
	if (theForm.titolo.value == "") {
		msgErr = "Non hai inserito il titolo!";
		ffocus = eval("document." + form + ".titolo");
	}
	if (theForm.relatore.value == "") {
		msgErr = "Non hai inserito il relatore!";
		ffocus = eval("document." + form + ".relatore");
	}
	if (theForm.testo_ita.value == "") {
		msgErr = "Non hai inserito nessun testo in italiano!";
		ffocus = eval("document." + form + ".testo_ita");
	}
	if (theForm.testo_eng.value == "") {
		msgErr = "Non hai inserito nessun testo in inglese!";
		ffocus = eval("document." + form + ".testo_ita");
	}
*/

// nuova form
	if (theForm.giorno.value == ""){
		msgErr = "Non hai inserito il giorno!";
		ffocus = eval("document." + form + ".giorno");
	}
	if(isNaN(giorno)){
		msgErr = "Il giorno che hai inserito non è un numero!";
		ffocus = eval("document." + form + ".giorno");
	}
	if(giorno > 31){
		msgErr = "Il giorno che hai inserito non è valido!";
		ffocus = eval("document." + form + ".giorno");
	}
/*
	if (theForm.mese.value == ""){
		msgErr = "Non hai inserito il mese!";
		ffocus = eval("document." + form + ".mese");
	}
	if(isNaN(mese)){
		msgErr = "Il mese che hai inserito non è un numero!";
		ffocus = eval("document." + form + ".mese");
	}
*/
/*
	if(mese > 12){
		msgErr = "Il mese che hai inserito non è valido!";
		ffocus = eval("document." + form + ".mese");
	}
	if (theForm.anno.value == ""){
		msgErr = "Non hai inserito l'anno!";
		ffocus = eval("document." + form + ".anno");
	}
	if(isNaN(anno)){
		msgErr = "L'anno che hai inserito non è un numero!";
		ffocus = eval("document." + form + ".anno");
	}
*/
	if (theForm.titolo_it.value == "") {
		msgErr = "Non hai inserito il titolo in italiano!";
		ffocus = eval("document." + form + ".titolo_it");
	}
/*
	if (theForm.sottotitolo_it.value == "") {
		msgErr = "Non hai inserito il sottotitolo in italiano!";
		ffocus = eval("document." + form + ".sottotitolo_it");
	}
*/
/*
	if (theForm.titolo_eng.value == "") {
		msgErr = "Non hai inserito il titolo in inglese!";
		ffocus = eval("document." + form + ".titolo_eng");
	}
*/
/*
	if (theForm.sottotitolo_eng.value == "") {
		msgErr = "Non hai inserito il sottotitolo in inglese!";
		ffocus = eval("document." + form + ".sottotitolo_eng");
	}
*/
/*
	if (theForm.destinatari_it.value == "") {
		msgErr = "Non hai inserito i destinatari in italiano!";
		ffocus = eval("document." + form + ".sottotitolo_it");
	}
*/
/*
	if (theForm.destinatari_eng.value == "") {
		msgErr = "Non hai inserito i destinatari in inglese!";
		ffocus = eval("document." + form + ".sottotitolo_eng");
	}
*/
/*
	if (theForm.coordinatori.value == "") {
		msgErr = "Non hai inserito i coordinatori!";
		ffocus = eval("document." + form + ".coordinatori");
	}
	if (theForm.collaborazione.value == "") {
		msgErr = "Non hai inserito le collaborazioni!";
		ffocus = eval("document." + form + ".collaborazione");
	}
*/
/*
	if (theForm.sponsor.value == "") {
		msgErr = "Non hai inserito lo sponsor!";
		ffocus = eval("document." + form + ".sponsor");
	}
*/
/*
	if (theForm.dettagli_it.value == "") {
		msgErr = "Non hai inserito i dettagli in italiano!";
		ffocus = eval("document." + form + ".dettagli_it");
	}
	if (theForm.dettagli_eng.value == "") {
		msgErr = "Non hai inserito i dettagli in inglese!";
		ffocus = eval("document." + form + ".dettagli_eng");
	}
*/
	if (msgErr == "") {
		theForm.submit();
	} else {
		alert (msgErr);
		ffocus.focus();
	}
}


function NewFormCheck2(form){
// funzione necessaria per la verifica dei dati provenienti da un FORM
// inserire nel FORM il campo <input type="button" onClick="NewFormCheck('nomeForm');">
// senza questo valore il controllo non funziona correttamente
	var ffocus, Char;
	var theForm = eval ("document." + form);
	var msgErr = "";
	var ore = theForm.ore.value;
	var minuti = theForm.minuti.value;
/*
	if (theForm.ore.value == ""){
		msgErr = "Non hai inserito l'ora!";
		ffocus = eval("document." + form + ".ore");
	}
	if(isNaN(ore)){
		msgErr = "L'ora che hai inserito non è un numero!";
		ffocus = eval("document." + form + ".ore");
	}
	if(isNaN(minuti)){
		msgErr = "L'ora che hai inserito non è un numero!";
		ffocus = eval("document." + form + ".minuti");
	}
	if(ore > 23){
		msgErr = "Hai inserito un'ora non corretta!";
		ffocus = eval("document." + form + ".ore");
	}
	if(minuti > 59){
		msgErr = "Hai inserito un'ora non corretta!";
		ffocus = eval("document." + form + ".minuti");
	}
*/
	if (theForm.titolo_it.value == "") {
		msgErr = "Non hai inserito il titolo in italiano!";
		ffocus = eval("document." + form + ".titolo_it");
	}

	if (theForm.titolo_eng.value == "") {
		//msgErr = "Non hai inserito il titolo in inglese!";
		theForm.titolo_eng.value = theForm.titolo_it.value;
		ffocus = eval("document." + form + ".titolo_eng");
	}
	if (theForm.testo_it.value == "") {
		msgErr = "Non hai inserito il testo in italiano!";
		ffocus = eval("document." + form + ".titolo_it");
	}

	if (theForm.testo_eng.value == "") {
		//msgErr = "Non hai inserito il titolo in inglese!";
		theForm.testo_eng.value = theForm.testo_it.value;
		ffocus = eval("document." + form + ".titolo_eng");
	}
/*
	if (theForm.relatore_it.value == "") {
		msgErr = "Non hai inserito il relatore in italiano!";
		ffocus = eval("document." + form + ".relatore_it");
	}
*/
/*
	if (theForm.relatore_eng.value == "") {
		msgErr = "Non hai inserito il relatore in inglese!";
		ffocus = eval("document." + form + ".relatore_eng");
	}
*/
/*
	if (theForm.testo_it.value == "") {
		msgErr = "Non hai inserito nessun testo in italiano!";
		ffocus = eval("document." + form + ".testo_ita");
	}
	if (theForm.testo_eng.value == "") {
		msgErr = "Non hai inserito nessun testo in inglese!";
		ffocus = eval("document." + form + ".testo_ita");
	}
*/
	if (msgErr == "") {
		theForm.submit();
	} else {
		alert (msgErr);
		ffocus.focus();
	}
}

// onClick="NewShow('n');"
function NewShow(n){
	//var mybutton = eval("document.getElementById('showbtn" + n + "')");
	//var theTable = eval("document.getElementById('mytable" + n + "')");
	var mybutton = eval("document.all('showbtn" + n + "')");
	var theTable = eval("document.all('mytable" + n + "')");

	if(mybutton.value == "Mostra agenda"){
		//theTable.style.visibility = "visible";
		theTable.style.display = "block";
		mybutton.value = "Nascondi agenda";
	}
	else{
		//theTable.style.visibility = "invisible";
		theTable.style.display = "none";
		mybutton.value = "Mostra agenda";
	}
}
function NewShowDett(n){
	// var mybutton = eval("document.getElementById('showbtn" + n + "')");
	// var theTable = eval("document.getElementById('mytable" + n + "')");
	// var theNewTable = eval("document.getElementById('myNewtable" + n + "')");
	var mybutton = eval("document.all('showbtn" + n + "')");
	var theTable = eval("document.all('mydiv" + n + "')");
	var theNewTable = eval("document.all('myNewdiv" + n + "')");
//	alert ("mytable>>> " + theTable + "mynewtable>>> " + theNewTable);

	if(theNewTable != null){
		if(mybutton.value == "dettagli"){
			theTable.style.display = "block";
			theNewTable.style.display = "block";
			mybutton.value = "nascondi";
		}
		else{
			theTable.style.display = "none";
			theNewTable.style.display = "none";
			mybutton.value = "dettagli";
		}
	}

	else{
		if(mybutton.value == "dettagli"){
			theTable.style.display = "block";
			mybutton.value = "nascondi";
		}
		else{
			theTable.style.display = "none";
			mybutton.value = "dettagli";
		}
	}

}

function NewShowDettEn(n){
	// var mybutton = eval("document.getElementById('showbtn" + n + "')");
	// var theTable = eval("document.getElementById('mytable" + n + "')");
	// var theNewTable = eval("document.getElementById('myNewtable" + n + "')");
	var mybutton = eval("document.all('showbtn" + n + "')");
	var theTable = eval("document.all('mydiv" + n + "')");
	var theNewTable = eval("document.all('myNewdiv" + n + "')");
//	alert ("mytable>>> " + theTable + "mynewtable>>> " + theNewTable);

	if(theNewTable != null){
		if(mybutton.value == "details"){
			theTable.style.display = "block";
			theNewTable.style.display = "block";
			mybutton.value = "hide";
		}
		else{
			theTable.style.display = "none";
			theNewTable.style.display = "none";
			mybutton.value = "details";
		}
	}

	else{
		if(mybutton.value == "details"){
			theTable.style.display = "block";
			mybutton.value = "hide";
		}
		else{
			theTable.style.display = "none";
			mybutton.value = "details";
		}
	}

}

function cambiaAzione(azione,form){
	var MioCampo = document.all('azione');
	MioCampo.value = azione;
	var theForm = eval ("document." + form);
	theForm.submit();
}

function cambialingua(lng, id){
	var msg = (lng + "  " + id);
	document.location.replace("myNewContent.asp?idParent=" + id + "&" + "lingua=" + lng);
}

function imgPopUp(theURL, winName, features){
	window.open(theURL, winName, features);
}




function CheckUpload(form,docType){
// funzione che controlla l'assenza di spazi bianchi nel nome del file da caricare ed eventualmente ne blcca l'upload
// inserire nel FORM il campo <input type="button" onClick="CheckUpload('nomeForm');">
// senza questo valore il controllo non funziona correttamente
// docType può essere 'doc' o 'img' a seconda dei dati che la form deve caricare
	
	var ffocus, Char;
	var theForm = eval ("document." + form);
	var msgErr = ""
	var num1 = theForm.uploadFile.value.lastIndexOf("\\");
	sub1 = theForm.uploadFile.value.substring(num1);
	controllo = sub1.search(" ");
	if(	theForm.uploadFile.value==""){controllo="0"}
	if(controllo == -1){
		//alert("File corretto");
		if(docType=="doc"){
			var sub2 = sub1.substr((sub1.lastIndexOf(".")+1),3);
			if(sub2=="pdf"){theForm.submit();}
			else if(sub2=="doc"){theForm.submit();}
			else if(sub2=="zip"){theForm.submit();}
			else if(sub2=="xls"){theForm.submit();}
			else{alert("Il formato del file non rientra tra quelli consentiti");}
		}
		else{theForm.submit();}
	}
	else{
		alert("Il nome del file contiene spazi vuoti. Per evitare problemi di visualizzazione rinominare il file sul disco e riprovare.");
	}
}
/* cambio titolo del menu al volo */
var submitID;
var submitLANG;
var submitIDp;

function cambianome(nID,nLANG,nIDp){
	submitID = nID;
	submitLANG = nLANG;
	submitIDp = nIDp;
	showlivello();
}
function cambiaordine(nID,nLANG,nIDp){
	submitID = nID;
	submitLANG = nLANG;
	submitIDp = nIDp;
	showlivello_ord();
}
function cambiatemplate(nID){
	submitID = nID;
	showlivello_tmp();
}
function showlivello(){
	var lvl = document.getElementById("miolivello");
	var asse_x = window.event.clientX;
	var asse_y = window.event.clientY;
	lvl.style.left=asse_x + 100;
	lvl.style.top=asse_y + document.body.scrollTop;
	lvl.style.display = "block";
}
function showlivello_ord(){
	var lvl = document.getElementById("cambiaOrdine");
	var asse_x = window.event.clientX;
	var asse_y = window.event.clientY;
	lvl.style.left=asse_x + 100;
	lvl.style.top=asse_y + document.body.scrollTop;
	lvl.style.display = "block";
}
function showlivello_tmp(){
	var lvl = document.getElementById("cambiatemplate");
	var asse_x = window.event.clientX;
	var asse_y = window.event.clientY;
	lvl.style.left=asse_x-200;
	lvl.style.top=asse_y + document.body.scrollTop;
	lvl.style.display = "block";
}
function showElemento(){
	var lvl = document.getElementById(idElemento);
	var asse_x = window.event.clientX;
	var asse_y = window.event.clientY;
	lvl.style.left=asse_x + 100;
	lvl.style.top=asse_y + document.body.scrollTop;
	lvl.style.display = "block";
}
function hidelivello_ord(){
	document.getElementById("cambiaOrdine").style.display = "none";
	submitID = "";
	submitLANG = "";
	submitIDp = "";
}
function hidelivello(){
	document.getElementById("miolivello").style.display = "none";
	submitID = "";
	submitLANG = "";
	submitIDp = "";
}
function hideEl(idEl){
	document.getElementById(idEl).style.display = "none";
}
function showvariables(){
	alert("mioID > " + submitID);
	alert("mioLANG > " + submitLANG);
}
function submitForm(){
	var myform = document.getElementById("pform");
	myform.mioIDp.value = submitID;
	myform.mioLANGp.value = submitLANG;
	myform.idparentp.value = submitIDp;
	myform.submit();
}
function submitForm_ord(){
	document.getElementById("pform_ord").mioID.value = submitID;
	document.getElementById("pform_ord").mioLANG.value = submitLANG;
	document.getElementById("pform_ord").idparent.value = submitIDp;
	document.pform_ord.submit();
}
function submitForm_tmp(){
	document.getElementById("pform_tmp").mioID.value = submitID;
	document.getElementById("pform_tmp").submit();
}
/* funzione per il ridimensionamento delle immagini nella galleria di amministrazione*/
function preview(img){
   document.getElementById("anteprima").style.visibility = "hidden";
   document.getElementById("anteprima").removeAttribute("height");
   document.getElementById("anteprima").removeAttribute("width");
   document.getElementById("anteprima").src = img;
}

function resizeImg(l,h,oggettoId,dimensione){

//alert("l >" + l);
//alert("h >" + h);
//alert("myId >" + myId);
   var myObj = document.getElementById(oggettoId);
	myObj.style.display="none";
   var MAX_WIDTH = dimensione;
   var MAX_HEIGHT = dimensione;
   var resize = false;
   //alert ("larg " + l + "  alt " + h);
   while( l > MAX_WIDTH || h > MAX_HEIGHT ) {
    l -= (l/100)*10;
    h -= (h/100)*10;
    var resize = true;
   }
   //alert ("largnew " + l + "  altnew " + h);
   if(resize==true){
      myObj.setAttribute("width",l);
      myObj.setAttribute("height",h);
   }
   myObj.style.display="block";
}
/* funzioni per la didascalia delle immagini nella gallery della sezione  admin*/
function moveDida(){
	var myDIV = document.getElementById("dida");
	var myX = window.event.clientX + document.body.scrollLeft + 15; 
	var myY = window.event.clientY + document.body.scrollTop;
	myDIV.style.left = myX;
	myDIV.style.top = myY;
}

function showDida(alt){
	var myDIV = document.getElementById("dida");
	myDIV.innerText = alt;
	myDIV.style.display="block";
}
function hideDida(){
	var myDIV = document.getElementById("dida");
	myDIV.style.display="none";
}

function formSubmit(myID){
	var myform = document.getElementById(myID);
	myform.submit();
}

function cambiaImmagine(){
   document.getElementById("anteprima").style.visibility = "hidden";
   document.getElementById("anteprima").removeAttribute("height");
   document.getElementById("anteprima").removeAttribute("width");
   var myNewImg = document.getElementById("cambiaimmagine");
   var myOldImg = document.getElementById("anteprima");
   if(myNewImg.value=="noImage"){
      myOldImg.src = "../admin/mlTextEditor/icons/noImage.gif";
   }
   else{   myOldImg.src = "../com/img/Content/" + myNewImg.value;}
   document.getElementById("anteprima").style.visibility = "visible";
}

function cambiaOpzione(img){
	var mySel = document.getElementById("cambiaimmagine");
	var i = 0;
	var myOpt;
	var myimg = img.substr(img.lastIndexOf("/")+1);
	while(i<mySel.length){
		myOpt = mySel.options[i].value;
		if(myOpt==myimg){
			mySel.selectedIndex=i;
		}
		i++;	
	}
}

/* cambia nome elemnto al volo dati ID - IDLANG */
function changeName(nID,nLang){
	submitID = nID;
	submitLANG = nLang;
	mostralivello();
}
function mostralivello(){
	var lvl = document.getElementById("cambianome");
	var asse_x = window.event.clientX;
	var asse_y = window.event.clientY;
	lvl.style.left=asse_x + 50;
	lvl.style.top=asse_y + document.body.scrollTop;
	lvl.style.display = "block";
}
function nascondilivello(){
	document.getElementById("cambianome").style.display = "none";
	submitID = "";
	submitLANG = "";
}

function inviaForm(){
	myForm = document.getElementById("pform")
	myForm.mioID.value = submitID;
	myForm.mioLANG.value = submitLANG;
	myForm.submit();
}

/* fine -- nuovo cambianome */


function formUtentiRec(n){
	var myForm = document.getElementById("saveRecUser");
	var formError = 0;
	
	if(myForm.email.value.indexOf("@") < 2){
		alert("L'indirizzo email inserito non è valido");
		formError=formError+1;
	}
	if(myForm.password.value != myForm.c_password.value){
		alert("La password di conferma è diversa da quella principale");
		formError=formError+1;
	}
	if(myForm.nome.value==""){
		alert("Il campo nome è obbligatorio");
		formError=formError+1;
	}
	if(myForm.cognome.value==""){
		alert("Il campo cognome è obbligatorio");
		formError=formError+1;
	}
	if(myForm.citta.value==""){
		alert("Il campo Città è obbligatorio");
		formError=formError+1;
	}
	if(myForm.zip.value==""){
		alert("Il campo Cap è obbligatorio");
		formError=formError+1;
	}
	if(isNaN(myForm.zip.value)){
		alert("Il valore inserito nel campo Cap non è valido");
		formError=formError+1;
	}
	if(myForm.stato.value==""){
		alert("Il campo Stato è obbligatorio");
		formError=formError+1;
	}
	if(formError==0){
	
		if(document.getElementById('privacy').checked)
		{
			myForm.submit();
		}
		else
		{
			alert("Devi dare il consenso al trattamento dei dati personali per continuare con la registrazione");
		}
		
		
	}	


}

/* gestione cookies*/
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
	window.location.reload();
}

/* funzione per la visualizzazione dei menu */
function _MenuShowDett(n){
	/* Funzione duplicata il 18_Gennaio_2008 da Emanuele Boccaletti per modificare il funzionamento dei menu */
	var myName = "menu" + n;
	var mySpan = document.getElementById(myName);
	
	if (mySpan.style.display == "none"){
		MenuOpenDett(n);
	} else {
		MenuCloseDett(n);
	}
}

function MenuShowDett(n)
{
	var i;
	for (i = 1; i <= 4; i ++)
	{
		MenuCloseDett(i);
	}
	MenuOpenDett(n);
}

function MenuCloseDett(n)
{
	var myName = "menu" + n;
	var mySpan = document.getElementById(myName);
	mySpan.style.display = "none";
}

function MenuOpenDett(n)
{
	var myName = "menu" + n;
	var mySpan = document.getElementById(myName);
	mySpan.style.display = "block";
}

/* funzione per la cancellazione dei menu */
function cancellaMenu(idM){
	if(confirm('Sei sicuro di voler cancellare il menu selezionato e tutti i contenuti ad esso collegati?')){
		window.location = "myMenu.asp?cmd=del&idm=" + idM;	
	}
}

// scrivo la cookie del popup 
function cookiePopUpChiudi()
{
   document.cookie = "MLPOP=1";
}

// nel form di registrazione controllo se l'utente è proprietario di una barca e mostro o nascondo il div con i dettagli
function controllaseproprietario(_n)
{
	//alert("funzioneok");
	if(_n == 0) //l'utente non è proprietario di nessuna barca
	{
		//alert("non sono proprietario");
		document.getElementById("soloseproprietario").style.display = "none";
	}
	else
	{
		//alert("sono proprietario");
		document.getElementById("soloseproprietario").style.display = "block";
		document.getElementById("materiale").disabled = true;
	}
}


// nel form di registrazione controllo il tipo di barca e mostro solo i materiali relativi
function scelgoIlTipoDiBarca(_tipo)
{
	
	var selectMateriale = 	document.getElementById("materiale");

	switch(_tipo)
	{
		case "Motore":
		case "Vela":
			
			svuotaOpzioniSelect(1,selectMateriale.options.length-1,document.getElementById("materiale"));
			
			selectMateriale.options[1] = new Option("VTR/compositi","VTR/compositi");
			selectMateriale.options[2] = new Option("Legno","Legno");
			selectMateriale.options[3] = new Option("Acciaio","Acciaio");
			selectMateriale.options[4] = new Option("Alluminio","Alluminio");
			
		
			selectMateriale.options[0].selected = true;
			selectMateriale.disabled = false;
		break;

		
		case "Gommone":
			
			svuotaOpzioniSelect(1,document.getElementById("materiale").options.length-1,document.getElementById("materiale"));
		
			selectMateriale.options[1] = new Option("Chiglia Pneumatica","Chiglia Pneumatica");
			selectMateriale.options[2] = new Option("Chiglia Rigida","Chiglia Rigida");

			selectMateriale.options[0].selected = true;
			selectMateriale.disabled = false;
		break;
		
		default:
			selectMateriale.options[0].selected = true;
			selectMateriale.disabled = true;
		break;

	}

}

// funzione che svuota le opzioni di una select: 
//	_nstart rappresenta l'indice della select da cui partire con la cancellazione
//	_nstop indica l'indice della select fino al quale cancellare
function svuotaOpzioniSelect(_nstart,_nstop,_select)
{	
	var i
	for(i=_nstop;i>=_nstart;i--)
	{
		_select.options[i] = null;
	}
}



function confermaEliminaImmagine(idImg,nome)
{

	var cancella = confirm("Sei sicuro di cancellare l'immagine \n\n" + nome + "\n\n Questa modifica riguarderà tutte le pagine in cui appare questa immagine");
	var collegamento = "myImgGallery.asp?azione=eliminaImmagine&idimmagine=" + idImg ;
	
	if(cancella)
	{
		location.href(collegamento);
	}
	
}

function confermaEliminaDocumento(iddoc,nome)
{

	var cancella = confirm("Sei sicuro di cancellare il documento \n\n" + nome + "\n\n Questa modifica riguarderà tutte le pagine cui è allegato questo documento");
	var collegamento = "myDocGallery.asp?azione=eliminaDoc&iddoc=" + iddoc ;
	
	if(cancella)
	{
		location.href(collegamento);
	}
	
}


function confermaElimina(link)
{

	var cancella = confirm("Sei sicuro di cancellare l'elemento selezionato?");
	var collegamento = link;
	
	if(cancella)
	{
		location.href(collegamento);
	}
	
}

