///////////////////////////////////FUNCTIONS JS//////////////////////////////////////
function fixPNG(myImage,w,h) // correctly handle PNG transparency in Win IE 5.5 or higher.
   {
   	 var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	 var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	 var imgTitle = (myImage.title) ? "title='" + myImage.title + "' " : "title='" + myImage.alt + "' "
	 var imgStyle = "display:inline-block;" + myImage.style.cssText 
	 var strNewHTML = "<span " + imgID + imgClass + imgTitle
	 strNewHTML += " style=\"" + "width:" + w + "px; height:" + h + "px;" + imgStyle + ";"
	 strNewHTML += "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
	 strNewHTML += "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>" 
	 myImage.outerHTML = strNewHTML
   }
   
function privacy() 
   {
open("util/privacy.htm","privacy","width=450,height=250,status=0,scrollbars=0")
   }
   
   
function admin() 
   {
open("admin/login.asp","admin","width=850,height=700,status=0,scrollbars=0")
   }
   
   
function insert() {
new_w=window.open("ins2.asp","insert","width=600,height=650,status=1,scrollbars=1");
new_w.focus()
}

function popnews(x) {
open("popnews.asp?idnews="+x,"popnews","width=450,height=450,status=0")
}
   
function privacy() {
open("util/privacy.htm","privacy","width=450,height=250,status=0,scrollbars=0")
}

//function stampa() {
//window.print()
//}

function confronta_print() {
open("confronta_print.asp","confronta_print","width=650,height=500,status=0,scrollbars=1")
}

function confronta_print_riv() {
open("confronta_print_riv.asp","confronta_print","width=650,height=500,status=0,scrollbars=1")
}

function park(x) {
if (document.all || document.getElementById) {
x.innerHTML="<p style='margin-top: 2; margin-bottom: 0' onmouseover='showlay(1)' onmouseout='showlay(0)'><img src=img/ListatoAuto/parcheggioSi.gif border='0'></p>"
}
}


function showlay(n) {
x=document.body.scrollLeft + event.clientX
y=document.body.scrollTop + event.clientY
lay1.style.posLeft=x;
lay1.style.posTop=y;
if ((document.all || document.getElementById) && n==1) {
lay1.style.visibility="visible";
}
if ((document.all || document.getElementById) && n==0) {
lay1.style.visibility="hidden";
}
}

function showlay2(n) {
x=document.body.scrollLeft + event.clientX
y=document.body.scrollTop + event.clientY
lay2.style.posLeft=x;
lay2.style.posTop=y;
if ((document.all || document.getElementById) && n==1) {
lay2.style.visibility="visible";
}
if ((document.all || document.getElementById) && n==0) {
lay2.style.visibility="hidden";
}
}


//////////////////////////////SCHEDA   

function stampa(par,par2,par3) {
if (par3==3) {
	if (par2==1) {
		open('print_riv_prev.asp?id_modello='+par+'&foto=1','stampaprev','width=650,height=600,status=0,scrollbars=1')
	}
}
else if (par3==2) {
	if (par2==1) {
		open('admin/print_riv_prev.asp?id_modello='+par+'&foto=1','stampa','width=650,height=600,status=0,scrollbars=1')
	}
	else if (par2==0) {
		open('admin/print_riv_prev.asp?id_modello='+par+'&foto=0','stampa','width=650,height=600,status=0,scrollbars=1')
	}
}
else if (par3==1) {
	if (par2==1) {
		open('admin/print.asp?id_modello='+par+'&foto=1','stampa','width=650,height=600,status=0,scrollbars=1')
	}
	else if (par2==0) {
		open('admin/print.asp?id_modello='+par+'&foto=0','stampa','width=650,height=600,status=0,scrollbars=1')
	}
}
}



function info(par) {
open('info.asp?id_modello='+par,'info','width=500,height=545,status=1,scrollbars=1')
}
function prova(par) {
open('prova.asp?id_modello='+par,'prova','width=500,height=555,status=0,scrollbars=1')
}
function noleggio(par) {
open('noleggio.asp?id_modello='+par,'noleggio','width=500,height=545,status=0,scrollbars=0')
}
function permuta(par) {
open('permuta.asp?id_modello='+par,'permuta','width=500,height=500,status=0,scrollbars=1')
}
function finanziamento(par) {
open('finanziamento.asp?id_modello='+par,'finanziamento','width=500,height=500,status=0,scrollbars=1')
}
function inviamico(par) {
open('inviamico.asp?id='+par,'inviamico','width=500,height=450,status=0,scrollbars=1')
}
function confronto(id,modello) {
open('confronto.asp?id_modello='+id+'&modello='+modello,'conronto','width=650,height=535,status=0,scrollbars=0')
}
function pop_foto(x) {
open("img_scheda.asp?id="+x,"img_foto","width=580,height=610,status=0,scrollbars=0")
}

function parkscheda() {
if (document.all || document.getElementById) {
parcheggio.innerHTML="<span style='color:cccc00;padding-left:5px'>Veicolo parcheggiato</span>"
}
}
////////////////////////////////////

valoreglobal="";
function setCookie(sNome, sValore, iGiorni, valore) {
//alert(sNome+sValore+iGiorni+valore)
  if (valoreglobal.indexOf("_" + sValore + "_")!=-1) {
  alert("Veicolo gi&agrave; parcheggiato")
  }
  
  else {
  var dtOggi = new Date()
  var dtExpires = new Date()
  dtExpires.setTime(dtOggi.getTime() + 24 * iGiorni * 3600000)
  if (valoreglobal!='') {
  valoreglobal+='_' + sValore
  //alert(valoreglobal)
  }
  else  {
  valoreglobal='_' + sValore
  //alert("valore 1")
  }
  document.cookie = sNome + "=" + escape(valoreglobal) + "_" + "; expires=" + dtExpires.toGMTString();
}

// restituisce il valore del cookie sNome
function getCookie(sNome) {
  // genera un array di coppie "Nome = Valore"
  // NOTA: i cookies sono separati da ';'
  var asCookies = document.cookie.split("; ");
  // ciclo su tutti i cookies
  for (var i = 0; i < asCookies.length; i++)
  {
    // leggo singolo cookie "Nome = Valore"
    var asCookie = asCookies[i].split("=");
    if (sNome == asCookie[0]) { 
      return (unescape(asCookie[1]));
    }
  }

  // SE non esiste il cookie richiesto
  return("");
}
}


/////////////////////////////////////////////////////////////////////////
function ctrlform(nomeform) {
df=document.forms[nomeform];
//alert(nomeform)
if (nomeform=="richiesta") {
	if (df.elements["modello"].value=="") {
	alert('Attenzione: modello non inserito')
	return false
	}
}
if (nomeform=="rivenditori") {
	if (df.elements["azienda"].value=="") {
	alert('Attenzione: nome azienda non inserito')
	return false
	}
	if (df.elements["piva"].value=="") {
	alert('Attenzione: P.IVA non inserita')
	return false
	}
}
if (nomeform=="contatti" || nomeform=="richiesta") {
	if (df.elements["nome"].value=="") {
	alert('Attenzione: Nome non inserito')
	return false
	}
	if (df.elements["cognome"].value=="") {
	alert('Attenzione: Cognome non inserito')
	return false
	}
}
if (nomeform=="contatti") {
	if (df.elements["citta"].value=="") {
	alert('Attenzione: Citta\' non inserita')
	return false
	}
}
if (df.elements["tel"].value=="") {
alert('Attenzione: Numero di telefono non inserito')
return false
}
if (isNaN(df.elements["tel"].value)) {
alert('Attenzione: Numero di telefono non valido')
return false
}
if (df.elements["mail"].value=="") {
alert('Attenzione: eMail non inserita')
return false
}
if (df.elements["mail"].value.indexOf("@")==-1) {
alert('Attenzione: eMail non valida')
return false
}
if (nomeform=="rivenditori") {
	if ((df.elements["passw"].value=="") || (df.elements["passw"].value.length<6) || (df.elements["passw"].value.length>10)) {
	alert('Attenzione: password non valida')
	return false
	}
}
if (!df.elements["privacy"].checked) {
alert('Attenzione: e\' necessario autorizzare il trattamento dei dati personali');
return false
}
}


function control_chk(nomeform) {
df=document.forms[nomeform];
if (!df.elements["privacy"].checked) {
alert('Attenzione: disabilitando questo campo la richiesta non verra\' inviata')
}
}


////////////////////////////////////////////////////////////////////////////////////////////

function messaggio() {
open("messaggio.asp","messaggio","width=400,height=400,status=0")
}

////////////////////////////////////////////////////////////////////////////////////

function linkpop(x) {
	if(x=="capellidonna"){
	open("pop_capellidonna.htm","_blank","width=500,height=400,scrollbars=1")
	}
	if(x=="approccio"){
	open("pop_approccio.htm","_blank","width=500px,height=515px,scrollbars=1")
	}
	if(x=="psoriasi"){
	open("pop_psoriasi.htm","_blank","width=500,height=580,scrollbars=1")
	}
	if(x=="crescitacapelli"){
	open("pop_crescitacapelli.htm","_blank","width=500,height=600,scrollbars=1")
	}
	if(x=="calvizia"){
	open("pop_calvizia.htm","_blank","width=500,height=580,scrollbars=1")
	}
	if(x=="trapianto"){
	open("pop_trapianto.htm","_blank","width=500px,height=580px,scrollbars=1")
	}
	if(x=="intervento"){
	open("pop_intervento.htm","_blank","width=500,height=535,scrollbars=1")
	}
	if(x=="post_operazione"){
	open("pop_post_operazione.htm","_blank","width=500,height=465,scrollbars=1")
	}
}

