//Allarga secondo dimensioni finestra
function get_wsize() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	var size;
	size = new Object();
	size.x=myWidth;
	size.y = myHeight;
	return size;
}


//allarga secondo dimensioni totali documento
function xDocSize() {
	var b=document.body, e=document.documentElement;
	var esw=0, eow=0, bsw=0, bow=0, esh=0, eoh=0, bsh=0, boh=0;
	if (e) {
		esw = e.scrollWidth;
		eow = e.offsetWidth;
		esh = e.scrollHeight;
		eoh = e.offsetHeight;
	}
	if (b) {
		bsw = b.scrollWidth;
		bow = b.offsetWidth;
		bsh = b.scrollHeight;
		boh = b.offsetHeight;
	}
	//  alert('compatMode: ' + document.compatMode + '\n\ndocumentElement.scrollHeight: ' + esh + '\ndocumentElement.offsetHeight: ' + eoh + '\nbody.scrollHeight: ' + bsh + '\nbody.offsetHeight: ' + boh + '\n\ndocumentElement.scrollWidth: ' + esw + '\ndocumentElement.offsetWidth: ' + eow + '\nbody.scrollWidth: ' + bsw + '\nbody.offsetWidth: ' + bow);
	return {w:Math.max(esw,eow,bsw,bow),h:Math.max(esh,eoh,bsh,boh)};
}


function xDef() {
	for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
	return true;
}

function xNum(){
	for(var i=0; i<arguments.length; ++i){if(isNaN(arguments[i]) || typeof(arguments[i])!='number') return false;}
	return true;
}


function xScrollTop(e, bWin) {
	var offset=0;
	if (!xDef(e) || bWin || e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
		var w = window;
		if (bWin && e) w = e;
		if(w.document.documentElement && w.document.documentElement.scrollTop) offset=w.document.documentElement.scrollTop;
		else if(w.document.body && xDef(w.document.body.scrollTop)) offset=w.document.body.scrollTop;
	} else {
		e = xGetElementById(e);
		if (e && xNum(e.scrollTop)) offset = e.scrollTop;
	}
	return offset;
}


function resize(this_div,centra_div) {
	var size = xDocSize();
	if (document.getElementById(this_div)) {
		document.getElementById(this_div).style.width = size.w+"px";
		document.getElementById(this_div).style.height = size.h+"px";
		centra (centra_div);
	}
}


function centra(tdiv,dx,dy) {
//	dx = document.getElementById(tdiv).style.width;
//	dy = document.getElementById(tdiv).style.height;
	if (!dx) dx=700;
	if (!dy) dy=200;	


	var size = get_wsize();
	var scroll = xScrollTop();
	newx = ( (size.x-dx) /2);	
	newy = scroll+(size.y/2)-dy;
	
	document.getElementById(tdiv).style.top = newy+"px";
	document.getElementById(tdiv).style.left = newx+"px";
}


//esempio di chiamata ajax
/*
dettagli = {
	open: function(thismacro, pos){		
		if ((thismacro) && (pos)) {
			new Ajax.Request("_comp/_dettagli.php", {
				method: "post",
				parameters: { this_macro: thismacro, this_pos: pos},
				onSuccess: function (a) { 
					$("dettagli_div").innerHTML = a.responseText
					resize("dettagli");
					$("dettagli_div").style.visibility = "visible";
					centra("finestra");
				}
			});
		}

	},
	close: function(thismacro) {
		$("dettagli").style.width = "100%";
		$("dettagli").style.height = "100%";
		$("dettagli_div").style.visibility="hidden";
	}
}

*/

