/*
 * sls.js
 * 
 * (c) 2004 eg.media
 * 
 * written by Christof Donat
 */

function mttg_center(d,w,dw) {
	var rDiv = document.getElementById(d);
	var nw = w;

	if( rDiv ) {
		if( document.all ) nw = document.body.offsetWidth;
		else               nw = window.innerWidth;
	
		if( w != nw ) {
			var l = Math.ceil((nw-dw)/2);
			if(l < 0 ) l = 0;
			rDiv.style.left = l;
		}
		setTimeout("mttg_center('"+d+"',"+nw+","+dw+")",250);
	} else
		setTimeout("mttg_center('"+d+"',"+nw+","+dw+")",10);
}

function mttg_center2(d,w,dw) {
	var rDiv = document.getElementById(d);
	var nw = w;

	if( rDiv ) {
		if( document.all ) nw = document.body.offsetWidth;
		else               nw = window.innerWidth;
	
		if( w != nw ) {
			var l = Math.ceil((nw-dw)/2)+565;
			if(l < 0 ) l = 0;
			rDiv.style.left = l;
		}
		setTimeout("mttg_center2('"+d+"',"+nw+","+dw+")",250);
	} else
		setTimeout("mttg_center2('"+d+"',"+nw+","+dw+")",10);
}



function getHeight(d) {
	var h = d.offsetHeight;
	var nh = 0;
	for( var i = 0; i < d.childNodes.length; i++ ) {
		elem = d.childNodes[i];
		if(elem.nodeType == 1) {
			var dis;
			if(document.defaultView.getComputedStyle)
				dis = document.defaultView.getComputedStyle(elem, '').getPropertyValue("display");
			else
				dis = elem.style.display;
			if( dis == 'block' || dis == 'table' ) 
				nh += getHeight(elem);
		}
	}
	return (nh > h)?nh:h;
}

function getTop(d) {
	var rval = d.offsetTop;
	if( d.parentNode.offsetTop ) rval += getTop(d.parentNode);
	return rval;
}

function mttg_scaleHeight(d,h,hs,od) {
	var rDiv = document.getElementById(d);

	var nh = h;

	if( rDiv ) {
		var oDiv = document.getElementById(od);

		nh = window.innerHeight;
		if( oDiv ) {
			var onh = getHeight(oDiv)+getTop(oDiv);
			onh+= 140;
			if( onh > nh ) nh = onh;
		}
	
		if( h != nh ) {
			var dh = nh - hs;
			if( dh < 0 ) dh = 0;
			rDiv.style.height = dh;
		}
	}

	setTimeout("mttg_scaleHeight('"+d+"',"+nh+","+hs+",'"+od+"')",250);
}


