function apriPopupCentrata(nome, titolo, lar, alt, feat){
        var wdt = screen.width;
        var hgt = screen.height;
        var x = Math.round( (wdt / 2) - (lar / 2) );
        var y = Math.round( (hgt / 2) - (alt / 2) );
        window.open(nome, titolo, 'width=' + lar + ',height=' + alt + ',left=' + x + ',screenX=' + x + ',top=' + y + ',screenY=' + y + ',' + feat);
}

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];}
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

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_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function emailCheck (emailStr)
{
var emailPat=/^(.+)@(.+)$/
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
var validChars="\[^\\s" + specialChars + "\]"
var quotedUser="(\"[^\"]*\")"
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
var atom=validChars + '+'
var word="(" + atom + "|" + quotedUser + ")"
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
 	alert("L'indirizzo e-mail inserito è scorretto ")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]
if (user.match(userPat)==null) {
    alert("Inserire il nome utente della mail.")
    return false
}
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("L'indirizzo ip di destinazione è invalido!")
		return false
	    }
    }
    return true
}
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("Il nome del domino è scorretto.")
    return false
}
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   alert("L'indirizzo deve terminare con due o tre lettere indicanti il dominio.")
   return false
}
if (len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   return false
}
return true;
}

function zoom(file) {
var finestra = null;
bName=navigator.appName;
finestra=window.open('../scripts/img.php?file='+file,'zoom','toolbar=no,location=no,directories=no,status=no,scrollbars=no,menubar=no,resizable=yes,width=50,height=50');
finestra.focus();
}

function dettagli(id,file) {
var finestra = null;
bName=navigator.appName;
finestra=window.open('newsletter/'+file+'.php?id='+id,'','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=yes,width=500,height=350');
if (bName=="Netscape") { finestra.focus(); }
}


function guida(dir,file) {
    var guida = null;    

    x_g=300;
    x=screen.availWidth-x_g;
    y=screen.availHeight;
    self.moveTo(0,0);
    self.resizeTo(x-10,y);

    guida=window.open('guida.php?file='+file+'&dir='+dir,'guida','toolbar=yes,location=no,directories=no,status=no,scrollbars=yes,menubar=no,resizable=yes,width='+x_g+',height='+y+',left='+(x));
    guida.focus();

}

function loadGuida(dir,file) {
    guida.location='guida.php?file='+file+'&dir='+dir;
}

function cancella(url)
{
if (confirm("Confermi la cancellazione?")){
 redir(url);
 return true;
 }
return false;
}

function nuovalingua(id) {
  var url = String(window.location) ;
  set_cookie('lang', id);

  var index = url.indexOf('?');
  
  conc=(index == -1)?"?":"&";
    
  url = url + conc+"lang="+id;
  //alert (url);
  window.location=url;
}

function redir(url)
{
window.location=url;
}


// -----------------------------------------------------------------------------
// --- Controllo dei dati nel form di richiesta informazioni
// -----------------------------------------------------------------------------
function controllo_richiesta()
{	
	var risultato = true;
	var ragione_sociale = document.forms['informazioni'].ragione.value;
	var nome = document.forms['informazioni'].nome_.value;
	var cognome = document.forms['informazioni'].cognome_.value;
	var telefono = document.forms['informazioni'].telefono_.value;
	var email = document.forms['informazioni'].email_.value;
	
	if (ragione_sociale == '')
	{
		document.getElementById('td_ragione').style.color = '#FF0033';
		document.getElementById('td_ragione').style.fontWeight = 'bold';
		risultato = false;
	}
	else
	{
		document.getElementById('td_ragione').style.color = '';
		document.getElementById('td_ragione').style.fontWeight = '';
	}
	if (cognome == '')
	{
		document.getElementById('td_cognome').style.color = '#FF0033';
		document.getElementById('td_cognome').style.fontWeight = 'bold';
		risultato = false;
	}
	else
	{
		document.getElementById('td_cognome').style.color = '';
		document.getElementById('td_cognome').style.fontWeight = '';
	}
	
	if (nome == '')
	{
		document.getElementById('td_nome').style.color = '#FF0033';
		document.getElementById('td_nome').style.fontWeight = 'bold';
		risultato = false;
	}
	else
	{
		document.getElementById('td_nome').style.color = '';
		document.getElementById('td_nome').style.fontWeight = '';
	}

	var tel_re = /^\d+$/;
	if ((telefono == '') || (!telefono.match(tel_re)))
	{
		document.getElementById('td_telefono').style.color = '#FF0033';
		document.getElementById('td_telefono').style.fontWeight = 'bold';
		risultato = false;
	}
	else
	{
		document.getElementById('td_telefono').style.color = '';
		document.getElementById('td_telefono').style.fontWeight = '';
	}

	var email_re = /^[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/;
  if ((email == '') || (!email.match(email_re)))
	{
		document.getElementById('td_email').style.color = '#FF0033';
		document.getElementById('td_email').style.fontWeight = 'bold';
		risultato = false;
	}
	else
	{
		document.getElementById('td_email').style.color = '';
		document.getElementById('td_email').style.fontWeight = '';
	}
	
	if (risultato == false)
	{
		alert('Sono stati rilevati dei campi non validi. Ricontrollare i campi evidenziati in rosso.');
	}

	return risultato;
}
// -----------------------------------------------------------------------------
