function sortNum(a, b) { return b - a }
function fixH2(one, two, three) {
    if (document.getElementById(one)) {
        var obj = new Array(3);
        var option = [one, two, three];
        for (var i = 0; i < option.length; i++) {
            document.getElementById(option[i]).style.height = "auto";
            obj[i] = document.getElementById(option[i]).offsetHeight;
            nh = obj.sort(sortNum);
        }
        nh1 = nh.splice(1, 2);
        for (var i = 0; i < option.length; i++) {
            document.getElementById(option[i]).style.height = nh + "px";
        }
    }
}

window.onload = function() {
    fixH2('Box1', 'Box2', 'Box3');
}

function formReset() {
    var x = document.forms.contact_entry
    x.reset()
}

function expCollapse(tableId, theImg) {
    $("#" + tableId).slideToggle({
        collapsible: true
    });
    var theTable = document.getElementById(tableId);
    var theImage = document.getElementById(theImg);
    var ImageAlt = theImage.alt.toLowerCase();
    var imgPath = document.getElementById(theImg).src.split('images/');

    if (imgPath[1] == 'expand.gif') {
        theImage.src = imgPath[0] + 'images/collapse.gif';
        theImage.alt = 'expand';
    }
    else if (imgPath[1] == 'collapse.gif') {
        theImage.src = imgPath[0] + 'images/expand.gif';
        theImage.alt = 'collapse';
    }
}

function popup(theSrc, theWidth, theHeight, scrollbar) {
    LeftPosition = (screen.width) ? (screen.width - theWidth) / 2 : 100;
    TopPosition = (screen.height) ? (screen.height - theHeight) / 2 : 100;

    window.open(theSrc, '', 'width=' + theWidth + ',height=' + theHeight + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scrollbar + ',resizable=1,location=0,toolbar=0,status=1');
}

function getElementsByClassName(oElm, strTagName, strClassName) {
    var arrElements = (strTagName == "*" && oElm.all) ? oElm.all :
        oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for (var i = 0; i < arrElements.length; i++) {
        oElement = arrElements[i];
        if (oRegExp.test(oElement.className)) {
            arrReturnElements.push(oElement);
        }
    }
    return (arrReturnElements)
}
