willow.fixPodiumNav();

var MenuArray = new Array(
	{pageid : 123536},
    {pageid : 123537},
    {pageid : 123538},
    {pageid : 123539},
    {pageid : 123540},
    {pageid : 137959},
	{pageid : 123542},
	{pageid : 123543},
	{pageid : 123544},
	{pageid : 123545},
	{pageid : 123546},
	{pageid : 123547}
);

willow.ready(function($){

	//List group used to hide login box.
	willow.getList(7608,function(data){
		if(data.list.length > 0){
			for(var i=0; i < data.list.length; i++){
				if(parseInt(data.list[i].brief) === pdGlobal.currentPages[pdGlobal.currentPages.length-1].id && pdGlobal.userLoggedIn == false){
					$("#L_c4i0").css("display","none");
				}
			}
		}
	});
	
    var options = {
        sid:427,
        direction:"down",
        settings:MenuArray,
        currentL1:pdGlobal.currentPages[0].id,
        showL3s:false 
    };
	willow.getMenu("123536|123537|123538|123539|123540|137959",function(data){
		$('#L1').menu(data.menu,options);
     });
	 willow.getMenu("123542|123543|123545|123544|123546|123547",function(data){
		$('#omni').menu(data.menu,options);
     });
    //L2 Page title - adding span tag and setting width so background doesn't go 100% of column
    	$(".ptl2").wrapInner("<span></span>");    
	$(".ptl2").width($(".ptl2 span").width()+14);
    
	/*
   if(pdGlobal.currentPages[0].type == "content"){
    	$("#L1").css("display","block");
    	$("#omni").css("display","block");
    }
	*/
	//CSP sdb 052710 widen sidebar with any curriculum directory
	/*if(pdGlobal.currentPages[1].parentId == 123542 && pdGlobal.currentPages[1].title != "Counseling" && pdGlobal.currentPages[1].title != "Samuel W. Peterson Library & Resource Center" && pdGlobal.currentPages[1].title != "About the Program"){//check curriculm parentId and title*/
	/*CSP NRM 02/08/2011 - Edited this to use only necessary page IDs */
	if (pdGlobal.currentPages[pdGlobal.currentPageLevel-1].id == 131255 || pdGlobal.currentPages[pdGlobal.currentPageLevel-1].id == 131044){
    	$("tr td:nth-child(3) img").attr("width","28px").css("width","10px");//resize middle spacer
		$("tr td:nth-child(4) div:eq(0)").css("width","246px");//resize directory sidebar
		$(".fsduil").prepend("<br>");
		$.log(pdGlobal.currentPages[1].title+" "+pdGlobal.currentPages[1].id+" "+pdGlobal.currentPages[1].parentId);
    }
	
	//emergency bulletin
	willow.getNews("12719",function(data){$('#Form1').bulletin(data,{emButton: false});},{"backlink":window.location});

	willow.footerLinks($("#links_f1"),20662);
	willow.footerLinks($("#links_f2"),20664);
	willow.footerLinks($("#links_f3"),20665);
	willow.footerLinks($("#links_f4"),20666);
	willow.footerCopyright($("footer"),98738);
});

//Footer Links
willow.footerLinks = function($obj,id){
	willow.getLinks(id,function(data){
		if(data.link.length === 0){return;}
		var link_string = "";
		for(var i = 0; i < data.link.length; i++){
			if(i > 0){
				link_string += " | ";
			}
			link_string += "<a href='"+data.link[i].url+"'" + ((data.link[i].target == "true") ? " target='_blank'" : "") + ">"+((typeof data.link[i].image !== "undefined") ? "<img src='"+data.link[i].image.path+"' border='0'/>" : data.link[i].title)+"</a>";
		}
		$obj.html(link_string);
	});
}

//Copyright
willow.footerCopyright = function($obj,id){
	willow.getText(id,function(data){
		if(data.body.length === 0){return;}
		var text_string = data.body;
		$obj.html(text_string);
	});
}

/*Search Functions */
function submitSearch(){
	__pdSiteSearch('', document.getElementById("search").value);
}
function SubmitOnEnter(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode
	if(charCode == "13" || charCode == "26"){
		submitSearch();
		return false;
	}
}


