// JavaScript Document
window.onload = function() {
    runCommonJS();

}

function runCommonJS() {
    // LEFT COL EXTENSION CHECK
    // IF NEITHER colRtSubPageArticle OR colRtSubPageArticle2 EXIST then do nothing
    if ((document.getElementById("colRtSubPageArticle") == null) && (document.getElementById("colRtSubPageArticle2") == null)) {
        RightColExtension();
    // IF colRtSubPageArticle EXISTS AND colRtSubPageArticle2 DOES NOT EXIST run LeftColExtension
    } else if ((document.getElementById("colRtSubPageArticle2") == null) && (document.getElementById("colRtSubPageArticle") != null)) {
        LeftColExtension();
    // IF colRtSubPageArticle2 EXISTS AND colRtSubPageArticle DOES NOT EXIST run LeftColExtension
    } else if ((document.getElementById("colRtSubPageArticle") == null) && (document.getElementById("colRtSubPageArticle2") != null)) {
        LeftColExtension();
    }
}

function LeftColExtension() {
    var LeftCol = document.getElementById("columnLeft");
    var RightColHeader = document.getElementById("colRtSubPageHeader");
    var RightColHeaderHeight = RightColHeader.offsetHeight;
    var RightColArticleRight = "0";

    // Determine RightColArticle vars
    if (document.getElementById("colRtSubPageArticle") != null) {
        var RightColArticle = document.getElementById("colRtSubPageArticle");
    // IF colRtSubPageArticle2 set RightColArticleRight vars
    } else if (document.getElementById("colRtSubPageArticle2") != null) {
        var RightColArticle = document.getElementById("colRtSubPageArticle2");
        RightColArticleRight = document.getElementById("colRtSubPageArticle2Right");
        RightColArticleRightHeight = RightColArticleRight.offsetHeight;
    } else if (document.getElementById("colRtIndex") != null) {
		 var RightColArticle = document.getElementById("colRtIndex");
		 RightColArticleRight = document.getElementById("colRtIndexRight");
		 RightColArticleRightHeight = RightColArticleRight.offsetHeight;
	}
    var RightColArticleHeight = RightColArticle.offsetHeight;
    LeftCol.style.height = RightColArticleHeight + RightColHeaderHeight + 10 + "px";

    // IF RightColArticleRight vars are not equal to 0 set height
    if (RightColArticleRight != "0") {
        RightColArticleRight.style.height = RightColArticleHeight + 2 + "px";
	}
}
function RightColExtension() {
	var LeftCol = document.getElementById("columnLeft");
    var RightCol = document.getElementById("columnRight");
	var RightColHeight = RightCol.offsetHeight;
	var LeftColHeight = LeftCol.offsetHeight;
    if (LeftColHeight > RightColHeight){
		RightCol.style.height = LeftColHeight;
	}
	else if (RightColHeight > LeftColHeight){
		LeftCol.style.height = RightColHeight;
	}
	else if (RightColHeight == LeftColHeight){
		null;
	}
}

