
// funzione per il rollover delle immagini
browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);
var version = "n2";
if ((navigator.appCodeName == 'Mozilla') && (navigator.appVersion.substring(0,1)
> 2)) {
        version = "n3+";
        }
if ((navigator.appCodeName == 'MSIE') && (navigator.appVersion.substring(0,1) >
3)) {
        version = "n3+";
        }
if (version=="n3+")js=1;
 else js=0;
             if (js)
             {
             toc1on = new Image;
             toc1on.src = "img/b1on.jpg";
	        toc2on = new Image;
             toc2on.src = "img/b2on.jpg";
	        toc3on = new Image;
             toc3on.src = "img/b3on.jpg";
             toc4on = new Image;
             toc4on.src = "img/b4on.jpg";
             toc5on = new Image;
             toc5on.src = "img/b5on.jpg";
             toc6on = new Image;
             toc6on.src = "img/b6on.jpg";
             toc7on = new Image;
             toc7on.src = "img/b7on.jpg";

            
 
             toc1off = new Image;
             toc1off.src = "img/b1.jpg";
	        toc2off = new Image;
             toc2off.src = "img/b2.jpg";
	        toc3off = new Image;
             toc3off.src = "img/b3.jpg";     
             toc4off = new Image;
             toc4off.src = "img/b4.jpg";
             toc5off = new Image;
             toc5off.src = "img/b5.jpg";
             toc6off = new Image;
             toc6off.src = "img/b6.jpg";
             toc7off = new Image;
             toc7off.src = "img/b7.jpg";
          
             }
     function img_act(imgName)
     {
             if (js)
             {
             imgOn = eval(imgName + "on.src");
             document [imgName].src = imgOn;
             }
     }
     function img_inact(imgName)
     {
             if (js)
             {
             imgOff = eval(imgName + "off.src");
             document [imgName].src = imgOff;
             }
     }

// funzione di conferma eliminazione elemento

function conferma(valore,tipo)
{
  risposta=window.confirm("Si conferma l'eliminazione di tale " + tipo + "?")
  if (risposta)
    {
           document.location.href='cancella.php?tipo='+tipo+'&id=' + valore;
    }
  
}


// funzione per la conferma delll'inserimento di un nuovo elemento

function conferma_inserimento()
{
 var risposta=window.confirm("Si conferma l'inserimento del nuovo elemento?");
 if (risposta)
     return true;
 else
     return false;  
}


// funzione per la conferma del salvataggio delle modifiche effettuate

function conferma_modifiche()
{
 var risposta=window.confirm("Si confermano le modifiche effettuate?");


 if (risposta)
     return true;
 else
     return false;  
}



// funzione per l'apertura di una finestra di popup al centro dello schermo

function openNewWindow(thepage,thewname,wheigth,wweigth,scroll_,menu_,tool_,resize_)
{

   var aw = screen.availWidth;
   var ah = screen.availHeight;
       //window.resizeTo(aw,ah);
       //window.moveTo(0,0);
   var film_width = wweigth; 
   var film_heigth = wheigth;

       posW = (screen.availWidth/2)-(film_width/2);
       posH = (screen.availHeight/2)-(film_heigth/2);
               
      
       if(document.all)
          newWin = window.open(thepage,thewname,"toolbar="+tool_+",scrollbars="+scroll_+",menubar="+menu_+",resizable="+resize_+",height="+film_heigth+",width="+film_width+",left="+posW+",top="+posH);

       else
         newWin = window.open(thepage,thewname,"toolbar="+tool_+",scrollbars="+scroll_+",menubar="+menu_+",resizable="+resize_+",height="+film_heigth+",width="+film_width+",screenX="+posW+",screenY="+posH);
 
        newWin.focus();
}


function chkEmail(theform)
  {
   campo=theform.email;
   if(campo.value.length > 7 )
   {
   var stremail = campo.value;
   var result1 = stremail.indexOf("@");
   var result2 = stremail.indexOf(".");
   if(result1 < 0 || result2 < 0)
    {
     alert("Indirizzo email non valido!");
     campo.focus();
     campo.select();
     return false;
    }
   }
  else
   {
     alert("Indirizzo email non valido!");
     campo.focus(); 
     campo.select();
     return false;
   }
  }


function bigPhoto(img,cat)
 {
    openNewWindow('zoom.php?img='+img+'&cat='+cat,'win_image',350,600,'yes','no','no','yes');
 }


function MakeZoom(code)
{
   openNewWindow('scheda_prodotto.php?cod='+ code,'schedap',420,750,'yes');
}


function checkForm_c(theform)
{
 if ((theform.nome.value.length==0) || (theform.attivita.value.length==0) || (theform.email.value.length==0) || (theform.telefono.value.length==0))
   {
        alert("Inserire i campi obbligatori!");
        return false;
    }
 else
       return true;
}


function checkForm_f(theform)
{
 if ((theform.nome.value.length==0) || (theform.zona.value.length==0) || (theform.email.value.length==0) || (theform.telefono.value.length==0))
   {
        alert("Inserire i campi obbligatori!");
        return false;
    }
 else
       return true;
}

function checkForm_m(theform)
{
 if ((theform.nome.value.length==0) || (theform.cogn.value.length==0) || (theform.email.value.length==0) || (theform.comm.value.length==0))
   {
        alert("Tutti i campi sono obbligatori!");
        return false;
    }
 else
       return true;
}

// form di controllo del form di registrazione utente
function controlla_r(theform)
{

cont=0;
mess2="I seguenti campi sono obbligatori:\n";

if (theform.ragsoc.value.length == 0)
{
  mess2+="Nominativo\n";
  cont++;
}

if (theform.ind.value.length == 0){
  mess2+="Indirizzo\n";
  cont++;
}

if (theform.cap.value.length == 0){
  mess2+="CAP\n";
  cont++;
}

if (theform.loc.value.length == 0){
  mess2+="Città\n";
  cont++;
}

if (theform.prov.value.length == 0){
  mess2+="Provincia\n";
  cont++;
}

if (theform.tel.value.length == 0){
  mess2+="Telefono\n";
  cont++;
}

if (theform.login.value.length == 0){
  mess2+="Login\n";
  cont++;
}

if (theform.passwd.value.length == 0){
  mess2+="Password\n";
  cont++;
}

if ((theform.cfpiva.value!='') && (theform.cfpiva.value.length != 11) && (theform.cfpiva.value.length != 16)) 
{
window.alert ("Codice fiscale o partita iva errati!");
theform.cfpiva.focus();
return false;
}

if (cont != 0)
{
 window.alert (mess2);
 return false;
}
else
{
  var risposta=confirm("Confermi l'inserimento dei tuoi dati?");
  if (risposta)
      return true;
  else
      return false;
}
}
// fine form di registrazione utente web

function cancellatutto_c(theform)
{
 theform.nome.value="";
 theform.attivita.value="";
 theform.email.value="";
 theform.comunicazioni.value="";
 theform.tel.value="";
 theform.nome.focus();
}

function cancellatutto_f(theform)
{
 theform.nome.value="";
 theform.zona.value="";
 theform.email.value="";
 theform.comunicazioni.value="";
 theform.tel.value="";
 theform.nome.focus();
} 

function cancellatutto_m(theform)
{
 theform.nome.value="";
 theform.cogn.value="";
 theform.email.value="";
 theform.comm.value="";
 theform.nome.focus();
}

function cancellatutto_r(theform)
{
 theform.ragsoc.value="";
 theform.ind.value="";
 theform.cap.value="";
 theform.loc.value="";
 theform.prov.value="";
 theform.stato.value="";
 theform.tel.value="";
 theform.fax.value="";
 theform.cfpiva.value="";
 theform.email.value="";
 theform.login.value="";
 theform.passwd.value="";
 theform.indsped.value="";
 theform.ragsoc.focus();
}


// funzione per la stampa
function printit(){  
if (NS) {
    window.print() ;  
} else {
    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 = "";  
}
}

// funzione per la conferma dell'invio dell'ordine
function ConfermaInvio()
{
 var risposta=confirm("Inviare l'ordine a Fallimentisrl.com?");
 if (risposta)
  return true;
 else
  return false;
}

// funzione per il controllo della qtà inserita in fase di ordine

function ChkQty(valore,disponibilita)
{
  if (valore > disponibilita)
  {
   alert ("Quantità non disponibile!");
   return false;
  }
  else
  {
    return true;
  } 
}