if (window.addEvent) window.addEvent('domready', startGallery);
window.onload = function () {
	setClickHandler();
	myLoadFunc();
}
function setClickHandler()
{
var elm;
var voci;
var classe = "";
var voce;
var voceId;
var voceCtx;

	elm = document.getElementById("menuSx");
	if (elm)
	{
		delim = "sub_";
		voci = elm.getElementsByTagName("a");
		if (voci)
		{
			for (var i = 0; i < voci.length; i++)
			{
				voce = voci.item(i);
				voceId = voce.id;
				if (voceId)
				{
					voceCtx = delim+voceId;
					if (voceCtx)
					{
						if (document.getElementById(voceCtx))
						{
							if (document.getElementById(voceCtx).className.indexOf("corrente") < 0)
							{
								nascondiElemento(voceCtx);
							}
							voce.onclick = new Function("visualchild('"+voceCtx+"', true);return false;");
						}
					}
				}
			}
		}
	}
}

function visualchild(elm)
{
var chl;
var elm1;
var voci;
var classe = "";
var voce;
var voceId;
var voceCtx;

	chl = document.getElementById(elm);
	
	if (chl)
	{
		elm1 = document.getElementById("menuSx");
		if (elm1)
		{
			delim = "sub_";
			voci = elm1.getElementsByTagName("a");
			if (voci)
			{
				for (var i = 0; i < voci.length; i++)
				{
					voce = voci.item(i);
					voceId = voce.id;
					if (voceId)
					{
						voceCtx = delim+voceId;
						if (voceCtx)
						{
							if (voceCtx != elm)
							{
								if (document.getElementById(voceCtx))
								{
									if (document.getElementById(voceCtx).className.indexOf("nascosto") < 0)
									{
										nascondiElemento(voceCtx);
									}
								}
							}
						}
					}
				}
			}
		}
		if (chl.className.indexOf("nascosto") > -1)
		{
			mostraElemento(elm);
		}
		else
		{
			nascondiElemento(elm);
		}
	}
}

function nascondiElemento(elem)
{
elm = document.getElementById(elem);

	if (elm)
	{
//		elm.style.visibility = 'hidden';
//		elm.style.display = 'none';
		if (elm.className)
		{
			if (elm.className.indexOf("nascosto") == -1)
			{
				elm.className += " nascosto";	
			}
		}
		else
		{
			elm.className = "nascosto";
		}
	}
}
function mostraElemento(elem)
{
elm = document.getElementById(elem);

	if (elm)
	{
//		elm.style.visibility = 'visible';
//		elm.style.display = '';
		if (elm.className)
		{
			if (elm.className.indexOf("nascosto") != -1)
			{
				elm.className = elm.className.replace(/nascosto/gi, "");
			}
		}
	}
}

function myLoadFunc()
{
	if (window.myPgInit)
	{
		myPgInit();
	}
	if (document.getElementById)
	{
		if (document.getElementById("legdocBody"))
		{
/*		
			nascondiElemento("cntResLst");
			nascondiElemento("cntOthTxt");
			MM_dragLayer('cntResLst','',0,0,0,0,true,false,-1,-1,-1,-1,false,false,0,'',false,'');
			MM_dragLayer('cntOthTxt','',0,0,0,0,true,false,-1,-1,-1,-1,false,false,0,'',false,'');
*/			
		}
		if (document.getElementById("llegdocBody"))
		{
/*		
			parent.visIF("OthTxt", document.getElementById("sezione").innerHTML);
			parent.settaZ("OthTxt", "ResLst");
*/			
		}
		if (document.getElementById("lparmlstBody"))
		{
/*		
			parent.visIF('ResLst'); 
			parent.settaZ('ResLst', 'OthTxt');		
*/			
		}
		if (document.getElementById("settazr"))
		{
/*		
			document.getElementById("settazr").onclick = function() {settaZ('ResLst', 'OthTxt');}
*/			
		}
		if (document.getElementById("settazo"))
		{
/*		
			document.getElementById("settazo").onclick = function() {parent.settaZ('OthTxt', 'ResLst')}
*/			
		}
	}
	if (document.getElementsByTagName)
	{
	var col;
	var elm;
	var sez;
	var ancora;
	var classe;
	
		col = document.getElementsByTagName("ul");
		if (col)
		{
/*		
			for (var i = 0; i < col.length; i++)
			{
				ancora = col.item(i);
				if (ancora.className)
				{
					classe = ancora.className;
					if (classe.indexOf("menusxP3") > -1)
					{
						ancora.onmouseover = function() {unCheckUserInput()};
						ancora.onmouseout = function() {checkUserInput(this)};
					}
				}
			}
*/			
		}
		col = document.getElementsByTagName("a");
		if (col)
		{
			for (var i = 0; i < col.length; i++)
			{
				ancora = col.item(i);
				if (ancora.className)
				{
					classe = ancora.className;
					if (classe.indexOf("extlnk") > -1)
					{
						ancora.onclick = function() {window.open(this.href,"fin","width=650,height=450,scrollbars,resizable,left=10,top=90");return false};
					}
/*					
					if (classe.indexOf("lnkemail") >= 0)
					{
						ancora.onclick = function() {};
					}
					if (classe.indexOf("lnkprint") >= 0)
					{
						ancora.onclick = function() {window.print();return false;};
					}
					if (classe.indexOf("lnkclose") >= 0)
					{
						ancora.onclick = function() {window.close();return false;};
					}
					if (classe.indexOf("closesearch") > -1)
					{
						ancora.onclick = function(){document.getElementById('arpaSrLay').style.display='none';document.getElementById('arpaSrLay').style.visibility='hidden';return false;}
					}
					if (classe.indexOf("innersearch") > -1)
					{
						ancora.onclick = function() {document.getElementById('arpaSrLay').style.display='';document.getElementById('arpaSrLay').style.visibility='visible';return false;}
					}
					if (classe.indexOf("nasfifr") > -1)
					{
						ancora.onclick = function() {nasFIF('ResLst'); return false;}
					}
					if (classe.indexOf("nasifr") > -1)
					{
						ancora.onclick = function() {nasIF('ResLst');return false}
					}
					if (classe.indexOf("nasfifo") > -1)
					{
						ancora.onclick = function() {nasFIF('OthTxt'); return false;}
					}
					if (classe.indexOf("nasifo") > -1)
					{
						ancora.onclick = function() {nasIF('OthTxt');return false}
					}
					if (classe.indexOf("vaisu") > -1)
					{
						ancora.onclick = function() {window.scroll(0,0);return false;}
					}
					if (classe.indexOf("smcont") > -1 && classe.indexOf("smconte") == -1)
					{
						ancora.onclick = function() {spostaEVisualizzaMenuSX(this.parentNode.getElementsByTagName("ul").item(0), this);return false;}
						ancora.onmouseout = function() {checkUserInput(this.parentNode.getElementsByTagName("ul").item(0))}
					} 
					if (classe.indexOf("smconte") > -1)
					{
						ancora.onmouseover = function() {unCheckUserInput()}
						ancora.onmouseout = function() {checkUserInput(this.parentNode)}
					} 
*/					
				}
			}
		}
		elm = document.getElementsByTagName("body").item(0);
		if (elm)
		{
			if (elm.id)
			{
				if (elm.id.indexOf("normalBody") > -1)
				{
				}
			}
		}
	}
}
function startGallery() 
{
	if ($('myGallery'))
	{
		var myGallery = new gallery($('myGallery'), {timed: false,  embedLinks: false, thumbCloseCarousel: false, carouselHorizontal: true, useExternalCarousel: true, carouselElement: $('myCarousel')});
		myGallery.showCarousel();
	}
}
