function aprifin(nome,titolo,larghezza,altezza,ridim,scrolla)	{
	centroX=(screen.width-larghezza)/2
	centroY=(screen.height-altezza)/2
	afin=window.open(nome,titolo,"width="+larghezza+",height="+altezza+",resizable="+ridim+",scrollbars="+scrolla+",screenX="+centroX+",left="+centroX+",screenY="+centroY+",top="+centroY);
	afin.focus();
}
function setVariables(){
	px="+'px'";
	if (navigator.appName == "Netscape") {
		if (parseInt(navigator.appVersion) >= 5){
			v=".top=";
			h=".left=";
			dS="document.getElementById(\"";
			sD="\").style";
			y="window.pageYOffset-400";
			x="window.pageXOffset";
		}
		else {
			v=".top=";
			h=".left=";
			dS="document.";
			sD="";
			y="window.pageYOffset-400";
			x="window.pageXOffset";
			px="";
		}
	}
	else {
		var validDoc=(document.compatMode && document.compatMode != "BackCompat")?1:0;
		h=".left=";
		v=".top=";
		dS="";
		sD=".style";
		y=(validDoc)?"document.documentElement.scrollTop":"document.body.scrollTop-400";
		x=(validDoc)?"document.documentElement.scrollLeft":"document.body.scrollLeft";
		
	}
	checkLocationA()
}

movex=0,movey=0,xdiff=0,ydiff=0,ystart=0,xstart=0

function checkLocation(){
	object="object1";
	yy=eval(y);
	xx=eval(x);
	ydiff=ystart-yy;
	xdiff=xstart-xx;
	if ((ydiff<(-1))||(ydiff>(1))) movey=Math.round(ydiff/10),ystart-=movey
	if ((xdiff<(-1))||(xdiff>(1))) movex=Math.round(xdiff/10),xstart-=movex
	if (ystart>=0){
		eval(dS+object+sD+v+ystart+px);
	} else {
		eval(dS+object+sD+v+0+px);
	}

	eval(dS+object+sD+h+xstart+px);
	setTimeout("checkLocation()",5);
}

function checkLocationA(){
	ystart=eval(y);
	xstart=eval(x);
}

var MA_OffColor="#FFFFFF";
var MA_ExpColor="#FFFFFF";

var MB_OffColor="#FFFFFF";
var MB_ExpColor="#FFFFB0";
var MB_OnColor="#FFFFB0";

var MC_OffColor="#FFFFFF";
var MC_OnColor="#FFFFD2";

var MA_backIMG="/img/MA_freccia_on_FIRC.gif"

//

var MA_elementi=new Array();
var MB_elementi=new Array();
var MC_elementi=new Array();

var MA_nomi=new Array();
var MB_nomi=new Array();
var MC_nomi=new Array();

var MA_stati=new Array();
var MB_stati=new Array();

var MA_espansa=null;
var MB_espansa=null;
var MC_selezionato=null;

var MA_indice=-1;
var MB_indice=-1;
var MC_indice=0;

function inizializza() {
var elementi=document.getElementsByTagName('div');
	for (var i=0; i<elementi.length; i++) {
		if (elementi[i].className.indexOf("MA")!=-1) {
			MA_indice++;
			MA_elementi[MA_indice]=elementi[i];
			MA_nomi[MA_indice]=elementi[i].id;
			MA_stati[MA_indice]=false;
			//
			//
			// --- ELEMENTI ---
			eval ("MB"+MA_indice+"_elementi=new Array();");
			eval ("MB_elementi["+MA_indice+"]=MB"+MA_indice+"_elementi;");
			//
			eval ("MC"+MA_indice+"_elementi=new Array();");
			eval ("MC_elementi["+MA_indice+"]=MC"+MA_indice+"_elementi;");
			//
			//
			// --- NOMI ---
			eval ("MB"+MA_indice+"_nomi=new Array();");
			eval ("MB_nomi["+MA_indice+"]=MB"+MA_indice+"_nomi;");
			//
			eval ("MC"+MA_indice+"_nomi=new Array();");
			eval ("MC_nomi["+MA_indice+"]=MC"+MA_indice+"_nomi;");
			//
			//
			// --- STATI ---
			eval ("MB"+MA_indice+"_stati=new Array();");
			eval ("MB_stati["+MA_indice+"]=MB"+MA_indice+"_stati;");
			//
			MB_indice=-1;
		} else if (elementi[i].className.indexOf("MB")!=-1) {
			MB_indice++;
			//
			//
			// --- ELEMENTI ---
			eval ("MB"+MA_indice+"_elementi["+MB_indice+"]=elementi["+i+"];");
			eval ("MB_elementi["+MA_indice+"]=MB"+MA_indice+"_elementi;");
			//
			eval ("MC"+MA_indice+"_elementi["+MB_indice+"]=\"\";");
			eval ("MC"+MA_indice+"_"+MB_indice+"_elementi=new Array();");
			eval ("MC_elementi["+MA_indice+"]["+MB_indice+"]=MC"+MA_indice+"_"+MB_indice+"_elementi;");
			//
			//
			// --- NOMI ---
			eval ("MB"+MA_indice+"_nomi["+MB_indice+"]=elementi["+i+"].id;");
			eval ("MB_nomi["+MA_indice+"]=MB"+MA_indice+"_nomi;");
			//
			eval ("MC"+MA_indice+"_nomi["+MB_indice+"]=elementi["+i+"].id;");
			eval ("MC"+MA_indice+"_"+MB_indice+"_nomi=new Array();");
			eval ("MC_nomi["+MA_indice+"]["+MB_indice+"]=MC"+MA_indice+"_"+MB_indice+"_nomi;");
			//
			//
			// --- STATI ---
			eval ("MB"+MA_indice+"_stati["+MB_indice+"]=false;");
			eval ("MB_stati["+MA_indice+"]=MB"+MA_indice+"_stati;");
			//
			MC_indice=0
		} else if (elementi[i].className.indexOf("MC")!=-1) {
			// --- ELEMENTI ---
			eval ("MC"+MA_indice+"_"+(MB_indice)+"_elementi["+MC_indice+"]=elementi["+i+"];");
			eval ("MC_elementi["+MA_indice+"]["+(MB_indice)+"]=MC"+MA_indice+"_"+(MB_indice)+"_elementi;");
			//
			// --- NOMI ---
			eval ("MC"+MA_indice+"_"+(MB_indice)+"_nomi["+MC_indice+"]=elementi["+i+"].id;");
			eval ("MC_nomi["+MA_indice+"]["+(MB_indice)+"]=MC"+MA_indice+"_"+(MB_indice)+"_nomi;");
			//
			MC_indice++;
		}
	}
}




function ctrlMenu(par,flag) {
	if (flag==0) {
		var nome=par.id;
	} else {
		var nome=par;
	}
	//
	var indiceA=null;
	var indiceB=null;
	var indiceC=null;
	// ---TROVA NOME ---
	ciclo :
	for (var i=0; i<MA_elementi.length; i++) {
		if (MA_elementi[i].id==nome) {
			indiceA=i;
			indiceB=null;
			indiceC=null;
			tipoA="MA";
			tipoB=null;
			tipoC=null;
			break ciclo;
		} else {
			for (var j=0; j<MB_elementi[i].length; j++) {
				if (MB_elementi[i][j]) {
					indiceA=i;
					indiceB=j;
					indiceC=null;
					if (MB_elementi[i][j].id==nome) {
						tipoA="MA";
						tipoB="MB";
						tipoC=null;
						break ciclo;
					} else {
						for (var k=0; k<MC_elementi[i][j].length; k++) {
							if (MC_elementi[i][j][k]) {
								indiceA=i;
								indiceB=j;
								indiceC=k;
								if (MC_elementi[i][j][k].id==nome) {
									tipoA="MA";
									tipoB="MB";
									tipoC="MC";
									break ciclo;
								} 
							}
						}
					}
				}
			}
		}
	}
	//
	if (tipoA=="MA") {
		if (MA_stati[indiceA]==false) {
			MA_stati[indiceA]=true;
			MA_img=MA_elementi[indiceA].id;
			MA_elementi[indiceA].style.backgroundColor=MA_ExpColor;
			MA_elementi[indiceA].style.backgroundImage="url(/img/MA_freccia_on_FIRC.gif)";
			for (var i=0; i<eval ("MB"+indiceA+"_elementi.length"); i++) {
				MB_elementi[indiceA][i].style.backgroundColor=MB_OffColor;
				MB_elementi[indiceA][i].style.display="block";
			}
					
		
			if (MA_espansa!=null){
			
				MA_stati[MA_espansa]=false;
				MA_elementi[MA_espansa].style.backgroundColor=MA_OffColor;
				MA_elementi[MA_espansa].style.backgroundImage="url(/img/MA_freccia_FIRC.gif)";
				for (var i=0; i<eval ("MB"+MA_espansa+"_elementi.length"); i++) {
					MB_elementi[MA_espansa][i].style.backgroundColor=MB_OffColor;

					MB_elementi[MA_espansa][i].style.display="none";
					MB_stati[MA_espansa][i]=false;
					for (var j=0; j<eval ("MC"+MA_espansa+"_elementi["+i+"].length"); j++) {
						if (MC_elementi[MA_espansa][i][j]) {
							MC_elementi[MA_espansa][i][j].style.backgroundColor=MC_OffColor;
							MC_elementi[MA_espansa][i][j].style.display="none";
						}
					}
				}
				
			}
			MA_espansa=indiceA;
			MB_espansa=null;
		}
	} 

	if (tipoB=="MB") {
	
		if (!MC_elementi[indiceA][indiceB][0]) {
			MB_elementi[indiceA][indiceB].style.backgroundColor=MB_OnColor;
		}
		
		if (MB_stati[indiceA][indiceB] == false){
			MB_stati[indiceA][indiceB] = true;
			for (var i=0; i<eval ("MC"+MA_espansa+"_elementi["+indiceB+"].length"); i++) {
				if (MC_elementi[indiceA][indiceB][i]){
					MB_elementi[indiceA][indiceB].style.backgroundColor=MB_ExpColor;
					MC_elementi[indiceA][indiceB][i].style.display="block";
				}
			}
			if (MB_espansa!=null){
				MB_stati[indiceA][MB_espansa] = false;
				MB_elementi[indiceA][MB_espansa].style.backgroundColor=MB_OffColor;
				for (var i=0; i<eval ("MC"+MA_espansa+"_elementi["+MB_espansa+"].length"); i++) {
					if (MC_elementi[indiceA][MB_espansa][i]){
						MC_elementi[indiceA][MB_espansa][i].style.backgroundColor=MC_OffColor;
						MC_elementi[indiceA][MB_espansa][i].style.display="none";
					}
				}
			}
			MB_espansa=indiceB;
			MC_selezionato=null
		}
	}
	if (tipoC=="MC") {
		MC_elementi[indiceA][indiceB][indiceC].style.backgroundColor=MC_OnColor;
		if (MC_selezionato!=null){
			MC_elementi[indiceA][indiceB][MC_selezionato].style.backgroundColor=MC_OffColor;
		}
		MC_selezionato=indiceC
	}
}
function esplodi(par) {
	ctrlMenu(par,1);
	document.images["banner"].src="/img/banner_"+MA_img+".jpg";
	document.images["tit"].src="/img/tit_"+MA_img+".gif";
}
function controlla(){
	if (document.forms.form_pop.NOME.value.length==0 ||
		document.forms.form_pop.CGN.value.length==0 || 
		document.forms.form_pop.IND.value.length==0 ||
		document.forms.form_pop.NCIV.value.length==0 ||
		document.forms.form_pop.LOC.value.length==0 ||
		document.forms.form_pop.CAP.value.length==0 ||
		document.forms.form_pop.PROV.value.length==0 
		)
		{
			alert("ATTENZIONE:\nAlcuni campi non sono stati compilati!");
		    return;
    	}
		
	document.forms.form_pop.submit();
}