if(!document) // for firefox, which doesn't find the document object sometimes...
{
    window.location.reload();
}


/**
* begin iframe resizing code
* The following is adapted from rasquis' posting at 10 March 05, 10:45am on
* http://www.geekforum.com/forum/forum_posts.asp?TID=347&PN=1&get=last
*/
function autoResizeIframe(iframe_obj)
{
    iframe_obj.scrolling = "no";
    /*
    alert('iframe height (outside): '+iframe_obj.height);
    alert('iframe height (peeking inside): '+iframe_obj.inside_height);
    alert('iframe height (peeking inside): '+iframe_obj.contentWindow.inside_height);
    */
    return;
    
    var newheight;
    if (!window.opera && !document.mimeType && document.all && document.getElementById)
    {
        newheight=iframe_obj.contentWindow.document.body.offsetHeight;
    }
    else if(document.getElementById)
    {
        newheight=iframe_obj.contentWindow.document.body.scrollHeight;
    }
    
    iframe_obj.height = (newheight + 30) + "px";
    iframe_obj.width = "100%";
}
/* end iframe resizing code */




/**
* begin query_string handling code
* The following is adapted from Peter A. Bromberg's script on
* http://www.eggheadcafe.com/articles/20020107.asp
*/
function PageQuery(q)
{
    if(q.length > 1)
    {
        this.q = q.substring(1, q.length);
    }
    else
    {
        this.q = null;
    }
    
    this.keyValuePairs = new Array();
    if(q)
    {
        for(var i=0; i < this.q.split("&").length; i++)
        {
            this.keyValuePairs[i] = this.q.split("&")[i];
        }
    }
    
    this.getKeyValuePairs = function()
    {
        return this.keyValuePairs;
    }
    
    this.getValue = function(s)
    {
        for(var j=0; j < this.keyValuePairs.length; j++)
        {
            if(this.keyValuePairs[j].split("=")[0] == s)
            {
                return this.keyValuePairs[j].split("=")[1];
            }
        }
        return false;
    }
    
    this.getParameters = function()
    {
        var a = new Array(this.getLength());
        for(var j=0; j < this.keyValuePairs.length; j++)
        {
            a[j] = this.keyValuePairs[j].split("=")[0];
        }
        return a;
    }
    
    this.getLength = function()
    {
        return this.keyValuePairs.length;
    }
}

function queryString(key)
{
    var page = new PageQuery(window.location.search);
    return unescape(page.getValue(key));
}

function getQueryStringValue(key)
{
    if(queryString(key)!='false')
    {
        return queryString(key);
    }
    else
    {
        //alert("you didn't enter a ?name=value querystring item.");
        return false;
    }
}
/* end query_string handling code */




/* begin page handling code */
function renderIframe(iframe)
{
    var page = false;
    
    switch (getQueryStringValue("page"))
    {
        case "node_status":
            page = "node_status";
        break;
        
        case "state":
            var state = getQueryStringValue("state");
            if (false != state)
            {
                page = "state_" + state;
            }
            else
            {
                page = "state";
            }
        break;
        
        case "dataflow":
            var id = getQueryStringValue("id");
            if (false != id)
            {
                page = "dataflow_" + id;
            }
        break;
    }
    
    if (false != page)
    {
        var src = "/exnet/html/" + page + ".html";
        iframe.src = src;
        //document.write("<iframe id=\"" + frame_id + "\" src=\"" + src + "\" width=\"100%\" height=\"250\" frameborder=\"0\" scrolling=\"no\" onload=\"autoResizeIframe('" + frame_id + "')\"></iframe>");
    }
}

// renderIframe();
/* end page handling code */
