// riporta ricerca
function setsearch(mitt1,dato1,mitt2,dato2){
   var actform = '';
   if (document.form1 != undefined){
     actform = 'form1';
   }
   if (document.doc1 != undefined){
     actform = 'doc1';
   }
   document[actform][mitt1].value=dato1;
   document.getElementById(mitt2).innerHTML = dato2;
   //debugger;
}
// fine riporta ricerca

// attach image su root
function attimgr(tab,id){
  window.open('../attimg1a1.aspx?tab='+tab+'&id='+id,'_blank','')
}
// fine attach image su root

// attach image su dir attuale
function attimg(tab,id){
  window.open('attimg1a1.aspx?tab='+tab+'&id='+id,'_blank','')
}
// fine attach image su dir attuale

// carico procxml.js
function IncludeJavaScript(jsFile)
{
document.write('<script type="text/javascript" src="' + jsFile + '"></script>'); 
}
IncludeJavaScript('procxml.js');
// fine carico procxml.js

// Hop200 su tnopeng.mdb
function printarr(){
   window.open('staarr1a1.aspx','_blank','width=700,height=500,toolbar=yes,scrollbars=yes,resizable=yes')
}
function printpar(){
   window.open('stapar1a1.aspx','_blank','width=700,height=500,toolbar=yes,scrollbars=yes,resizable=yes')
}
function printpre(){
   window.open('stapre1a1.aspx','_blank','width=700,height=500,toolbar=yes,scrollbars=yes,resizable=yes')
}
function printcal1a1(){
   window.open('stacal1a1.aspx','_blank','width=700,height=500,toolbar=yes,scrollbars=yes,resizable=yes')
}

// Gestione hotel su nadia
function printarr1(){
   window.open('staarr2a1.aspx','_blank','width=700,height=500,toolbar=yes,scrollbars=yes,resizable=yes')
}
function printpar1(){
   window.open('stapar2a1.aspx','_blank','width=700,height=500,toolbar=yes,scrollbars=yes,resizable=yes')
}
function printpre1(){
   window.open('stapre2a1.aspx','_blank','width=700,height=500,toolbar=yes,scrollbars=yes,resizable=yes')
}
function printcal2a1(){
   window.open('stacal2a1.aspx','_blank','width=700,height=500,toolbar=yes,scrollbars=yes,resizable=yes')
}

function printcli1a1(){
   window.open('stacli1a1.aspx','_blank','width=700,height=500,toolbar=yes,scrollbars=yes,resizable=yes')
}
function printmag1a1(){
   window.open('stamag1a1.aspx','_blank','width=700,height=500,toolbar=yes,scrollbars=yes,resizable=yes')
}
function carmag1a1(){
   window.open('carmag1a1.aspx','_blank','width=700,height=500,toolbar=yes,scrollbars=yes,resizable=yes')
}
function estmag1a1(){
   window.open('estmag1a1.aspx','_blank','width=900,height=600,toolbar=yes,scrollbars=yes,resizable=yes')
}
function visgiac1a1(){
   window.open('visgiac1a1.aspx','_blank','width=900,height=600,toolbar=yes,scrollbars=yes,resizable=yes')
}
function visbar1a1(){
   window.open('visbar1a1.aspx','_blank','width=900,height=600,toolbar=yes,scrollbars=yes,resizable=yes')
}
function stapiaco1a1(){
   window.open('stapiaco1a1.aspx','_blank','width=900,height=600,toolbar=yes,scrollbars=yes,resizable=yes')
}
function staestco1a1(){
   window.open('staestco1a1.aspx','_blank','width=900,height=600,toolbar=yes,scrollbars=yes,resizable=yes')
}
function staestcopn1a1(){
   window.open('staestcopn1a1.aspx','_blank','width=900,height=600,toolbar=yes,scrollbars=yes,resizable=yes')
}
function stabil1a1(){
   window.open('stabil1a1.aspx','_blank','width=900,height=600,toolbar=yes,scrollbars=yes,resizable=yes')
}
function carlist1a1(){
   window.open('carlist1a1.aspx','_blank','width=700,height=400,toolbar=yes,scrollbars=yes,resizable=yes')
}
function vislibgio1a1(){
   window.open('vislibgio1a1.aspx','_blank','width=900,height=600,toolbar=yes,scrollbars=yes,resizable=yes')
}
function viscoscc1a1(){
   window.open('viscoscc1a1.aspx','_blank','width=900,height=600,toolbar=yes,scrollbars=yes,resizable=yes')
}
function popup(prog){
   window.open(prog,'_blank','width=350,height=200,left=300,top=300,toolbar=yes,scrollbars=yes,resizable=yes')
}
function compatta(){
   wind = window.open('compattadb.aspx?db=nadia.mdb&passwd=','_blank','width=200,height=100');
   wind.moveTo(400,300);
}
function stacqven(){
   window.open('stacqven1a1.aspx','_blank','width=900,height=600,toolbar=yes,scrollbars=yes,resizable=yes')
}
function help(param){
   window.open('help/' + param + '.htm','_blank','width=900,height=600,toolbar=yes,scrollbars=yes,resizable=yes')
}
function impclihop1a1(){
   window.open('impclihop1a1.aspx','_blank','width=900,height=600,toolbar=yes,scrollbars=yes,resizable=yes')
}
function inviosms1a1(){
   window.open('inviosms1a1.aspx','_blank','width=850,height=500,toolbar=yes,scrollbars=yes,resizable=yes')
}
function mandafax1a1(){
   window.open('gestfax1a1.aspx','_blank','width=700,height=500,toolbar=yes,scrollbars=yes,resizable=yes')
}
function copyarc(){
   window.open('copyarc1a1.aspx','_blank','width=300,height=300,toolbar=yes,scrollbars=yes,resizable=yes')
}
function stainv1a1(){
   window.open('stainv1a1.aspx','_blank','width=700,height=500,toolbar=yes,scrollbars=yes,resizable=yes')
}
function reginv1a1(){
   window.open('reginv1a1.aspx','_blank','width=700,height=500,toolbar=yes,scrollbars=yes,resizable=yes')
}
function ecommerce(){
   window.open('ecommerce.aspx','_blank','width=900,height=700,toolbar=yes,scrollbars=yes,resizable=yes')
}
function staqucam1a1(){
   window.open('staqcamp1a1.aspx','_blank','width=800,height=500,toolbar=yes,scrollbars=yes,resizable=yes')
}
function webexp1a1(){
   window.open('webexp/default.asp','_blank','width=800,height=600,toolbar=yes,scrollbars=yes,resizable=yes')
}
//function openwinmXML(prog,mitt1,mitt2,pini,pfin,cod,desc) {
//  fin = window.open(prog+'?mitt1='+mitt1+'&mitt2='+mitt2+'&pagini='+pini+'&pagfin='+pfin+'&cod='+cod+'&desc='+desc, 'Window', 'width=700,height=480,scrollbars=yes');
//}
function openwinXML(prog,tabel,mitt1,mitt2,pini,pfin,cod,desc) {
  fin = window.open(prog+'?tabel='+tabel+'&mitt1='+mitt1+'&mitt2='+mitt2+'&pagini='+pini+'&pagfin='+pfin+'&cod='+cod+'&desc='+desc, 'Window', 'width=700,height=480,scrollbars=yes');
}

// nomeimmagine,orizz o vert,x img,y img,x finestra,y finestra
function openwinimg(img,orizvert,ximg,yimg,xwin,ywin) {
	//alert(img+' '+orizvert+' '+ximg+' '+yimg+' '+xwin+' '+ywin);
	immag = '<img src= "public/site/'+img+'" width='+ximg+', height='+yimg+'>'
	finestra= window.open('vuoto.htm','nome','width=400,height=400')
	finestra.focus()
	finestra.resizeTo(xwin,ywin)
	finestra.document.write('<html><title>Immagini</title><body>' + immag +' </body></html>')
	finestra.document.close()
};

function invia(rtable)
{
    appendHidden(rtable);
    document.doc1.method = "post";
    document.doc1.action = "memo.aspx";
    document.doc1.submit();
    alert("Aggiornamento effettuato!");
}

function inviadbt(rtable)
{
    appendHidden(rtable);
    document.doc1.method = "post";
    document.doc1.action = "memo.aspx";
    document.doc1.submit();
    alert("Aggiornamento effettuato!");
}

function inviapar(prog)
{
    document.doc1.method = "post";
    document.doc1.action = prog;
    document.doc1.submit();
    alert("Aggiornamento effettuato!");
}

function inviaparn(prog,nuovo)
{
    document.doc1.method = "post";
    document.doc1.action = prog;
    document.doc1.submit();
    alert("Aggiornamento effettuato!");
    window.open(nuovo,'_parent','width=900,height=600,toolbar=yes,scrollbars=yes,resizable=yes')
}

function inviaparf(prog)
{
    document.form1.method = "post";
    document.form1.action = prog;
    document.form1.submit();
}

function inviapars(prog)
{
    document.doc1.method = "post";
    document.doc1.action = prog;
    document.doc1.submit();
}

function isintnum(evt)
{
  var charCode = (evt.which) ? evt.which : event.keyCode
  if (charCode > 31 && (charCode < 48 || charCode > 57))
     return false;

  return true;
}

function isintnumv(evt)
{
  var charCode = (evt.which) ? evt.which : event.keyCode
// ammessa la virgola
  if (charCode == 44) return true;
  if (charCode < 48 || charCode > 57)
     return false;

  return true;
}

function appendHidden(tblStr)
{
  var tbl = document.getElementById(tblStr);
  var row = tbl.insertRow(tbl.rows.length);
  
  // aggiungo hidden text che contiene il num di righe della tabella righe
  var cellInputText = row.insertCell(0);
  var el = document.createElement('input');
  el.setAttribute('type', 'hidden');
  el.setAttribute('name', 'numrighe');
  el.setAttribute('value', (tbl.rows.length - 1));
  cellInputText.appendChild(el);
}


function inviap(prog)
{
    document.form1.method = "post";
    document.form1.action = prog;
    document.form1.submit();
}

function openwin1(finestra) {
  fin = window.open(finestra, 'Window', 'width=700,height=620,scrollbars=yes,status=yes');
}


// cancellazione record parametrico - funziona con parametri tipo numerico
function cancrow2(arrivada,tabella,numpar,tipopar,par1,val1,par2,val2){
    if (confirm("Sei veramente sicuro?"))
       {
       window.open('../cancrecord.aspx?arrivada=' + arrivada + '&tabella=' + tabella + '&numpar=' + numpar + '&tipopar=' + tipopar + '&par1=' + par1 + '&val1=' + val1 + '&par2=' + par2 + '&val2=' + val2,'_self','');
       } 
    else
       {
      // alert("no")
       }
}

function cancgiocon(esercizio,numreg){
    if (confirm("Sei veramente sicuro?"))
       {
       window.open('canc.aspx?esercizio=' + esercizio + '&numreg=' + numreg,'_self','');
       } 
    else
       {
      // alert("no")
       }
}

function cancpriman(esercizio,primanid){
    if (confirm("Sei veramente sicuro?"))
       {
       window.open('canc.aspx?esercizio=' + esercizio + '&priman_id=' + primanid,'_self','');
       } 
    else
       {
      // alert("no")
       }
}

function cancforpag(forpagtid){
    if (confirm("Sei veramente sicuro?"))
       {
       window.open('canc.aspx?forpagtid=' + forpagtid,'_self','');
       } 
    else
       {
      // alert("no")
       }
}
function staric(id){
     window.open('../staric1a1.aspx?id='+id,'_blank','width=700,height=500,toolbar=yes,scrollbars=yes,resizable=yes')
}

// ricerca parametrica 1 parametro - funzione di ricerca presenza art in archivio
// da finire -> se il parametro è numerico o str
function cercap(art) {
var ricevuto
xmlhttp=null
if (window.XMLHttpRequest) // Mozilla
  {xmlhttp=new XMLHttpRequest()}
else if (window.ActiveXObject) // IE
  {xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}

artic = document.getElementById(art)
if (artic.value == ""){
  alert("Inserire il codice!");
  return true;
}
xmlhttp.open('GET','../cercacod.aspx?npar=1&articolo=' + artic.value,false)
xmlhttp.send(null)

if (xmlhttp.readyState==4) 
  {
  ricevuto = xmlhttp.responseText;
  if (ricevuto == "1"){
    alert("Articolo già presente!");
    artic.value = "";
  }
  }
 return false
}

// restituisce codice a barre
function dammibar(art) {
var ricevuto
xmlhttp=null
if (window.XMLHttpRequest) // Mozilla
  {xmlhttp=new XMLHttpRequest()}
else if (window.ActiveXObject) // IE
  {xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}

artic = document.getElementById(art)
if (artic.value == ""){
  alert("Inserire il codice!");
  return true;
}
xmlhttp.open('GET','../dammibar.aspx?articolo=' + artic.value,false)
xmlhttp.send(null)

if (xmlhttp.readyState==4) 
  {
  ricevuto = xmlhttp.responseText;
  alert('Codice a barre: ' + ricevuto);
  }
 return true
}

// ricerca codicebarre
function cercab(art) {
var ricevuto
xmlhttp=null
if (window.XMLHttpRequest) // Mozilla
  {xmlhttp=new XMLHttpRequest()}
else if (window.ActiveXObject) // IE
  {xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}

artic = document.getElementById(art)
if (artic.value == ""){
  alert("Inserire il codice!");
  return true;
}
xmlhttp.open('GET','../cercacbar.aspx?npar=1&articolo=' + artic.value,false)
xmlhttp.send(null)

if (xmlhttp.readyState==4) 
  {
  ricevuto = xmlhttp.responseText;
  if (ricevuto == "1"){
    alert("Cod. barre già presente!");
    artic.value = "";
  }
  }
 return ricevuto
}

// ricerca parametrica 2 parametri - funzione di ricerca presenza art in archivio
// da finire -> se i parametri sono num o str
function cercap2(art,art1) {
var ricevuto
xmlhttp=null
if (window.XMLHttpRequest) // Mozilla
  {xmlhttp=new XMLHttpRequest()}
else if (window.ActiveXObject) // IE
  {xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}

artic  = document.getElementById(art)
artic1 = document.getElementById(art1)
if (artic1.value == ""){
  alert("Inserire il codice!");
  return true;
}

xmlhttp.open('GET','../cercacod.aspx?npar=2&articolo=' + artic.value + '&articolo1=' + artic1.value,false)
xmlhttp.send(null)

if (xmlhttp.readyState==4) 
  {
  ricevuto = xmlhttp.responseText;
  if (ricevuto == "1"){
    alert("Codice già presente!");
    artic1.value = "";
  }
  }
 return false
}

function appendRowCon(tblStr)
{
  var tbl = document.getElementById(tblStr);
  var row = tbl.insertRow(tbl.rows.length);
  
  // input text cell conto
  var cellInputText = row.insertCell(0);
  var el = document.createElement('input');
  el.setAttribute('type', 'text');
  el.setAttribute('name', 'conto'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'conto'+ (tbl.rows.length - 1));
  el.setAttribute('size', '11');
  cellInputText.appendChild(el);
  
  // binocolo
  var cellInputText = row.insertCell(1);
  var link = document.createElement('a');
  link.href = 'javascript:openwin1("../searchtabXML.aspx?tabel=search_conti&mitt1=conto'+(tbl.rows.length - 1)+'&mitt2=descrc'+(tbl.rows.length - 1)+'");';
  var img = document.createElement('img');
  img.src = '../immagini/binocolo.gif';
  //aggancio img al link
  link.appendChild(img);
  cellInputText.appendChild(link);
  
  // input text cell descr conto
  var cellInputText = row.insertCell(2);
  var el = document.createElement('input');
  el.setAttribute('type', 'text');
  el.setAttribute('name', 'descrc'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'descrc'+ (tbl.rows.length - 1));
  el.setAttribute('size', '15');
  cellInputText.appendChild(el);
  
  // input text cell descr operazione
  var cellInputText = row.insertCell(3);
  var el = document.createElement('input');
  el.setAttribute('type', 'text');
  el.setAttribute('name', 'descro'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'descro'+ (tbl.rows.length - 1));
  el.setAttribute('size', '55');
  cellInputText.appendChild(el);
  
  // input text cell dare
  var cellInputText = row.insertCell(4);
  var el = document.createElement('input');
  el.setAttribute('type', 'text');
  el.setAttribute('name', 'dare'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'dare'+ (tbl.rows.length - 1));
  el.setAttribute('value', '0');
  el.setAttribute('size', '10');
  el.setAttribute('style', 'text-align:right');
  el.setAttribute('onkeypress', 'javascript:return isintnumv(event)');
  cellInputText.appendChild(el);
  
  // input text cell avere
  var cellInputText = row.insertCell(5);
  var el = document.createElement('input');
  el.setAttribute('type', 'text');
  el.setAttribute('name', 'avere'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'avere'+ (tbl.rows.length - 1));
  el.setAttribute('value', '0');
  el.setAttribute('size', '10');
  el.setAttribute('style', 'text-align:right');
  el.setAttribute('onkeypress', 'javascript:return isintnumv(event)');
  cellInputText.appendChild(el);
  
  // input text cell hidden non serve a nulla - placeholder
  var cellInputText = row.insertCell(6);
  var el = document.createElement('input');
  el.setAttribute('type', 'hidden');
  cellInputText.appendChild(el);
  
  // input text cell cancella
  var cellInputText = row.insertCell(7);
  var el = document.createElement('input');
  el.setAttribute('type', 'checkbox');
  el.setAttribute('name', 'canc'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'canc'+ (tbl.rows.length - 1));
  el.setAttribute('size', '1');
  cellInputText.appendChild(el);
  
}

function appendRowForpag(tblStr)
{
  var tbl = document.getElementById(tblStr);
  var row = tbl.insertRow(tbl.rows.length);
  
  // input text cell riga
  var cellInputText = row.insertCell(0);
  var el = document.createElement('input');
  el.setAttribute('type', 'text');
  el.setAttribute('name', 'riga'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'riga'+ (tbl.rows.length - 1));
  el.setAttribute('value', '0');
  el.setAttribute('size', '5');
  el.setAttribute('style', 'text-align:right');
  el.setAttribute('onkeypress', 'javascript:return isintnum(event)');
  cellInputText.appendChild(el);
  
  // input text cell descr
  var cellInputText = row.insertCell(1);
  var el = document.createElement('input');
  el.setAttribute('type', 'text');
  el.setAttribute('name', 'descr'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'descr'+ (tbl.rows.length - 1));
  el.setAttribute('size', '15');
  cellInputText.appendChild(el);
  
  // input text cell giorni
  var cellInputText = row.insertCell(2);
  var el = document.createElement('input');
  el.setAttribute('type', 'text');
  el.setAttribute('name', 'giorni'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'giorni'+ (tbl.rows.length - 1));
  el.setAttribute('value', '0');
  el.setAttribute('size', '5');
  el.setAttribute('style', 'text-align:right');
  el.setAttribute('onkeypress', 'javascript:return isintnum(event)');
  cellInputText.appendChild(el);
  
  // input text cell fine mese
  var cellInputText = row.insertCell(3);
  var el = document.createElement('input');
  el.setAttribute('type', 'text');
  el.setAttribute('name', 'finem'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'finem'+ (tbl.rows.length - 1));
  el.setAttribute('value', '0');
  el.setAttribute('size', '5');
  el.setAttribute('style', 'text-align:right');
  el.setAttribute('onkeypress', 'javascript:return isintnum(event)');
  cellInputText.appendChild(el);
  
  // input text cell perc imp
  var cellInputText = row.insertCell(4);
  var el = document.createElement('input');
  el.setAttribute('type', 'text');
  el.setAttribute('name', 'percimp'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'percimp'+ (tbl.rows.length - 1));
  el.setAttribute('value', '0');
  el.setAttribute('size', '10');
  el.setAttribute('style', 'text-align:right');
  el.setAttribute('onkeypress', 'javascript:return isintnumv(event)');
  cellInputText.appendChild(el);
  
  // input text cell perc iva
  var cellInputText = row.insertCell(5);
  var el = document.createElement('input');
  el.setAttribute('type', 'text');
  el.setAttribute('name', 'perciva'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'perciva'+ (tbl.rows.length - 1));
  el.setAttribute('value', '0');
  el.setAttribute('size', '10');
  el.setAttribute('style', 'text-align:right');
  el.setAttribute('onkeypress', 'javascript:return isintnumv(event)');
  cellInputText.appendChild(el);
  
  // input text cell perc spe
  var cellInputText = row.insertCell(6);
  var el = document.createElement('input');
  el.setAttribute('type', 'text');
  el.setAttribute('name', 'percspe'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'percspe'+ (tbl.rows.length - 1));
  el.setAttribute('value', '0');
  el.setAttribute('size', '10');
  el.setAttribute('style', 'text-align:right');
  el.setAttribute('onkeypress', 'javascript:return isintnumv(event)');
  cellInputText.appendChild(el);
  
  // input text cell perc tot
  var cellInputText = row.insertCell(7);
  var el = document.createElement('input');
  el.setAttribute('type', 'text');
  el.setAttribute('name', 'perctot'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'perctot'+ (tbl.rows.length - 1));
  el.setAttribute('value', '0');
  el.setAttribute('size', '10');
  el.setAttribute('style', 'text-align:right');
  el.setAttribute('onkeypress', 'javascript:return isintnumv(event)');
  cellInputText.appendChild(el);
  
  // input text cell hidden non serve a nulla - placeholder
  var cellInputText = row.insertCell(8);
  var el = document.createElement('input');
  el.setAttribute('type', 'hidden');
  cellInputText.appendChild(el);
  
  // input text cell cancella
  var cellInputText = row.insertCell(9)
  var el = document.createElement('input');
  el.setAttribute('type', 'checkbox');
  el.setAttribute('name', 'canc'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'canc'+ (tbl.rows.length - 1));
  el.setAttribute('size', '1');
  cellInputText.appendChild(el);
}

function appendRowDb(tblStr)
{
  var tbl = document.getElementById(tblStr);
  var row = tbl.insertRow(tbl.rows.length);
  
  // input text cell riga
  var cellInputText = row.insertCell(0);
  var el = document.createElement('input');
  el.setAttribute('type', 'text');
  el.setAttribute('name', 'riga'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'riga'+ (tbl.rows.length - 1));
  el.setAttribute('value',+ (tbl.rows.length - 1));
  el.setAttribute('size', '5');
  el.setAttribute('style', 'text-align:right');
  el.setAttribute('onkeypress', 'javascript:return isintnum(event)');
  cellInputText.appendChild(el);
  
  // input text cell codice
  var cellInputText = row.insertCell(1);
  var el = document.createElement('input');
  el.setAttribute('type', 'text');
  el.setAttribute('name', 'cod'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'cod'+ (tbl.rows.length - 1));
  el.setAttribute('size', '25');
  cellInputText.appendChild(el);
  
  // binocolo
  var cellInputText = row.insertCell(2);
  var link = document.createElement('a');
  link.href = 'javascript:openwin1("../searchtabXML.aspx?tabel=search_artmag&mitt1=cod'+(tbl.rows.length - 1)+'&mitt2=descr'+(tbl.rows.length - 1)+'");';
  var img = document.createElement('img');
  img.src = '../immagini/binocolo.gif';
  //aggancio img al link
  link.appendChild(img);
  cellInputText.appendChild(link);
  
  // input text cell descr
  var cellInputText = row.insertCell(3);
  var el = document.createElement('input');
  el.setAttribute('type', 'text');
  el.setAttribute('name', 'descr'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'descr'+ (tbl.rows.length - 1));
  el.setAttribute('size', '45');
  el.setAttribute('style', 'text-align:left');
  cellInputText.appendChild(el);
  
  // input text cell um
  var cellInputText = row.insertCell(4);
  var el = document.createElement('input');
  el.setAttribute('type', 'text');
  el.setAttribute('name', 'um'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'um'+ (tbl.rows.length - 1));
  el.setAttribute('size', '5');
  cellInputText.appendChild(el);
  
  // input text cell qta
  var cellInputText = row.insertCell(5);
  var el = document.createElement('input');
  el.setAttribute('type', 'text');
  el.setAttribute('name', 'qta'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'qta'+ (tbl.rows.length - 1));
  el.setAttribute('value', '1');
  el.setAttribute('size', '5');
  el.setAttribute('style', 'text-align:right');
  el.setAttribute('onkeypress', 'javascript:return isintnumv(event)');
  cellInputText.appendChild(el);
  
  // input text cell hidden non serve a nulla - placeholder
  var cellInputText = row.insertCell(6);
  var el = document.createElement('input');
  el.setAttribute('type', 'hidden');
  el.setAttribute('style', 'text-align:center');
  cellInputText.appendChild(el);
  
  // input text cell cancella
  var cellInputText = row.insertCell(7)
  var el = document.createElement('input');
  el.setAttribute('type', 'checkbox');
  el.setAttribute('name', 'canc'+ (tbl.rows.length - 1));
  el.setAttribute('id', 'canc'+ (tbl.rows.length - 1));
  el.setAttribute('size', '1');
  cellInputText.appendChild(el);
}

// ************** calendario in js *********************
// default settings
var fontFace="verdana";
var fontSize=9;

var titleWidth=90;
var titleMode=1;
var dayWidth=12;
var dayDigits=1;

//var titleColor="#DDE3EB";
var titleColor="#0000FF";
//var daysColor="#99CCFF";
var daysColor="#D4D0C8";
var bodyColor="#ffffff";
var dayColor="#ffffff";
//var currentDayColor="#000000";
var currentDayColor="#FF0000";
//var footColor="#cccccc";
var footColor="#FFFFCC";
var borderColor="#333333";

//var titleFontColor = "#333333";
var titleFontColor = "#FFFFFF";
var daysFontColor = "#333333";
var dayFontColor = "#333333";
var currentDayFontColor = "#FFFFFF";
var footFontColor = "#333333";

//var calFormat = "yyyy/mm/dd";
var calFormat = "dd/mm/yyyy";

//var weekDay = 0;
var weekDay = 1;
// ------

// codes
var calWidth=200, calHeight=200, calOffsetX=-200, calOffsetY=16;
var calWin=null;
var winX=0, winY=0;
var cal="cal";
var cals=new Array();
var currentCal=null;

var yxMonths=new Array("Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre");
var yxDays=new Array("Domenica", "Lunedi", "Martedi", "Mercoledi", "Giovedi", "Venerdi", "Sabato", "Domenica");
var yxLinks=new Array("Chiudi", "Pulisci");

var isOpera=(navigator.userAgent.indexOf("Opera")!=-1)?true:false;
var isOpera5=(navigator.appVersion.indexOf("MSIE 5")!=-1 && navigator.userAgent.indexOf("Opera 5")!=-1)?true:false;
var isOpera6=(navigator.appVersion.indexOf("MSIE 5")!=-1 && navigator.userAgent.indexOf("Opera 6")!=-1)?true:false;
var isN6=(navigator.userAgent.indexOf("Gecko")!=-1);
var isN4=(document.layers)?true:false;
var isMac=(navigator.userAgent.indexOf("Mac")!=-1);
var isIE=(document.all && !isOpera && (!isMac || navigator.appVersion.indexOf("MSIE 4")==-1))?true:false;

if (isN4) {
  fontSize+=2;
}

var span2="</span>";

function span1(tag) {
  return "<span class='"+tag+"'>";
}
function spanx(tag, color) {
  return "."+tag+" { font-family:"+fontFace+"; font-size:"+fontSize+"px; color:"+color+"; }\n";
}

function a1(tag) {
  return "<a class='"+tag+"' href=";
}

function ax(tag, color) {
  return "."+tag+" { text-decoration:none; color:"+color+"; }\n";
}

function calOBJ(name, title, field, form) {
  this.name = name;
  this.title = title;
  this.field = field;
  this.formName = form;
  this.form = null
}

function setFont(font, size) {
  if (font != "") {
    fontFace=font;
  }
  if (size > 0) {
    fontSize=size;

    if (isN4) {
      fontSize+=2;
    }
  }
}

function setWidth(tWidth, tMode, dWidth, dDigits) {
  if (tWidth > 0) {
    titleWidth=tWidth;
  }
  if (tMode == 1 || tMode == 2) {
    titleMode=tMode;
  }
  if (dWidth > 0) {
    dayWidth=dWidth;
  }
  if (dDigits > 0) {
    dayDigits=dDigits;
  }
}

function setColor(tColor, dsColor, bColor, dColor, cdColor, fColor, bdColor) {
  if (tColor != "") {
    titleColor=tColor;
  }
  if (dsColor != "") {
    daysColor=dsColor;
  }
  if (bColor != "") {
    bodyColor=bColor;
  }
  if (dColor != "") {
    dayColor=dColor;
  }
  if (cdColor != "") {
    currentDayColor=cdColor;
  }
  if (fColor != "") {
    footColor=fColor;
  }
  if (bdColor != "") {
    borderColor=bdColor;
  }
}

function setFontColor(tColorFont, dsColorFont, dColorFont, cdColorFont, fColorFont) {
  if (tColorFont != "") {
    titleFontColor=tColorFont;
  }
  if (dsColorFont != "") {
    daysFontColor=dsColorFont;
  }
  if (dColorFont != "") {
    dayFontColor=dColorFont;
  }
  if (cdColorFont != "") {
    currentDayFontColor=cdColorFont;
  }
  if (fColorFont != "") {
    footFontColor=fColorFont;
  }
}

function setFormat(format) {
  calFormat = format;
}

function setSize(width, height, ox, oy) {
  if (width > 0) {
    calWidth=width;
  }
  if (height > 0) {
    calHeight=height;
  }

  calOffsetX=ox;
  calOffsetY=oy;
}

function setWeekDay(wDay) {
  if (wDay == 0 || wDay == 1) {
    weekDay = wDay;
  }
}

function setMonthNames(janName, febName, marName, aprName, mayName, junName, julName, augName, sepName, octName, novName, decName) {
  if (janName != "") {
    yxMonths[0] = janName;
  }
  if (febName != "") {
    yxMonths[1] = febName;
  }
  if (marName != "") {
    yxMonths[2] = marName;
  }
  if (aprName != "") {
    yxMonths[3] = aprName;
  }
  if (mayName != "") {
    yxMonths[4] = mayName;
  }
  if (junName != "") {
    yxMonths[5] = junName;
  }
  if (julName != "") {
    yxMonths[6] = julName;
  }
  if (augName != "") {
    yxMonths[7] = augName;
  }
  if (sepName != "") {
    yxMonths[8] = sepName;
  }
  if (octName != "") {
    yxMonths[9] = octName;
  }
  if (novName != "") {
    yxMonths[10] = novName;
  }
  if (decName != "") {
    yxMonths[11] = decName;
  }
}

function setDayNames(sunName, monName, tueName, wedName, thuName, friName, satName) {
  if (sunName != "") {
    yxDays[0] = sunName;
    yxDays[7] = sunName;
  }
  if (monName != "") {
    yxDays[1] = monName;
  }
  if (tueName != "") {
    yxDays[2] = tueName;
  }
  if (wedName != "") {
    yxDays[3] = wedName;
  }
  if (thuName != "") {
    yxDays[4] = thuName;
  }
  if (friName != "") {
    yxDays[5] = friName;
  }
  if (satName != "") {
    yxDays[6] = satName;
  }
}

function setLinkNames(closeLink, clearLink) {
  if (closeLink != "") {
    yxLinks[0] = closeLink;
  }
  if (clearLink != "") {
    yxLinks[1] = clearLink;
  }
}

function addCalendar(name, title, field, form) {
  cals[cals.length] = new calOBJ(name, title, field, form);
}

function findCalendar(name) {
  for (var i = 0; i < cals.length; i++) {
    if (cals[i].name == name) {
      if (cals[i].form == null) {
        if (cals[i].formName == "") {
          if (document.forms[0]) {
            cals[i].form = document.forms[0];
          }
        }
        else if (document.forms[cals[i].formName]) {
          cals[i].form = document.forms[cals[i].formName];
        }
      }

      return cals[i];
    }
  }

  return null;
}

function getDayName(y,m,d) {
  var wd=new Date(y,m,d);
  return yxDays[wd.getDay()].substring(0,3);
}

function getMonthFromName(m3) {
  for (var i = 0; i < yxMonths.length; i++) {
    if (yxMonths[i].toLowerCase().substring(0,3) == m3.toLowerCase()) {
      return i;
    }
  }

  return 0;
}

function getFormat() {
  var calF = calFormat;

  calF = calF.replace(/\\/g, '\\\\');
  calF = calF.replace(/\//g, '\\\/');
  calF = calF.replace(/\[/g, '\\\[');
  calF = calF.replace(/\]/g, '\\\]');
  calF = calF.replace(/\(/g, '\\\(');
  calF = calF.replace(/\)/g, '\\\)');
  calF = calF.replace(/\{/g, '\\\{');
  calF = calF.replace(/\}/g, '\\\}');
  calF = calF.replace(/\</g, '\\\<');
  calF = calF.replace(/\>/g, '\\\>');
  calF = calF.replace(/\|/g, '\\\|');
  calF = calF.replace(/\*/g, '\\\*');
  calF = calF.replace(/\?/g, '\\\?');
  calF = calF.replace(/\+/g, '\\\+');
  calF = calF.replace(/\^/g, '\\\^');
  calF = calF.replace(/\$/g, '\\\$');

  calF = calF.replace(/dd/i, '\\d\\d');
  calF = calF.replace(/mm/i, '\\d\\d');
  calF = calF.replace(/yyyy/i, '\\d\\d\\d\\d');
  calF = calF.replace(/day/i, '\\w\\w\\w');
  calF = calF.replace(/mon/i, '\\w\\w\\w');

  return new RegExp(calF);
}

function getDateNumbers(date) {
  var y, m, d;

  var yIdx = calFormat.search(/yyyy/i);
  var mIdx = calFormat.search(/mm/i);
  var m3Idx = calFormat.search(/mon/i);
  var dIdx = calFormat.search(/dd/i);

  y=date.substring(yIdx,yIdx+4)-0;
  if (mIdx != -1) {
    m=date.substring(mIdx,mIdx+2)-1;
  }
  else {
    var m = getMonthFromName(date.substring(m3Idx,m3Idx+3));
  }
  d=date.substring(dIdx,dIdx+2)-0;

  return new Array(y,m,d);
}

function hideCal() {
  calWin.close();
  calWin = null;
  window.status = "";
}

function getLeftIE(x,m) {
  var dx=0;
  if (x.tagName=="TD"){
    dx=x.offsetLeft;
  }
  else if (x.tagName=="TABLE") {
    dx=x.offsetLeft;
    if (m) { dx+=(x.cellPadding!=""?parseInt(x.cellPadding):2); m=false; }
  }
  return dx+(x.parentElement.tagName=="BODY"?0:getLeftIE(x.parentElement,m));
}
function getTopIE(x,m) {
  var dy=0;
  if (x.tagName=="TR"){
    dy=x.offsetTop;
  }
  else if (x.tagName=="TABLE") {
    dy=x.offsetTop;
    if (m) { dy+=(x.cellPadding!=""?parseInt(x.cellPadding):2); m=false; }
  }
  return dy+(x.parentElement.tagName=="BODY"?0:getTopIE(x.parentElement,m));
}

function getLeftN4(l) { return l.pageX; }
function getTopN4(l) { return l.pageY; }

function getLeftN6(l) { return l.offsetLeft; }
function getTopN6(l) { return l.offsetTop; }

function lastDay(d) {
  var yy=d.getFullYear(), mm=d.getMonth();
  for (var i=31; i>=28; i--) {
    var nd=new Date(yy,mm,i);
    if (mm == nd.getMonth()) {
      return i;
    }
  }
}

function firstDay(d) {
  var yy=d.getFullYear(), mm=d.getMonth();
  var fd=new Date(yy,mm,1);
  return fd.getDay();
}

function dayDisplay(i) {
  if (dayDigits == 0) {
    return yxDays[i];
  }
  else {
    return yxDays[i].substring(0,dayDigits);
  }
}

function calTitle(d) {
  var yy=d.getFullYear(), mm=yxMonths[d.getMonth()];
  var s;

  if (titleMode == 2) {
    s="<tr align='center' bgcolor='"+titleColor+"'><td colspan='7'>\n<table cellpadding='0' cellspacing='0' border='0'><tr align='center' valign='middle'><td align='right'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if(window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(-10)'>&nbsp;&#171;</a>&nbsp;"+a1("titlea")+"'javascript:if(window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(-1)'>&#139;&nbsp;</a></b>"+span2+"</td><td width='"+titleWidth+"'><b>"+span1("title")+yy+span2+"</b></td><td align='left'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(1)'>&nbsp;&#155;</a>&nbsp;"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(10)'>&#187;&nbsp;</a></b>"+span2+"</td></tr><tr align='center' valign='middle'><td align='right'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.prepMonth) window.opener.prepMonth("+d.getMonth()+")'>&nbsp;&#139;&nbsp;</a></b>"+span2+"</td><td width='"+titleWidth+"'><b>"+span1("title")+mm+span2+"</b></td><td align='left'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.nextMonth) window.opener.nextMonth("+d.getMonth()+")'>&nbsp;&#155;&nbsp;</a></b>"+span2+"</td></tr></table>\n</td></tr><tr align='center' bgcolor='"+daysColor+"'>";
  }
  else {
    s="<tr align='center' bgcolor='"+titleColor+"'><td colspan='7'>\n<table cellpadding='0' cellspacing='0' border='0'><tr align='center' valign='middle'><td>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if(window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(-1)'>&nbsp;&#171;</a>&nbsp;"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.prepMonth) window.opener.prepMonth("+d.getMonth()+")'>&#139;&nbsp;</a></b>"+span2+"</td><td width='"+titleWidth+"'><nobr><b>"+span1("title")+mm+" "+yy+span2+"</b></nobr></td><td>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.nextMonth) window.opener.nextMonth("+d.getMonth()+")'>&nbsp;&#155;</a>&nbsp;"+a1("titlea")+"'javascript:if(window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(1)'>&#187;&nbsp;</a></b>"+span2+"</td></tr></table>\n</td></tr><tr align='center' bgcolor='"+daysColor+"'>";
  }

  for (var i=weekDay; i<weekDay+7; i++) {
    s+="<td width='"+dayWidth+"'>"+span1("days")+dayDisplay(i)+span2+"</td>";
  }

  s+="</tr>";

  return s;
}
//"+currentCal.title+"
function calHeader() {
  return "<head>\n<title></title>\n<style type='text/css'>\n"+spanx("title",titleFontColor)+spanx("days",daysFontColor)+spanx("foot",footColor)+spanx("day",dayFontColor)+spanx("currentDay",currentDayFontColor)+ax("titlea",titleFontColor)+ax("daya",dayFontColor)+ax("currenta",currentDayFontColor)+ax("foota",footFontColor)+"</style>\n</head>\n<body>\n<table align='center' border='0' bgcolor='"+borderColor+"' cellspacing='0' cellpadding='1'><tr><td>\n<table cellspacing='1' cellpadding='3' border='0'>";
}

function calFooter() {
  return "<tr bgcolor='"+footColor+"'><td colspan='7' align='center'>"+span1("foot")+"<b>"+a1("foota")+"'javascript:if (window.opener && !window.opener.closed && window.opener.hideCal) window.opener.hideCal()'>"+yxLinks[0]+"</a>&nbsp;&nbsp;"+a1("foota")+"'javascript:if (window.opener && !window.opener.closed && window.opener.clearDate) window.opener.clearDate()'>"+yxLinks[1]+"</a></b>"+span2+"</td></tr></table>\n</td></tr></table>\n</body>";
}

function calBody(d,day) {
  var s="", dayCount=1, fd=firstDay(d), ld=lastDay(d);

  if (weekDay > 0 && fd == 0) {
    fd = 7;
  }

  for (var i=0; i<6; i++) {
    s+="<tr align='center' bgcolor='"+bodyColor+"'>";
    for (var j=weekDay; j<weekDay+7; j++) {
      if (i*7+j<fd || dayCount>ld) {
        s+="<td>"+span1("day")+"&nbsp;"+span2+"</td>";
      }
      else {
        var bgColor=dayColor;
        var fgTag="day";
        var fgTagA="daya";
        if (dayCount==day) { 
          bgColor=currentDayColor; 
          fgTag="currentDay";
          fgTagA="currenta";
        }
       																																																				
        s+="<td bgcolor=\'"+bgColor+"\' style=\"cursor:default;\" onMouseOver=\"this.bgColor=\'#DDE3EB\'\" onMouseOut=\"this.bgColor=\'"+bgColor+"\'\" >"+span1(fgTag)+a1(fgTagA)+"'javascript: if (window.opener && !window.opener.closed && window.opener.pickDate) window.opener.pickDate("+dayCount+")'>"+(dayCount++)+"</a>"+span2+"</td>";
      }
    }
    s+="</tr>";
  }

  return s;
}

function moveYear(dy) {
  cY+=dy;
  var nd=new Date(cY,cM,1);
  changeCal(nd);
}

function prepMonth(m) {
  cM=m-1;
  if (cM<0) { cM=11; cY--; }
  var nd=new Date(cY,cM,1);
  changeCal(nd);
}

function nextMonth(m) {
  cM=m+1;
  if (cM>11) { cM=0; cY++;}
  var nd=new Date(cY,cM,1);
  changeCal(nd);
}

function changeCal(d) {
  var dd = 0;

  if (currentCal != null) {
    var calRE = getFormat();

    if (currentCal.form[currentCal.field].value!="" && calRE.test(currentCal.form[currentCal.field].value)) {
      var cd = getDateNumbers(currentCal.form[currentCal.field].value);
      if (cd[0] == d.getFullYear() && cd[1] == d.getMonth()) {
        dd=cd[2];
      }
    }
    else {
      var cd = new Date();
      if (cd.getFullYear() == d.getFullYear() && cd.getMonth() == d.getMonth()) {
        dd=cd.getDate();
      }
    }
  }

  var calendar=calHeader()+calTitle(d)+calBody(d,dd)+calFooter();

  calWin.document.open();
  calWin.document.write(calendar);
  calWin.document.close();
}

function markClick(e) {
  if (isIE || isOpera6) {
    winX=event.screenX;
    winY=event.screenY;
  }
  else if (isN4 || isN6) {
    winX=e.screenX;
    winY=e.screenY;

    document.routeEvent(e);
  }

  if (isN4 || isN6) { 
    document.routeEvent(e); 
  } 
  else { 
    event.cancelBubble=false; 
  } 

  return true;
}

function showCal(name) {
  var lastCal=currentCal;
  var d=new Date(), hasCal=false;

  currentCal = findCalendar(name);

  if (currentCal != null && currentCal.form != null && currentCal.form[currentCal.field]) {
    var calRE = getFormat();

    if (currentCal.form[currentCal.field].value!="" && calRE.test(currentCal.form[currentCal.field].value)) {
      var cd = getDateNumbers(currentCal.form[currentCal.field].value);
      d=new Date(cd[0],cd[1],cd[2]);

      cY=cd[0];
      cM=cd[1];
      dd=cd[2];
    }
    else {
      cY=d.getFullYear();
      cM=d.getMonth();
      dd=d.getDate();
    }

    var calendar=calHeader()+calTitle(d)+calBody(d,dd)+calFooter();

    if (calWin != null && !calWin.closed) {
      hasCal=true;
      calWin.moveTo(winX+calOffsetX,winY+calOffsetY);
    }

    if (!hasCal) {
      if (isIE || isOpera6) {
        calWin=window.open("","cal","toolbar=0,width="+calWidth+",height="+calHeight+",left="+(winX+calOffsetX)+",top="+(winY+calOffsetY));
      }
      else {
        calWin=window.open("","cal","toolbar=0,width="+calWidth+",height="+calHeight+",screenx="+(winX+calOffsetX)+",screeny="+(winY+calOffsetY));
      }
    }

    calWin.document.open();
    calWin.document.write(calendar);
    calWin.document.close();

    calWin.focus();
  }
  else {
    if (currentCal == null) {
      window.status = "Calendar ["+name+"] not found.";
    }
    else if (!currentCal.form) {
      window.status = "Form ["+currentCal.formName+"] not found.";
    }
    else if (!currentCal.form[currentCal.field]) {
      window.status = "Form Field ["+currentCal.formName+"."+currentCal.field+"] not found.";
    }

    if (lastCal != null) {
      currentCal = lastCal;
    }
  }
}

function get2Digits(n) {
  return ((n<10)?"0":"")+n;
}

function clearDate() {
  currentCal.form[currentCal.field].value="";
  hideCal();
}

function pickDate(d) {
  hideCal();
  window.focus();

  var date=calFormat;
  date = date.replace(/yyyy/i, cY);
  date = date.replace(/mm/i, get2Digits(cM+1));
  date = date.replace(/MON/, yxMonths[cM].substring(0,3).toUpperCase());
  date = date.replace(/Mon/i, yxMonths[cM].substring(0,3));
  date = date.replace(/dd/i, get2Digits(d));
  date = date.replace(/DAY/, getDayName(cY,cM,d).toUpperCase());
  date = date.replace(/day/i, getDayName(cY,cM,d));

  currentCal.form[currentCal.field].value=date;
  // IE5/Mac needs focus to show the value, weird.
  currentCal.form[currentCal.field].focus();
}
// ------

// user functions
function checkDate(name) {
  var thisCal = findCalendar(name);

  if (thisCal != null && thisCal.form != null && thisCal.form[thisCal.field]) {
    var calRE = getFormat();

    if (calRE.test(thisCal.form[thisCal.field].value)) {
      return 0;
    }
    else {
      return 1;
    }
  }
  else {
    return 2;
  }
}

function getCurrentDate() {
  var date=calFormat, d = new Date();
  date = date.replace(/yyyy/i, d.getFullYear());
  date = date.replace(/mm/i, get2Digits(d.getMonth()+1));
  date = date.replace(/dd/i, get2Digits(d.getDate()));

  return date;
}

function compareDates(date1, date2) {
  var calRE = getFormat();
  var d1, d2;

  if (calRE.test(date1)) {
    d1 = getNumbers(date1);
  }
  else {
    d1 = getNumbers(getCurrentDate());
  }

  if (calRE.test(date2)) {
    d2 = getNumbers(date2);
  }
  else {
    d2 = getNumbers(getCurrentDate());
  }

  var dStr1 = d1[0] + "" + d1[1] + "" + d1[2];
  var dStr2 = d2[0] + "" + d2[1] + "" + d2[2];

  if (dStr1 == dStr2) {
    return 0;
  }
  else if (dStr1 > dStr2) {
    return 1;
  }
  else {
    return -1;
  }
}

function getNumbers(date) {
  var calRE = getFormat();
  var y, m, d;

  if (calRE.test(date)) {
    var yIdx = calFormat.search(/yyyy/i);
    var mIdx = calFormat.search(/mm/i);
    var m3Idx = calFormat.search(/mon/i);
    var dIdx = calFormat.search(/dd/i);

    y=date.substring(yIdx,yIdx+4);
    if (mIdx != -1) {
      m=date.substring(mIdx,mIdx+2);
    }
    else {
      var mm=getMonthFromName(date.substring(m3Idx,m3Idx+3))+1;
      m=(mm<10)?("0"+mm):(""+mm);
    }
    d=date.substring(dIdx,dIdx+2);

    return new Array(y,m,d);
  }
  else {
    return new Array("", "", "");
  }
}
// ------

if (isN4 || isN6) {
  document.captureEvents(Event.CLICK);
}
document.onclick=markClick;



//Define calendar(s): addCalendar ("Unique Calendar Name", "Window title", "Form element's id", Form name")
addCalendar("Calendar1", "Select Date", "inizio", "form1");
addCalendar("Calendar2", "Select Date", "fine", "form1");
addCalendar("Calendar3", "Select Date", "ini", "form1");
addCalendar("Calendar4", "Select Date", "fin", "form1");
addCalendar("Calendar5", "Select Date", "dtanasc", "form1");
addCalendar("Calendar6", "Select Date", "dtasoggini", "form1");
addCalendar("Calendar7", "Select Date", "dtasoggfin", "form1");
addCalendar("Calendar8", "Select Date", "datareg", "doc1");
addCalendar("Calendar9", "Select Date", "perini", "doc1");
addCalendar("Calendar10", "Select Date", "perfin", "doc1");

//20061223 Da oggi usare sempre le seguenti chiamate per gli n calendari presenti nella pagina
//Definisce calendari: addCalendar ("Nome unico", "Window title", "Id dell'elemento", "Nome Form")
addCalendar("CalendarA", "Select Date", "dataA", "doc1");
addCalendar("CalendarB", "Select Date", "dataB", "doc1");
addCalendar("CalendarC", "Select Date", "dataC", "doc1");
//20080118 Aggiunti
addCalendar("CalendarD", "Select Date", "dataD", "doc1");
addCalendar("CalendarE", "Select Date", "dataE", "doc1");
addCalendar("CalendarF", "Select Date", "dataF", "doc1");
addCalendar("CalendarG", "Select Date", "dataG", "doc1");
addCalendar("CalendarH", "Select Date", "dataH", "doc1");
//20080913 Aggiunti
addCalendar("CalendarI", "Select Date", "dataI", "doc1");
addCalendar("CalendarJ", "Select Date", "dataJ", "doc1");
addCalendar("CalendarK", "Select Date", "dataK", "doc1");
addCalendar("CalendarT", "Select Date", "dataT", "doc1");
addCalendar("CalendarU", "Select Date", "dataU", "doc1");
addCalendar("CalendarV", "Select Date", "dataV", "doc1");
addCalendar("CalendarZ", "Select Date", "dataZ", "doc1");

addCalendar("CalendarL", "Select Date", "dataL", "form1");
addCalendar("CalendarM", "Select Date", "dataM", "form1");
addCalendar("CalendarN", "Select Date", "dataN", "form1");
//20080118 Aggiunti
addCalendar("CalendarO", "Select Date", "dataO", "form1");
addCalendar("CalendarP", "Select Date", "dataP", "form1");
addCalendar("CalendarQ", "Select Date", "dataQ", "form1");
addCalendar("CalendarR", "Select Date", "dataR", "form1");
addCalendar("CalendarS", "Select Date", "dataS", "form1");

// default settings for English
// Uncomment desired lines and modify its values
// setFont("verdana", 9);
 setWidth(90, 1, 15, 1);
// setColor("#cccccc", "#cccccc", "#ffffff", "#ffffff", "#333333", "#cccccc", "#333333");
// setFontColor("#333333", "#333333", "#333333", "#ffffff", "#333333");
// setFormat("yyyy/mm/dd");
// setSize(200, 200, -200, 16);

// setWeekDay(0);
// setMonthNames("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
// setDayNames("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
// setLinkNames("[Close]", "[Clear]");

// ************** calendario in js

