willow.ready(function($) {
	willow.currentNewsStory = 0;
	
	$('#search').pdSearch({showButton:true, showButtonClass:'searchButton', showButtonText:''});
	$(".searchButton").css("margin", "0");
	
	var emOptions = {
		emButtonPosition: "right",
		emButton: false
	};
	
	//CSP NRM 01/20/2011 - Changed to use announcements category for em bulletin
	//willow.getNews("13157",function(data){$('#Form1').bulletin(data,emOptions);},{"backlink":window.location});
	willow.getAnnouncement("4181",function(data){$('#Form1').bulletin(data,emOptions);},{"backlink":window.location});
				
	var menuOptions = {
		direction:"down",
		showL3s:false
	};
	willow.getMenu("138644|138645|138646|138647|138648|138649|138650",function(data){
		$('#L1').menu(data.menu,menuOptions);
	});

	$(".eventTitle").each(function(){
		$(this).html(willow.fsplit($(this).html(),25));
	})
	$(".newsLeftDetail").each(function(){
		$(this).html(willow.fsplit($(this).html(),225));
	})
	$(".newsTitle").each(function(){
		$(this).html(willow.fsplit($(this).html(),75));
	})
	$(".newsDetail").each(function(){
		$(this).html(willow.fsplit($(this).html(),325));
	})
	$(".button a").each(function(){
		$(this).html(willow.fsplit($(this).html(),28));
	})
	
	willow.buildNewsPager($(".pager"));
	
	$("#L1_138650").attr("hoffset","-72");
});	

willow.buildNewsPager = function($obj){

	var $stories = $("#stories li"),pString = "";
	
	for(var i = 0; i < $stories.length; i++){
		if(i > 0){
			$stories.eq(i).css("display","none");
		}
		pString += "<li><a href='#' id='pager_"+i+"'>"+(i+1)+"</a></li>";
	}
	
	$obj.append(pString);
	
	$("#pager_0").addClass("on_pager");
	
	$(".pager li a").click(function(e){
		e.preventDefault();
		var $obj = $(this),index = parseInt($obj.html()) - 1;
		
		$(".pager li a").removeClass("on_pager");
		$obj.addClass("on_pager");
		
		for(var i = 0; i < $stories.length; i++){
			if($stories.eq(i).is(":visible")){
				$stories.eq(i).fadeOut(250,function(){
					$stories.eq(index).fadeIn();
					willow.currentNewsStory = index;
				});
				return;
			}
		}
	});
}


