/**
 * Careers namespace.  
 * Dependencies:
 * JQuery - tested with version 1.3.2 - include above this file
 */
Careers = {
	manageTableOfContentWidths : function() {
		var max = 0;

		// get the max width
		$('#center .contentOverviewColumn ul li a').each(function() {
			var width = this.offsetWidth;

			max = (width > max  ? width : max);
		});

		// set the others
		$('#center .contentOverviewColumn ul li').each(function() {
			$(this).width(max);
		});
	},
		
	manageOverviewHeights : function() {
		var lHeight = $('.contentOverview .contentTwoColumn').outerHeight();
		var rHeight = $('.contentOverview .contentColumn').outerHeight();

		if (lHeight > 0 && rHeight > 0) {
			if (lHeight > rHeight) {
				// put the border on the left-hand side
				$('.contentOverview .contentTwoColumn').css('border-right','21px #ffffff solid');
			}
			else {
				// put the border on the right-hand side
				$('.contentOverview .contentColumn').css('border-left','21px #ffffff solid');
			}
		}
	},
	
	managePromoLinks : function() {
		// click on the promo and open the link straight away
		$('.promo').click(function(e) {
			var a = $('a', this);

			// make sure there is only one link, otherwise just let the default action handle the click
			if (a.length == 1) {
				var url = a.attr('href');
				location.href = url;

				// prevent the default action
				e.stopPropagation();
				e.preventDefault();	
			}
		});
	}
}

$(document).ready(function() {
	if (Careers) {
		// single click promptions are clickable anywhere
		Careers.managePromoLinks();
		// the underlines on table of content links are the width of the widest
		Careers.manageTableOfContentWidths();
		// allow sIFR to run and then set the heights on LoS pages
		window.setTimeout(Careers.manageOverviewHeights, 1000);
	}
});
