willow.fixPodiumNav();

$(document).ready(function() {
	if(pdGlobal.currentPages[0].type === "content"){
		$("body").addClass("content");
	}
	$(".content #banner_photo").attr("src","http://cdn.media56.whipplehill.net/ftpimages/243/podium/style455/banner/banner_photo_"+pdGlobal.currentPages[0].id+".jpg");
	willow.SetPageTitles();
	//menu
	willow.getMenu("109866|109867|109868|109871|109877|109876|109880|109881",function(data){
   	    var menu = data.menu;
  	 	$('#nav').menu(menu,{currentL1:pdGlobal.currentPages[0].id,showL3s:false});  	 		
   	});
	
	willow.smButtons($(".buttons"),20278);
});

willow.SetPageTitles = function(){
	var LevelOne = "";
	var LevelTwo = undefined;
	switch(pdGlobal.currentPages[0].type){
		case "application":
			$("#page-title").html(pdGlobal.currentPages[0].title);
			LevelOne =pdGlobal.currentPages[0].title
			break;
		case "portal":
			$("page-title").html(pdGlobal.currentPages[0].title);
			LevelOne =pdGlobal.currentPages[0].title
		break;
		case "content":
			if(pdGlobal.currentPageLevel >= 2){
				$("#page-title").html(pdGlobal.currentPages[1].title);
				LevelTwo = pdGlobal.currentPages[1].title
			}
		break;
	}
	
	if(LevelTwo != undefined){
		fvars ={flashTxt:LevelTwo}
	} else {
		fvars ={flashTxt:LevelOne}
	}
	$('div#page-title').each(function(){
		flashembed(this, {src:"/flash/pagetitles.swf",width: 545,height: 35,wmode:"transparent"}, fvars);
		$(this).addClass('flash-replaced');
	});
}

willow.smButtons = function($obj,id){
    willow.getLinks(id,function(data){
        var links = data.link;
        if(links.length === 0){return;}
        var lstring = "";
		var maxLinks = links.length > 5 ? 5 : links.length;
        for(var i = 0; i < maxLinks; i++){
            lstring += "<a href='"+links[i].url+"'" + ((links[i].target == "true") ? " target='_blank'" : "") + ">"+
            ((typeof links[i].image !== "undefined") ? "<img src='"+links[i].image.path+"' border='0'/>" : links[i].title)+"</a>";
        }
        $obj.html(lstring);
    });
}
