function popUp(nome_pagina,w,h) {
		var l = Math.floor((screen.width-w)/2);
    	var t = Math.floor((screen.height-h)/2);
        window.open(nome_pagina,"","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l + ",resizable=no, menubar=no, scrollbars=yes");
 }
 
function enlarge3d(tlink,larghezza,altezza,scroll) {
	a=window.open(tlink,"3d","width=" + larghezza + ",height=" + altezza + ",resizable=no,menubar=no,scrollbars=" + scroll);
	a.focus;
}

function ControllaForm(valore,val) {
	var nonok = 0;
	for (i = 1; i < obbligatori.length; i++) {	
		eval ("if(!self.document.formmia."+obbligatori[i]+".value) nonok = 1");
	}
	if (nonok == 1)
		alert("Attenzione!!!\nTutti i campi contrassegnati con * sono obbligatori");
	else {
		if (val==1) {
			if (self.document.formmia.Privacy[1].checked) {
				alert("Per procedere bisogna accettare l'informativa.");
				return;
			}	
		}
		self.document.formmia.azione.value=valore;
		self.document.formmia.submit();	
	}	
}


function ControlloDeleteFile(linkpage) {
if(confirm('Sei sicuro di voler cancellare il file?')== false)
{
return;
}
else { window.location = linkpage;
	}
}

function ControllaForm_Pwd(valore) {
	var nonok = 0;
	for (i = 1; i < obbligatori_pwd.length; i++) {	
		eval ("if(!self.document.formmia."+obbligatori_pwd[i]+".value) nonok = 1");
	}
	if (nonok == 1)
		alert("Attenzione!!!\nInserire username valido.");
	else {
		if (valore==1) {
			if (self.document.formmia.Privacy[1].checked) {
				alert("Per iscriversi bisogna accettare l'informativa.");
				return;
			}	
		}
		self.document.formmia.azione.value=valore;
		self.document.formmia.submit();	
	}	
}

function ControllaForm_Pre(valore) {
	var nonok = 0;
	for (i = 1; i < obbligatori_pre.length; i++) {	
		eval ("if(!self.document.formmia."+obbligatori_pre[i]+".value) nonok = 1");
	}
	if (nonok == 1)
		alert("Attenzione!!!\nTutti i campi contrassegnati con * sono obbligatori");
	else {
		if (valore==1) {
			if (self.document.formmia.Privacy[1].checked) {
				alert("Per iscriversi bisogna accettare l'informativa.");
				return;
			}	
		}
		self.document.formmia.azione.value=valore;
		self.document.formmia.submit();	
	}	
}

function verTel(field,type) {
	var valid = "0123456789"
	var ok = "0";	
	var temp;
	for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "1";
	}
	if (ok == "1") {
		alert("Numero di " + type + " non valido.");
		field.value = "";
		field.select();
		return;
  		}		
}


function verProv(field,type) {
	var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	var ok = "0";	
	var temp; 

	if (field.value.length>0) {
		for (var i=0; i<field.value.length; i++) {
			temp = "" + field.value.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") ok = "1";
		}
		if (field.value.length<2) ok = "1";
		if (ok == "1") {
			alert("Provincia non valida!");
			field.value = "";
			field.select();
			return;
		}	
	}
}

function verPassword(field) {
	var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
	var ok = "0";	
	var temp;
	
	if (self.document.formmia.password.value != self.document.formmia.repassword.value) {
		
				alert("Password non valida!");
				self.document.formmia.password.value = "";
				self.document.formmia.repassword.value = "";
				self.document.formmia.password.select();
				return;
	}
	
	if ((self.document.formmia.password.value.length>0)&&(self.document.formmia.password.value.length<5)) 
	{
			alert("La password deve essere almeno di 5 caratteri!");
			self.document.formmia.password.value = "";
			self.document.formmia.repassword.value = "";
			self.document.formmia.password.select();
			return;
	}

	for (var i=0; i<self.document.formmia.password.value.length; i++) {
			temp = "" + self.document.formmia.password.value.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") ok = "1";
	}
	if (ok == "1") { 
			alert("La password deve contenere solo numeri e lettere!");
			self.document.formmia.password.value = "";
			self.document.formmia.repassword.value = "";
			self.document.formmia.password.select();
			return;
				
	}
}

function verPassword_user(field) {
	var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
	var ok = "0";	
	var temp;

	if (self.document.formmia.uname.value.length==0) 
	{
			alert("Il campo username non deve essere vuoto!");
			self.document.formmia.uname.value = "";
			self.document.formmia.uname.select();
			return;
	}
	
	for (var i=0; i<self.document.formmia.uname.value.length; i++) {
			temp = "" + self.document.formmia.uname.value.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") ok = "1";
	}
	if (ok == "1") { 
			alert("Il campo username deve contenere solo numeri e lettere!");
			self.document.formmia.uname.value = "";
			self.document.formmia.uname.select();
			return;
				
	}

	if (((self.document.formmia.passw.value.length>0)&&(self.document.formmia.passw.value.length<5)) || (self.document.formmia.passw.value.length==0)) 
	{
			alert("La password deve essere almeno di 5 caratteri!");
			self.document.formmia.passw.value = "";
			self.document.formmia.passw.select();
			return;
	}

	for (var i=0; i<self.document.formmia.passw.value.length; i++) {
			temp = "" + self.document.formmia.passw.value.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") ok = "1";
	}
	if (ok == "1") { 
			alert("La password deve contenere solo numeri e lettere!");
			self.document.formmia.passw.value = "";
			self.document.formmia.passw.select();
			return;
				
	}
	self.document.formmia.submit();
}


function verUsername(field) {
	var valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
	var ok = "0";	
	var temp;

	for (var i=0; i<self.document.formmia.username.value.length; i++) {
			temp = "" + self.document.formmia.username.value.substring(i, i+1);
			if (valid.indexOf(temp) == "-1") ok = "1";
	}
	if (ok == "1") { 
			alert("Il campo username deve contenere solo numeri e lettere!");
			self.document.formmia.username.value = "";
			self.document.formmia.username.select();
			return;
	}
}
			
function indirizzoEmailValido(indirizzo) {
 		if (window.RegExp) {
   		var nonvalido = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
   		var valido = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
   		var regnv = new RegExp(nonvalido);
   		var regv = new RegExp(valido);
   		if (!regnv.test(indirizzo) && regv.test(indirizzo)) return true;
   		return false;
	} else {
   		if(indirizzo.indexOf("@") >= 0) return true;
   		return false;
 		}
 	}

function mail(modulo) {
	if ((modulo.value.length>0)&&(!indirizzoEmailValido(modulo.value))) {
		alert("Si prega di inserire un indirizzo email valido");
		modulo.value = "";
		modulo.select();
		return false;
	}
	else
		return true;
}

function numeri(modulo){
	var temp = modulo.value;
	temp=temp.replace(".", ",");
	if (isNaN(temp)) {
		alert("Solo numeri sono ammessi");
		modulo.value = 0;
		modulo.select();
		return;
	}
}

function numeri_lung(modulo,lunghezza){
	var temp = modulo.value;
	temp=temp.replace(".", ",");
	if ((isNaN(temp))||((temp.length>0)&&(temp.length<lunghezza))) {
		alert("Solo numeri sono ammessi di lunghezza " + lunghezza);
				modulo.value = "";
		modulo.select();
		return;
	}
}

function numData(modulo,tipo){
	var ok = "0";
	var temp = modulo.value;
	if ((temp.length>0)&&(isNaN(temp))) {
		alert("Solo numeri sono ammessi");
		ok = "1";
	} else {
		ok = "0";
		if ((tipo=="G")&&(temp>31)) {
			alert("Valore non valido Giorno");
			ok = "1";
		}
		if ((tipo=="M")&&(temp>12)) {
			alert("Valore non valido Mese");
			ok = "1";
		} 
		if ((tipo=="A")&&((temp.length>0)&&(temp.length < 4))) {
			alert("Valore non valido Anno");
			ok = "1";
		}
	}	
	if (ok == "1") {
		modulo.value = "";
		modulo.select();
		return;
	}
}

function secure_email(id_email){
	var id_email;
	if (id_email>0){
		msg = "ATTENZIONE!!!\nQuesta è un'operazione irreversibile pertanto non sarà\npiù possibile recuperare i dati eliminati.";
	}
	
	if (confirm(msg)){
		self.location.href="del_Newsletter.asp?id="+id_email;
	}
}

function checkPassword(){
	password = self.document.frmPassword.password.value;
	password_secure = self.document.frmPassword.password_secure.value;
	
	if (password==""){
		alert("ATTENZIONE!\nInserire la nuova password.");
		self.document.frmPassword.password.focus();
		return false;
	}
	if (password.indexOf("'")!=(-1)){
		alert("ATTENZIONE!\nInserire la nuova password senza il carattere apice ( ' ).");
		self.document.frmPassword.password.focus();
		return false;
	}
	if (password_secure==""){
		alert("ATTENZIONE!\nInserire la conferma della nuova password.");
		self.document.frmPassword.password_secure.focus();
		return false;
	}
	if (password_secure != password){
		alert("ATTENZIONE!\nInserire controllare la correttezza della password e della sua conferma.");
		self.document.frmPassword.password_secure.focus();
		return false;
	}
	
	return true;
}

function checkData2(Modulo, Tipo) {
	Val=Modulo.value;
	if (Val.length>0) {
		Modulo.style.backgroundColor='#FFFFFF';
	}
	if (Tipo=='Data'&&Val.length>0) {
		Temp=Val.toString();
		Data_vet=Temp.split("/");
		num=Data_vet.length;
		Errore=false;
		if (num==3) {
			if (isNaN(Data_vet[0])||isNaN(Data_vet[1])||isNaN(Data_vet[2])) {Errore=true}
			if (!Errore) {
				if (Data_vet[2]<1900||Data_vet[2]>2100||Data_vet[0]<1||Data_vet[0]>31||Data_vet[1]<1||Data_vet[1]>12) {Errore=true}
			}
		} else {
			Errore=true
		}
		if (Errore) {
			alert("Attenzione! \nLe date vanno inserite nella forma gg/mm/aaaa")
			Modulo.value="";
			Modulo.focus();
		} else {
			if (Data_vet[0].length==1||Data_vet[1].length==1) {
				if (Data_vet[0].length==1) {Data_vet[0]='0'+Data_vet[0].toString()}
				if (Data_vet[1].length==1) {Data_vet[1]='0'+Data_vet[1].toString()}
				Temp=Data_vet[0]+'/'+Data_vet[1]+'/'+Data_vet[2];
				Modulo.value=Temp;
			}
		}
	}
}

function checkData(Campo, Tipo) {
	eval("Val=self.document.frmEvento." + Campo + ".value;");
	if (Val.length>0) {
		eval("self.document.frmEvento." + Campo + ".style.backgroundColor='#FFFFFF';");
	}
	if (Tipo=='Data'&&Val.length>0) {
		Temp=Val.toString();
		Data_vet=Temp.split("/");
		num=Data_vet.length;
		Errore=false;
		if (num==3) {
			if (isNaN(Data_vet[0])||isNaN(Data_vet[1])||isNaN(Data_vet[2])) {Errore=true}
			if (!Errore) {
				if (Data_vet[2]<1900||Data_vet[2]>2100||Data_vet[0]<1||Data_vet[0]>31||Data_vet[1]<1||Data_vet[1]>12) {Errore=true}
			}
		} else {
			Errore=true
		}
		if (Errore) {
			alert("Attenzione! \nLe date vanno inserite nella forma gg/mm/aaaa")
			eval('self.document.frmEvento.' + Campo + '.value="";');
			eval('self.document.frmEvento.' + Campo + '.focus();');
		} else {
			if (Data_vet[0].length==1||Data_vet[1].length==1) {
				if (Data_vet[0].length==1) {Data_vet[0]='0'+Data_vet[0].toString()}
				if (Data_vet[1].length==1) {Data_vet[1]='0'+Data_vet[1].toString()}
				Temp=Data_vet[0]+'/'+Data_vet[1]+'/'+Data_vet[2];
				eval('self.document.frmEvento.' + Campo + '.value=Temp;');
			}
		}
	}
}

function checkNewsletter() {
	/*if (self.document.frmNewsletter.email_mitt.value.length==0){
		alert("ATTENZIONE!\nInserire l'indirizzo email del mittente.");
		return false;
	}
	if (self.document.frmNewsletter.email_mitt.value.indexOf('@') == -1) {
       	alert ("Attenzione!\nInserire una email valida per il mittente.");
		return false;
	}	
   	if (self.document.frmNewsletter.email_mitt.value.indexOf('.') == -1) {
      	alert ("Attenzione!\nInserire una email valida per il mittente.");
		return false;
   	}*/
	if (self.document.frmNewsletter.mittente.value.length==0){
		alert("ATTENZIONE!\nInserire il nome del mittente.");
		return false;
	}
	if (self.document.frmNewsletter.object.length==0){
		alert("ATTENZIONE!\nInserire l'oggetto della newsletter.");
		return false;
	}
	if (self.document.frmNewsletter.testo_email.length==0){
		alert("ATTENZIONE!\nInserire il testo della newsletter.");
		return false;
	}
	return true;
}

function seltutti() {
	for(i=0;i<self.document.frmNewsletter.length;++i) {
		if (frmNewsletter.elements[i].checked==true)
			{
			frmNewsletter.elements[i].checked=false
			}
		else
			{
			frmNewsletter.elements[i].checked=true
			}
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/*
Open Centered Popup Window Script-
© DHTML Shock (www.dhtmlshock.com)
To add more shock to your site, visit www.DHTML Shock.com
modified!
*/

/*
function OpenBrWindow(theURL, winName, features, myWidth, myHeight, isCenter)
{

	if (window.screen)
	{
    		var myLeft = (screen.width -  myWidth ) / 2;
    		var myTop  = (screen.height - myHeight) / 2;
    		features += (features != '') ? ',' : '';
    		features += ',left=' + myLeft + ',top=' + myTop;
  	}

  	myWindow = window.open(theURL, winName, features + ((features != '') ? ',' : '') + 'width=' + myWidth + ',height=' + myHeight);
  	myWindow.focus();
}
*/

function popupWindow(target, h, w)
{
	// Upper Left
	var height	= (h != null ? h : screen.availHeight / 2);
	var width	= (w != null ? w : screen.availWidth  / 2);
	var top		= (screen.availHeight - height)	/ 2;
	var left	= (screen.availWidth  - width)	/ 2;

	myWindow = window.open(target, "popup", "scrollbars=yes,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left);
	myWindow.focus();
}

function openChat()
{
	window.open('http://www.pliner.net/appchat/475/','chat41','width=525, height=475');
	return false;
}

function openWindow(url, title, options)
{
    var newWindow = window.open(url,title,options);

	if (window.focus)
    	newWindow.focus();

	return false;
}