willow.fixPodiumNav();
willow.pgTitleIcon = "";

switch(pdGlobal.currentPages[0].id){ // L1 specific styling
	case 158427: willow.pgTitleIcon = "aboutIcon"; $("body").addClass("about");break; // About Us
	case 158403: willow.pgTitleIcon = "academicsIcon"; $("body").addClass("academics");break; // Academics
	case 158474: willow.pgTitleIcon = "programsIcon"; $("body").addClass("programs");break; // Distinctive Programs
	case 158508: willow.pgTitleIcon = "boardingIcon"; $("body").addClass("boarding"); break; // Elite Boarding
	case 160683: willow.pgTitleIcon = "schoolsIcon"; $("body").addClass("global"); break; // Global Academy
	case 158514: willow.pgTitleIcon = "schoolsIcon"; $("body").addClass("schools");break; // Our Schools
	case 158911: $("body").addClass("homepage"); break; // Homepage
	default:;break;
}
switch(pdGlobal.currentPages[pdGlobal.currentPages.length-1].type){ // Page type specific styling
	case "portal": willow.pgTitleIcon = "myMeritasIcon"; $("#L1_portal").addClass("on"); break;
	case "content": $("body").addClass("hideLeftCol"); break;
	default:;break;
}

willow.ready(function($) {
	$("#Form1").bulletin({data:[{type:"news",id:12412}]});// EM bulletin
	$("img[name='s_i_whiptas']").css("display","none");// Hides the image tag created by omniture to remove it from holding space
	
	willow.getMenu("158427|158403|158474|158508|160683|158514",function(data){// Menu data 
		$('#L1').menu(data.menu,{showL3s:false, currentL1:pdGlobal.currentPages[0].id});
		
		var $sitemap = $(".sitemap");
		if($sitemap.length > 0){
			$sitemap.sitemap(data);
			//$("#expand").click(); // uncomment this if you want to expand all by default 
		}
		
		/* Client wanted custom dropdown removed
		for(var i = 0; i < data.menu.length; i++){ // Drop down menu
			if(i === data.menu.length-1){
				var $m = $("#ddTmpl").tmpl(data.menu[i]);
				$("#L2_"+data.menu[i].id).html($m).wrap(function(){ 
					willow.menuShow(); // Fires willow.menuShow only once after menus are built
				});
			}else{
				$("#ddTmpl").tmpl(data.menu[i]).appendTo("#L2_"+data.menu[i].id);
			}
		}
		*/
		
		$("#footNavTmpl").tmpl(data.menu).appendTo("#footNav");// Footer nav
	});
	
	// Add icon to page title
	$(".ptl1, .ptl2, .ptl3").css("background-image","url(/ftpimages/448/podium/style649/images/"+willow.pgTitleIcon+".png)");
	
	if(pdGlobal.currentPages[pdGlobal.currentPages.length-1].id === 158911){
		if(willow.hasFlash()){
			var flash_api = flashembed("hpFlashContainer", {src: "/flash/Meritas_Header_wh.swf",wmode:"transparent"});
		}else{
			$("#hpFlashContainer").css("background","url(/ftpimages/448/podium/style649/images/nonFlashImage_v3.png) no-repeat").html("<a class='flashLink' href='http://www.adobe.com/go/getflashplayer' target='_blank'>Get Adobe Flash player</a>");
		}
	}
	
	// Edits width of detail pages for news, events, list, and annoucements with proper styles if coming from HP
	var $curPg = pdGlobal.currentPages[pdGlobal.currentPages.length-1].id;
	if($curPg === 204 || $curPg === 52416 || $curPg === 6648 || $curPg === 52563 || ($curPg === 158911 && typeof pdGlobal.currentPages[pdGlobal.currentPages.length-2] !== "undefined")){
		$("body").removeClass("homepage").addClass("hideLeftCol");
	}
	
	// Updates margins on news archive pages
	if(typeof pdGlobal.currentPages[pdGlobal.currentPages.length-2] !== "undefined"){
		if($curPg === pdGlobal.currentPages[pdGlobal.currentPages.length-2].id){
			$("#pgCol_2").css({"width":"930px","margin":"0 25px"});
		}
	}
	
	// jQuery template self managed links
	willow.getLinks(20658,function(data){$("#linksTmpl").tmpl(data.link).appendTo("#socialMedia");});
});

/* Client wanted custom dropdown removed
willow.menuShow = function(){
	var $L2menu = $(".menuL2container"),
		$allL2 = $(".bannerL2li"),
		$allL3 = $(".bannerL3li"),
		maxH = 375,
		curPgID = pdGlobal.currentPages[pdGlobal.currentPages.length-1].id;

	// Loop to determin tallest dropdown for animate to work
	for(var i = 0; i < $L2menu.length; i++){ 
		var $curMenuHeight = $L2menu.eq(i).height();
		
		if($curMenuHeight > maxH){
			maxH = $curMenuHeight;
		}
	}
	$(".bannerL2menu").css("top","-"+maxH+"px");
	
	$(".bannerL1li").hover(
		function(){ // On hover show that particular menu
			var $this = $(this);
			$this.children(".bannerL1a").addClass("hover");
			$this.children(".menuL2container").addClass("menuShow");
			$this.find(".bannerL2menu").queue("fx", []).stop().animate({top: 0});
		},
		function(){ // Off hover hide all menus
			$(".bannerL1a").removeClass("hover");
			$(".bannerL2menu").queue("fx", []).stop().animate({top: -maxH},function(){
				$(this).parents(".menuL2container").removeClass("menuShow");
			}).queue().dequeue();
		}
	);
	
	// Loops through L2 items to set on state for current page
	for(var i = 0; i < $allL2.length; i++){
		var $curL2 = $allL2.eq(i),
			curL2ID = parseInt($curL2.attr("id").split("_")[1]);
		if(curL2ID === curPgID){
			$curL2.children(".bannerL2a").addClass("on");
		}
	}
	
	// Loops through L3 items to set on state for current page
	for(var i = 0; i < $allL3.length; i++){
		var $curL3 = $allL3.eq(i),
			curL3ID = parseInt($curL3.attr("id").split("_")[1]);
		if(curL3ID === curPgID){
			$curL3.parents(".bannerL3menu").siblings(".bannerL2a").addClass("on");
			$curL3.children().addClass("on");
		}
	}
}
*/
