// JavaScript Document
// Scripting by: andrea.bettoni@ideaup.com
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

MM_preloadImages('/immagini/testata_15_f2.png','/immagini/testata_17_f2.png','/immagini/testata_19_f2.png','/immagini/testata_20_f2.png','/immagini/testata_22_f2.png','/immagini/testata_24_f2.png','/immagini/testata_26_f2.png','immagini/testata/testata01_03_f2.jpg','immagini/testata/testata01_04_f2.jpg','immagini/testata/testata01_05_f2.jpg','immagini/testata/testata01_06_f2.jpg','immagini/testata/testata01_07_f2.jpg','immagini/testata/testata01_08_f2.jpg')

function maiuscola(cosa) {
document.modulocomm.provincia.value = cosa.toUpperCase();
}

function add(aux)
{
numero = parseInt(aux)
return parseInt(numero + 1);
}

function prendiElemento(quale) {
var elemento;
if(document.getElementById)
elemento = document.getElementById(quale);
else
elemento = document.all[quale];
return elemento;
}

function chiudiDiv(ilDiv) {
if(document.getElementById)
prendiElemento(ilDiv).style.display='none';
else
document.all[ilDiv].style.display='none';
}

function confermaOrdinazione(par,act,trig) {
var strEliminazione='\n\rEliminare completamente questa ordinazione?\n\r';
var strOrdinazione='\n\rProseguire con la procedura di ordinazione?\n\r';
var strAvvisoMinimo='\n\rL\'importo minimo di ordinazione è di 50.00 Euro\n\r';
var strAvvisoErrore='\n\rErrore del sistema...\n\rSiete pregati di riprovare più tardi...\n\r'
//if (parseInt(trig)<=50)    {
if (false)    {
alert(strAvvisoMinimo);
return false
} else {
	if (par == 1)    { 
document.riepilogo.action = act;
return confirm(strOrdinazione);
} else if (par == 2)  {  
document.riepilogo.action = act;
return confirm(strEliminazione);
} else { 
alert(strAvvisoErrore);
return false;
} 
	}
}

function die(dove,msg) {
	if (msg != null)    { 
strDoveVai = dove + "?item="+msg;
} else { 
strDoveVai = dove;
}
document.location.replace(strDoveVai);
} 

function cancellaTutto(act) {
var strEliminazione = '\n\rEliminare completamente questa ordinazione?\n\r';
document.ordinazione.action = act;
return confirm(strEliminazione);
} 

function addbookmark() {
url="http://www.casadellapelle.it/"
title="Casa della Pelle vendita on-line articoli in cuoio e medievali. "
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("\n\rPremere i tasti: CTRL+D (Netscape) oppure CTRL+T (Opera)\n\rPer aggiungere questo sito nei segnalibri...\n\r");
  }
}

function lostpwd() { 
larg=550; 
alt=160; 
toptop=30;//(screen.height/2)-(alt/2)
leftleft=30;//(screen.width/2)-(larg/2); 
searchWin = window. open('/lostpwd.htm','pwdwindow','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=no,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
} 

function popModulo() { 
larg=505; 
alt=550; 
toptop=(screen.height/2)-(alt/2)
leftleft=(screen.width/2)-(larg/2); 
searchWin = window. open('/_form/modulo.htm','formwindow','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=no,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
} 

function condizioni() { 
larg=640; 
alt=500; 
toptop=(screen.height/2)-(alt/2); 
leftleft=(screen.width/2)-(larg/2); 
window.open('condizioni.htm','legalPop','top='+toptop+',left='+leftleft+',width='+larg+',height='+alt+',scrollbars=yes,status=no,location=no,toolbar=no'); 
} 

function istruzioni() { 
larg=640; 
alt=550; 
toptop=(screen.height/2)-(alt/2); 
leftleft=(screen.width/2)-(larg/2); 
window.open('istruzioni.htm','legalPop','top='+toptop+',left='+leftleft+',width='+larg+',height='+alt+',scrollbars=yes,status=no,location=no,toolbar=no'); 
} 

function popImg(ImgSrc) { 
var imgToPop = "zoom.asp?src=" + ImgSrc  ;
larg = 20;
alt = 20;
toptop= (screen.height/2)-(alt/2);
leftleft=(screen.width/2)-(larg/2); 
window.open(imgToPop,'imgpopwindow','top='+toptop+',left='+leftleft+',scrollbars=no,resizable=no,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
} 

function demo(msg) { //v1.0
  alert(msg);
}


function conferma(z) { // richiede all'utente conferma dell'azione
if ((z == '')||(z == undefined)) z = '\r\nSiete sicuri di voler eliminare l\'articolo selezionato?\r\n';
  return confirm(z);
}



function doEmail(aux)     {  
var emailriddlerarray=[105,110,102,111,64,99,97,115,97,100,101,108,108,97,112,101,108,108,101,46,105,116]
var encryptedemail_id19='' //variable to contain encrypted email 
for (var i=0; i<emailriddlerarray.length; i++)
 encryptedemail_id19+=String.fromCharCode(emailriddlerarray[i])
document.write('<a href="mailto:'+encryptedemail_id19+'?subject=Richiesta dal sito web...">'+encryptedemail_id19+'</a>')

}

function doEmailWebmaster()     { 
var emailriddlerarray=[97,110,100,114,101,97,46,98,101,116,116,111,110,105,64,119,101,98,97,110,100,115,116,121,108,101,46,99,111,109]
var encryptedemail_id94='' //variable to contain encrypted email 
for (var i=0; i<emailriddlerarray.length; i++)
encryptedemail_id94+=String.fromCharCode(emailriddlerarray[i])
document.write('<a href="mailto:'+encryptedemail_id94+'?subject=Richiesta di assistenza dal sito Casa della Pelle...">'+encryptedemail_id94+'</a>')
}

var isNav4, isIE4;
isNav4 = (navigator.appName.indexOf("Netscape") != -1) ? 1 : 0;
isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;

function controlla() {
if (isNav4) {
window.innerWidth = (document.images[0].width +5);
window.innerHeight = (document.images[0].height+5);
}
if (isIE4) {
window.resizeTo(505, 505);
width = 500 - (document.body.clientWidth -  document.images[0].width);
height = 340 - (document.body.clientHeight -  document.images[0].height);
//width = (document.images[0].width + 20);
//height = (document.images[0].height +20);
window.resizeTo(width, height);
   }
}

function privacy() { 
larg=480; 
alt=400; 
toptop=(screen.height/2)-(alt/2); 
leftleft=(screen.width/2)-(larg/2); 
window.open('privacy.htm','privacyPop','top='+toptop+',left='+leftleft+',width='+larg+',height='+alt+',scrollbars=yes,status=no,location=no,toolbar=no'); 
} 

function popForm() { 
larg=480; 
alt=350; 
toptop=(screen.height/2)-(alt/2); 
leftleft=(screen.width/2)-(larg/2); 
window.open('','popForm','top='+toptop+',left='+leftleft+',width='+larg+',height='+alt+',scrollbars=yes,status=no,location=no,toolbar=no'); 
} 

function seleziona(id) {
  if (!document.getElementById) return;
  selDiv = document.getElementById(id);
  selDiv.style.color = "#FF0000";
	selDiv.style.fontWeight = "Bold";
}

function deseleziona(id) {
  if (!document.getElementById) return;
  selDiv = document.getElementById(id);
		selDiv.style.color = "#000000";
		selDiv.style.fontWeight = "Normal";
}


function checkLogin() {
if ((document.loginform.nome_utente.value != "")&&(document.loginform.password_utente.value != "")) {
return true
} else {
alert('Inserite un nome e una password validi!!');
document.loginform.password_utente.value='';
document.loginform.nome_utente.select();
return false 
}
}

function checkFields() {
missinginfo = "";
if (document.modulocomm.nomeazienda.value == "") {
missinginfo += "\n     -  Nome ";
}
//if (document.modulocomm.settore.value == "") {
//missinginfo += "\n     -  Settore merceologico";
//}
if (document.modulocomm.responsabile.value == "") {
missinginfo += "\n     -  Cognome";
}
if (document.modulocomm.indirizzo.value == "") {
missinginfo += "\n     -  Indirizzo";
}
if (document.modulocomm.city.value == "") {
missinginfo += "\n     -  Città";
}
if (document.modulocomm.provincia.value == "") {
missinginfo += "\n     -  Provincia";
}
if (document.modulocomm.cap.value == "") {
missinginfo += "\n     -  C.A.P.";
}
if (document.modulocomm.telefono.value == "") {
missinginfo += "\n     -  Telefono";
}
if ((document.modulocomm.email.value == "") || (document.modulocomm.email.value.indexOf('@') == -1) || (document.modulocomm.email.value.indexOf('.') == -1)) {
missinginfo += "\n     -  E-mail";
}
if (document.modulocomm.dettaglio.value == "") {
missinginfo += "\n     -  Dettaglio richiesta informazioni";
}
if (missinginfo != "") {
missinginfo2 = "Non avete inserito i seguenti dati obbligatori:\n" ;
missinginfo2 += missinginfo ;
alert(missinginfo2);
return false
}
else {
strUrl="/_form/send";
strUrl+="mail.asp?x=1"
document.modulocomm.action=strUrl;
document.modulocomm.submit();
//return true
}
}