function newWindow(url,width,height){
 if (document.all){
      var x = window.screenLeft;
      var y = window.screenTop;
      var w = window.document.body.offsetWidth;
      var h = window.document.body.offsetHeight;
 } else {
   var x = window.screenX;
   var y = window.screenY;
   var w = window.outerWidth;
   var h = window.outerHeight;
 }
 var cntx = x + Math.round((w - width) / 2);
 var cnty = y + Math.round((h - height) / 2);
 var aa = window.open (url, null, 'left=' + cntx + ',top=' + cnty + ',width=' + width + ',height=' + height);
 aa.focus();
}
function popImage(url,width,height)
{
  if (document.all){
      var x = window.screenLeft;
      var y = window.screenTop;
      var w = window.document.body.offsetWidth;
      var h = window.document.body.offsetHeight;
 } else {
   var x = window.screenX;
   var y = window.screenY;
   var w = window.outerWidth;
   var h = window.outerHeight;
 }
 var cntx = x + Math.round((w - width) / 2);
 var cnty = y + Math.round((h - height) / 2);
 var aa = window.open (url, null, 'left=' + cntx + ',top=' + cnty + ',width=' + width + ',height=' + height);
 aa.document.open();
 aa.document.write('<html><title>Boss Equipment</title><body bgcolor="#FFFFFF" onBlur="self.close()"><img src="'+url+'"></body></html>');
 aa.document.close();
}

function sicuro(){
	return confirm("Sei sicuro? - Are you sure?");
}

function PopUp(url,name,width,height){
 if (document.all){
      var x = window.screenLeft;
      var y = window.screenTop;
      var w = window.document.body.offsetWidth;
      var h = window.document.body.offsetHeight;
 } else {
   var x = window.screenX;
   var y = window.screenY;
   var w = window.outerWidth;
   var h = window.outerHeight;
 }
 var cntx = x + Math.round((w - width) / 2);
 var cnty = y + Math.round((h - height) / 2);
 var aa = window.open (url, name, 'left=' + cntx + ',top=' + cnty + ',width=' + width + ',height=' + height);
}

function check_mail(mail){
  var emailStr=mail
  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("Indirizzo e-mail non valido!\nInvalid e-mail address!");
    return false
  }
  var user=matchArray[1]
  var domain=matchArray[2]
  if(user.match(userPat)==null) {
	alert("Indirizzo e-mail non valido!\nInvalid e-mail address!");
    return false
  }
  var IPArray=domain.match(ipDomainPat)
  if(IPArray!=null) {
	 for(var i=1;i<=4;i++) {
		if(IPArray[i]>255) {
		 	alert("Indirizzo e-mail non valido!\nInvalid e-mail address!");
    		return false
	    }
	 }
	 return true
   }
   var domainArray=domain.match(domainPat)
   if(domainArray==null) {
	   alert("Indirizzo e-mail non valido!\nInvalid e-mail address!");
       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("Indirizzo e-mail non valido!\nInvalid e-mail address!");
      return false
	}
	if(len<2) {
	     alert("Indirizzo e-mail non valido!\nInvalid e-mail address!");
    	 return false
	}
	return true
}
function checkForm(f){
    if(f.privacy[1].checked){
	  alert("Per procedere deve autorizzare il trattamento dei dati!\nIn order to proceed, authorization of data management must be confirmed!");
      return false
	}
	if(f.nome.value==""){
	  alert("Manca il nome!\nName missing!");
	  return false  
	}
	if(f.cognome.value==""){
	  alert("Manca il cognome!\nSurname missing!");
	  return false
	}
	if(f.email.value==""){
	  alert("Manca l\'indirizzo e-mail!\nE-mail address missing!");
	  return false 
    }else {
	  if(!check_mail(f.email.value)){
	     return false;
	  }
    }
	if(f.richieste.value==""){
	  alert("Mancano le richieste!\nRequest missing!");
	  return false;
	}
	return sicuro();
}//fine check()
