
function mttg_resize(d,w,h,ws,hs,wt) {
	rDiv = document.getElementById(d);

	nw  = w;
	nh  = h;
	mwt = wt;

	if( document.all ) {
		nh = document.body.offsetHeight;
		nw = document.body.offsetWidth - ws;

		if( h != nh || w != nw ) {
			if( nw > wt && nh > hs ) rDiv.style.height = nh - hs;
			else if( nh > hs + 16 )  rDiv.style.height = nh - (hs + 16);
		}
	} else {
		nh = window.innerHeight;
		nw = window.innerWidth - ws;	

		if( h != nh || w != nw ) {
			if( nw > wt && nh > hs ) rDiv.style.height = nh - hs;
			else if( nh > hs + 16 )  rDiv.style.height = nh - (hs + 16);
		}
	}

	setTimeout("mttg_resize('"+d+"',"+nw+","+nh+","+ws+","+hs+","+wt+")",10);
}

var countbottom = 0;

function mttg_scaleHeight(d,h,hs) {
	rDiv = document.getElementById(d);

	nh = h;

	if( rDiv) {
		if( document.all ) nh = document.body.offsetHeight;
		else               nh = window.innerHeight;
	
		if( h != nh ) {
			dh = nh - hs;
			if( dh < 0 ) dh = 0;
			rDiv.style.height = dh;
		}
	}

	setTimeout("mttg_scaleHeight('"+d+"',"+nh+","+hs+")",10);
}

function mttg_align_bottom(d,w,ws,wt) {
	rDiv = document.getElementById(d);

	nw = w;

	if( document.all ) nw = document.body.offsetWidth - ws;
	else               nw = window.innerWidth  - (ws - 4);

	if( w != nw ) {
		if( nw > wt || document.all ) rDiv.style.bottom = 0;
		else                          rDiv.style.bottom = 16;
	}

	setTimeout("mttg_align_bottom('"+d+"',"+nw+","+ws+","+wt+")",10);
}

function mttg_scaleWidth(d,w,ws) {
	rDiv = document.getElementById(d);

	nw = w;

	if( document.all ) nw = document.body.offsetWidth;
	else               nw = window.innerWidth;

	if( w != nw ) rDiv.style.width = nw-ws;

	setTimeout("mttg_scaleWidth('"+d+"',"+nw+","+ws+")",10);
}

function mttg_scaleWidthInParent(d,p) {
	rDiv = document.getElementById(d);
	pDiv = document.getElementById(p);

	if( document.all ) rDiv.style.width = pDiv.offsetWidth-17;
	else               rDiv.style.width = pDiv.innerWidth;

	setTimeout("mttg_scaleWidthInParent('"+d+"','"+p+"')",2000);
}

function mttg_center(d,w,dw) {
	rDiv = document.getElementById(d);
	nw = w;

	if( rDiv ) {
		if( document.all ) nw = document.body.offsetWidth;
		else               nw = window.innerWidth;
	
		if( w != nw ) {
			var l = (nw-dw)/2;
			if(l < 0 ) l = 0;
			rDiv.style.left = l;
		}
	}

	setTimeout("mttg_center('"+d+"',"+nw+","+dw+")",10);
}

