function checkDel(url, msg){
	if(confirm(msg)){
		window.open(url, '_self');
	}else{
		return false;
	}
}//END checkDel(url)

// JavaScript Document
function checkNumber(obj){
	var number = obj.value;
	var tempAry=number.match(/[^0-9]/g);
	if(tempAry!=null){
		obj.value='';
		//obj.focus();
		return false;
	}else{
		return true;
	}
}//END checkNumber

function phoneCheck(obj){
	var phoneStr=obj.value;
//	var tempAry=phoneStr.match(/[^0-9\/\-,\s]/g);
	var tempAry=phoneStr.match(/[^0-9,]/g);
 	if(tempAry!=null){
		obj.value='';
		return false;
	}else{
		return true;
	}
}//END phoneCheck
function isDouble(obj){
	var doubleStr=obj.value;
	var tempAry=doubleStr.match(/[^0-9.]/g);
	var parts = doubleStr.split('.');
	if(tempAry!=null || (parts.length > 2)){
		obj.value='';
		return false;
	}else{
		return true;
	}
}//END isDouble
function checkMail(email){
  var parts = new Array();
  var dominio = new Array();
  parts = email.split('@')
  if(parts.length != 2){
    return false; /*se utilizzando come valore discriminante @ in un indirizzo e-mail le parti sono piu di 2 l'indirizzo non e' corretto*/
  }else{
  /*controlli ulteriori*/
    if(!parts[0] || !parts[1]){
      return false; /*se uno dei segmenti e' vuoto l'indirizzo non e' valido*/
    }else{
      dominio = parts[1].split('.');
      if(dominio.length != 2){
        return false
      }else{
        if(!dominio[0] || !dominio[1] || dominio[1].length > 4 || dominio[1].length < 2){
          return false;
        }else{
          return true;
        }
      }
    }
  }
}//END checkMail()

function pivaCheck(piva){

var checked=0;
var disomma=0;
var pasomma=0;
var result=0;
var i, tempStr;

var tempAry=piva.match(/\D/);
var cifre=piva.match(/^\d{11}$/);

  if( (tempAry==null) && (cifre!=null) ){ //considero esclusivamente stringhe di 11 cifre
    cifre=piva.match(/^(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)$/);
    for(i=1;i<=9;i=i+2){ // sommo le cifre dispari fino alla 9a
      disomma=disomma+parseInt(cifre[i]);
    }
    for(i=2;i<=10;i=i+2){ //sommo le cifre pari fino alla 10a con un procedimento piu' elaborato
      tempStr=parseInt(cifre[i])*2; //raddoppio il valore di ogni cifra
      tempStr=parseInt(tempStr/10)+(tempStr-(parseInt(tempStr/10)*10)); //per ogni valore ottenuto sommo le decine alle unita'
      pasomma=pasomma+tempStr;
    }
    result=(pasomma+disomma); //sommo la somma-dispari alla somma-pari
    result=result-(parseInt(result/10)*10); //considero solamente le unita'
    result=10-result; //complemento a 10
    result=result-(parseInt(result/10)*10); //considero solamente le unita'
    if(result==cifre[11]){ //controllo la corrispondenza con l'ultima (11a) cifra
      checked=1;
    }
  }
  if(checked){
    return true;
  }else{
    return false;
  }
}//END piva_check()
/*
function cp_hanlder(id_panel, id_img){
	var panel = document.getElementById(id_panel);
	var img_p = document.getElementById(id_img);
	if(panel.style.display == "" || panel.style.display == "none"){
		panel.style.display = "block";
		img_p.src = "../images/meno.png";
	}else{
		panel.style.display = "none";
		img_p.src = "../images/piu.png";
	}
}*/
function showPanel(prefisso, id, blocchiMenu){
	
	if(document.getElementById(prefisso + id).style.display == "block"){
		document.getElementById(prefisso + id).style.display = "none";
	}else{
		//Azzeramento blocchi menu
		for(i = 0; i < blocchiMenu; i++){
			idClose = prefisso + i;
			document.getElementById(idClose).style.display = "none";
		}
		document.getElementById(prefisso + id).style.display = "block";
	}
}
// blocchiMenu = 10;
