willow.fixPodiumNav();

willow.ready(function($) {
	// Menu data 
	var menuOptions = {direction:"down", showL3s:false, currentL1:pdGlobal.currentPages[0].id};
	willow.getMenu("111445|111446|111450|111447|111448|111449",function(data){
		$('#L1').menu(data.menu,menuOptions);
		
		var $sitemap = $(".sitemap");
		if($sitemap.length > 0){
			$sitemap.sitemap(data);
			//uncomment this if you want to expand all by default $("#expand").click();
		}
	});
	
	// Emergency Bulletin
	var emOptions = {emButtonPosition: "right", emButton: false};
	willow.getNews("9495",function(data){$('#Form1').bulletin(data,emOptions);},{"backlink":window.location});
	
	// Podium Search 
	$('#search').pdSearch({showButton:true, showButtonClass:'searchBtn', showButtonText:''});
	
	// On states for left col omni nav
	if(pdGlobal.currentPages[pdGlobal.currentPages.length-1].id === 111808){$("#sitemap").addClass("on");}
	if(pdGlobal.currentPages[pdGlobal.currentPages.length-1].id === 111845){$("#privacy").addClass("on");}
	
	// Homepage specific styles //
	if(pdGlobal.currentPages[pdGlobal.currentPages.length-1].id === 136352){
		$("#Form1").addClass("homepage");
		$("#bannerPhotos").removeClass("hideEl");
		
		willow.getPhotos(23945,function(data){//
			// default photo path var so only one template can be used
			var dPath = {path:"https://cdn.media910.whipplehill.net/ftpimages/371/podium/Style620/images/defaultPhoto.jpg"};
			if(typeof data.photo.images === "undefined"){
				$("#bannerImgTmpl").tmpl(dPath).appendTo("#photos");
			}else{
				// Check to see if there are photos added to the album if not show default photo
				if(data.photo.images[0].path.length > 22){
					$("#bannerImgTmpl").tmpl(data.photo.images).appendTo("#photos");
					$("#photos").cycle({after: willow.capChange, speed: 500});
				}else{$("#bannerImgTmpl").tmpl(dPath).appendTo("#photos");}
			}
		});
	}
});

willow.capChange = function(){
	if($(this).attr("desc").length > 0){
		$("#photoCaption").html("<span>"+$(this).attr("desc")+"</span>").removeClass("hideEl");
	}
	else{
		if(!$("#photoCaption").hasClass("hideEl")){$("#photoCaption").addClass("hideEl");}
	}
}


