﻿addEvent(window, "load", initLayout);

function initLayout(){
	var siteLayout = new Layout();
	siteLayout.Adjust();
}

//This function is used to stretch each of the three columns to the lowest common denominator of all three columns
function Layout(){
	var ch = $("channelHeading");
	var pc = $("primaryColumn");
	var cc = $("contentColumn");
	//var sc = $("secondaryColumn");  //removed b/c we don't have a secondaryColumn
	var maxHeight;
	var ccTopMargin = 12;

    this.Adjust = function(){with(this){
    
    
		if (GetHeight(pc) > GetHeight(cc)){
			maxHeight = GetHeight(pc);
		}else{
			maxHeight = GetHeight(cc);
		}
		/*if (maxHeight < GetHeight(sc)){
			maxHeight = GetHeight(sc);
		}*/

		maxHeight += (ccTopMargin * 2)

		SetHeight(pc, maxHeight + 1); 
		SetHeight(cc, maxHeight - GetHeight(ch) + ccTopMargin + 1); 
		//SetHeight(sc, maxHeight - GetHeight(ch) + ccTopMargin + 1);
		
	}}
	
	function GetHeight(id){
		return id.offsetHeight;
	}

	function SetHeight(id, newHeight){
		id.style.height = newHeight + 'px';
	}
	
	function Cleanup(){
		ch = null;
		pc = null;
		cc = null;
		//sc = null;
		removeEvent(window,"unload",Cleanup);
	}
	addEvent(window,"unload",Cleanup);
}