// Cambia l'URL della pagina
function Gox(coc) {window.location.href='index.php?'+coc;}
// Chiama lo script per scaricare un file
function FileDW(id){window.location.href='scripts/filedw.php?id='+id;}

var pagina=""; var pagposiz=9;
var pagx = new Array(20); 
for(a=1;a<20;a++){pagx[a]="";}
// Cambia pagina salvando la precedente per il back - forward 
function axLoadBZ(url){
  var id="bodyzone";
  var x=(window.ActiveXObject) ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
  x.onreadystatechange=function() {if (x.readyState==4 && x.status==200){el=document.getElementById(id).innerHTML=x.responseText; PosizBZ(x.responseText);} }
  x.open('GET',url,true); x.send(null);
}
// Aggiorna la pagina compreso la pag attuale nel il back - forward, senza aggiungere una pagina 
function axLoadBF(url){
  var id="bodyzone";
  var x=(window.ActiveXObject) ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
  x.onreadystatechange=function() {if (x.readyState==4 && x.status==200){el=document.getElementById(id).innerHTML=x.responseText; pagx[9]=x.responseText;} }
  x.open('GET',url,true); x.send(null);
}
// Funzioni per andare avanti ed indietro di pagina 
function PosizBZ(body){
  // Sposta indietro le vecchie pagine memorizzate per far posto alla nuova (9 memorizzate, la più recente è la 9 la più vecchia la 1) 
  if(pagposiz<9){ var delta=9-pagposiz; for(a=9;a>0;a--){ if((a-delta)>0){pagx[a]=pagx[a-delta];}else{pagx[a]="";} } pagposiz=9; }
  for(a=1;a<9;a++){pagx[a]=pagx[a+1];} pagx[9]=body;
}
function VaiDietro(){ if(pagposiz>1 && pagx[pagposiz-1]!=""){ pagposiz--; document.getElementById("bodyzone").innerHTML=pagx[pagposiz]; } }
function VaiAvanti(){ if(pagposiz>0 && pagposiz<9 && pagx[pagposiz+1]!=""){ pagposiz++; document.getElementById("bodyzone").innerHTML=pagx[pagposiz]; } }
function axSRC(url,id){ if(document.getElementById(id)){ document.getElementById(id).src=url; } }

// Crea un oggetto Flash per evitare il problema "dell'attivazione"
function theflash(movie,width,height){
  document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="'+width+'" height="'+height+'">\n');
  document.write('<param name="movie" value="'+movie+'">\n');
  document.write('<param name="quality" value="high" />\n');
  document.write('<param name="menu" value="false">\n');
  document.write('<param name="wmode" value="transparent">\n');
  document.write('<embed src="'+movie+'" width="'+width+'" height="'+height+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false" wmode="transparent"></embed>\n');
  document.write('</object>\n');
}
// Chiama un URL il ajax mettendo il risultato in un oggetto
function axLoader(url,id){
  var x=(window.ActiveXObject) ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
  x.onreadystatechange=function() {if(x.readyState==4 && x.status==200){el=document.getElementById(id).innerHTML=x.responseText;} }
  x.open('GET',url,true); x.send(null);
}
// Chiama un URL il ajax passando i risultati ad unoscript JS
function axLoaderScript(url,scriptname){
  var x = (window.ActiveXObject) ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
  x.onreadystatechange = function() { if(x.readyState == 4 && x.status == 200){eval(scriptname+"(x.responseText);");} }
  x.open('GET', url, true);  x.send(null);
}
// Chiama un URL il ajax passando i risultati ad unoscript JS
function axLoaderReturn(variable){
  var url='scripts/get_label.php?v='+variable;
  var x = (window.ActiveXObject) ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
  x.onreadystatechange = function() { if(x.readyState == 4 && x.status == 200){return x.responseText;} }
  x.open('GET', url, true);  x.send(null);
}
// Mostra / nasconde un DIV con la modalità "display"
function DispBlock(id){
  var divx=document.getElementById(id);
  divx.style.display=(divx.style.display=="block") ? "none" : "block";
}

// Definisce il browser ed imposta gli oggetti relativi 
function Browser(){
  var ua, s, i;   this.isIE    = false;   this.isNS    = false;   this.version = null;   ua = navigator.userAgent;
  s='MSIE';        if((i = ua.indexOf(s)) >= 0){this.isIE = true;   this.version = parseFloat(ua.substr(i + s.length));  return; }
  s='Netscape6/';  if((i = ua.indexOf(s)) >= 0){this.isNS = true;   this.version = parseFloat(ua.substr(i + s.length));  return; }
  // Treat any other "Gecko" browser as NS 6.1.
  s='Gecko';       if((i = ua.indexOf(s)) >= 0){this.isNS = true;   this.version = 6.1;  return; }
}
var browser = new Browser();
var dragObj = new Object();
dragObj.zIndex = 0;
// Ritorna la posizione del cursone nella finestra (va richiamata con un evento ONqualcosa non href del TAG A) 
function DoveSono(event){
  if (browser.isIE) { x = window.event.clientX + document.body.scrollLeft;  y = window.event.clientY + document.body.scrollTop; }
  if (browser.isNS) { x = event.clientX + window.scrollX;   y = event.clientY + window.scrollY; }
  if(browser.isIE){ var xwin=document.body.offsetWidth; var ywin=document.body.offsetHeight; var bcorr=-4;}
  if(browser.isNS){ var xwin=window.innerWidth; var ywin=window.innerHeight; var bcorr=6;}
  return x+','+y+','+xwin+','+ywin;
}
// Mostra un DIV (SchDescrTxt e SchDescr da dichiarare in index)
function SchDescrOn(event,id){
  document.getElementById('SchDescrTxt').innerHTML='&nbsp;';
  axLoader('scripts/bodyz_schedaart_txt.php?id='+id,'SchDescrTxt');
  var lay_width=220; var lay_height=80;
  var maindiv=70;
  var a=DoveSono(event).split(','); var xm=a[0]*1; var ym=a[1]*1; var xwin=a[2]*1; var ywin=a[3]*1;
  var xspace=(xwin-maindiv)/2; // Corregge la posizione relativa rispetto al DIV maindiv
  xpos=xm-xspace+10; ypos=ym+10;
  if((ypos+lay_height)>ywin){ypos=ypos-lay_height-10;}
  document.getElementById('SchDescr').style.left=xpos;
  document.getElementById('SchDescr').style.top=ypos;
  document.getElementById('SchDescr').style.display='block';
}
function SchDescrOff(){ document.getElementById('SchDescr').style.display='none'; }

// Box del login
function invia_login(){
  var err=0; var err_txt=''; var fil="";
  var cname_nor="GreyInputOK"; var cname_err="GreyInputERR";
  var idd=document.getElementById('idd').value; var pwd=document.getElementById('pwd').value;
  // Controllo campi obbligatori, setta il colore di sfondo rosso se non compilati
  fil=document.getElementById('idd'); if(fil.value==''){err=1; fil.className=cname_err;}else{fil.className=cname_nor;}
  fil=document.getElementById('pwd'); if(fil.value==''){err=1; fil.className=cname_err;}else{fil.className=cname_nor;}
  if(err==0){axLoaderScript("scripts/box_login.php?idd="+idd+"&pwd="+pwd,"invia_loginExe");}else{alert('I campi in rosso sono vuoti o compilati in modo incorretto');}
}
function invia_loginExe(esito){
  var cosa=esito.split('||');
  if(cosa[1]){document.getElementById('box_login').innerHTML=cosa[0]; document.getElementById('box_login_txt').innerHTML=cosa[1];}else{document.getElementById('box_login').innerHTML=esito;}
}
// Box del login
function invia_losty(){
  var err=0; var err_txt=''; var fil="";
  var cname_nor="GreyInputOK"; var cname_err="GreyInputERR";
  var mail=document.getElementById('mail').value;
  // Controllo campi obbligatori, setta il colore di sfondo rosso se non compilati
  fil=document.getElementById('mail'); if(fil.value=='' || checkEmail(fil.value)==0){err=1; fil.className=cname_err;}else{fil.className=cname_nor;}
  if(err==0){axLoader("scripts/box_login.php?x=lty_send&mail="+mail,"box_login");}else{alert('I campi in rosso sono vuoti o compilati in modo incorretto');}
}
// Box del login
function invia_logout(){
  axLoader("scripts/box_login.php?x=lty_exe","box_login");
}

function ContSubmit(){
  var ko=0; var kon=''; var err='';
  // Creazione oggetti dei campi 
  var nome_cognome=document.getElementById('nome_cognome');  var e_mail=document.getElementById('e_mail');
  var tel=document.getElementById('tel');  var cons_carr=document.getElementById('cons_carr');  var testo_sup=document.getElementById('testo_sup');
  // Controllo campi parte informazioni cliente 
  if(nome_cognome.value==''){ko++; nome_cognome.style.background=ErrFld;}else{nome_cognome.style.background=OkFld;}
  if(e_mail.value=='' || checkEmail(e_mail.value)==0){ko++; e_mail.style.background=ErrFld;}else{e_mail.style.background=OkFld;}
  if(tel.value!='' && checkTel(tel.value)==0){ko++; tel.style.background=ErrFld;}else{tel.style.background=OkFld;}
  if(testo_sup.value==''){ko++; testo_sup.style.background=ErrFld;}else{testo_sup.style.background=OkFld;}
  // Controllo accettazione privacy e condizioni generali 
  if(cons_carr.checked==false){ko++; cons_carrTxt.style.background=ErrFld;}else{cons_carrTxt.style.background=OkFld;}
  if(ko==1){lett='Il campo indicato è obbligatorio o non è stato compilato in modo corretto:\n\n'+err;}
  if(ko>1){lett='I campi indicati sono obbligatori o non sono stati compilati in modo corretto:\n\n'+err;}

  if(ko>0){alert(lett);} else{ document.getElementById('d1cont').submit();}
}

// Aggiunta articolo al carrello
function Compra(event,id){
  var maindiv=770;
  if(carret==1){var carrdivconf='add_carrm'; var lay_width=293; var lay_height=200; }else{var carrdivconf='carreadded'; var lay_width=160; var lay_height=40;}
  var a=DoveSono(event).split(','); var xm=a[0]*1; var ym=a[1]*1; var xwin=a[2]*1; var ywin=a[3]*1;
  var xspace=(xwin-maindiv)/2; // Corregge la posizione alla relativa rispetto al DIV maindiv
  xpos=xm-xspace-lay_width-20; ypos=ym+5;
  if((ypos+lay_height)>ywin){ypos=ypos-lay_height-50;}
  document.getElementById(carrdivconf).style.left=xpos;
  document.getElementById(carrdivconf).style.top=ypos;
  document.getElementById(carrdivconf).style.display='block';
  if(carret==1){axLoader('scripts/carreadd_show.php?id='+id,'add_carr_txt');}else{
	axLoader('scripts/carreadd_exe.php?id='+id+'&qta=1','small_carr');
	document.getElementById('small_carr').style.visibility='visible';
	setTimeout('CompraHide()',1000);
  }
}
function CompraHide(){
  if(document.getElementById('add_carr_txt')){document.getElementById('add_carr_txt').innerHTML='';}
  if(document.getElementById('add_carrm')){document.getElementById('add_carrm').style.display='none';}
  if(document.getElementById('carreadded')){document.getElementById('carreadded').style.display='none';}
}
function SchDescrOn(event,id){
  document.getElementById('SchDescrTxt').innerHTML='&nbsp;';
  axLoader('scripts/bodyz_schedaart_txt.php?id='+id,'SchDescrTxt');
  var lay_width=220; var lay_height=80;
  var maindiv=770;
  var a=DoveSono(event).split(','); var xm=a[0]*1; var ym=a[1]*1; var xwin=a[2]*1; var ywin=a[3]*1;
  var xspace=(xwin-maindiv)/2; // Corregge la posizione relativa rispetto al DIV maindiv
  xpos=xm-xspace+10; ypos=ym+10;
  if((ypos+lay_height)>ywin){ypos=ypos-lay_height-10;}
  document.getElementById('SchDescr').style.left=xpos;
  document.getElementById('SchDescr').style.top=ypos;
  document.getElementById('SchDescr').style.display='block';
}
function SchDescrOff(){
  document.getElementById('SchDescr').style.display='none';
}
function CompraExe(){
  var id=document.getElementById('idpr').value;
  var qta=document.getElementById('carr_qta').value*1;
  var minpz=document.getElementById('minpz').value*1;
  var maxpz=document.getElementById('maxpz').value*1;
  var multipz=document.getElementById('multipz').value*1;
  // Calcolo multiplo della confezione
  if(qta/multipz!=parseInt(qta/multipz)){var qtaconf=2;}else{var qtaconf=1;}
  // Controllo della quantità acquistata
  if(maxpz==0){maxpz1=1000000;}else{maxpz1=maxpz;}
  if(qta>=minpz && qta<=maxpz1 && qtaconf==1){
    document.getElementById('add_carr_txt').innerHTML='';
	document.getElementById('add_carrm').style.display='none';
	axLoader('scripts/carreadd_exe.php?id='+id+'&qta='+qta,'small_carr');
	document.getElementById('small_carr').style.visibility='visible';
  }else{
    if(maxpz==0){maxpz1='';}
    if(qtaconf==1){
	  if(qta<minpz) {var errorepz=document.getElementById('minpztxt').value+' ('+minpz+')';}
	  if(qta>maxpz1){var errorepz=document.getElementById('maxpztxt').value+' ('+maxpz1+')';}
	}else{var errorepz=document.getElementById('multipztxt').value+' '+multipz;}
	alert(errorepz);
  }
}
function CarrelloUpdate(id,qta){
  if(qta!=0){ qta=document.getElementById('Qta'+id).value; }
  // Controlla se la quantità indicata è ordinabile per l'articolo
  var minpz=document.getElementById('minpz'+id).value*1;
  var maxpz=document.getElementById('maxpz'+id).value*1;
  var multipz=document.getElementById('multipz'+id).value*1;
  // Calcolo multiplo della confezione
  if(qta/multipz!=parseInt(qta/multipz)){var qtaconf=2;}else{var qtaconf=1;}
  // Controllo della quantità acquistata
  if(maxpz==0){maxpz1=1000000;}else{maxpz1=maxpz;}
  if(qta>=minpz && qta<=maxpz1 && qtaconf==1 || qta==0){
    axLoaderScript('scripts/carreadd_exe.php?id='+id+'&qta='+qta,'CarrelloUpdateExe');
  }else{
    if(maxpz==0){maxpz1='';}
    if(qtaconf==1){
	  if(qta<minpz) {var errorepz=document.getElementById('minpztxt').value+' ('+minpz+')';}
	  if(qta>maxpz1){var errorepz=document.getElementById('maxpztxt').value+' ('+maxpz1+')';}
	}else{var errorepz=document.getElementById('multipztxt').value+' '+multipz;}
	alert(errorepz);
  }
}
function CarrelloUpdateExe(small_carr_body){
  document.getElementById('small_carr').innerHTML=small_carr_body;
  axLoadBF('scripts/bodyz.php?s=115&t=carrello');
}
function CarrelloShowForm(){
  axLoader('scripts/carre_form_show.php','form_carr1');
  document.getElementById('form_carr1').style.visibility='visible';
  document.getElementById('bott1_carr').style.display='none';
}
function CarrelloImporto(){
  var ko=0; var err='';
  // Controllo importo dell'ordine, per vedere se rispetta il range impostato per il metodo pagamento scelto 
  var id_pagamento=document.getElementById('id_pagamento');
  if(id_pagamento.value>0){
    var idpag=id_pagamento.value;
    var impord=document.getElementById('totc').value*1; var impmin=document.getElementById('omin'+idpag).value*1; var impmax=document.getElementById('omax'+idpag).value*1;
    if(impord < impmin){ko++; var etmp=axLoaderReturn('carrelab[100]'); err+=etmp.replace(/#impmin#/g,impmin);}
    if(impord > impmax){ko++; var etmp=axLoaderReturn('carrelab[100]'); err+=etmp.replace(/#impmax#/g,impmax);}
  }
  if(ko>0){alert(err);}
}
// Calcola le spese di spedizione per l'ordine, in base ai dati di ritiro/consegna ed alla destinazione
function CarrelloSpediz(){
  var totc=document.getElementById('totc').value;  var pesor=document.getElementById('pesor').value;
  var adress=document.getElementById('adress').value;  var cap=document.getElementById('cap').value;  var citta=document.getElementById('citta').value;  var id_paese=document.getElementById('id_paese').value;  var provincia=document.getElementById('provincia').value;
  var adress_d=document.getElementById('adress_d').value;  var cap_d=document.getElementById('cap_d').value;  var citta_d=document.getElementById('citta_d').value;  var id_paese_d=document.getElementById('id_paese_d').value;  var provincia_d=document.getElementById('provincia_d').value; 
  var consx=document.getElementById('consx').value; 
  var spd_txt1=document.getElementById('spd_txt1').value;  var spd_txt2=document.getElementById('spd_txt2').value;
  var txt='';  var txt_imp='&nbsp;';
  var dati='';
  if(consx=='C1' && adress!='' && cap!='' && citta!='' && id_paese!='' && provincia!=''){
    id_paese=id_paese.replace(/\&/g,'!and!');  cap=cap.replace(/\&/g,'!and!');  citta=citta.replace(/\&/g,'!and!');  provincia=provincia.replace(/\&/g,'!and!');
    dati='&id_paese='+id_paese+'&cap='+cap+'&citta='+citta+'&provincia='+provincia+'&consx='+consx;  dati=dati.replace(/\+/g,'!piu!');
  }else if(consx=='C2' && adress_d!='' && cap_d!='' && citta_d!='' && id_paese_d!='' && provincia_d!=''){
    id_paese=id_paese.replace(/\&/g,'!and!');  cap=cap.replace(/\&/g,'!and!');  citta=citta.replace(/\&/g,'!and!');  provincia=provincia.replace(/\&/g,'!and!');
    dati='&id_paese='+id_paese_d+'&cap='+cap_d+'&citta='+citta_d+'&provincia='+provincia_d+'&consx='+consx;  dati=dati.replace(/\+/g,'!piu!');
  }
  if(dati!=''){ axLoaderScript('scripts/spese_spedizione.php?totc='+totc+'&pesor='+pesor+dati,'CarrelloSpedizExe'); }
  else{
    txt=spd_txt1+'<br>'+spd_txt2; costo='';
	if(consx=='C3'){txt=spd_txt1; costo=0; txt_imp='0,00'} // Ritiro presso magazzino
	document.getElementById('spedimp').value='';
    document.getElementById('txt_spediz').innerHTML=txt;
    document.getElementById('imp_spediz').innerHTML=txt_imp;
    CarrelloTotali('spediz'); // Gli passo lo script chiamante per evitare eventuali loop
  }
}
function CarrelloSpedizExe(costo){
  var totc=parseFloat(document.getElementById('totc').value);
  var sped_riduz=parseFloat(document.getElementById('sped_riduz').value);
  var spd_txt1=document.getElementById('spd_txt1').value;  var spd_txt2=document.getElementById('spd_txt2').value;
  var txt='';  var txt_imp='&nbsp;';
  if(costo!='' && checkNumero(costo)==1){costo=costo-sped_riduz; costo=parseFloat(costo); if(costo<0){costo=0;} txt=spd_txt1; txt_imp=Cents(costo,'.',',',2)+'&nbsp;'; totc=totc+costo*1; imp_spediz.style.background=OkFld;}else{txt=spd_txt1+'<br>'+spd_txt2; costo='';}
  document.getElementById('spedimp').value=costo;
  document.getElementById('txt_spediz').innerHTML=txt;
  document.getElementById('imp_spediz').innerHTML=txt_imp;
  CarrelloTotali('spediz'); // Gli passo lo script chiamante per evitare eventuali loop
}
function CarrelloTotali(da){
  var totc=document.getElementById('totc').value*1;
  var totiva=document.getElementById('tot_ci').value*1;
  if(document.getElementById('spedimp')) {var sped=document.getElementById('spedimp').value*1;}   else{var sped=0;}
  if(da!='promo'){CarrelloPromo();} // Ricalcola le promo
  if(document.getElementById('promoimp')){var promo=document.getElementById('promoimp').value*1;} else{var promo=0;}
  if(document.getElementById('credito')) {var credito=document.getElementById('credito').value*1;}else{var credito=0;}
  // Aggiorna i totali mostrati, aggiungendo o scorporando l'IVA a seconda del settaggio di $civa
  if(civa=='0'){ totiva=totiva+sped*(ivabase/100)+promo*(ivabase/100); var promoniva=promo; var spedniva=sped;  var creditoniva=credito;}
                else{ totiva=totiva+(sped-sped/(1+ivabase/100))+(promo-promo/(1+ivabase/100)); var promoniva=promo/(1+ivabase/100); var spedniva=sped/(1+ivabase/100); var creditoniva=credito/(1+ivabase/100);}
  var tot=totc+promoniva+spedniva;
  if(creditoniva>tot){creditoniva=tot; tot=0;}else{tot=tot-creditoniva;}
  if(document.getElementById('txt_credito')){document.getElementById('txt_credito').innerHTML='-'+Cents(credito,'.',',',2)+'&nbsp;';}
  var tot_cn=tot; var tot_ci=totiva; var tot_ct=tot+totiva;
  document.getElementById('txt_tot_netto').innerHTML=Cents(tot_cn,'.',',',2)+'&nbsp;';
  document.getElementById('txt_tot_iva').innerHTML=Cents(tot_ci,'.',',',2)+'&nbsp;';
  document.getElementById('txt_tot_lordo').innerHTML=Cents(tot_ct,'.',',',2)+'&nbsp;';
}
function CarrelloPromo(){
  var totc=document.getElementById('totc').value;
  var sped=document.getElementById('spedimp').value;
  var promo=document.getElementById('promocod').value;
  axLoaderScript('scripts/promo_ajax.php?totc='+totc+'&promo='+promo+'&spedimp='+sped,'CarrelloPromoExe');
}
function CarrelloPromoExe(dati){
  var a=dati.split('###!###');   // riceve: immagine, testo, importo separati da ###!###
  document.getElementById('img_promo').innerHTML=a[0];
  document.getElementById('txt_promo').innerHTML=a[1];
  var promo=a[2]*1;
  if(promo!=''){var promof=Cents(a[2],'.',',',2)+'&nbsp;';}else{var promof='';}
  var promof=Cents(a[2],'.',',',2)+'&nbsp;';
  document.getElementById('imp_promo').innerHTML=promof;
  document.getElementById('promoimp').value=promo;
  CarrelloTotali('promo'); // Gli passo lo script chiamante per evitare eventuali loop
}
// Controlla che il paese scelto sia fra quelli in cui si consegna, in caso negativo mostra l'avviso
function CarrelloPaese(id){
  var id_paese=document.getElementById(id).value;
  if(id_paese!=''){ axLoaderScript('scripts/carre_paese_check.php?id_paese='+id_paese,'CarrelloPaeseExe'); }
}
function CarrelloPaeseExe(esito){
  if(esito==0){alert(axLoaderReturn('carrelab[95]'));}
}
var ErrFld='#ED8B6D'; var OkFld='#E4E4E4';
function CarrelloSubmit(){
  var ko=0; var kon=''; var err='';
  // ***** Va messo un controllo, usando axLoaderScript, per controllare che il carrello sia pieno e non si sia vuotato per scsdenza della sessione ***** 
  // Creazione oggetti dei campi 
  if(document.getElementById('B2B2')){var jktra=1; var B2B2=document.getElementById('B2B2');  var B2B2lab=document.getElementById('B2B2lab');}else{var jktra=0;}
  var spedimp=document.getElementById('spedimp');  var imp_spediz=document.getElementById('imp_spediz');
  var azienda=document.getElementById('azienda');  var nome_cognome=document.getElementById('nome_cognome');  var PI_CF=document.getElementById('PI_CF');  var e_mail=document.getElementById('e_mail');
  var tel=document.getElementById('tel');  var fax=document.getElementById('fax');  var cell=document.getElementById('cell');  var adress=document.getElementById('adress');
  var cap=document.getElementById('cap');  var citta=document.getElementById('citta');  var id_paese=document.getElementById('id_paese');  var provincia=document.getElementById('provincia');
  var consegna=document.getElementById('consegna');  var pagamento=document.getElementById('pagamento');  var consx=document.getElementById('consx');  var id_pagamento=document.getElementById('id_pagamento');
  var azienda_d=document.getElementById('azienda_d');  var nome_cognome_d=document.getElementById('nome_cognome_d');  var tel_d=document.getElementById('tel_d');  var adress_d=document.getElementById('adress_d');
  var cap_d=document.getElementById('cap_d');  var citta_d=document.getElementById('citta_d');  var id_paese_d=document.getElementById('id_paese_d');  var provincia_d=document.getElementById('provincia_d');
  var cons_carr=document.getElementById('cons_carr');  var cons_carrTxt=document.getElementById('cons_carrTxt');  var cotr_carr=document.getElementById('cotr_carr');  var cotr_carrTxt=document.getElementById('cotr_carrTxt');
  // Controllo importo dell'ordine, per vedere se rispetta il range impostato per il metodo pagamento scelto 
  if(id_pagamento.value>0){
    var idpag=id_pagamento.value;
    var impord=document.getElementById('totc').value*1; var impmin=document.getElementById('omin'+idpag).value*1; var impmax=document.getElementById('omax'+idpag).value*1;
	if(impord < impmin){ko++; var etmp=axLoaderReturn('carrelab[100]')+"\n"; err+=etmp.replace(/#impmin#/g,impmin);}
	if(impord > impmax){ko++; var etmp=axLoaderReturn('carrelab[101]')+"\n"; err+=etmp.replace(/#impmax#/g,impmax);}
  }
  // Controllo che siano state calcolate le spese di spedizione 
  if((spedimp.value=='' || checkNumero(spedimp.value)==0) && consx.value!='C3'){ko++; err+=axLoaderReturn('carrelab[102]')+"\n"; imp_spediz.style.background=ErrFld;}else{imp_spediz.style.background=OkFld;}
  // Controllo scelta tipo cliente, se i campi esistono 
  if(jktra==1){ if(B2B2.checked==false){ko++; err+=axLoaderReturn('carrelab[103]')+"\n"; B2B2lab.style.background=ErrFld;}else{B2B2lab.style.background=OkFld;} }
  // Controllo campi parte informazioni cliente 
  if(azienda.value==''){ko++; err+=axLoaderReturn('carrelab[104]')+"\n"; azienda.style.background=ErrFld;}else{azienda.style.background=OkFld;}
  if(nome_cognome.value==''){ko++; err+=axLoaderReturn('carrelab[105]')+"\n"; nome_cognome.style.background=ErrFld;}else{nome_cognome.style.background=OkFld;}
  if(PI_CF.value==''){ko++; err+=axLoaderReturn('carrelab[106]')+"\n"; PI_CF.style.background=ErrFld;}else{PI_CF.style.background=OkFld;}
  if(e_mail.value=='' || checkEmail(e_mail.value)==0){ko++; err+=axLoaderReturn('carrelab[107]')+"\n"; e_mail.style.background=ErrFld;}else{e_mail.style.background=OkFld;}
  if(tel.value==''|| checkTel(tel.value)==0){ko++; err+=axLoaderReturn('carrelab[108]')+"\n"; tel.style.background=ErrFld;}else{tel.style.background=OkFld;}
  if(checkTel(fax.value)==0){ko++; err+=axLoaderReturn('carrelab[109]')+"\n"; fax.style.background=ErrFld;}else{fax.style.background=OkFld;}
  if(checkTel(cell.value)==0){ko++; err+=axLoaderReturn('carrelab[110]')+"\n"; cell.style.background=ErrFld;}else{cell.style.background=OkFld;}
  if(adress.value==''){ko++; err+=axLoaderReturn('carrelab[111]')+"\n"; adress.style.background=ErrFld;}else{adress.style.background=OkFld;}
  if(cap.value==''){ko++; err+=axLoaderReturn('carrelab[112]')+"\n"; cap.style.background=ErrFld;}else{cap.style.background=OkFld;}
  if(citta.value==''){ko++; err+=axLoaderReturn('carrelab[113]')+"\n"; citta.style.background=ErrFld;}else{citta.style.background=OkFld;}
  if(id_paese.value==''){ko++; err+=axLoaderReturn('carrelab[114]')+"\n"; id_paese.style.background=ErrFld;}else{id_paese.style.background=OkFld;}
  if(provincia.value==''){ko++; err+=axLoaderReturn('carrelab[115]')+"\n"; provincia.style.background=ErrFld;}else{provincia.style.background=OkFld;}
  if(consx.value==''){ko++; err+=axLoaderReturn('carrelab[116]')+"\n"; consx.style.background=ErrFld;}else{consx.style.background=OkFld;}
  if(id_pagamento.value==''){ko++; err+=axLoaderReturn('carrelab[117]')+"\n"; id_pagamento.style.background=ErrFld;}else{id_pagamento.style.background=OkFld;}
  // Controllo campi parte indirizzo alternativo 
  if(consx.value=='C2'){
    if(azienda_d.value==''){ko++; err+=axLoaderReturn('carrelab[118]')+"\n"; azienda_d.style.background=ErrFld;}else{azienda_d.style.background=OkFld;}
    if(nome_cognome_d.value==''){ko++; err+=axLoaderReturn('carrelab[119]')+"\n"; nome_cognome_d.style.background=ErrFld;}else{nome_cognome_d.style.background=OkFld;}
    if(tel_d.value=='' || checkTel(tel_d.value)==0){ko++; err+=axLoaderReturn('carrelab[120]')+"\n"; tel_d.style.background=ErrFld;}else{tel_d.style.background=OkFld;}
    if(adress_d.value==''){ko++; err+=axLoaderReturn('carrelab[121]')+"\n"; adress_d.style.background=ErrFld;}else{adress_d.style.background=OkFld;}
    if(cap_d.value==''){ko++; err+=axLoaderReturn('carrelab[122]')+"\n"; cap_d.style.background=ErrFld;}else{cap_d.style.background=OkFld;}
    if(citta_d.value==''){ko++; err+=axLoaderReturn('carrelab[123]')+"\n"; citta_d.style.background=ErrFld;}else{citta_d.style.background=OkFld;}
    if(id_paese_d.value==''){ko++; err+=axLoaderReturn('carrelab[124]')+"\n"; id_paese_d.style.background=ErrFld;}else{id_paese_d.style.background=OkFld;}
    if(provincia_d.value==''){ko++; err+=axLoaderReturn('carrelab[125]')+"\n"; provincia_d.style.background=ErrFld;}else{provincia_d.style.background=OkFld;}
  }
  // Controllo accettazione privacy e condizioni generali 
  if(cons_carr.checked==false){ko++; err+=axLoaderReturn('carrelab[130]')+"\n"; cons_carrTxt.style.background=ErrFld;}else{cons_carrTxt.style.background=OkFld;}
  if(cotr_carr.checked==false){ko++; err+=axLoaderReturn('carrelab[131]')+"\n"; cotr_carrTxt.style.background=ErrFld;}else{cotr_carrTxt.style.background=OkFld;}
  if(ko==1){lett='Il campo indicato è obbligatorio o non è stato compilato in modo corretto:\n\n'+err;}
  if(ko>1){lett='I campi indicati sono obbligatori o non sono stati compilati in modo corretto:\n\n'+err;}
  if(ko>0){alert(lett);} else{document.getElementById('d1f').submit();}
}
// Controlla l'esito dell'inserimento dell'ordine ed aggiorna la pagina 
function CarreInsert(body){
  document.getElementById('bodyzone').innerHTML=body;
  pagx[9]=body;
  document.getElementById('small_carr').innerHTML="";
}
function CarrelloSubmitT(){
  document.d1.submit();
}
function SuppSubmit(){
  var ko=0; var kon=''; var err='';
  // Creazione oggetti dei campi 
  var id_motivo=document.getElementById('id_motivo');  var nome_cognome=document.getElementById('nome_cognome');  var e_mail=document.getElementById('e_mail');
  var tel=document.getElementById('tel');  var cons_carr=document.getElementById('cons_carr');  var testo_sup=document.getElementById('testo_sup');
  // Controllo campi parte informazioni cliente 
//  if(id_motivo.value==''){ko++; err+=axLoaderReturn('supplab[4]')+"\n"; id_motivo.style.background=ErrFld;}else{id_motivo.style.background=OkFld;}
  if(nome_cognome.value==''){ko++; err+=axLoaderReturn('supplab[1]')+"\n"; nome_cognome.style.background=ErrFld;}else{nome_cognome.style.background=OkFld;}
  if(e_mail.value=='' || checkEmail(e_mail.value)==0){ko++; err+=axLoaderReturn('supplab[2]')+"\n"; e_mail.style.background=ErrFld;}else{e_mail.style.background=OkFld;}
//  if(tel.value==''|| checkTel(tel.value)==0){ko++; err+=axLoaderReturn('supplab[3]')+"\n"; tel.style.background=ErrFld;}else{tel.style.background=OkFld;}
  if(testo_sup.value==''){ko++; err+=axLoaderReturn('supplab[6]')+"\n"; testo_sup.style.background=ErrFld;}else{testo_sup.style.background=OkFld;}
  // Controllo accettazione privacy e condizioni generali 
  if(cons_carr.checked==false){ko++; err+=axLoaderReturn('supplab[5]')+"\n"; cons_carrTxt.style.background=ErrFld;}else{cons_carrTxt.style.background=OkFld;}
  if(ko==1){lett='The item in red it\'s empty or filled in a wrong way:\n\n';} // +err
  if(ko>1){lett='The items in red are empty or filled in a wrong way:\n\n';} // +err

  if(ko>0){alert(lett);} else{ document.document.getElementById('d1cont').submit();}
}
// Controlla l'esito dell'inserimento del messaggio ed aggiorna la pagina 
function SuppInsert(body,errik){
  if(errik==0){document.getElementById('bodyzone').innerHTML=body;}else{alert(axLoaderReturn('Il messaggio non è stato inviato, controllate di aver immesso tutti i dati necessari e riprovate.'));}
}
// Invio form di modifica profilo di accesso
function ProfiSubmit(){
  var ko=0; var kon=''; var err='';
  // Creazione oggetti dei campi 
  var azienda=document.getElementById('azienda');  var nome_cognome=document.getElementById('nome_cognome');  var PI_CF=document.getElementById('PI_CF');  var e_mail=document.getElementById('e_mail');
  var tel=document.getElementById('tel');  var fax=document.getElementById('fax');  var cell=document.getElementById('cell');  var adress=document.getElementById('adress');
  var cap=document.getElementById('cap');  var citta=document.getElementById('citta');  var id_paese=document.getElementById('id_paese');  var provincia=document.getElementById('provincia');
  var loginn=document.getElementById('loginn');  var lpw=document.getElementById('lpw');

  // Controllo campi parte informazioni cliente 
  if(azienda.value==''){ko++; err+=axLoaderReturn('proflab[104]')+"\n"; azienda.style.background=ErrFld;}else{azienda.style.background=OkFld;}
  if(nome_cognome.value==''){ko++; err+=axLoaderReturn('proflab[105]')+"\n"; nome_cognome.style.background=ErrFld;}else{nome_cognome.style.background=OkFld;}
  if(PI_CF.value==''){ko++; err+=axLoaderReturn('proflab[106]')+"\n"; PI_CF.style.background=ErrFld;}else{PI_CF.style.background=OkFld;}
  if(e_mail.value=='' || checkEmail(e_mail.value)==0){ko++; err+=axLoaderReturn('proflab[107]')+"\n"; e_mail.style.background=ErrFld;}else{e_mail.style.background=OkFld;}
  if(tel.value==''|| checkTel(tel.value)==0){ko++; err+=axLoaderReturn('proflab[108]')+"\n"; tel.style.background=ErrFld;}else{tel.style.background=OkFld;}
  if(checkTel(fax.value)==0){ko++; err+=axLoaderReturn('proflab[109]')+"\n"; fax.style.background=ErrFld;}else{fax.style.background=OkFld;}
  if(checkTel(cell.value)==0){ko++; err+=axLoaderReturn('proflab[110]')+"\n"; cell.style.background=ErrFld;}else{cell.style.background=OkFld;}
  if(adress.value==''){ko++; err+=axLoaderReturn('proflab[111]')+"\n"; adress.style.background=ErrFld;}else{adress.style.background=OkFld;}
  if(cap.value==''){ko++; err+=axLoaderReturn('proflab[112]')+"\n"; cap.style.background=ErrFld;}else{cap.style.background=OkFld;}
  if(citta.value==''){ko++; err+=axLoaderReturn('proflab[113]')+"\n"; citta.style.background=ErrFld;}else{citta.style.background=OkFld;}
  if(id_paese.value==''){ko++; err+=axLoaderReturn('proflab[114]')+"\n"; id_paese.style.background=ErrFld;}else{id_paese.style.background=OkFld;}
  if(provincia.value==''){ko++; err+=axLoaderReturn('proflab[115]')+"\n"; provincia.style.background=ErrFld;}else{provincia.style.background=OkFld;}
  if(loginn.value==''){ko++; err+=axLoaderReturn('proflab[116]')+"\n"; loginn.style.background=ErrFld;}else{loginn.style.background=OkFld;}
  if(lpw.value==''){ko++; err+=axLoaderReturn('proflab[118]')+"\n"; lpw.style.background=ErrFld;}else{lpw.style.background=OkFld;}
  if(ko==1){lett='Il campo indicato è obbligatorio o non è stato compilato in modo corretto:\n\n'+err;}
  if(ko>1){lett='I campi indicati sono obbligatori o non sono stati compilati in modo corretto:\n\n'+err;}

  if(ko>0){alert(lett);} else{document.getElementById('d1prof').submit();}
}
// Controlla l'esito dell'inserimento dell'ordine ed aggiorna la pagina 
function ProfiInsert(body,errik){
  if(errik==0){document.getElementById('bodyzone').innerHTML=body;}
  else{
    if(errik<3){alert(axLoaderReturn('profform[8]'));}
	if(errik==3){alert(axLoaderReturn('profform[9]'));}
  }
}