// 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/Nav_r2_c1_f2.gif','immagini/Nav_r4_c1_f2.gif','immagini/Nav_r6_c1_f2.gif','immagini/Nav_r8_c1_f2.gif','immagini/Nav_r10_c1_f2.gif','immagini/Nav_r12_c1_f2.gif','immagini/Nav_r14_c1_f2.gif');

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 stampausato(idveicolo,marca,titolo) { 
if ((idveicolo!='')&&(marca!='')&&(titolo!='')) {
urlToGo='/auto_usate_scheda.asp?id='+idveicolo+'&marca='+marca+'&modello='+tiolo;
larg=850; 
alt=590; 
toptop=(screen.height/2)-(alt/2)
leftleft=(screen.width/2)-(larg/2); 
window.open(urlToGo,'printwindow','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
} else { 
alert('ERRORE: DATI NON VALIDI!!');
return false
}
} 


function stampakmzero(idveicolo,marca,titolo) { 
if ((idveicolo!='')&&(marca!='')&&(titolo!='')) {
urlToGo='/auto_usate_scheda_stampa.asp?id='+idveicolo+'&marca='+marca+'&modello='+tiolo;
larg=850; 
alt=590; 
toptop=(screen.height/2)-(alt/2)
leftleft=(screen.width/2)-(larg/2); 
window.open(urlToGo,'printwindow','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
} else { 
alert('ERRORE: DATI NON VALIDI!!');
return false
}
} 
*/

function die(dove,msg) {
	if (msg != null)    { 
strDoveVai = dove + "?item="+msg;
} else { 
strDoveVai = dove;
}
document.location.replace(strDoveVai);
} 

function addbookmark() {
url="http://www.laterza.com/"
title="Concessionaria FIAT LANCIA ALFA ROMEO - auto usate e a Km Zero"
  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('/_form/privacy.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 demo(msg) { //v1.0
  alert(msg);
}


function doEmail(aux)     {  
var emailriddlerarray=[105,110,102,111,64,108,97,116,101,114,122,97,46,99,111,109]
var encryptedemail_id22='' //variable to contain encrypted email 
for (var i=0; i<emailriddlerarray.length; i++)
 encryptedemail_id22+=String.fromCharCode(emailriddlerarray[i])
document.write('<a href="mailto:'+encryptedemail_id22+'?subject=Richiesta dal sito web...">'+encryptedemail_id22+'</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>')
}

function privacy() { 
larg=480; 
alt=400; 
toptop=(screen.height/2)-(alt/2); 
leftleft=(screen.width/2)-(larg/2); 
window.open('/_form/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 (document.modulocomm.privacy.checked == false ) {
missinginfo += "\n     -  Dovete accettare l\'informativa sulla privacy\n        selezionando l\'apposita casella...";
}
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
}
}
