// JavaScript Document

// Restituisce il top per centrare una finestra alta height
function getCenterTop(height){
	var hs = screen.height;
	var top = (hs / 2) - (height / 2);
	return top;
}

// Restituisce il left per centrare una finestra larga width
function getCenterLeft(width){
	var ws = screen.width;
	var left = (ws / 2) - (width / 2);
	return left;
}

// Apre una finestra di popup
var _openpop = null;
function openpop(page, w, h, scrolling){
	if(_openpop!=null) _openpop.close();
	if(page==null || page=='') return;
	var opt = 'resizable=no,scrollbars=no,statusbar=no';
	if(scrolling!=null && scrolling==true) opt = 'resizable=yes,scrollbars=yes,statusbar=yes';
	if(w!=null && !isNaN(w)) opt = opt + ',top='+getCenterTop(h)+',height='+h;
	if(h!=null && !isNaN(h)) opt = opt + ',left='+getCenterLeft(w)+',width='+w;
	_openpop = window.open(page, '_blank', opt);
}


function swapVisibility(id1,id2){
	elm1 = document.getElementById(id1);
	elm2 = document.getElementById(id2);
	if(elm1.style.visibility=='visible') {
		elm1.style.visibility='hidden';
		elm1.style.display='none';
		
		elm2.style.visibility='visible';
		elm2.style.display='block';
	} else {
		elm2.style.visibility='hidden';
		elm2.style.display='none';
		
		elm1.style.visibility='visible';
		elm1.style.display='block';
	}
}

function visibilityOff(id){
	el = document.getElementById(id);
	el.style.visibility='hidden';
	el.style.display='none';
}

function visibilityOn(id){
	el = document.getElementById(id);
	el.style.visibility='visible';
	el.style.display='block';
}

function displayOnOff(id){
	el = document.getElementById(id);
	if(el.style.visibility=='visible') {
		el.style.visibility='hidden';
		el.style.display='none';
	} else {
		el.style.visibility='visible';
		el.style.display='block';
	}
}
