willow.ready(function($) {
	// Menu data 
	willow.getMenu("126536|126586|126605|126708|126728|127010|126751|126769",function(data){
		$('#L1').menu(data.menu,{showL3s:false});
	});
	
	// Podium Search 
	$('#search').pdSearch({showButton:true, showButtonClass:'searchButton', showButtonText:''});
	
	$("#Form1").bulletin({data:[{type:"news",id:12674}]});// EM bulletin
	
	// Photo rotation
	$("#photos").cycle({timeout: 5000, before:willow.changeTxt, next: "#nextPhoto", prev: "#prevPhoto", cleartypeNoBg:true});
	
	// News cycle
	$("#stories").cycle({timeout: 10000, pager: $("#pItems"), cleartypeNoBg:true, fit: 1});
	
	// Events html objects
	var $calenar = $("#calendar");
	var $sports = $("#sports");
	var $regEvents = $("#regEvents");
	var $athEvents = $("#athEvents");
	
	// Show calendar events and hide sports events
	$calenar.click(function(){
		$(this).css("z-index","40"); // headers
		 $sports.css("z-index","50");
		 
		 $regEvents.css("visibility","hidden"); // stories
		 $athEvents.css("visibility","visible");
	});
	// Show sports events and hide calendar events
	$sports.click(function(){
		$(this).css("z-index","40"); // headers
		 $calenar.css("z-index","50");
		 
		 $regEvents.css("visibility","visible"); // stories
		 $athEvents.css("visibility","hidden");
	});
	
	// Force character limtes, auto strips HTML	accept for news detail
	// News
	$(".newsTitle").fsplit(55);
	$(".newsDetail span").each(function(){
		$(this).html(willow.fsplit($(this).html(),425,false));
	});
	
	// Events
	$("#events .eventTitle").fsplit(25);
	$("#events .eventDetail span").fsplit(50);
	
	// Accordion links
	$(".aHead span").fsplit(25); 
	$(".aTitle").fsplit(55);
	$(".aDesc").fsplit(180);

	// Right accordion links
	var aOpts = {header:".aHead"};
    $('#accordion').accordion(aOpts);
	
	//Was adding 1px space below footer
	$("img[name*='s_i_whipgreenhill']").css("display","none");
});

// Function to change text when a photo is rotated, grabs data from image alt and title tags
willow.changeTxt = function(){
	// Strips HTML from attributes on images to get the correct character count for the photo text
	$("#largeTxt").html(willow.striphtml($(this).attr("title")));
	$("#smallTxt").html(willow.striphtml($(this).attr("alt")));
	// Keeps hardcoded in HTML #largeTxt and #smallTxt elements in photo text to keep font styling
	$("#photoText").html(willow.fsplit($("#photoText").html(),240,false));
}

