
function appendRow()
{
 var numi = document.getElementById('theValue');
 var num = (document.getElementById("theValue").value -1)+ 2;
 numi.value = num;

 var tbody = document.getElementById("PERSPROD").getElementsByTagName("tbody")[0];
 var row = document.createElement("tr");
 var a = document.createElement("td");
 var b = document.createElement("td");
 //var c = document.createElement("td");
 //var d = document.createElement("td");
 var e = document.createElement("td");

 a.innerHTML="<input type=\"hidden\" name=\"ID_PRODOTTO"+num+"\" value=\"1\"><input type=\"text\" name=\"TESTO"+num+"\" value=\"Prod. Supplementare\" class=\"longvalue\" />"
 b.innerHTML="<input type=\"text\" name=\"PREZZO"+num+"\" value=\"0\" class=\"smallvalue\" />"
 //c.innerHTML="<input type=\"hidden\" name=\"QUANTITA"+num+"\" value=\"1\" class=\"smallvalue\" />"
 //d.innerHTML="<input type=\"hidden\" name=\"REGIMEIVA"+num+"\" value=\"20\" class=\"smallvalue\" />"
 e.innerHTML="<input type=\"button\" value=\"Elimina\" onclick=\"deleteRow(this)\" />"

 row.appendChild(a);
 row.appendChild(b);
 //row.appendChild(c);
 //row.appendChild(d);
 row.appendChild(e);

 tbody.appendChild(row);
}
function deleteRow(r)
{
  var i=r.parentNode.parentNode.rowIndex
  document.getElementById('PERSPROD').deleteRow(i)
}

function newCliente(){
    if(document.getElementById('newclientediv').style.display='none') { document.getElementById('newclientediv').style.display='block'; }
    else { document.getElementById('newclientediv').style.display='none'; }
}

function toggleLayer( whichLayer ){
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function showdiv(pass) {
  var divs = document.getElementsByTagName('div');
  for(i=0;i<divs.length;i++){
   if(divs[i].id.match(pass)){
     if (document.getElementById)
      divs[i].style.visibility="visible";
    else
     if (document.layers) // Netscape 4
      document.layers[divs[i]].display = 'visible';
    else // IE 4
     document.all.hideShow.divs[i].visibility = 'visible';
 }
 }
}
function visualizzaCampoIva(pannello,formagiuridica){
  var elem, vis;
  elem = document.getElementById(pannello);
  vis = elem.style;
  if(formagiuridica=='Persona Fisica')
      vis.display = 'none';
  else
      vis.display = 'block';
}
function visualizzaCliente(codicefiscale,strcliente){
  //var cliente;
  //var array_clienti = new Array();
  //array_clienti = strcliente.split("/");
  //document.FrontPage_Form2.NCLI_CAP.value=array_clienti.length;
  //cliente = array_clienti[1];
  //document.FrontPage_Form2.NCLI_CITTA.value=cliente['NAZIONE'];
  /*for(i=0;i<array_clienti.length;i++)
      if(array_clienti['CFISC']==codicefiscale){
          document.FrontPage_Form2.NCLI_RAGSOC.value=array_clienti['DENOMINAZIONE'];
          document.FrontPage_Form2.NCLI_FORMAGIURIDICA.value=array_clienti['FORMAGIURIDICA'];
          document.FrontPage_Form2.NCLI_PIVA.value=array_clienti['PIVA'];
          document.FrontPage_Form2.NCLI_INDIRIZZO.value=array_clienti['INDIRIZZO'];
          document.FrontPage_Form2.NCLI_CAP.value=array_clienti['CAP'];
          document.FrontPage_Form2.NCLI_CITTA.value=array_clienti['CITTA'];
          document.FrontPage_Form2.NCLI_PROV.value=array_clienti['PROV'];
          document.FrontPage_Form2.NCLI_NAZIONE.value=array_clienti['NAZIONE'];
          document.FrontPage_Form2.NCLI_NUMTEL.value=array_clienti['TELEFONO'];
          document.FrontPage_Form2.NCLI_EMAIL.value=array_clienti['EMAIL'];
      }*/
}

