willow.fixPodiumNav();

if(typeof pdGlobal.currentPages[0].id !== "undefined"){
	switch(pdGlobal.currentPages[0].id){
		case 129192: $("#omni_parents").addClass("on"); break; //parents
		case 129218: $("#omni_alumni").addClass("on"); break; //alumni
		default:; break;
	}
}

willow.ready(function($) { 
	// Podium Search 
	$('#search').pdSearch({showButton:true, showButtonClass:'searchBtn', showButtonText:''}); 
	$(".searchBtn").css("margin","0");

	// Menu data 
	var menuOptions = {showL3s:false, currentL1:pdGlobal.currentPages[0].id};
	willow.getMenu("3355|10596|4658|4660|4661|10595|4659|4664|10594",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 
	willow.getNews("12893",function(data){$('#Form1').bulletin(data,{emButton: false}).wrap(function(){
			var w = $("#em-bar-text #text").width() + 74; // hack to center em bar text
			w = (1179 - w) / 2;
			$("#em-bar-text #text").css("margin-left",w+"px");
		});},{"backlink":window.location});
		
	willow.getText("73838",function(data){
		$("#footerSEO").html(data.text[0].body);
	});
	
	// jQuery template self managed links
	willow.getLinks(16102,function(data){
		var links = data.link;
		if(links.length === 0){return;}
		$("#linksTmpl").tmpl(links,{
			target : willow.checkTarget,
			img : willow.checkImg
		}).appendTo("#leftColLinks");
	});
	
	// homepage specific styles
	if(pdGlobal.currentPages[pdGlobal.currentPages.length-1].id === 129255){
		$("body").addClass("homepage");
	}
	
	// increase login field widths
	$("#L_lbsc_txtUserName, #L_lbsc_txtPasswordHelp, #L_lbsc_txtPassword").css("width","105px");

	/* Shift the usernav and schoolnav flyouts to the left or right */
	$("#GL_un_-1").mouseover(function(){
		var p = $("TABLE.u2g").parent();
		var l = p.css('left');
		var nl = parseInt(l) - parseInt($('#Form1').offset().left);
		nl = nl - 4;
		p.css('left',nl);
	});
	$("#GL_c5i0_sn_-1").mouseover(function(){
		var p = $("TABLE.s4g").parent();
		var l = p.css('left');
		var nl = parseInt(l) - parseInt($('#Form1').offset().left);
		nl = nl - 4;
		p.css('left',nl);
	});
	
	//live 133530
	//dev 133096
	if(pdGlobal.currentPages[pdGlobal.currentPages.length-1].id == 133530){
		//live2 5548
		//live 5521
		//dev 5509
		willow.getList(5548,function(data){
			
			if(data.list.length > 0){
				willow.createMap($("#campusMap"),data);
			}
		});
	}
});

// Checks to see if self managed link has the 'open in new tab' flag set 
willow.checkTarget = function(t){
	if(t === 1 || t === true || t === "true"){
		return " target='_blank'";
	}
	return "";
};

// Checks to see if self managed link has an image
willow.checkImg = function(lk){
	if(typeof lk.data.image !== "undefined"){
		if(lk.data.image.height > 0 && lk.data.image.width > 0){
			return "<img src='"+lk.data.image.path+"' height='"+lk.data.image.height+"' width='"+lk.data.image.width+"' alt='"+lk.data.title+"' border='0'/>"
		}else{
			return "<img src='"+lk.data.image.path+"' alt='"+lk.data.title+"' border='0'/>"
		}
	}
	return lk.data.title;
}
