//switcho le immagini
function attachSwitch()
{	
	var images = document.getElementsByTagName('img');
	
	//percorro tutte le immagini		
	for (var i=0; i<images.length; i++)
	{
		var image = images[i];
		var relAttribute = String(image.getAttribute('name'));
		//se hanno match over... associo funzioni di swap img
		if (relAttribute.toLowerCase().match('over'))
		{
			image.onmouseover = function(){
			if(this.className!="active")
				{
					this.src= this.src.replace('_off', '_on');
				}
			};
			image.onmouseout = function(){
			if(this.className!="active")
				{
					this.src= this.src.replace('_on', '_off');
				}
			};			
		}
		if(image.className == "active")
		{
			image.src= image.src.replace('_off', '_on');
		}
	}
}


function preloadIMG()
{	
	var images = document.getElementsByTagName('img');
	var immagini=new Array();	
	var cont = 0;
	//percorro tutte le immagini		
	for (var i=0; i<images.length; i++)
	{
		var image = images[i];
		var relAttribute = String(image.getAttribute('name'));
		//se hanno match preload... associo funzioni di preload
		if (relAttribute.toLowerCase().match('preload'))
		{
			immagini[cont]=new Image();
			immagini[cont].src=image.src;
			cont++;
		}

	}
}

function startMenu() {
	var node;
	var displaymenu;

	displaymenu = document.getElementById("menu");
	for (i=0; i<displaymenu.childNodes.length; i++) {
		node = displaymenu.childNodes[i];
		if (node.nodeName=="LI") {
			node.onmouseover=function() {
			this.className+=" over";
			}
			node.onmouseout=function(){                  
				this.className=this.className.replace("over", "")
			}
		}
	}

}


/*
<!--[if gte IE 5.5000]>
 	<script type="text/javascript" src="pngfix.js"></script>
 	<![endif]-->

function correctPNG() 
   {
   for(var i=0; i<document.images.length; i++)
      {
      var img = document.images[i];
      var imgName = img.src.toUpperCase();
      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
         var imgID = (img.id) ? "id='" + img.id + "' " : "";
         var imgClass = (img.className) ? "class='" + img.className + "' " : "";
         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
         var imgStyle = "display:inline-block;" + img.style.cssText ;
         if (img.align == "left") imgStyle = "float:left;" + imgStyle;
         if (img.align == "right") imgStyle = "float:right;" + imgStyle;
         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;     
         var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
         img.outerHTML = strNewHTML;
         i = i-1;
         }
      }
   }
*/

/*
function goToLocation(elem)
{
	if(elem.firstChild)
	window.location.href= elem.firstChild.href;
}
*/

function allFunctions()
{
	
	preloadIMG();
	attachSwitch();
//	startMenu();
//	correctPNG();
	$('loading-page').hide();
}		


