var vecchio_top;
var num_sub;
var selezionato = 0;
var selezionato_old = 0;
var b_ver = 0;
var submenu_sel = "";
var vecchio_mese = "agosto";
var vecchio_pallino = "foto1";
var vecchio_oggetto = "";
var vecchio_oggetto_az = "";
var vecchio_sub_oggetto = "";
var lista = new Array("", "azienda", "prodotti", "press", "news", "designer");
var selezionato_scorta = 0;
var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;


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];}
}


function cambiafestivita(pagina){	
	load(pagina,'aperturefestive');
}
function cambiastriscia(pagina){	
	load(pagina,'striscia');
}
function cambiaPop(pagina){	
	load(pagina,'pop1');
}
function cambiacapitoli(pagina){	
	load(pagina,'capitoli');
}
function cambiasecondomenu(pagina){	
	load(pagina,'secondomenu');
}
function cambiacapitstris(pagina1,pagina2)
{	
	paginacapit = pagina1;
	paginastris = pagina2;
	//alert (paginacapit + "   " + paginastris);
	cambiacapitoli(paginacapit);
	//setTimeout("cambiacapitoli(paginacapit)", 200);
	//cambiastriscia(paginastris);
	setTimeout("cambiastriscia(paginastris)", 200);
}
function cambianegofestivi(pagina1,pagina2)
{	
	paginanego = pagina1;
	paginastris = pagina2;
	var data = new Date()
	meseattuale = data.getMonth();
	//alert (meseattuale);	
	  switch (meseattuale)
  	  {
 		//i mesi sono calcolati da 0 a 11
 		case 0 :
        	paginastris = "aperturafestivaGEN.html"
        	break;
     	case 1 :
        	paginastris = "aperturafestivaFEB.html"
        	break;
      	case 2 :
        	paginastris = "aperturafestivaMAR.html"
        	break;
     	case 3 :
        	paginastris = "aperturafestivaAPR.html"
        	break;		
      	case 4 :
        	paginastris = "aperturafestivaMAG.html"
        	break;
      	case 5 :
       	 	paginastris = "aperturafestivaGIU.html"
        	break;
      	case 6 :
        	paginastris = "aperturafestivaLUG.html"
        	break;
     	case 7 :
        	paginastris = "aperturafestivaAGO.html"
        	break;
     	case 8 :
        	paginastris = "aperturafestivaSET.html"
        	break;
      	case 9 :
        	paginastris = "aperturafestivaOTT.html"
        	break;
     	case 10 :
        	paginastris = "aperturafestivaNOV.html"
        	break;		
      	case 11 :
        	paginastris = "aperturafestivaDIC.html"
        	break;
  	  }
	//alert (paginanego + "   " + paginastris);
	cambiasecondomenu(paginanego);
	//setTimeout("cambiasecondomenu(paginanego)", 200);
	//cambiastriscia(paginastris);
	setTimeout("cambiastriscia(paginastris)", 200);
}

function cambianegostris(pagina1,pagina2)
{	
	paginanego = pagina1;
	paginastris = pagina2;
	//alert (paginanego + "   " + paginastris);
	cambiasecondomenu(paginanego);
	//setTimeout("cambiasecondomenu(paginanego)", 200);
	//cambiastriscia(paginastris);
	setTimeout("cambiastriscia(paginastris)", 200);
}

function cambiainfo(pagina){	
	load(pagina,'infoauto');
}

function cambiamap(pagina){	
	load(pagina,'infomap');
}

function cambiainfoauto(pagina1,pagina2)
{	
	paginainfo = pagina1;
	paginamap = pagina2;
	//alert (paginanego + "   " + paginastris);
	cambiainfo(paginainfo);
	//setTimeout("cambiasecondomenu(paginanego)", 200);
	//cambiastriscia(paginastris);
	setTimeout("cambiamap(paginamap)", 200);
}

// JavaScript Document


function ahah(url, target) {
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {ahahDone(url, target);};
    req.open("GET", url, true);
    req.send("");
  }
}  

function ahahDone(url, target) {
 if (req.readyState == 4) { // only if req is "complete"
    if (req.status == 200) { // only if "OK"
	  document.getElementById(target).innerHTML = req.responseText;
    } else {
      document.getElementById(target).innerHTML=" Errore caricamento pagina:\n"+ req.status + "\n" +req.statusText;
    }
  }
}

function load(name, div) {
	ahah(name,div);
	return false;
}

function mouseOut(oggetto){
	if (document.getElementById(oggetto).className != 'menured') {
		document.getElementById(oggetto).className = 'menu';
	}
}
function mouseIn(oggetto){
if (oggetto.substring(0,4) != 'menu') {
		if (document.getElementById(oggetto).className != 'menured') {
			document.getElementById(oggetto).className = 'menured12';
		}
	}
}

function mouseOut2(oggetto){
//alert (oggetto);
if (document.getElementById(oggetto).className = 'menured') {
		document.getElementById(oggetto).className = 'menu9';
	}
}
function mouseIn2(oggetto){
//if (oggetto.substring(0,4) != 'menu') {
//alert (oggetto);
if (document.getElementById(oggetto).className = 'menu9') {
			document.getElementById(oggetto).className = 'menured';
		}
//	}
}

function mouseOut3(oggetto){
//alert (oggetto);
	document.getElementById("lavoraconnoi").className = 'menu';
}
function mouseIn3(oggetto){
//alert (oggetto);
	document.getElementById("lavoraconnoi").className = 'menured12';
}


function mouseClick(oggetto){
	document.getElementById(oggetto).className = 'menured';
	if (document.getElementById(vecchio_oggetto) != null && oggetto != vecchio_oggetto) {
		document.getElementById(vecchio_oggetto).className = 'menu';
	}
	vecchio_oggetto = oggetto;
}



function cambiaImm(foto, nomeoggetto)
{
	var imma=new Image(10,5);
	imma.src=foto;
	var theImg=document.getElementById(nomeoggetto);
	theImg.setAttribute("src",foto);
}

function mouseOutFoto(oggetto){
	if (document.getElementById(oggetto).className != 'menu') {
		document.getElementById(oggetto).className = 'menubold';
	}
}

function mouseInFoto(oggetto){
	if (document.getElementById(oggetto).className != 'menu16') {
		document.getElementById(oggetto).className = 'menu16';
	}
}
function mouseInFoto2(oggetto){
	if (document.getElementById(oggetto).className != 'menu16') {
		document.getElementById(oggetto).className = 'menu16';
	}
}

function mouseClickFoto(oggetto){
	if (document.getElementById(vecchio_pallino) != null && oggetto != vecchio_pallino) {
		document.getElementById(vecchio_pallino).className = 'menu16';
	}
	document.getElementById(oggetto).className = 'menu16';
	vecchio_pallino = oggetto;
}

	function ControllaCampi()
	{	var testo;
		var genere;
		var infook;
		if (document.getElementById("nome").value == "" )
		{	alert ("Compilare il campo 'Nome'");
			return;
		}
		if (document.getElementById("cognome").value == "" )
		{	alert ("Compilare il campo 'Cognome'");
			return;
		}
		if (document.getElementById("mailmittente").value == "" )
		{	alert ("Compilare il campo 'Indirizzo E-mail'");
			return;
		}
		genere = " "
		for (i=0;i<document.form1.gr1.length;i++)
		{	if (document.form1.gr1[i].checked)
			{	genere = genere + (" <br>" + document.form1.gr1[i].value);
				//alert (document.form1.gr1[i].value);
			}
		}
		if (genere == " " )
		{	alert ("Scegliere almeno un argomento di richiesta");
			return;
		}
		if (document.getElementById("accetto").checked)
		{	infook = (document.getElementById("accetto").value);
		} else
		{	alert ("Informativa art.13 D.Lgs.196/03: accettazione obbligatoria");
			return;
		}
		testo = ("<br> Nome: <b>" +  document.getElementById("nome").value + "</b>");
		testo = testo + (" <br>Cognome: <b>" +  document.getElementById("cognome").value + "</b>");
		testo = testo + (" <br>Indirizzo E-mail: <b>" +  document.getElementById("mailmittente").value + "</b>");
		testo = testo + (" <br>Per cortesia, inviatemi informazioni su: <b>" +  genere + "</b>");
		testo = testo + (" <br>Informativa ai sensi dell'articolo 13 del D.Lgs. 196/03: <b>" +  infook + "</b>");
		//alert (testo);
		document.getElementById("testo").value = testo;
		document.getElementById("mittente").value = document.getElementById("mailmittente").value;
		document.form2.submit();
	}

	function ControllaCampi2()
	{	var testo;
		if (document.getElementById("suggerimenti").value == "" )
		{	alert ("Inserire un testo");
			return;
		}
		if (document.getElementById("mailmittente2").value == "" )
		{	alert ("Compilare il campo 'Indirizzo e-mail'");
			return;
		}
		testo = ("<br><b>" +  document.getElementById("suggerimenti").value + "</b>");
		testo = testo + (" <br>Indirizzo E-mail: <b>" +  document.getElementById("mailmittente2").value + "</b>");
		document.getElementById("testo").value = testo;
		document.getElementById("mittente").value = document.getElementById("mailmittente2").value;
		document.form3.submit();
	}
	
	function ControllaCampi3()
	{	var testo;
		var negozi;
		var infook;
		if (document.getElementById("nome").value == "" )
		{	alert ("Compilare il campo 'Nome'");
			return;
		}
		if (document.getElementById("cognome").value == "" )
		{	alert ("Compilare il campo 'Cognome'");
			return;
		}
		if (document.getElementById("mailmittente").value == "" )
		{	alert ("Compilare il campo 'Indirizzo E-mail'");
			return;
		}
		negozi = " "
		for (i=0;i<document.form1.gr1.length;i++)
		{	if (document.form1.gr1[i].checked)
			{	negozi = negozi + (" <br>" + document.form1.gr1[i].value);
				//alert (document.form1.gr1[i].value);
			}
		}
		if (negozi == " " )
		{	alert ("Scegliere almeno un negozio");
			return;
		}
		if (document.getElementById("accetto").checked)
		{	infook = (document.getElementById("accetto").value);
		} else
		{	alert ("Informativa art.13 D.Lgs.196/03: accettazione obbligatoria");
			return;
		}
		testo = ("<br> Nome: <b>" +  document.getElementById("nome").value + "</b>");
		testo = testo + (" <br>Cognome: <b>" +  document.getElementById("cognome").value + "</b>");
		testo = testo + (" <br>Indirizzo E-mail: <b>" +  document.getElementById("mailmittente").value + "</b>");
		testo = testo + (" <br>Sono disponibile a impiegarmi presso uno dei seguenti punti vendita: <b>" +  negozi + "</b>");
		testo = testo + (" <br>Ruolo proposto: <b>" +  document.getElementById("ruolo").value + "</b>");		
		testo = testo + (" <br>Informativa ai sensi dell'articolo 13 del D.Lgs. 196/03: <b>" +  infook + "</b>");
		//alert (testo);
		document.getElementById("testo").value = testo;
		document.getElementById("mittente").value = document.getElementById("mailmittente").value;
		document.form2.submit();
	}	