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 = "no";
	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+',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 CheckUpload(form){
// 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
	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(controllo == -1){
		//alert("File corretto");
		theForm.submit();
	}
	else{
		alert("Il nome del file contiene spazi vuoti. Per evitare problemi di visualizzazione rinominare il file sul disco e riprovare.");
	}
}