function PrSch(url){myWindow = window.open(url,'scheda','toolbar=no,scrollbars=yes,resizable=no,directories=no,menubar=no,status=no,width=625,height=550');}
function PrZoo(p){var n=document.getElementById('zomnum').value; axLoaderScript('scripts/scheda_img_zoom.php?id='+p+'&n='+n,'PrZooExe');}
function PrZooExe(imgurl){document.getElementById('ImgZommy').style.background="url("+imgurl+") no-repeat center top";  document.getElementById('ImgZommy').style.display="block";}
function PrZooH(){document.getElementById('ImgZommy').style.background="url(images/sch_noimg_280.gif) no-repeat center top"; document.getElementById('ImgZommy').style.display="none";}

function CatOn(id){ document.getElementById("DIVcat"+id).className='CategBoxON'; document.getElementById("TDcat"+id).className='CategTxtON'; }
function CatOff(id){ document.getElementById("DIVcat"+id).className='CategBox'; document.getElementById("TDcat"+id).className='CategTxt'; }

function CrImgOff(id){ document.getElementById("CrI"+id).src='images/carr-off.png'; document.getElementById("CrTD"+id).className='TDoff';}
function CrImgOn(id){ document.getElementById("CrI"+id).src='images/carr-on.png';  document.getElementById("CrTD"+id).className='TDon';}

function ScImgOff(id,s){ document.getElementById("ScI"+id).src='images/scheda_'+s+'.gif'; document.getElementById("ScTD"+id).className='TDoff';}
function ScImgOn(id){ document.getElementById("ScI"+id).src='images/scheda_on.gif'; document.getElementById("ScTD"+id).className='TDon';}

function CrrImgOff(id){ document.getElementById("CrrI"+id).src='images/cestino-off.gif'; document.getElementById("CrrTD"+id).className='TDoff';}
function CrrImgOn(id){ document.getElementById("CrrI"+id).src='images/cestino-on.gif';  document.getElementById("CrrTD"+id).className='TDon';}

function SchedaImgChange(bodys){ 
  var imgs=bodys.split("||");
  document.getElementById("Foto").style.background='url('+imgs[0]+') no-repeat center top';
  document.getElementById("Fotine").innerHTML=imgs[1];
}
function ShowFormDesty(id,id2) {
  var vall=document.getElementById(id2).value;
  var divv=document.getElementById(id);
  if(vall=='C2'){divv.style.display="block"}else{divv.style.display="none"}
}
function ShowHideRegme() {
  var rdo=document.getElementById('B2B2');
  var regm=document.getElementById('reg_mediv');
  if(rdo.checked==true){regm.style.display="block"}else{regm.style.display="none"}
}
function ShowHide(id) {
  var divv=document.getElementById(id);
  divv.style.display=(divv.style.display=="block") ? "none" : "block";
}
function PagBanca(url){window.location.href=url;}

function NewCliSubmit(){
  var ko=0; var kon=''; var err='';
  // Creazione oggetti dei campi 
  var nome_cognome=document.getElementById('nome_cognome');  var piva=document.getElementById('piva');
  var address=document.getElementById('address');  var citta=document.getElementById('citta');  var cap=document.getElementById('cap');
  var prov=document.getElementById('prov');  var e_mail=document.getElementById('e_mail'); var tel=document.getElementById('teln');
  var cons_carr=document.getElementById('cons_carr');
  // Controllo campi obbligatori
  if(nome_cognome.value==''){ko++; nome_cognome.style.background=ErrFld;}else{nome_cognome.style.background=OkFld;}
  if(piva.value==''){ko++; piva.style.background=ErrFld;}else{piva.style.background=OkFld;}
  if(address.value==''){ko++; address.style.background=ErrFld;}else{address.style.background=OkFld;}
  if(citta.value==''){ko++; citta.style.background=ErrFld;}else{citta.style.background=OkFld;}
  if(cap.value==''){ko++; cap.style.background=ErrFld;}else{cap.style.background=OkFld;}
  if(prov.value==''){ko++; prov.style.background=ErrFld;}else{prov.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;}
  // 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';}
  if(ko>1){lett='I campi indicati sono obbligatori o non sono stati compilati in modo corretto:\n\n';}

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

function NewReselSubmit(){
  var ko=0; var kon=''; var err='';
  // Creazione oggetti dei campi 
  var nome_cognome=document.getElementById('nome_cognome');  var piva=document.getElementById('piva');
  var address=document.getElementById('address');  var citta=document.getElementById('citta');  var cap=document.getElementById('cap');
  var prov=document.getElementById('prov');  var e_mail=document.getElementById('e_mail'); var tel=document.getElementById('teln');
  var cons_carr=document.getElementById('cons_carr');
  // Controllo campi obbligatori
  if(nome_cognome.value==''){ko++; nome_cognome.style.background=ErrFld;}else{nome_cognome.style.background=OkFld;}
  if(piva.value==''){ko++; piva.style.background=ErrFld;}else{piva.style.background=OkFld;}
  if(address.value==''){ko++; address.style.background=ErrFld;}else{address.style.background=OkFld;}
  if(citta.value==''){ko++; citta.style.background=ErrFld;}else{citta.style.background=OkFld;}
  if(cap.value==''){ko++; cap.style.background=ErrFld;}else{cap.style.background=OkFld;}
  if(prov.value==''){ko++; prov.style.background=ErrFld;}else{prov.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;}
  // 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';}
  if(ko>1){lett='I campi indicati sono obbligatori o non sono stati compilati in modo corretto:\n\n';}

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

// Funzione per la ricerca testuale
function KCerca(){
  if(document.getElementById('kcrc')){
    var kk=document.getElementById('kcrc').value;
	if(kk!=' cerca prodotto' && kk!=''){document.getElementById('fkcrc').submit();}else{alert('Scrivere il testo da cercare');}
  }else{alert('Il campo non esiste');}
}
// Mostra / nasconde un DIV con la modalità "display"
function DSwb(id,opz){
  var divx=document.getElementById(id).style.display=opz;
}
// Scarica il file indicato
function FileDown(id){
  window.location.href='fileareadlw.php?id='+id;
}

