function getInnerSize ( ) {
	var x, y;

	if ( self.innerHeight ) {
		x = self.innerWidth;
		y = self.innerHeight;
	} else if ( document.documentElement && document.documentElement.clientHeight ) {
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	} else if ( document.body ) {
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}

	return [ x, y ];
}

function resizeToInner( w, h ) {
	window.moveTo( 0, 0 );
	window.resizeTo( screen.availWidth, screen.availHeight );

	var inner = getInnerSize( );
	var ox = screen.availWidth - inner[ 0 ];
	var oy = screen.availHeight - inner[ 1 ];

	if ( w + ox > screen.availWidth - 20 ) {
		var neww = screen.availWidth - ox - 20;
		var newh = ( h * neww ) / w;

		w = Math.floor( neww );
		h = Math.floor( newh );
	}

	if ( h + oy > screen.availHeight - 20 ) {
		var newh = screen.availHeight - oy - 20;
		var neww = ( w * newh ) / h;

		w = Math.floor( neww );
		h = Math.floor( newh );
	}

	if ( navigator.userAgent.indexOf( "Mac" ) != -1 ) { 
		ox += 20;
	} else if ( navigator.userAgent.indexOf( "MSIE" ) != -1 ) { 
		ox += 20; 
	}

	window.resizeTo( w + ox, h + oy );
	window.moveTo( ( screen.availWidth - ( w + ox ) ) / 2, ( screen.availHeight - ( h + oy ) ) / 2 );
}