﻿// JScript File

function elem(id) {
    if (document.getElementById != null) {
        return document.getElementById(id);
    }
    if (document.all != null) {
        return document.all[id];
    }
    if (document.layers != null) {
        return document.layers[id];
    }
    return null;
}

function height(id) {
    var e = elem(id);
    if (e) {
        return parseInt(e.offsetHeight);
    }
    return 0;
}

function windowHeight() {
    var height = 0;
    if( typeof( window.innerHeight ) == 'number' ) {
	//Non-IE
	height = window.innerHeight;
    } else if( document.documentElement && document.documentElement.clientHeight ) {
	//IE 6+ in 'standards compliant mode'
	height = document.documentElement.clientHeight;
    } else if( document.body && document.body.clientHeight ) {
	//IE 4 compatible
	height = document.body.clientHeight;                                                                                                                   }
    return parseInt(height);
}

function stretchPage() 
{
    if (document.location.href.indexOf("?q") == -1)
    {
        var spacer = elem('body');
        var newheight = windowHeight() - height('footer') - height('header') - height('logo');
        if (newheight < 1) newheight = 1; // set to 1 because there are bugs in moz and konq when setting height to 0
        spacer.style.height = newheight + 'px';
    }
}

frame = null;

function forceHeight()
{
    res = document.getElementById("results_017645156902814103425:oqoknjohjt8");
    if (res)
    {
        if (res.getElementsByTagName("iframe").length > 0)
        {
            frame = res.getElementsByTagName("iframe")[0];
            frame.onreadystatechange = onloadiframe;
            frame.style.display = "block";
            frame.style.width = "700px";
        }
        else
            stretchPage();
    }
//    if (document.getElementById("hIsPost").value != "false")
//    {
//        stretchPage();
//    }
    //alert(document.getElementById("hIsPost").value);
    //if (!(this.window.location.href.indexOf("?q") > 0))
    //    stretchPage();
}

function onloadiframe()
{
    if (frame.readyState == "complete")
        stretchPage();
        
}