$(document).ready(function(){

	// last item fixes (for IE)
	$("#footer ul li:last-child").addClass("last");
	
	
	// wrap 'call outs' in spans for formatting
	$('#content #leftCol p.callout').wrapInner('<span><span><span><span></span></span></span></span>');

	// wrap 'form errors' in spans for formatting
	$('#content #leftCol form .errors').wrapInner('<span><span><span><span></span></span></span></span>');
	
	// balance height of landing columns
	function landingColBalance(){
		landingPromo = $("#content #landingPage #leftCol .gradientBox .gradientBox2").height();
		landingRelated = $("#content #landingPage #rightCol .relatedInfo .relatedInfo2").height();
		if (landingPromo > landingRelated){
			newHeight =  $("#content #landingPage #leftCol .gradientBox .gradientBox2").height();
			$("#content #landingPage #rightCol .relatedInfo .relatedInfo2").height(newHeight - 2 + "px");
		}
	}
	$(window).resize(function(){
		landingColBalance();
	})
	landingColBalance();

	// balance height of 'I Am A...' columns
	function iAmAColBalance(){
		iAmAPromo = $("#content #iAmA #leftCol .gradientBox .gradientBox2").height() + 31;
		iAmARelated = $("#content #iAmA #rightCol .relatedInfo .relatedInfo2").height();
		if (iAmAPromo > iAmARelated){
			newHeight =  $("#content #iAmA #leftCol .gradientBox .gradientBox2").height() + 31;
			$("#content #iAmA #rightCol .relatedInfo .relatedInfo2").height(newHeight + "px");
		}
	}
	$(window).resize(function(){
		iAmAColBalance();
	})
	iAmAColBalance();

	

	// show/hide 'useful links'
	$('#content #iAmA #leftCol .usefulLinks .box h3').addClass("off"); // show h3s as 'off' by default
	$('#content #iAmA #leftCol .usefulLinks .box ul').addClass("off"); // hide all ULs by default
	$('#content #iAmA #leftCol .usefulLinks .box h3').click(function() {
		$(this).next().slideToggle();
		if($(this).attr("class")=="on"){
			$(this).attr("class","off");
		} else {
			$(this).attr("class","on");
		}
	});

	// homepage news items (show/hide)
	$('#content #homepage .showHideListing div').hide().removeClass("hide"); // hide all divs, remove 'hide' class (used to stop flickering)
	$('#content #homepage #leftCol .latestNews .showHideListing div:lt(3)').show(); // show first three news items
	$('#content #homepage #leftCol .events .showHideListing div:lt(3)').show(); // show first three events items

	$('#content #homepage .showHideMore').click(function() {
		$(this).parent().parent().parent().find('.showHideListing div:hidden:first').show();
	}); // show more items

	$('#content #homepage .showHideLess').click(function() {
		$(this).parent().parent().parent().find('.showHideListing div:visible:last').hide();
	}); // show less items
	
// homepage tabs
	$('#content #homepage ul.tabs li a').click(function() {
		$('#content #homepage ul.tabs li').removeClass("tabsOn"); // remove all 'on' state IDs
		$('#content #tabBoxes .featureBox').hide(); // hide all divs
		$("#tabBoxes .featureBox:eq("+ $('#content #homepage ul.tabs li a').index(this) + ")").show(); //show div based on index of clicked tab
		$(this).parent().addClass("tabsOn"); // add 'on' state to selected tab
		$('#content #homepage #leftCol .gradientBox h2').sifr({font: '/fonts/dax-medium.swf', verticalAlign: 'bottom', textAlign: 'left'}); // make sure sIFR is loaded
		return false; // kill links
	});

	// do sifr replacements
	// JR - // $('#content #leftCol h1').sifr({font: '/fonts/dax-medium.swf', verticalAlign: 'bottom', textAlign: 'left'});
	// JR - // $('#content #leftCol .resources h2, #content #homepage h2, #content #landingPage #leftCol h2, #content #iAmA #leftCol h2, #content #iAmA #leftCol .left h3, #content #iAmA #leftCol thead th, #content #rightCol h2').sifr({font: '/fonts/dax-regular.swf', verticalAlign: 'bottom', textAlign: 'left'});
	
	 

});
