function allFunctions()
{
	var loading = document.getElementById('page_loading');		
	var main = document.getElementById('main');
	main.style.visibility="hidden";
		
	preloadIMG();
/*	attachSwitch();
	startMenu();
	bordaImmagini();
	//startSezioni();
	//mainHeight(contenitore);
	*/
	////mainHeight();
	
	
//	correctPNG();	

	loading.style.display="none";	
	main.style.visibility="visible";	
}		

//switcho le immagini
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 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 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", "");
			}
		}
	}
}

function bordaImmagini()
{
try
{
	if($('contenuto'))
	{
		var new_width;
		var discendenti = $('contenuto').descendants();						
		var discendenti_img = discendenti.findAll(function(n) {if(n.nodeName == 'IMG') return n; });
		discendenti_img.each(function(el)
		{
			//alert(el.ancestors().inspect());
			if(!el.descendantOf('colonna') && (!el.className.match('bordinoAlto') || !el.className.match('guestbook')))
			{

					
					//per prevenire bordino... mettere border a none in linea
					//alert(el.getStyle('border'));
					if(!el.getStyle('border').match('none'))
					{										
					//alert('metto');
									new_width = el.offsetWidth-16;
									Element.setStyle(el,{
									'width': new_width+'px',
									'padding': '1px',
									'border': '7px solid #B8E6F5'
									});
					}			
			}
			
		});
	}
}
catch(e){/*alert(e.toString());*/}
}
function mainHeight(){
	headHeight();
	colonnaSxHeight();
	containerHeight();
//	colonnaDxHeight();
	footerHeight();
	main = document.getElementById('main');
	
	if(document.getElementById('colonna'))
	{
		if(container.offsetHeight > document.getElementById('colonna').offsetHeight) document.getElementById('colonna').style.height = container.offsetHeight +'px';
	}
	
//	questa quando il layout ? a due colonne
	heightTotale = Math.max(colonnaSx.offsetHeight,container.offsetHeight) + head.offsetHeight + footer.offsetHeight;

	var super_header = $('super_header');
	
	main.style.height = heightTotale + 20 +super_header.offsetHeight+ 'px';

	super_header.style.top = heightTotale +36+ 'px';
}

