// JavaScript Document
var tastoON='url(i/vocemenu_a.png)';
var tastoOFF='url(i/vocemenu.png)';
var menuAttivo=new Array(tastoOFF, tastoOFF, tastoOFF, tastoOFF, tastoOFF, tastoOFF);

function menuNoSel(){
	$('.tastomenu').css('background-image', tastoOFF);
	for(i=0;i<6;i++)menuAttivo[i]=tastoOFF;
}

function loadP(p){
	$('#loading').height($('#contenuto').height());
	$('#loading').show();
	$('#contenuto').load(p+'?t='+(new Date()).getTime(), loadEnd);
}

function loadEnd(pagina){
	$('#cornice').height('0');
	$('#contenuto').html( pagina );
	$('#cornice').height($('#contenuto').height());
	$('#loading').hide();
}

function menuSel(idm, pagina){	
	menuNoSel();
	var tasti=$('.tastomenu');
	tasti[idm].style.backgroundImage=tastoON;
	menuAttivo[idm]=tastoON;
	loadP(pagina);
}

function tastoSel(tasto, idm, pagina){
	menuSel(idm, pagina);
	tasto.style.backgroundImage=tastoON;
}

var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}


// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 
// -->

function initInterface(){
    menuNoSel();
	document.getElementById('barra_nera').style.visibility='visible';
	document.getElementById('footer_hp').style.visibility='visible';
	var u=document.getElementById('userid2');
	var p=document.getElementById('pass');
	if(u.value=='')	ripristina(u); else cambia(u);	
	if(p.value=='')	ripristina(p); else cambia(p);
}
