document.write("<style>#links { visibility:hidden; }</style>")
document.write("<style>.off { display:none; }</style>")

var	JavaScriptSchoolID = 403, EM_ID = 11114,
	noTabSelect = (parent.location.hash.length==0 || parent.location.hash=="#undefined")?true:false,
	monthArray = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),
	linksListRun = 0,
	MenuArray = new Array(
		{pageid:120168, hoffset:-1, voffset:-4, animate:"true"},
		{pageid:120169, hoffset:-1, voffset:-4, animate:"true"},
		{pageid:120170, hoffset:-1, voffset:-4, animate:"true"},
		{pageid:120171, hoffset:-1, voffset:-4, animate:"true"},
		{pageid:120172, hoffset:-1, voffset:-4, animate:"true"},
		{pageid:120173, hoffset:-74, voffset:-4, animate:"true"}
	);

$(document).ready(
	function(){
		$("body").bulletin({
			sid:JavaScriptSchoolID,
			gid:EM_ID,
			emButton:true,
			emButtonContainer:'.omniListItem.first',
			emButtonInsertType:'before',
			callback:function(){
				if($("#em-button").length>0){
					$("li.omniListItem:first").removeClass("first").addClass("second");
					$("#em-button").addClass("hideText banner").wrap(
						$("<li>").addClass("omniListItem first")
					);
					$("#omni").addClass("emButton");
				}
			}
		});
	

		//News & Events stuff
		$("#news").newsHeadline({
			maxNews:3,
			callback:function(){
				$("#news .newsItem").wrapInner($("<div>").addClass("newsItemWrapper"));
				$("#news .pubDate").each(function(){setDateBlock(this)});
			}
		});
		$("#events").grabEvents({
			maxEvents:3,
			callback:function(){
				$("#events .eventsItem").wrapInner($("<div>").addClass("eventsItemWrapper"));
				$("#events .startdate").each(function(){setDateBlock(this)});
			}
		});
		
		$("#newsTab a").click(
			function(){
				$("#eventsTab").removeClass("off"); $("#newsTab").addClass("off");
				$("#events").removeClass("off"); $("#news").addClass("off");
				return false;
			}
		).attr("href","")

		$("#eventsTab a").click(
			function(){
				$("#eventsTab").addClass("off"); $("#newsTab").removeClass("off");
				$("#events").addClass("off"); $("#news").removeClass("off");
				return false;
			}
		).attr("href","");
		
		//Links stuff
		$("#largeLinks").linksList({
			maxLinks:1,
			linkImage:1,
			hardPhotoWidth:302,
			callback:function(){ linksListRun++; setLinkVisibility(); }
		});
		$("#smallLinks").linksList({
			maxLinks:2,
			linkImage:1,
			hardPhotoWidth:151,
			callback:function(){ linksListRun++; setLinkVisibility(); }
		});

		//and the dropdowns
		initMenu("nav","down",MenuArray,0);
	}
);

function setLinkVisibility(){
	if(linksListRun>1){
		if($("#largeLinks .linksReturn .linkItem").length>0){ $("#smallLinks").css("display","none"); }
		else{ $("#largeLinks").css("display","none"); }
		$("#links").css("visibility","visible");
	}
}

function setDateBlock(obj){
	$(obj).html("<div class='month'>"+monthArray[$(obj).html().split("/")[0]-1]+"</div><div class='day'>"+(($(obj).html().split("/")[1].length==1)?"0"+$(obj).html().split("/")[1]:$(obj).html().split("/")[1])+"</div>");	
}