PathImgMenu = "images/menu/";
Cliccato = 1;

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_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_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 attivaSottoMenu(menu)
{
		document.getElementById(menu).style.backgroundImage= 'url(../images/sotto_menu/bg_down.gif)';
}

function swapSottoMenuOver(menu)
{
	
		if( typeof(sotto_menu_attivo) != "undefined" && sotto_menu_attivo != menu.id)
		{
			menu.style.backgroundImage= 'url(../images/sotto_menu/bg_over.gif)';
			menu.style.color = "#ffffff";
			menu.style.cursor="hand";
		}
}

function swapSottoMenuOut(menu)
{
		if( typeof(sotto_menu_attivo) != "undefined" && sotto_menu_attivo != menu.id)
		{
		menu.style.backgroundImage= 'url(../images/spessore.gif)';
		menu.style.color = "#ffffff";
		menu.style.cursor="hand";
		}
}

function setSottoMenu( idSM )
{
	sottoMenu = document.getElementById(idSM);
	imgSottoMenu = document.getElementById('img' + idSM);
	sottoMenu.style.backgroundImage= 'url(../images/sotto_menu/bg_down.gif)';
	sottoMenu.style.color = "#ffffff";
	imgSottoMenu.src="../images/sotto_menu/maggiore_sotto_menu.gif";
	
}

function swapImageMenuOver(menu)
{
	if (typeof(menu_attivo)=="undefined")
	{
		menu_attivo="null"
	}
	
	if (menu_attivo!=menu)
	{
//menu.style.backgroundImage= 'url(../img/menu/sfondo_angolo_blu.gif)';
		menu.style.color = "#ffffff";
		menu.style.cursor="hand";
	}
}

function swapImageMenuOut(menu)
{
	if (typeof(menu_attivo)=="undefined")
	{
		menu_attivo="null"
	}
	
	if (menu_attivo!=menu)
	{
		menu.style.backgroundImage= 'url(../img/spessore.gif)';
		menu.style.color = "#F39128";
	}
}

function clickMenu(id,obj,Link)
{
	if (typeof(Link)!="undefined")
	{
	if ( id == 0 || id == 4 || id == 5)
		top.location.replace(Link)
	else
		top.IframeContenuto.location.replace(Link);
		setMenu(id)
	}

}

function setMenu(obj)
{
ImgId = obj;
	
	if (typeof(obj)=="undefined")
	{
		if (typeof(top.document.all['menu0'])!="undefined")	obj=document.all['menu0']
	}
	else
	{
		if (typeof(eval("top.document.all['menu"+obj+"']"))!="undefined") obj =eval("top.document.all['menu"+obj+"']");
	}
/*	
	if(typeof(menu_attivo)!="undefined") //se ho già un menu attivo lo disattivo
	{
		if (menu_attivo!="null")
		{
			menu_attivo.src = PathImgMenu + NumImg + ".gif"		
		}
	}
*/	
	NumImg = ImgId + 1 //per il nome dell'immagine: 1 è la home 2 il profilo...etc.
	
	if ( typeof( eval ( "top.document.all['img_menu" + ImgId + "']" ) ) != "undefined" ) 
	{
	if ( typeof(PathImgMenuIcatalog) == "undefined" ) PathImgMenuIcatalog = "";
		for ( i=0,j=1; i<7; i++,j++ )
		{
			top.document.all['img_menu' + i ].src = PathImgMenuIcatalog + PathImgMenu + j + ".gif";
		}
		ObjImg = eval ( "top.document.all['img_menu" + ImgId + "']" );
		ObjImg.src = PathImgMenuIcatalog + PathImgMenu + NumImg + "_b.gif";
//		menu_attivo=ObjImg;
	}
}

function ControllaPagina( NomePagina, Id, IdSottoMenu )
{


	if ( (parent.location.pathname == "/gestionazienda/contenitore.asp") || ( parent.location.pathname == "/azienda/contenitore.asp") || (parent.location.pathname == "/contenitore.asp"))
	{

		setMenu(Id)
		if (IdSottoMenu != "" )
		setSottoMenu(IdSottoMenu)
//		top.location.href = "../contenitore.asp?Pagina=htm/" + NomePagina;
//		top.IframeContenuto.location.replace("htm/mission.asp");
	}
	else
	{
		top.location.href = "../contenitore.asp?Pagina=htm/" + NomePagina;
	}
}

function InserisciLink()
{
	finestra_testo =		window.prompt("Inserire l`url","");
	if (finestra_testo == null || finestra_testo == "")
	{
		Fuoco();
		return
	}
	else
	{
			x=InsFFZCode(2,'<a href="http://'+finestra_testo+'" target="_blank">'+finestra_testo+'</a>');
		//document.form1.Corpo.value = document.form1.Corpo.value + '<a href="' + finestra_testo + '" target="_blank">' + finestra_testo + '</a>';
	}
	Fuoco();
}

function InserisciMail()
{
	finestra_testo =		window.prompt("Inserire l`indirizzo email","");
//alert(InsFFZCode(1,"[Email]","[=Email]","[//Email]"))
	if (finestra_testo == null || finestra_testo == "")
	{
		Fuoco();
		return
	}
	else
	{
				x=InsFFZCode(2,'<a href="mailto:'+finestra_testo+'">'+finestra_testo+'</a>');
		//document.form1.Corpo.value = document.form1.Corpo.value + '<a href="mailto:' + finestra_testo + '">' + finestra_testo + '</a>';
	}
	Fuoco();
}

function InsFFZCode(Opz,tgSx,tgDx,tgDx2) 
{
	Fuoco();
	var TR=document.selection.createRange();
	
	if(TR!=null)
	{
		var str=new String(TR.text);
		if(Opz!=2) {
			if(Opz==1 && str.length<1) return(2);
			if(tgDx2!="") 		TR.text=tgSx+TR.text+tgDx+TR.text+tgDx2;
			else if(tgDx!="") 	TR.text=tgSx+TR.text+tgDx;
			else 			TR.text=tgSx+TR.text;
		}
		if(Opz==2)	{
			TR.text=tgSx;
		}
		return(0);
	} 
	return(1);
}

function Fuoco() 
{
	document.form1.corpo.focus();
}

function postaA(nome_email, dominio, region)
{
    var chiocciola= String.fromCharCode(30+34);
    var stringa = nome_email + chiocciola + dominio +"."+ region;
    location.replace("m"+"a"+"i"+"l" + "to:" + stringa);
}

function scriviPostaA(nome_email, dominio, region, classe)
{
 var chiocciola= String.fromCharCode(30+34);
 var indirizzo = nome_email + chiocciola + dominio +"."+ region;
 document.write('<a class="' + classe + '" href="m' + 'a'+'i'+'l' + 't'+'o'+':' + indirizzo + '">' + indirizzo + '</a>');
}

function ApriPopUp( Img, Home )
{
	//Home: variabile che aggiunge 'htm/' al percorso del popup, nel caso in cui uso il flash dall'homepage
	PathImg='../images/';
	if (typeof(Home) == "undefined")
		Home="";
	window.open( Home + "popup.htm?Img=" + PathImg + Img, 'ImmaginiGestione', 'width=20 height=20, top=200, left=300, scrollbars=no'); 
}

function PopUp()
{
	window.open( "cartina.htm", 'Cartina', 'width=532 height=600, top=200, left=300, scrollbars=no'); 
}

function CambiaCartina( Img, Src )
{
	PathImg='../images/';
	ImgRif = document.all['img'+Img];
	if(Cliccato!=0)
	{
		Src = Src +'_1.gif';		
		Cliccato=0;
	}
	else
	{
		Cliccato = 1;
		Src = Src +'_2.gif';
	}
	ImgRif.src= PathImg + Src;
}

function Stampa ()
{
	window.open( "cartina_p.htm", 'CartinaP', 'width=100 height=100, top=-2000, left=-3000'); 
}
