﻿// File JScript
function getElem(nome){
if (document.getElementById){
ritorna = document.getElementById(nome);
} else {
ritorna = eval("document.all."+nome);
}
return ritorna
}

var popmenu = null;

function outMenu(obj){
obj.src = obj.src.replace(/alt=1/gi, "alt=0");
}

function inMenu(obj){
obj.src = obj.src.replace(/alt=0/gi, "alt=1");
showMenu(null, 0);
}

function showMenu(obj, popid) {

if (obj != null){
inMenu(obj);
}

if (popmenu != null){
popmenu.style.display = "none";
popmenu = null;
}

if (obj != null && popid != 0){
    
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	
	
	
	//curtop -= obj.height;
popmenu = getElem("popmenu" + popid);
popmenu.style.display = "block";
popmenu.style.top = (curtop+19) + "px";
popmenu.style.left = (curleft-2) + "px";
}

}

function showhint(obj, testo){
var tbox = document.getElementById("hintbox");
if (testo == null){
tbox.style.display="none";
} else {
tbox.innerHTML = testo;


//posizionalo
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}

tbox.style.left = (curleft+10) + "px";
tbox.style.top = (curtop+20) + "px";
	
	
//infine mostralo
tbox.style.display = "block";



}
}

function getPageSize(){
    
    var xScroll, yScroll;
    
    if (window.innerHeight && window.scrollMaxY) {    
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }
    
    var windowWidth, windowHeight;
    if (self.innerHeight) {    // all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }    
    
    // for small pages with total height less then height of the viewport
    if(yScroll < windowHeight){
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }

    // for small pages with total width less then width of the viewport
    if(xScroll < windowWidth){    
        pageWidth = windowWidth;
    } else {
        pageWidth = xScroll;
    }

    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
    return arrayPageSize;
}


function adatta(){
posiziona("cpright");
posiziona("rbox");
}

function posiziona(divname){
	var obj = document.getElementById(divname);


if (obj != null){
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	obj = document.getElementById(divname);	
	
	var dimensions = getPageSize();
	var hg = parseInt((obj.style.height + "").replace(/[^0-9]/gi, ""), 10);
	
    obj.style.paddingTop = (dimensions[1]-curtop-hg) + "px";
	}

	}

window.onresize = adatta;
window.onload = adatta;

