/*
For equalising the columns - right and left on the pages. So despite the size of content in either they both line up.
*/


function equalisecolumns() {
	var columns = new Array();
	var maxheight = 0;
	
	for (var i=0; i<arguments.length; i++) {
		//creating the empty element and inserting it into the DOM
		var column = document.getElementById(arguments[i]);
		var p = document.createElement("p");
		p.style.clear = 'both';
		p.className = 'spacerelement';
		column.insertBefore(p, getLastElement(column));

		//creating array of elements / their spacer elements 
		columns.push(new Array(column, p));
			
		//set max height equal to current elements height if its greater than the current max height
		maxheight = (column.offsetHeight > maxheight ? column.offsetHeight : maxheight);
	};
	
	//setting the sizes of all the spacer elements
	for (var i=0; i<columns.length; i++) {
		if (columns[i][0].offsetHeight < maxheight) {
			columns[i][1].style.paddingBottom = parseInt(maxheight - columns[i][0].offsetHeight) + "px";
		};
	};
}

function getLastElement(ele) {
	var rtn;
	for (var i in ele.childNodes) {
		if (ele.childNodes[i].nodeType == 1) { rtn = ele.childNodes[i]; };
	};
	return rtn;
}

function callEqualise(){
if ((navigator.userAgent.indexOf('WebKit') == -1 ) && (!window.opera)) { //Not for Safari or Opera
		if (document.getElementById != 'undefined') {
			if (document.getElementById('leftcolumn')) { 
				equalisecolumns('leftcolumn', 'rightcolumn');
			}
			else {
				equalisecolumns('left', 'center', 'right');
			};
		};
	};
}

/* call the function when the page has loaded */
addLoadListener(callEqualise);
