// ====================
// Function:    addEvent
//
// Purpose:     Attach an event dynamically to any object.
//
// Input:       obj - the object to attach event to
//              evType - name of the event - DONT ADD "on", pass only "mouseover", etc
//              fn - function to call
//
// Output:      true | false
//
// Assumptions: -
//
// History:     20090113 RW Included from Seth Banks http://www.subimage.com/dhtml/
// ====================
function addEvent(obj, evType, fn) {
    //alert("addEvent here");
    if (obj.addEventListener) {
        obj.addEventListener(evType, fn, false);
        return true;
    } else if (obj.attachEvent){
        var r = obj.attachEvent("on"+evType, fn);
        return r;
    } else {
        return false;
    }
}

// ====================
// Function:    GetObjectHeight
//
// Purpose:     Returns the height of any passed in block level object
//
// Input:       ID of item
//
// Output:      Returns the height of any passed in block level object
//
// Assumptions: -
//
// History:     SC 2006-05-15
// ====================
function GetObjectHeight(objectRef) {
    var intHeight = -1;

    if (document.getElementById) {
        if (document.getElementById(objectRef)) {
            intHeight = eval(document.getElementById(objectRef).offsetHeight);
        }
    } else if (document.all) {
        if (document.all[objectRef]) {
            intHeight = document.all[objectRef].scrollHeight;
        }
    } else if (document.layers) {
        if (document[objectRef]) {
            intHeight = document[objectRef].clip.bottom;
        }
    }

    return intHeight;
}

// ====================
// Function:    SetUniformHeight
//
// Purpose:     Sets a number of page objects to a uniform height, being the
//              maximum height of any of the given objects.
//
// Input:       strPageObjects - Comma separated list of object IDs that should
//              be set to a uniform height.
//
// Output:      Updates the height of the given objects.
//
// Assumptions: GetObjectHeight()
//
// History:     20060823 RW Created
// ====================
function SetUniformHeight(strPageObjects) {
    intMaxHeight = 0;

    if (strPageObjects) {
        arrPageObjects = strPageObjects.split(",");
    }

    if (arrPageObjects) {
        // Find the height of the tallest object.
        for (i = 0; i < arrPageObjects.length; i++) {
            intThisHeight = GetObjectHeight(arrPageObjects[i]);
            if (intThisHeight > intMaxHeight) {
                intMaxHeight = intThisHeight;
            }
        }

        // Set all the objects to the same (maximum) height if a height larger
        // than 0 was found.
        if (intMaxHeight > 0 ) {
            for (i = 0; i < arrPageObjects.length; i++) {
                //if (gblnIE)  {
                //    strMaxHeight = intMaxHeight;
                //} else {
                    strMaxHeight = intMaxHeight + 'px';
                //}
                if(document.getElementById(arrPageObjects[i])) {
                    document.getElementById(arrPageObjects[i]).style.height = strMaxHeight;
                }
            }
        }
    }
}

//addEvent(window,"load",SetUniformHeight('Content,blogsummaries'));
addEvent(window,"load",function(){SetUniformHeight('Content,sidebar');});
