
// Functions for Outer Frame


var lastId = "";

function adjustIFrameHeight(iFrameId, fragmentName, padding){
    if (window.location.hash.length == 0) return;

    if(location.hash != lastId){

        lastId = location.hash;

        if (location.hash.lastIndexOf(fragmentName) == -1) return;

        height = lastId.replace('#' + fragmentName, '');

        height_with_padding = parseInt(height) + padding;

        document.getElementById(iFrameId).style.height= height_with_padding + 'px';
    }
}

// Functions for Inner Frame


function sendDocHeightToParent(parent_url, fragmentName, adjustment){
    if (parent_url.search(/^http/) == -1) return false;
    if (adjustment === undefined) { adjustment = 0 }


	parent.location =
        parent_url + '#' +
        fragmentName +
        getBodyHeight(adjustment);
}

function getBodyHeight(adjustment)
{
    var height = 0;
    var scrollHeight;
    var offsetHeight;

    if (document.height){
    	height = document.height;
    } else if (document.body) {
    	if (document.body.scrollHeight){
    	    height = scrollHeight = document.body.scrollHeight;
    	}
    }
    return height + adjustment;
}

