//variabili globali
var numMenuExp = 2; //numero menu che si espandono
var numVoci = 10; //numero di voci/pagine/DIV di contenuto
var idLayer = 0;

function controllaDimTab(nomeTabella) {				
	var dw = document.body.clientWidth;
		
	if (parseInt(dw) < 720) {
		document.getElementById(nomeTabella).style.width = '700px';
	} else {
		document.getElementById(nomeTabella).style.width = '100%';
	}
}	
		
function MJ_OpenMenu(MJ)
{	
	for (i=0; i < numMenuExp; i++) {
		if (parseInt(MJ) == i)
			document.getElementById("MJ_" + i).className = "MJ_VisibleLink";
		else
			document.getElementById("MJ_" + i).className = "MJ_HiddenLink";
	}
}

function MJ_CloseMenu()
{
	for (var i=0; i < numMenuExp; i++) {
			document.getElementById("MJ_" + i).className = "MJ_HiddenLink";
	}	
}

function V_Open(MJ)
{	
	idLayer = MJ;
	for (var i=0; i < numVoci; i++) {
		if (parseInt(MJ) == i) {
			document.getElementById("voce_" + i).className = "V_VisibleLink";
			resize(MJ);
		} else
			document.getElementById("voce_" + i).className = "V_HiddenLink";
	}
}
function resize(MJ){
	if (parseInt(findPosY(document.getElementById("close_"+MJ))) > 500)
		document.getElementById("mainTable").style.height = parseInt(findPosY(document.getElementById("close_"+MJ)));		
	else
		document.getElementById("mainTable").style.height = 500;

}

function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (1) {
            curleft+=obj.offsetLeft;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.x) {
        curleft+=obj.x;
    }
    return curleft;
}
function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (1) {
            curtop+=obj.offsetTop;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.y) {
        curtop+=obj.y;
    }
    return curtop;
}

function finish(){
	document.getElementById("loading").style.visibility = "hidden";
}

