var _width = 0;
var _height = 0;

function getWindowWidth()
{
    if (typeof window.innerWidth != 'undefined') 
    {
        return window.innerWidth;
    }
    if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth !='undefined' && document.documentElement.clientWidth != 0) 
    {
        return document.documentElement.clientWidth;
    }
    
    return document.getElementsByTagName('body')[0].clientWidth;
}

function getWindowHeight()
{
    if (typeof window.innerHeight != 'undefined') 
    {
        return window.innerHeight;
    }
    if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientHeight !='undefined' && document.documentElement.clientHeight != 0)
    {
        return document.documentElement.clientHeight;
    }
    
    return document.getElementsByTagName('body')[0].clientHeight;
}

function onWindowResize(pWidth, pHeight)
{
    var f = document.getElementById('main');
    if (f) 
	{
		f.style.width = getWindowWidth() > pWidth ? getWindowWidth() : pWidth;
		f.style.height = getWindowHeight() > pHeight ? getWindowHeight() : pHeight;
	}
}

function setResize(pWidth,pHeight)
{
    _width = pWidth;
    _height = pHeight;
    onWindowResize(_width, _height);
}

window.onload = window.onresize = function()
{
    onWindowResize(_width, _height);
}