// <!-- 
var obbligatori="";

// ------------------- GESTIONE LIVELLI MULTIBROWSER
// var isNetscape=(navigator.appName=="Netscape");
var isNetscape=(navigator.appName.indexOf("Netscape") >= 0 && parseFloat(navigator.appVersion) >= 4) ? 1 : 0;

var layerRef="";
var styleRef="";

if (isNetscape){
  layerRef=".layers";
  styleRef="";
}
else {
  layerRef=".all";
  styleRef=".style";
}

var LenCampi="22";
var TagFont="";
if (isNetscape){
  // TagFont="<font face=verdana size=1 color=navy>";
  LenCampi="15";
  }

function livello(id,stato,testo){
  if (isNetscape) stato=(stato=="hidden") ? "hide" : (stato=="visible") ? "show" : stato;
  if (!stato){
     var v=eval("document"+layerRef+"[\'"+id+"\']"+styleRef+".visibility");
     stato=(v=="hidden" || !v)?"visible":"hidden";
   } 
  eval("document"+layerRef+"[\'"+id+"\']"+styleRef+".visibility=\'"+stato+"\'");
  if (testo!=null){
    if (isNetscape) {
     eval("document."+id+".document.write(testo)");
     eval("document."+id+".document.close()");
     }
    else {
     eval(id+".innerHTML=testo");
     }
   }
}


function show_info(){
  if (isNetscape){
    var v=document.info.innerHTML;
  }
  else {
    var v=info.innerHTML;
  }
  if (v.indexOf('livello')==-1){
    v='<table bgcolor=gainsboro><tr><td align=center><b>Maggiori informazioni</b><br><table bgcolor=lightyellow cellpadding=10><tr><td>'+v+'</td></tr>';
    v+='<tr><td align=center><a href="#" onclick="livello(\'info\',\'hidden\');return false;">Chiudi</a></td></tr>';
    v+='</table></td></tr></table>';
    }
  livello("info","visible",v);
}

// ------------------- GESTIONE LIVELLO CARRELLO

// var affiliato="";

// var fattura_imponibile=0;
// var fattura_iva=0;
// var fattura_totale=0;

// var arrCarrello;
// arrCarrello=new Array(Array("","","",""));
// arrCarrello=Array(Array("CODART","SERVIZIO","DATI","PREZZO"));

function AggiornaCarrello(azione,id,v1,v2,v3,v4){
  var c=parent.arrCarrello;
  var l=c.length;
  azione=azione.toUpperCase();
    
  if (azione=="AGGIUNGI") {       //aggiunge valore ad array
    var i=l;
    c[i++]=new Array(v1,v2,v3,v4);
  }
  
  if (!l){return false;}
  
  if (azione=="RIMUOVI") {        //cancella valore da array
    // if (confirm("Vuoi veramente rimuovere la richiesta selezionata ?")){ 
       if (id){
         c[id]=Array("","","","");
       }
       else {
         for (var i=0;i<l;i++){ 
           if (c[i][0]==v1) {c[i]=Array("","","","");}
         }
       } 
    // }
  }

  if (azione=="VUOTA"){           //aggiorna valore in array
    if (confirm('Vuoi veramente svuotare il carrello ?')){
     parent.arrCarrello=new Array(Array("","","",""));
     self.location="index.asp?f=2&btn=2&lay="+parent.layout;
     }
  }
  
  if (azione=="AGGIORNA"){        //aggiorna valore in array
    // for (var i=0;i<m.length;i++){   
    // if (c[i][0]==vMenuOld){c[i][0]=vMenu}
    // }
    if (v1){c[id][0]=v1}
    if (v2){c[id][1]=v2}
    if (v3){c[id][2]=v3}
    if (v4){c[id][3]=v4}
  }
  
  return true;
  
}


function Carrello(){
  var d=document;
  var c=parent.arrCarrello;
  var l=c.length;
  var r="";
  var sw=false;
  var imp=0;
  
  parent.fattura_imponibile=0;
  parent.fattura_iva=0;
  parent.fattura_totale=0;

  if (l){
    r+='<form name=\"F_CARRELLO\" method=\"post\" action=\"index.asp\">';
    r+='<input type=\"hidden\" name=\"aff\" value=\"'+parent.affiliato+'\">';
    r+='<input type=\"hidden\" name=\"f\" value=\"2\">';
    r+='<input type=\"hidden\" name=\"btn\" value=\"8\">';
    r+='<table width=85% border=0 cellpadding=3 cellspacing=0 class=\"testaform\">';
    r+='<tr>';
    r+='<th>&nbsp;</th><th width=40>Articolo</th><th width=300>Servizio Richiesto</th><th width=40>Importo</th><th>Elimina</th>';
    r+='</th></tr>';
    for (var i=0;i<l;i++){
     if (c[i][0]!=""){
      r+='<tr class=\"bgTdCarrello\">';
      r+='<td align=center><a href=\"#\" onclick=\"mostraric('+i+');return false;\">Dettaglio</a></td>';
      r+='<td align=center>'+c[i][0]+'</td><td>'+c[i][1]+'</td><td align=right>'+c[i][3]+'</td>';
      r+='<td align=center><input type=checkbox name=sel value=\"'+i+'\"></td>';
      r+='</tr>';
      sw=true;
        }
     imp+=c[i][3]*1
       }

    parent.fattura_imponibile=ImportoEuro(imp*1);
    parent.fattura_iva=ImportoEuro(imp*20/100);
    parent.fattura_totale=ImportoEuro(parseFloat(parent.fattura_imponibile)+parseFloat(parent.fattura_iva));

    r+='<tr><td colspan=6>';
    
    r+='<table border=0 align=center width=100% cellspacing=0>';
    r+='<tr bgcolor=\"white\"><td align=center width=33%>Imponibile</td><td align=center width=33%>Iva</td><td align=center width=34%><b>Totale da saldare</b></td></tr>';
    r+='<tr bgcolor=\"white\"><td align=center>'+parent.fattura_imponibile+'</td><td align=center>'+parent.fattura_iva+'</td><td align=center><b>'+parent.fattura_totale+'</b></td></tr>';
    r+='</table>';
    
    r+='</td></tr>';
    r+='</table>';
    
    r+='<p align=center>';
    r+='<input type=button name=btnAltraRic value=\"&lt;&lt; Altra richiesta\" onclick=\"self.location=\'index.asp?f=2&btn=1&lay='+parent.layout+'\';\" class=\"pulsanti\">&nbsp;';
    r+='<input type=button name=btnVuota value=Vuota onclick=\"AggiornaCarrello(\'VUOTA\')\" class=\"pulsanti\">&nbsp;';
    r+='<input type=button name=btnAggiorna value=Aggiorna class=\"pulsanti\" onclick=\"EliminaSelCarrello();\">';
    r+='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
    r+='<input type=submit name=btnContinua value=\"Continua &gt;&gt;\" class=\"pulsanti\">';
    r+='<input type=hidden name=lay value=\"'+parent.layout+'\">';
    r+='</p></form>';    
    }
    
  if (!sw) {
    r='Il carrello non contiene richieste..';
    r+='<form><br><br><br><p align=center>';
    r+='<input type=button name=btnAltraRic value=\"&lt;&lt; Nuova richiesta\" onclick=\"self.location=\'index.asp?f=2&btn=1&lay='+parent.layout+'\';\" class=\"pulsanti\">&nbsp;';
    r+='</p></form>';    
   }
  
  r='<table border=0 width=625><tr><td align=center><p  class=\"corpo14\">CARRELLO DELLE RICHIESTE</p>'+r+'</td></tr></table>';

  //livello('tabella4','visible',r);
  document.write(r);

}


 
 function EliminaSelCarrello(){
  if (confirm('Vuoi veramente eliminare le richieste selezionate ?')){
  var f=document.F_CARRELLO;
  var campi=f.elements;
  var i=0;
  var nome="";
  var valore="";
    
  for (i=0;i<campi.length;i++) {
    nome=campi[i].name;
    valore=campi[i].value;
    if (nome=='sel'){
       if (campi[i].checked){
         AggiornaCarrello('RIMUOVI',valore)
         }
      } 
     }
     self.location="index.asp?f=2&btn=2&lay="+parent.layout;
   }  
 }
 
 
 function mostraric(id){
    var c=parent.arrCarrello;
    var t="";
    d=window.open('','dettaglio','scrollbars=no,menubar=no,toolbar=no,height=300,width=400,left=10,top=10').document;
    
    t+='<html><head><link href="'+parent.stile+'" rel="stylesheet" type="TEXT/CSS">\n';
    t+='<title>DETTAGLIO RICHIESTA</title></head><body class=\'bgLight\' onblur=\"self.close();\">\n';
    t+='<table border=0 width=100% height=100% cellpadding=2 cellspacing=1 align=center class=\"testaform\">\n';
    t+='<tr><th height=10 colspan=2>DETTAGLIO RICHIESTA</th></tr>\n';
    t+='<td bgcolor="white" align="center" valign="top">\n';
    t+='<table border="0" width="95%" height="95%" cellspacing=1 cellpadding=3 class="corpo11" align=center>\n';
    t+='<tr><td height=10 width=20%><b>CODART:</b></td><td>'+c[id][0].toUpperCase()+'</td></tr>\n';
    t+='<tr><td height=10 width=20%><b>SERVIZIO:</b></td><td>'+c[id][1].toUpperCase()+'</td></tr>\n';
    t+='<tr><td height=10 width=20%><b>IMPORTO:</b></td><td>'+c[id][3].toUpperCase()+'</td></tr>\n';
    t+='<tr><td height=100 width=20% valign=top><b>DATI:</b></td>\n';
    t+='<td valign=top><pre class="corpo11">'+c[id][2].toUpperCase()+'</pre></td></tr>\n';
    t+='<tr><td height=10 colspan=2 align=center valign=bottom bgcolor=white><p><a href="#" onclick="self.close();return false;"><b><u>Chiudi</u></b></a></p></td></tr>\n';
    t+='</table>\n';
    t+='</td></tr></table>\n';
    t+='</body></html>\n';
    d.writeln(t);
  }
  
  

 

// ------------------- GESTIONE LIVELLO DI CONFERMA ORDINE
  
 function InitCampiConfermaOrdine(){
  var oggi=new Date();
  var c=parent.arrCarrello;
  var l=c.length;
  var r="";
  var sw=false; 
  var f=document.F_MODPAG;
  
  carica(f);
  
  if (l){
    for (var i=0;i<l;i++){
     if (c[i][0]!=""){
      sw=true;
      r+="\n------------------- PRODOTTO \n";
      r+="SERVIZIO: "+c[i][1]+"\n";
      r+="CODART: "+c[i][0]+"\n";
      r+="IMPORTO: "+c[i][3]+"\n";
      r+="DATI:\n  "+replace(c[i][2],'\n','\n  ')+"\n";
        }
       }
    }
   
   f.dati_ordine.value=r;

   // f.num_ordine.value='';
   // f.data_ordine.value=oggi.getDate()+"/"+(oggi.getMonth()+1)+"/"+oggi.getYear()+" "+oggi.getHours()+":"+oggi.getMinutes()+":"+oggi.getSeconds();
   f.oggetto.value='RICHIESTA SERVIZIO VISURE E CERTIFICATI';
   f.aff.value=parent.affiliato;
   f.httpref.value=parent.ref;
   f.fattura_imponibile.value=parent.fattura_imponibile;
   f.fattura_iva.value=parent.fattura_iva;
   f.fattura_totale.value=parent.fattura_totale;
 }
 
 
 function LivelloRiepilogoImporti(){
    r='<table width=150 border=0 cellspacing=0 cellpadding=2 align=center>\n';
    r+='<tr><td>Imponibile</td><td align=right>'+parent.fattura_imponibile+'</td></tr>\n';
    r+='<tr><td>Iva 20%</td><td align=right>'+parent.fattura_iva+'</td></tr>\n';
    r+='<tr><td colspan=2><hr size=1></td></tr>\n';
    r+='<tr><td valign=top><b>Totale</b></td><td align=right><b>'+parent.fattura_totale+'</b><br></td></tr>\n';
    r+='<tr><td valign=bottom colspan=2 align=center>\n';
    r+='<br><a href="#" onclick=\"return VediOrdine();\">Vedi Ordine</a>';
    r+='</td></tr></table>\n';

    livello('tabella6','visible',r);
 }
 
 
function ordine()
{
var theForm=document.F_MODPAG;
var i=0;
var linea="================================================================\n";
var linea2="----------------------------- ";
var temp="";
var campi=theForm.elements;
var num_ordine=campi["num_ordine"].value;
var oggetto=campi["oggetto"].value+" (";
oggetto=oggetto.split(' (')[0];

var ordine="Ordine n. "+num_ordine+" del "+campi["data_ordine"].value+"\n";
ordine+=linea;
// ordine+=" "+campi["oggetto"].value.toUpperCase()+" ("+campi["aff"].value.toUpperCase()+")\n";
ordine+=" "+oggetto.toUpperCase()+" ("+campi["aff"].value.toUpperCase()+")\n";
ordine+=linea;

ordine+="\n"+linea2+"Servizi/Prodotti richiesti\n";
ordine+=campi["dati_ordine"].value+"\n";

ordine+="fattura imponibile: E. "+campi["fattura_imponibile"].value+"\n";
ordine+="fattura iva: E. "+campi["fattura_iva"].value+"\n";
ordine+="fattura totale: E. "+campi["fattura_totale"].value+"\n";

ordine+="\n"+linea2+"Dati Ordinante\n";
ordine+="nominativo: "+campi["nominativo"].value.toUpperCase()+"\n";
ordine+="indirizzo: "+campi["indirizzo"].value.toUpperCase()+"\n";
ordine+="cap: "+campi["cap"].value+"\n";
ordine+="localita: "+campi["localita"].value.toUpperCase()+"\n";
ordine+="provincia:"+campi["provincia"].value.toUpperCase()+"\n";
ordine+="partita iva: "+campi["partita_iva"].value.toUpperCase()+"\n";
ordine+="contatto: "+campi["contatto"].value.toUpperCase()+"\n";
ordine+="telefono: "+campi["telefono"].value.toUpperCase()+"\n";
ordine+="telefax: "+campi["telefax"].value.toUpperCase()+"\n";
ordine+="email: "+campi["email"].value.toUpperCase()+"\n";
// ordine+="altre informazioni: "+campi["altre_informazioni"].value+"\n";


ordine+="\n"+linea2+"Mezzo di spedizione\n";
ordine+="spedizione: "+campi["spedizione"][campi["spedizione"].selectedIndex].value+"\n";
// if (campi["spedizione"].value=="email") ordine+="email risposta: "+campi["email"].value+"\n";
// else ordine+="fax risposta: "+campi["fax"].value+"\n";

ordine+="\n"+linea2+"Metodo di Pagamento\n";
ordine+="pagamento: "+campi["pagamento"][campi["pagamento"].selectedIndex].value+"\n";

ordine+="\n"+linea2+"Estremi ordine\n";
ordine+="numero ordine: "+campi["num_ordine"].value+"\n";
ordine+="data ordine: "+campi["data_ordine"].value+"\n\n";
ordine+="tassazione: "+campi["tassazione"].value+"\n\n";
// ordine+="condizioni di vendita e privacy: accettate\n\n";
ordine+=(campi["privacy"].checked)?"condizioni di vendita e privacy: accettate\n\n":"\n";
ordine+=(parent.affiliato)?"codice affiliato: "+campi["aff"].value.toUpperCase()+"\n":"\n";
ordine+=linea;

return ordine;
}


function VediOrdine() {
  var win1=window.open("ordine_fax.htm","OrdineFax","toolbar=yes,directories=no,scrollbars=yes,resizable=yes,width="+(screen.width-100)+",top=10,left=10");
  // var win1=window.open("","OrdineFax","toolbar=yes,directories=no,scrollbars=yes,resizable=yes,width="+(screen.width-100)+",top=10,left=10");
  // win1.document.write ("<pre>"+ordine()+"</pre>")
  return false; 
}




// ------------------- ROUTINES VARIE

function uscita (){
  if (fattura_imponibile>0){
    alert("Con questa operazione vengono abbandonate tutte le richieste inserite !");
    // if (confirm("Ci sono delle richieste nel carrello..\n\nVuoi uscire senza completare l'ordine ?")){
    //   return true;
    //}
    //else {
    //  return false;
    //}
  }
}

function  finestra(strUrl,larghezza,altezza,barre){
      if (!larghezza){ larghezza=600;altezza=350; barre=1;}
      if(screen.width<larghezza){larghezza=screen.width}winNuova=window.open(strUrl,"finestra","toolbar=yes,directories=no,menubar=yes,scrollbars="+barre+",width="+larghezza+",height="+altezza+",left=10,top=10");
      winNuova.focus();
      return false;
  }


function Add2Select (fldSelect,optName,optValue) {
  var t=fldSelect.options.length;     
  var lastoption = new Option();
  fldSelect.options[t]=lastoption;
  fldSelect.options[t].text=optName;
  if (optValue!=""){fldSelect.options[t].value=optValue;}
}



function ImportoEuro (n) {
  var i='';
  var d='';
  var s='';
  n=n+'';
  var p=n.indexOf('.');
  if (p>0){i=n.substr(0,p);d=n.substr(p+1,2);d=d+'00';d=d.substr(0,2)}
  else    {i=n;d='00'}
  s=i+'.'+d;
  return s;
};


function go_url(sUrl) {
   sUrl+=(sUrl.indexOf('?')>-1)?'&':'?';
   self.location=sUrl+'lay='+parent.layout+'&aff='+parent.affiliato;
}

// --------------------- CONVALIDA VALORI FORM ------------------------
function convalida(theForm2,obbligatori)
{
var i=0;
var campi=theForm2.elements;
var errati="";

// var prov=theForm2._Provincia;
// if (prov[prov.selectedIndex].value=='GO'){
//  alert('ATTENZIONE !!\n\nPer questa provincia il servizio non č disponibile..');
//  return false;
//}

for (i=0;i<campi.length;i++) {
   var nome=campi[i].name;
   var tipo=campi[i].type;
   var valore=campi[i].value;
   
   if (tipo=="checkbox"){valore=(campi[i].checked)?valore:"";}
   
   if (obbligatori.toLowerCase().indexOf(nome.toLowerCase())!= -1 
       && valore==""){
       if (nome.substr(0,1)=="_") nome=nome.substr(1)
       errati+=nome+"\n";
   }
}
  if (errati != "")
  {
    alert("Inserire un valore per i seguenti campi:\n\n"+errati);
    return (false);
  }
  
    
  return (true);
}
 
 
 function ValidaImmissioneRichieste(theForm2,obbligatori){
  var campi=theForm2.elements;
  if (convalida(theForm2,obbligatori)){
    formattacampi (theForm2);
    if (AggiornaCarrello("AGGIUNGI","",campi["CODART"].value,campi["SERVIZIO"].value,campi["DATI_RICHIESTA"].value,campi["IMPORTO"].value)){
     // setTimeout('alert(\"Aggiunto al carrello !\")',200);
     return true;
     }
   }
   return false;
 }
 
 
 function ValidaOrdine(theForm)
 {
   if (convalida(theForm,"nominativo,indirizzo,cap,localita,provincia,telefono,email,privacy")) {
     salva(theForm); 
     var oggetto=theForm.oggetto.value+" (";
     oggetto=oggetto.split(' (')[0];

     theForm.testo_ordine.value=ordine();
//     theForm.oggetto.value=theForm.oggetto.value+" ("+theForm.aff.value+")";
     theForm.oggetto.value=oggetto+" ("+theForm.aff.value+")";
     var s=theForm.pagamento[theForm.pagamento.selectedIndex].value;
     if (s=="BONIFICO" || s=="C/C POSTALE" || s=="VAGLIA POSTALE" || s=="CONTRASSEGNO"){
       theForm.action="InviaOrdine.asp";
     }
     if (checkemail(theForm.email.value)) {
       return (true)
       }
     else {
       return (false)
       } 
   }
   else{
     return (false);
   }

 }
 

 
 function CheckPagamento(cSelect){
    var a=cSelect[cSelect.selectedIndex].text.toUpperCase();
    if (a=="CONTRASSEGNO"){
        var m="ATTENZIONE !!\n\n";
        m+="Con questa modalitā di pagamento la risposta verrā inviata\n";
        m+="tramite servizio postale con addebito delle spese di spedizione\n";
        m+="pari a E. 5,00";
        //document.F_MODPAG.Spedizione.value="Posta";
        alert(m);
    }
    else {
      if (a.indexOf("CARTA")==-1){
        var m="ATTENZIONE !!\n\n";
        m+="Con questa modalitā di pagamento la risposta verrā inviata\n";
        m+="solo dopo la trasmissione VIA EMAIL o VIA FAX al n. 0765-735079\n";
        m+="della ricevuta di pagamento del servizio richiesto";
        alert(m);
      }
    }
   }

function formattacampi (theForm) {
var i=0;
var campi=theForm.elements;
var ric="";

for (i=0;i<campi.length;i++) {
   var nome=campi[i].name.substr(1);
   var tipo=campi[i].type;
   var valore=campi[i].value;
   
   if (tipo.indexOf('select')>-1) {
    var n=campi[i].selectedIndex;
    var valore=campi[i][n].value;
    }
   
   if ((tipo=='text' || tipo=='textarea' || tipo.indexOf('select')>-1) && valore) {
       ric+=nome+": "+valore+"\n";
       campi[i].nome="";
    }
  }
 theForm.DATI_RICHIESTA.value=ric;
 
}


// --------------------- CONTROLLA VALIDITA EMAIL ------------------------
function checkemail(str){
  var testresults;
  var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
  if (filter.test(str))
    testresults=true
  else{
    alert("Inserire un indirizzo di email valido !")
    testresults=false
  }
  return (testresults)
}


// ------------------- SOSTITUZIONE CARATTERI
function replace (testo,vecchio,nuovo) {
  var d=testo.split(vecchio);
  var i;
  var t="";
  if (d.length>0){
    for (i=0;i<d.length;i++){
      if (t!=""){t+=nuovo}
      t+=d[i];
    }
   }
  else{
    t=testo;
   }
  return t;
}


// --------------------- ROUTINES DI GESTIONE COOKIE ------------------------
var CampiDaSalvare;

function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime (date.getTime() - skew);
}

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}


function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return "";
}


function SetCookie (name, value) {
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
if (expires!=null) FixCookieDate(expires); 
  document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
}


function DeleteCookie (name) {
  var exp = new Date();
  FixCookieDate (exp);
  exp.setTime (exp.getTime() - 1);  
  var cval = GetCookie (name);
  if (cval != null)
    document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}


// --------------------- CARICA VALORI COOKIE IN FORM ------------------------
function carica (theForm){
   var l;
   // var campi=document.forms[0].elements;

   var campi=theForm.elements;
   
    if (CampiDaSalvare != "" && CampiDaSalvare != null){
       var ArrayCampi=CampiDaSalvare.split(",");
       for (l=0;l<ArrayCampi.length;l++) 
         {
            campi[ArrayCampi[l]].value=GetCookie(ArrayCampi[l]);
    	  }
    }
    else {
      for (l=0;l<campi.length;l++) 
       {
          if (campi[l].type == "text") {
             campi[l].value=GetCookie(campi[l].name);
             }
       }
    }
    
    // document.forms[0].elements[5].value=CampiDaSalvare;

}



// --------------------- SALVA VALORI FORM IN COOKIE ------------------------
function salva (theForm){
   // 10 years from now the cookie will expire
   var l;
   var expdate = new Date ();
   var ArrayCampi;
   expdate.setTime (expdate.getTime() + (3600 * 24 * 60 * 60 * 1000));

   //var campi=document.forms[0].elements;
   var campi=theForm.elements;
   
   if (CampiDaSalvare != "" && CampiDaSalvare != null){
     var ArrayCampi=CampiDaSalvare.split(",");
     for (l=0;l<ArrayCampi.length;l++) 
       {
          SetCookie(ArrayCampi[l],campi[ArrayCampi[l]].value,expdate);    
    	}
    }
    else {
     for (l=0;l<campi.length;l++) 
       {
         if (campi[l].type == "text") {
           SetCookie(campi[l].name,campi[l].value,expdate);    
            }
       }
    }
}
 

// --------------------- STAMPA PAGINA ------------------------
function stampa () {
  safeIEstring=navigator.appVersion;
  if (document.layers || (safeIEstring.indexOf ("MSIE 5") != -1) || (safeIEstring.indexOf ("MSIE 6") != -1)) {
  // se si tratta di netscape dalla versione 4 usa il metodo print() di window  
    	print();
  }  
  else if (document.all) {
  // se invece il browser non č MSIE 5.0, ma ad esempio un browser 4.0 usa l'activex per stampare
   	var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
    	document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    	WebBrowser1.ExecWB(6, 2);
		WebBrowser1.outerHTML = "";  
  }
}

 
// -->

