// aggiustamento campo form "CERCA" per Firefox
/*
window.onload=function () { 
  if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent))
  {
    D=document.getElementById('MFinput')
    D.style.top='-1px';
  }
}
*/

function showHideClasseEnergeticaRow(campo){
									
if(campo==1 || campo == 3){
	classe_energetica_row1.style.display='block';
	classe_energetica_row2.style.display='block';
	}else{
		classe_energetica_row1.style.display='none';
		classe_energetica_row2.style.display='none';
		}
}
// funzione per impostare il sito come Homepage (IE)
function impostahomepage(sito) { 
  if(document.all)
  {
    document.body.style.behavior='url(#default#homepage)';
    document.body.setHomePage(sito);
    confirm('Il sito '+sito+' ora è impostato come homepage.');
  }
  else
  {
    alert('Il browser che stai utilizzando non supporta questa funzione!');
  }
} 

// controllo form chat
function controlla() //controllo campi vuoti
{
  var nick = document.chatform.n.value;
    
    if ((nick=="")||(nick=="Nickname")) 
    { 
      alert("Inserisci un nickname!");
      return false;
    }
}

// controllo form annunci
function controllo() //controllo campi vuoti
    {
    var tipocli = document.form1.tipocli.value;
    var nome = document.form1.nome.value;
    var cognome = document.form1.cognome.value;
    var indirizzo = document.form1.indirizzo.value;
    var civico = document.form1.civico.value;
    var cap = document.form1.cap.value;
    var citta = document.form1.citta.value;
    var telefono = document.form1.telefono.value;
    var email = document.form1.email.value;
    var categoria = document.form1.categoria.value;
    var sottocategoria = document.form1.sottocategoria.value;
    var cartaidentita = document.form1.cartaidentita.value;
    var tipo = document.form1.tipo.value;
    var titolo = document.form1.titolo.value;
    var testo = document.form1.testo.value;
    
    if ((cartaidentita=="")&&(sottocategoria==""))
        {
        alert("Attenzione: tutti i campi sono obbligatori!");
        return false;
        }
    else if ((tipocli=="")||(nome=="")||(cognome=="")||(indirizzo=="")||(civico=="")||(cap=="")||(citta=="")||(telefono=="")||(email=="")||(categoria=="")||(tipo=="")||(titolo=="")||(testo=="")) 
        { 
        alert("Attenzione: tutti i campi sono obbligatori!");
        return false;
        }
    else
        {
        Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
        if (!(Filtro.test(email)))
            {
            alert("Per favore inserisci un indirizzo Email corretto!");
            return false;
            }
        }
    }

// programmino per generare numeri del Lotto (SONO VINCENTI DAVVERO!!!!!!)
function genera() {
  var a = Math.round((15-01) * Math.random() + 01);
  var b = Math.round((30-16) * Math.random() + 16);
  var c = Math.round((45-31) * Math.random() + 31);
  var d = Math.round((60-46) * Math.random() + 46);
  var e = Math.round((75-61) * Math.random() + 61);
  var f = Math.round((90-76) * Math.random() + 76);
  var numeri = a+" | "+b+" | "+c+" | "+d+" | "+e+" | "+ f;
  //  alert(a+" | "+b+" | "+c+" | "+d+" | "+e+" | "+ f);
  var ruota = new Array();
  ruota[0] = "Milano";
  ruota[1] = "Torino";
  ruota[2] = "Venezia";
  ruota[3] = "Genova";
  ruota[4] = "Firenze";
  ruota[5] = "Roma";
  ruota[6] = "Bari";
  ruota[7] = "Napoli";
  ruota[8] = "Palermo";
  ruota[9] = "Cagliari";
  var x = Math.round(9 * Math.random());
  //  alert(ruota[x]);
  document.getElementById('numeri_lotto').value=numeri;
  document.getElementById('ruota').value="La ruota su cui giocare è: "+ruota[x];
}

// programmino per generare una combinazione al totocalcio
function generatot() 
{
  pron="0";
	document.getElementById('tit').innerHTML="E' stato elaborato in modo casuale il seguente pronostico Totocalcio:";
  document.getElementById('risultato').style.display='block';
  document.form.risultato.value="";
  for(x=0;x<13;x++) 
  {
		t=Math.round(Math.random()*99)+1;
    if (t>=1 && t<=45) {
			p="1";
		}
		if(t>=46 && t<=80) {
			p="X";
		}
		if(t>=81 && t<=100) {
			p="2";
		}
    document.form.risultato.value=document.form.risultato.value+" "+p;
	}
}

// Funzione per aprire l'immagine con pop-up
function apriimg(imgurl,titolo)
  {
    	i1 = new Image;
    	i1.src = imgurl;
    	html = '<HTML>\n<HEAD>\n<TITLE>'+titolo+'</TITLE>\n</HEAD>\n<BODY style="margin:0;" BGCOLOR=#FFFFFF>\n<CENTER><IMG SRC="'+imgurl+'" BORDER=0 NAME=imageTest onLoad="window.resizeTo(document.imageTest.width+20,document.imageTest.height+70)"></CENTER>\n</BODY>\n</HTML>';
    	popupImage = window.open('','_blank','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=0');
    	popupImage.document.open();
    	popupImage.document.write(html);
    	popupImage.document.close()
  }
  
// Funzione per aprire il box ASPETTI LEGALI
function apri_mini_popup()
  {
    if(document.getElementById)
    {
      document.getElementById('mini_popup').style.display='block';
    }
    else
    {
      document.all['mini_popup'].style.display='block';
    }
  }
function chiudi_mini_popup()
  {
    if(document.getElementById)
    {
      document.getElementById('mini_popup').style.display='none';
    }
    else
    {
      document.all['mini_popup'].style.display='none';
    }
  }
