document.write("<style>#lInTblLCell { display:none; }</style>");
if (pdGlobal.currentPages[pdGlobal.currentPageLevel-1].type == "content"){$("#lInTblLCell").css("display","none");}
//make content page wider if we're on a content page - else show left column for portals and app pages
//add in check for list detail and news detail pages
	if((pdGlobal.currentPages[pdGlobal.currentPageLevel-1] && pdGlobal.currentPages[pdGlobal.currentPageLevel-1].type == "content") || pdGlobal.currentPages[pdGlobal.currentPageLevel-1].id == 204 || pdGlobal.currentPages[pdGlobal.currentPageLevel-1].id == 52416){
		document.write("<style>#lInTblRCell, #lPg { width:988px; }</style>");
	}else{
		document.write("<style>#lInTblLCell { display:block; }</style>");
	}
if(pdGlobal.currentPages[pdGlobal.currentPageLevel-1].id == 204){
	document.write("<style>#cbcb151 { padding-left: 20px; }</style>");
}
if(pdGlobal.currentPages[pdGlobal.currentPageLevel-1].id==6648){document.write("<style>#lInTblLCell { display: none; }</style>");}
	
	var JavaScriptSchoolID = 435, L2HoverTimeout, L2HeightTimeout, defaultL2height;
	
	function menuCallback(L1on){
		defaultL2height = ($("#L20_"+L1on).height()>0)?$("#L20_"+L1on).height():"30px";
		$("#L2nav").css("height",defaultL2height);
		
		$(".submenuhorizontal").hover(
			function(){
				clearTimeout(L2HoverTimeout);
			},function(){
				L2HoverTimeout = setTimeout(function(){ $("#L2nav").css("height",defaultL2height); },100);
			}
		);
	}
	
	/*Search Functions */
function submitSearch(){
	__pdSiteSearch('Mercersburg Academy', document.getElementById("search").value);
}
function SubmitOnEnter(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode
	if(charCode == "13" || charCode == "26"){
		submitSearch();
		return false;
	}
}
// Flash page title code
myFlash = $.flash({
	swf: '/flash/L1pagetitle.swf',
	flashvars: {
		txt: pdGlobal.currentPages[0].title,
		callback: 'flashResizeHeader'
	},
	height: 50,
	id:'flashptl1'
	
});	
	
function flashResizeHeader(id,w){
	$("#flashptl1").width(w+"px");
}	
	
$(document).ready(function(){
	$('div.ptl1').html(myFlash);
	
	var options = {
	xml_path:"/xml/default.asp",
	sid:435,
	gid:10943
	};
	$('body').bulletin(options);
	
	var MenuArray = new Array(
	{pageid : 124638,hoffset:8,voffset:0},
	{pageid : 124641,hoffset:8,voffset:0},
	{pageid : 124642,hoffset:8,voffset:0},
	{pageid : 124643,hoffset:8,voffset:0},
	{pageid : 124644,hoffset:8,voffset:0},
	{pageid : 124645,hoffset:8,voffset:0},
	{pageid : 124646,hoffset:8,voffset:0},
	{pageid : 124647,hoffset:8,voffset:0},
	{pageid : 124648,hoffset:8,voffset:0}
	);

	var options = {
	css_path:"/css/menu_h.css",
	xml_path:"/xml/default.asp",
	sid:435,
	direction:"horizontal",
	settings:MenuArray,
	currentL1: pdGlobal.currentPages[0].id,
	showL3s:false,
	callback: function(L1on){menuCallback(L1on)},
	speed:0
	};
	$('#nav').menu(options); 	
	$('#quicklinksList').listL2s({callback:function(){dropQuicklinks();}}); 
	$('#L1_124638').listL2s(); 
	$('#L1_124641').listL2s();
	$('#L1_124642').listL2s();
	$('#L1_124644').listL2s();
	$('#L1_124645').listL2s();
	$('#L1_124648').listL2s();
	$('#L1_124646').listL2s();
	
	$("#nav a").hover(
		function(){
			var thisL1 = $(this).attr("id").split("_")[1];
			clearTimeout(L2HoverTimeout);
			if($("#L20_"+thisL1).height()<$("#L2nav").height()){
				L2HeightTimeout = setTimeout(function(){ $("#L2nav").css("height",$("#L20_"+thisL1).height()); },50);
			} else {
				$("#L2nav").css("height",$("#L20_"+thisL1).height());
			}
			
		},function(){
			clearTimeout(L2HeightTimeout);
			L2HoverTimeout = setTimeout(function(){ $("#L2nav").css("height",defaultL2height); },100);
		}
	);
	
	switch(pdGlobal.currentPages[0].id){
  	case 124638: GetPhotos(16867); break;
  	case 124641: GetPhotos(16868); break;
  	case 124642: GetPhotos(16869); break;
  	case 124643: GetPhotos(16870); break;
  	case 124644: GetPhotos(16871); break;
	case 124645: GetPhotos(16872); break;
	case 124646: GetPhotos(16873); break;
	case 124647: GetPhotos(16874); break;
	case 124648: GetPhotos(16875); break;
	default: GetPhotos(17377); break;
  } 

});

//removing quicklinks that don't fit	
	function dropQuicklinks(){
		while ($("#L2list_124649").width() > 735){
			$("#L2list_124649 li.L2item:last").attr("class","hide");
		}
	} 

//banner photo function
function GetPhotos(pID){	
	var hasPhotos = false;
	$.ajax({
		type: "GET",
		url: "/xml/default.asp?sid=435&type=photoall&id="+pID+"&dPhoto=/ftpimages/435/podium/Style744/images/default_banner.jpg",
		dataType: "xml",
		success: function(xml) {
			//alert(lphotos);		
				var totalphotos = parseInt($(xml).find('item').attr("totalphotos"));
				var randomNum = Math.floor(Math.random() * (totalphotos-1));
				var randCount = 0;
				$(xml).find('image').each(function(){
					if(randCount == randomNum){
						//set my photo					
						var path = $(this).find("path").text();												
						$("#banner_photo").css("background","url("+path+") no-repeat");						
					}
					randCount++;
				});			
		},
		error: function(request,tStatus,eThrown){
			//alert("Cant Get Photos");
		}
	});		
}
