
$(window).load(function(){
	
	// resize displayed content columns to equal heights
	var height = 0; padding = 0; border = 0; totalHeight = 0; calculatedBorder = 0; margin = 0;
	var innerHeight = 0;
	var maxHeight = 0;
	var heightSource = '';
	var msg = '';
	$('#content_container > [id$=container]').each(function(){
		margin = $(this).css('marginTop') + $(this).css('marginBottom');
		if ($(this).outerHeight(margin)>maxHeight) {
			maxHeight = $(this).outerHeight(margin);
			heightSource = $(this).attr("id");	
		}
	});
	$('#content_container > [id$=container]').each(function(){
		// maxHeight is the total of border, padding, height, and margin which is ADDED IN
		margin = parseInt($(this).css('marginTop')) + parseInt($(this).css('marginBottom'));
		totalHeight = parseInt($(this).outerHeight(margin));
		padding = parseInt($(this).css('paddingTop')) + parseInt($(this).css('paddingBottom'));
		height = parseInt($(this).height());
		var noBorder = margin + padding + height;
		calculatedBorder = totalHeight - noBorder;
		setHeight = maxHeight - (padding + calculatedBorder + margin);
		$(this).css('height', setHeight); // setting this may include borders - not sure...	
	});
	$('#content_container').trigger('columnsResized');
	

});

function doColumns(){
	
	$('#content_container > [id$=container]').css('height', 'auto');
	var height = 0; padding = 0; border = 0; totalHeight = 0; calculatedBorder = 0; margin = 0;
	var innerHeight = 0;
	var maxHeight = 0;
	var heightSource = '';
	var msg = '';
	$('#content_container > [id$=container]').each(function(){
		margin = $(this).css('marginTop') + $(this).css('marginBottom');
		if ($(this).outerHeight(margin)>maxHeight) {
			maxHeight = $(this).outerHeight(margin);
			heightSource = $(this).attr("id");	
		}
	});
	$('#content_container > [id$=container]').each(function(){
		// maxHeight is the total of border, padding, height, and margin which is ADDED IN
		margin = parseInt($(this).css('marginTop')) + parseInt($(this).css('marginBottom'));
		totalHeight = parseInt($(this).outerHeight(margin));
		padding = parseInt($(this).css('paddingTop')) + parseInt($(this).css('paddingBottom'));
		height = parseInt($(this).height());
		var noBorder = margin + padding + height;
		calculatedBorder = totalHeight - noBorder;
		setHeight = maxHeight - (padding + calculatedBorder + margin);
		$(this).css('height', setHeight); // setting this may include borders - not sure...	
	});	

}


// Removes leading whitespaces
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}

