/**
 * All functions that need to be run when page is loaded.
 */

// All links with the rel="external" attribute should open a new window.
function setExternalLinks() {
	$("a[rel*=external]").click( function() {
        window.open(this.href);
        return false;
        // $(this).title	= "Opens a new window";        // The following conflicts with the urchin script as it also sets the title attribute.
    });
}

// The id="action-print" link should invoke a print dialog box.  We need to replace id with class as we might have more print links on one page.
function setPrintLink() {
	$("#action-print").click(function() {
		window.print();
		$(this).removeAttr("href");	// Firefox would use the href attribute if we left it here.
		$(this).css("cursor", "pointer");	// But without href, browser does not change the cursor to the "hand" icon.
		return false;
	});
}

// TODO Teon: description needed
function setEqualHeight(oGroup) {
	var iTallest = 0;
	var iHeightThis = 0;
	oGroup.each(function() {
		iHeightThis = $(this).height();
		if(iHeightThis > iTallest) {
			iTallest = iHeightThis;
		}
	});
	oGroup.height(iTallest);
}



// All functions gathered in this file are fired up when page is loaded.
$(document).ready(function() {
	setEqualHeight($('#columns > div'));
	setExternalLinks();
	setPrintLink();
});
