document.write("<style>#annualFund, .hideOnLoad { visibility:hidden; }</style>");

var	EM_ID=0, bannerPhotoID=34004, leftColPhotoID=0, leftColButtonID=0, leftColTextID=0, L1title=0;

//set up "per-L1" groups
switch(pdGlobal.currentPages[0].id){
	case 125556: bannerPhotoID=34004; leftColPhotoID=33993; leftColButtonID=14332; leftColTextID=67525; L1title="About"; break;
	case 125580: bannerPhotoID=34233; leftColPhotoID=34223; leftColButtonID=14384; leftColTextID=67815; L1title="Admissions"; break;
	case 125581: bannerPhotoID=34234; leftColPhotoID=34224; leftColButtonID=14385; leftColTextID=67816; L1title="Academics"; break;
	case 125582: bannerPhotoID=34235; leftColPhotoID=34225; leftColButtonID=14386; leftColTextID=67817; L1title="Twenty First Century Institute"; break;
	case 125583: bannerPhotoID=34236; leftColPhotoID=34226; leftColButtonID=14387; leftColTextID=67818; L1title="The Arts"; break;
	case 125584: bannerPhotoID=34238; leftColPhotoID=34227; leftColButtonID=14388; leftColTextID=67823; L1title="Athletics"; break;
	case 125586: bannerPhotoID=34239; leftColPhotoID=34229; leftColButtonID=14389; leftColTextID=67824; L1title="Student Life"; break;
	case 131658: bannerPhotoID=34240; leftColPhotoID=34230; leftColButtonID=14390; leftColTextID=67825; L1title="Summer Programs"; break;
	case 125588: bannerPhotoID=34241; leftColPhotoID=34232; leftColButtonID=14391; leftColTextID=67826; L1title="Support Cushing Academy"; break;
}

var bulloptions = {
	emButtonPosition: "right",
    emButton: true
};

willow.portalButtons = function($obj,id){
	willow.getLinks(id,function(data){
	
		var links = data.link;
		if(links.length === 0){return;}
		var lstring = "<ul class='portalButtons'>";
		for(var i=0; i<links.length;  i++){
			lstring += "<li><a href='"+links[i].url+"'"+ ((links[i].target) ? " target='_blank'" : "") +">"+
			((typeof links[i].image !== "undefined") ? "<img src='"+links[i].image.path+"' border='0'/>" : links[i].title)+"</a></li>";
		}
		lstring += "</ul>";
		$obj.html(lstring);
	});
}

willow.ready(function(){
	willow.getNews("12215",function(data){$('body').bulletin(data,bulloptions);},{"backlink":window.location});
	/*
	if (pdGlobal.userLoggedIn){
		
		var facebookURL = $("#social_face").attr("href").slice(7);
		var linkedinURL = $("#social_linked").attr("href").slice(7);
		var twitterURL = $("#social_twit").attr("href").slice(7);
		var googletransURL = $(".goog-logo-link").attr("href").slice(7);
		var googletransImg = (".goog-logo-link img").attr("src").slice(7);
		
		$("#social_face").attr("href").val("https://"+facebookURL);
		$("#social_linked").attr("href").val("https://"+linkedinURL);
		$("#social_twit").attr("href".val("https://"+twitterURL);
		$(".goog-logo-link").attr("href".val("https://"+googletransURL);
		(".goog-logo-link img").attr("src".val("https://"+googletransImg);
		
		var secureContent =	"<li class='first navListItem'><a id='social_face' class='hideText socialNet' href='http://www.facebook.com/CushingAcademyFans' target='_blank' title='Facebook'>Facebook</a></li>			<li class='navListItem'><a id='social_linked' class='hideText socialNet' href='http://www.linkedin.com/groupInvitation?gid=53189&sharedKey=49EE4709B3BE ' target='_blank' title='linkedIn'>linkedIn</a></li>			<li class='last navListItem'><a id='social_twit' class='hideText socialNet' href='http://twitter.com/cushingacademy' target='_blank' title='Twitter'>Twitter</a></li>"
		$("#socialNetworkLinks").val(secureContent);
		
	}
	*/	
	willow.smButtons($("#socialNetworkLinks"),20341);	
	
	if (pdGlobal.currentPages[0].type === "portal"){
		willow.portalButtons($("#portalLeftColButtons"),14920);
		leftColPhotoID = 35986;
		$("#leftColItems").css("padding-top","15px");
	}
	willow.portalButtons($("#leftColButtons"),leftColButtonID);
	
	//willow.setSearch($("#search"));
	$('#search').pdSearch({showButton:false, showButtonClass:'searchSubmit',showButtonText:''});
	
	if(L1title){ $("#L1title").html(L1title).addClass(L1title.split(" ")[0]).removeClass("hideOnLoad"); }

	var $sitemap = $(".sitemap");
	willow.getMenu("125556|125580|125581|125582|125583|125584|125586|131658|125588",function(data){
		$('#nav').menu(data.menu,{ currentL1:pdGlobal.currentPages[0].id,showL3s:false });
		if($sitemap.length > 0){
			$sitemap.sitemap(data);
					//$("#expand").click();//uncomment this if you want to expand all by default
		}
	});
	
	$("#annualFund").create_annual_fund({
		html:'/afBar.html',
		dropDecimals:true,
		callback:function(){
			$("#annualFund").parent().parent().parent().parent().parent().parent().parent().parent().css("padding-right","0");
			$("#annualFund").css("visibility","visible");
		}
	});

	if(bannerPhotoID){
		var defaultBannerPhoto = $("#photoArea").html();
		$("#photoArea").attr("pid",bannerPhotoID).writePhotoAlbums({		//banner photo
			maxAlbums:1,
			randomizeAlbums:1,
			randomizePhotos:1,
			maxItems:1,
			photosPerItem:1,
			hardPhotoWidth:972,
			callback:function(numAlbums){
				if(numAlbums==0){ $("#photoArea").html(defaultBannerPhoto); }
				$("#photoArea").removeClass("hideOnLoad");
			}
		});
	}else{ $("#photoArea").removeClass("hideOnLoad"); }
	
	if(leftColPhotoID){
		$("#leftColPhoto").attr("pid",leftColPhotoID).writePhotoAlbums({		//left column photo
			maxAlbums:1,
			randomizeAlbums:1,
			randomizePhotos:1,
			maxItems:1,
			photosPerItem:1,
			setTitle:1,
			hardPhotoWidth:197,
			callback:function(numAlbums){ if(numAlbums>0){ $("#leftColPhotoWrapOut").removeClass("hideOnLoad"); } }
		});
	}
	
	/*if(leftColButtonID){
		$("#leftColButtons").attr("linkid",leftColButtonID).writeLinks({			//left column link buttons
			maxLinks:5,
			linkImage:1,
			setTitleToImage:1,
			hardPhotoWidth:205,
			callback:function(numLinks){ if(numLinks>0){ $("#leftColButtons").removeClass("hideOnLoad"); } }
		});
	}*/
	
	if(leftColTextID){
		$("#leftColText").attr("textid",leftColTextID).writeText({ callback:function(txtLength){ if(txtLength>0){ $("#leftColText").removeClass("hideOnLoad"); } } });	//left column text
	}
	
	$("embed").each(function(){
		if(parseInt($(this).attr("width")) == 478){ $(this).attr("width","448"); }
	});
	$("object").each(function(){
		if(parseInt($(this).attr("width")) == 478){ $(this).attr("width","448"); }
	})
	
});

function translatePage(languagePair){
	var e = ( document.charset || document.characterSet ), currentURL = location.href;
	location.href='http://translate.google.com/translate?u='+escape(currentURL)+'&hl=en&langpair=' + escape(languagePair) + '&tbb=1&ie='+e;
}


willow.smButtons = function($obj,id){
    willow.getLinks(id,function(data){
        var links = data.link;
        if(links.length === 0){return;}
        var lstring = "";
        for(var i = 0; i < links.length; i++){
            lstring += "<li><a  class='socialIcon' href='"+links[i].url+"'" + ((links[i].target == "true") ? " target='_blank'" : "") + ">"+
            ((typeof links[i].image !== "undefined") ? "<img src='"+links[i].image.path+"' height='20' border='0'/>" : links[i].title)+"</a></li>";
        }
		lstring += "<li id='findText'></li>"
        $obj.html(lstring);
    });
}

