/**
* wp-tangenziale r1 // 2010.04.08
* 
*
* @author    Luca Iacobini <luca@binario.it>
*/
function isReady() {
	return true;
}

function getpagewidth() {
	return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : 0;
}

function getpageheight() {
	return window.innerHeight != null ? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : 0;
}

function getpagexoffset() {
	return window.pageXOffset != null ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body != null ? document.body.scrollLeft : 0;
}

function getpageyoffset() {
	return window.pageYOffset != null ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body != null ? document.body.scrollTop : 0;
}

function openlinkinthiswindow(url) {
	location.href = url;
}

function openlinkinnewwindow(url) {
	window.open(url);
}

function getmaxheight(element, exclude) {
	var children = element.childNodes;
	var length   = children.length;
	var height   = element.offsetTop + element.offsetHeight;
	
	for (var i = 0; i < length; ++i) {
		if (children[i].className != exclude) {
			var t = getmaxheight(children[i]);
			height = height < t ? t : height;
		}
	}
	
	return height;
}

function mapresize() {
	var maxheight = 0;
	if (document.getElementById('home-map')) {
		maxheight = getmaxheight(document.getElementById('page'), 'home-map');
		document.getElementById('home-map').style.height = maxheight + 'px';
	}
	if (document.getElementById('page-map')) {
		maxheight = getmaxheight(document.getElementById('page'), 'page-map');
		document.getElementById('page-map').style.height = maxheight + 'px';
	}
	if (document.getElementById('media-map')) {
		maxheight = getmaxheight(document.getElementById('page'), 'media-map');
		document.getElementById('media-map').style.height = maxheight + 'px';
	}
	
	if (getpagewidth() < 980) {
		document.getElementById('page').style.width = '980px';
		document.getElementById('right-menu').style.left = '760px';
		document.getElementById('right-menu').style.right = null;
		
		if (document.getElementById('home-map')) {
			document.getElementById('home-map').style.width = '280px';
			document.getElementById('home-map').style.right = null;
		}
		if (document.getElementById('page-map')) {
			document.getElementById('page-map').style.width = '280px';
			document.getElementById('page-map').style.right = null;
		}
		if (document.getElementById('media-map')) {
			document.getElementById('media-map').style.width  = '760px';
			document.getElementById('media-map').style.right  = null;
		}
	}
	else {
		document.getElementById('page').style.width = null;
		document.getElementById('right-menu').style.left = null;
		document.getElementById('right-menu').style.right = '0px';
		
		if (document.getElementById('home-map')) {
			document.getElementById('home-map').style.width = 'auto';
			document.getElementById('home-map').style.right = '220px';
		}
		if (document.getElementById('page-map')) {
			document.getElementById('page-map').style.width = 'auto';
			document.getElementById('page-map').style.right = '220px';
		}
		if (document.getElementById('media-map')) {
			document.getElementById('media-map').style.width  = 'auto';
			document.getElementById('media-map').style.right  = '220px';
		}
	}
}

function getscreenbottom() {
	var bottom = getpageheight() + getpageyoffset();
	
	return bottom;
}
