// JavaScript Document
  var ricerca_pro;   
  var stringa;
  var ricerca_prodx;
  var nomediv;
  var ricerca_pro1;
    function PreparaDati(){
  stringa = "";
  var form = document.forms[0];
  var numeroElementi = form.elements.length;
 
  for(var i = 0; i < numeroElementi; i++){
	
    if(i < numeroElementi-1){
      stringa += form.elements[i].name+"="+encodeURIComponent(form.elements[i].value)+"&";
    }else{
      stringa += form.elements[i].name+"="+encodeURIComponent(form.elements[i].value);
    } 
  } 
}
    function PreparaDati1(){
  stringa = "";
  var form = document.forms[1];
  var numeroElementi = form.elements.length;
 
  for(var i = 0; i < numeroElementi; i++){
	
    if(i < numeroElementi-1){
      stringa += form.elements[i].name+"="+encodeURIComponent(form.elements[i].value)+"&";
    }else{
      stringa += form.elements[i].name+"="+encodeURIComponent(form.elements[i].value);
    } 
  } 
}


function vaifin(url,divnome,id_piano,tiporichiesta,m) 
{  

document.m.id_piano.value=id_piano;
document.m.tiporichiesta.value=tiporichiesta;
nomediv=divnome;
PreparaDati();
alert(stringa)
// branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        ricerca_pro = new XMLHttpRequest();
        ricerca_pro.onreadystatechange = ricevifin;
        ricerca_pro.open("POST", ""+url+"?m="+m,true);
		ricerca_pro.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1")
        ricerca_pro.send(stringa);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        ricerca_pro = new ActiveXObject("Microsoft.XMLHTTP");
        if (ricerca_pro) {
            ricerca_pro.onreadystatechange = ricevifin;
            ricerca_pro.open("POST", ""+url+"?rand="+(Math.random())+"&m="+m,true);
          		ricerca_pro.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1")

		    ricerca_pro.send(stringa);
        }
    }
}
  function ricevifin() {   

//var divapri=document.getElementById('livelloccnl')
    var strRes;       
	strRes=nomediv;
    var arrValori;      
	  if (ricerca_pro.readyState == 4) {	    
			 document.getElementById(strRes).innerHTML = unescape(ricerca_pro.responseText);
    } else {
      var results = "caricamento dati in corso";
      document.getElementById(strRes).innerHTML = results; 
    }
	}



  function ricevicosto() {   

//var divapri=document.getElementById('livelloccnl')
    var strRes;       
	strRes=nomediv;
    var arrValori;      
	  if (ricerca_pro.readyState == 4) {	    
			 document.getElementById('livelloccnl').innerHTML = unescape(ricerca_pro.responseText);
    } else {
      var results = "caricamento dati in corso";
      document.getElementById('livelloccnl').innerHTML = results; 
    }
	}






function cercabase(base) 
{
	document.m.base.value=base;
	calcola();
}
function cercaccnl(url,appoccnl) 
{  
appoccnl=appoccnl.split(";");
ipsoa=appoccnl[0];
divisore=appoccnl[1];
document.m.ipsoa.value=ipsoa;
document.m.divisore.value=divisore;
document.m.base.value=0;
PreparaDati();

    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        ricerca_pro = new XMLHttpRequest();
        ricerca_pro.onreadystatechange = ricevicosto;
        ricerca_pro.open("POST", ""+url+"?ipsoa="+ipsoa,true);
		ricerca_pro.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1")
        ricerca_pro.send(stringa);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        ricerca_pro = new ActiveXObject("Microsoft.XMLHTTP");
        if (ricerca_pro) {
            ricerca_pro.onreadystatechange = ricevicosto;
            ricerca_pro.open("POST", ""+url+"?rand="+(Math.random())+"&ipsoa="+ipsoa,true);
          		ricerca_pro.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1")

		    ricerca_pro.send(stringa);
        }
    }
}


function cercaente(url,id_avviso) 
{  
/*appoccnl=appoccnl.split(";");
ipsoa=appoccnl[0];
divisore=appoccnl[1];
document.m.ipsoa.value=ipsoa;
document.m.divisore.value=divisore;
document.m.base.value=0;*/
document.m.id_avviso.value=id_avviso;
PreparaDati1();

    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        ricerca_pro = new XMLHttpRequest();
        ricerca_pro.onreadystatechange = riceviisp;
        ricerca_pro.open("POST", ""+url+"",true);
		ricerca_pro.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1")
        ricerca_pro.send(stringa);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        ricerca_pro = new ActiveXObject("Microsoft.XMLHTTP");
        if (ricerca_pro) {
            ricerca_pro.onreadystatechange = riceviisp;
            ricerca_pro.open("POST", ""+url+"?rand="+(Math.random()),true);
          		ricerca_pro.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1")

		    ricerca_pro.send(stringa);
        }
    }
}


  function riceviisp() {   

//var divapri=document.getElementById('livelloccnl')
    var strRes;       
    var arrValori;      
	  if (ricerca_pro.readyState == 4) {	    
			 document.getElementById('entattu').innerHTML = unescape(ricerca_pro.responseText);
    } else {
      var results = "caricamento dati in corso";
      document.getElementById('entattu').innerHTML = results; 
    }
	}





function vaicodice(url,codicegen) 
{  


    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        ricerca_pro = new XMLHttpRequest();
        ricerca_pro.onreadystatechange = ricevi;
        ricerca_pro.open("GET", ""+url+"?codicegen="+codicegen,true);
		ricerca_pro.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1")
        ricerca_pro.send();
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        ricerca_pro = new ActiveXObject("Microsoft.XMLHTTP");
        if (ricerca_pro) {
            ricerca_pro.onreadystatechange = ricevi;
            ricerca_pro.open("GET", ""+url+"?rand="+(Math.random())+"&codicegen="+codicegen,true);
          		ricerca_pro.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1")

		    ricerca_pro.send();
        }
    }
}


function vaiprov(url,id,divnome,nomeinput) 
{  
 nomediv=divnome;

    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        ricerca_pro = new XMLHttpRequest();
        ricerca_pro.onreadystatechange = ricevipro;
		
        ricerca_pro.open("GET", ""+url+"?id="+id+"&nomeinput="+nomeinput,true);
		ricerca_pro.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1")
        ricerca_pro.send();
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        ricerca_pro = new ActiveXObject("Microsoft.XMLHTTP");
        if (ricerca_pro) {
            ricerca_pro.onreadystatechange = ricevipro;
            ricerca_pro.open("GET", ""+url+"?rand="+(Math.random())+"&id="+id+"&nomeinput="+nomeinput,true);
          		ricerca_pro.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1")

		    ricerca_pro.send();
        }
    }
}

  function ricevipro() {   

//var divapri=document.getElementById('livelloccnl')
    var strRes;    
	 strRes=nomediv;
	
    var arrValori;      
	  if (ricerca_pro.readyState == 4) {	    
			 document.getElementById(strRes).innerHTML = unescape(ricerca_pro.responseText);
    } else {
      var results = "caricamento dati in corso";
      document.getElementById(strRes).innerHTML = results; 
    }
	}






  function ricevi() {   

//var divapri=document.getElementById('livelloccnl')
    var strRes;       
    var arrValori;      
	  if (ricerca_pro.readyState == 4) {	    
			 document.getElementById('livelloccnl').innerHTML = unescape(ricerca_pro.responseText);
    } else {
      var results = "caricamento dati in corso";
      document.getElementById('livelloccnl').innerHTML = results; 
    }
	}
	
	
	function numero(bb,aa)
   {/* alert( document.getElementById(bb)); 
alert(document.getElementById(aa).value) */
   var bb=bb.replace(",",".")

   bb = bb.replace(/^\s*/,"").replace(/\s*$/,"").replace(/\s+/g," ");

    if(bb.length==0){  
	/* for(i=0; i<document.m.elements.length-6;i++){
	document.m.elements[i].value=0;
	} */
  alert('digitare solo numeri ! !');
 document.getElementById(aa).value=0;
		   return   false ;}
  
   
   if (isNaN(bb.substring())==true){
       alert('digitare solo numeri!!');
	 document.getElementById(aa).value=0;  
           return  false;}
          else
    {
	 
calcola();
	 }
         }


function calcola(){
	// alert(document.m.lorda.value)
	document.m.q13.value=((eval(document.m.base.value)+eval(document.m.lorda.value))/12).toFixed(2);
	//document.m.q14.value=(eval(document.m.base.value)/12).toFixed(2);
	document.m.totretr.value=(eval(document.m.base.value)+eval(document.m.q13.value)+eval(document.m.q14.value)+eval(document.m.qfe.value)+eval(document.m.lorda.value)).toFixed(2)
//document.m.oneri.value=((eval(document.m.totretr.value)*eval(document.m.perc_oneri.value))/100).toFixed(2);
document.m.totoneri.value=(eval(document.m.totretr.value)+eval(document.m.oneri.value)).toFixed(2);
//document.m.qtfr.value=((eval(document.m.base.value)+eval(document.m.q13.value)+eval(document.m.q14.value))/13.5).toFixed(2);
document.m.tototfr.value=(eval(document.m.totoneri.value)+eval(document.m.qtfr.value)).toFixed(2);
document.m.costo.value=(eval(document.m.tototfr.value)/eval(document.m.divisore.value)).toFixed(2)
}

function Vstampa()
{ 

if (document.m.appoccnl.value.length < 1 || document.m.appoccnl.value==0) {
	    window.alert("prego scegliere ccnl");
	    document.m.q13.focus();
		return false;
	}


if (document.m.liv_ccnl.value.length < 1 || document.m.liv_ccnl.value==0) {
	    window.alert("prego scegliere livello");
	    document.m.liv_ccnl.focus();
		return false;
	}


/*if (document.m.q13.value.length < 1 || document.m.q13.value==0) {
	    window.alert("prego digitare 13 mensilita");
	    document.m.q13.focus();
		return false;
	}
	*/
	if (document.m.divisore.value.length < 1 || document.m.divisore.value==0 || document.m.divisore.value=="---") {
	    window.alert("prego digitare divisore");
	    document.m.divisore.focus();
		return false;
	}
	
	
	
	window.print()
	
}
