/*
JavaScript file for sretching the Sidebar and Main "columns" within the Yaletown theme for Wordpress.
*/
function setHeight() {
	if (document.getElementById) {
		var oColumns=new Array();
		oColumns[0] = document.getElementById('main');

		var oColumn = document.getElementById('sidebar');
		if(oColumn) {
			oColumns[1] = oColumn;
		}
		
		for(var i=1; i<=9; i++) {
			oColumn = document.getElementById('sidebar' + i.toString());
			if(oColumn) {
				oColumns[oColumns.length] = oColumn;
			}
		}
		var maxHeight = 0;
		for(i=0; i<oColumns.length; i++) {
			if (oColumns[i].offsetHeight > maxHeight) {
				maxHeight = oColumns[i].offsetHeight;
			}
		}
		for(i=0; i<oColumns.length; i++) {
			oColumns[i].style.height = maxHeight + 'px';
			if (oColumns[i].offsetHeight > maxHeight) {
				oColumns[i].style.height = (maxHeight - (oColumns[i].offsetHeight - maxHeight)) + 'px';
			}
		}
	}
}
function doResize() {
	if(window.setActiveStyleSheet && (typeof window.setActiveStyleSheet == 'function')) { //If Stylesheet switcher present set the active StyleSheet
		setActiveStyleSheet();
	}
	setHeight();
}
function init() {
	doResize();
	window.onresize = function(){ doResize(); }
}
