var bad_browser = 0;

function publishHeight()
{
    var actualHeight = getBodyHeight();
    var currentHeight = getViewPortHeight();

    if ( (Math.abs(actualHeight - currentHeight) > 15) && bad_browser == 0)
    {
	    message = "height="+getBodyHeight();
	    if (window.parent.postMessage) {
		window.parent.postMessage(message, '*');
	    }
	    else 
	    {
	    	bad_browser = 1;
	 	alert ("Your browser does not support the postMessage method used for this site feature.  Please upgrade to Firefox 3 or IE 8.");
	 	window.top.location = "http://c42.se/yabb/YaBB.pl";
	    }
    }

}

function getBodyHeight()
{
    var height;
    var scrollHeight;
    var offsetHeight;

    if (document.height)
    {
        height = document.height;
    }
    else if (document.body)
    {
        if (document.body.scrollHeight)
        {
            height = scrollHeight = document.body.scrollHeight;
        }
        if (document.body.offsetHeight)
        {
            height = offsetHeight = document.body.offsetHeight;
        }

        if (scrollHeight && offsetHeight)
        {
            height = Math.max(scrollHeight, offsetHeight);
        }
    }

    return height;
}

function getViewPortHeight()
{
    var height = 0;

    if (window.innerHeight)
    {
        height = window.innerHeight - 18;
    }
    else if ((document.documentElement) && (document.documentElement.clientHeight))
    {
        height = document.documentElement.clientHeight;
    }
    else if ((document.body) && (document.body.clientHeight))
    {
        height = document.body.clientHeight;
    }

    return height;
}

window.onload = function(event)
{
	window.setInterval(publishHeight, 300);
}

