/* 
        by Paul@YellowPencil.com and Scott@YellowPencil.com
        feel free to delete all comments except for the above credit
*/

// Initialize Scripts - is this a browser that understands DOM?

function scriptInit() {
if (!document.getElementById) {
        return;
        }
}



// Set up Event Listener - the script that allows us to use the addEvent call below

function addEvent(elm, evType, fn, useCapture) {
        if (elm.addEventListener) {
        elm.addEventListener(evType, fn, useCapture);
        return true;
        } else if (elm.attachEvent) {
        var r = elm.attachEvent('on' + evType, fn);
        return r;
        } else {
        elm['on' + evType] = fn;
        }
}

// Start Column Script

function setDivHeight(div, height) {
            div.style.height = height + 'px';
                        // Now, if the browser's in standards-compliant mode, the height property
                        // sets the height excluding padding, so we figure the padding out by subtracting the
                        // old maxHeight from the new offsetHeight, and compensate!  So it works in Safari AND in IE 5.x
                       //if (div.offsetHeight > height) {
                        //    newHeight = (height - (div.offsetHeight - height));
                        //    if(newHeight >= 0)
                        //          div.style.height = (height - (div.offsetHeight - height)) + 'px';
                        //}

                }
                
function setTallDivs(divs, padding) {
//var iframeElement = parent.document.getElementById('iframeName'); 
//iframeElement.style.height = 100; //100px or 100% 
//var framewidth = (593 - (document.getElementById('right').offsetLeft));
//alert(framewidth + "px");
//document.getElementById('iframeright').style.width = (framewidth + "px");
//alert(parent.document.getElementById('iframeright').style.width);
//(document.getElementById('right').offsetLeft - 593) + 'px');
//w = document.getElementById('iframeright').offsetLeft;
//strip=/[px]/gi; w = w.replace(strip,''); w = parseInt(w); 
//alert(w);

        if (document.getElementById) {
                // the divs array contains references to each column's div element.  
                // Replace 'center' 'right' and 'left' with your own.  
                // Or remove the last one entirely if you've got 2 columns.  Or add another if you've got 4!
                // Let's determine the maximum height out of all columns specified
                var maxHeight = 0;
                for (var i = 0; i < divs.length; i++) {
                        if (divs[i].offsetHeight - padding[i] > maxHeight) maxHeight = divs[i].offsetHeight - padding[i];
                }
                        
                // Let's set all columns to that maximum height
                for (var i = 0; i < divs.length; i++) {
                    setDivHeight(divs[i], maxHeight + padding[i]);
                }

        }
}

function setTall() {
    setTallDivs( new Array(document.getElementById('center'), document.getElementById('right'), document.getElementById('left')) ,
                    new Array(0, 0, 0));
     setTallDivs( new Array(document.getElementById('topleft'), document.getElementById('topright')), 
                    new Array(0, 14) );

        setFrame();
}
/*
        Fire Events - you can add other scripts here and call them using the following method.  
        This one balances the columns when the page loads, and again when the window is resized
        Some have asked about users changing text size, because this script won't fire and your page can look weird.  If you were resizing text via a script, we could run this script when the user calls that script.  However, if you're relying on browser methods for text resizing, I'm not aware of a method to watch for that kind of an event.  If someone smarter than me knows of one, please let me know!  If you don't understand what I mean, then pretend I didn't say anything...
*/

//addEvent(window, 'load', setTall, false);
//addEvent(window, 'resize', setTall, false);

function setFrame() {
var framewidth = (591 - (document.getElementById('frameparent').offsetLeft));
//document.getElementById('iframeright').style.width = (framewidth + "px");
//document.getElementById('iframeright').style.height = ((document.getElementById('history').offsetHeight-12))  + 'px';

}



