var $events=new Array();var $currentPage="default";var $page="";var $jumps=0;$(function(){$("#nDown").on("click",function(event){if(!$("#slider").is(':animated')){var $height=$("#news-scroller").height();var $sliderheight=$("#slider").height();var $border=1;var $move=0;var $i=0;var $currentTop=$("#slider").css("marginTop");$currentTop=$currentTop.substr(0,$currentTop.length-2);if($currentTop-$height>($sliderheight*-1)){$("#slider").children().each(function(){if($i++==$jumps){if($move+$(this).height()+$border<=$height){$jumps++;$move+=($(this).height()+$border);}else{return false;}}});$("#slider").animate({marginTop:'-='+$move},1000);}}});$("#nUp").on("click",function(event){if(!$("#slider").is(':animated')){$("#slider").animate({marginTop:'0'},1000);$jumps=0;}});$("#permalink").on("click",function(event){$url=$(location).prop('href');$url=$url.split("?");if($page!="")$url=$url[0]+"?page="+$page;alert($url);});$("#refresh").on("click",function(event){if($page!="")refreshPage();});$(".upcoming-item").on("click",function(event){var $base=247;if($(this).width()==$base){var $len=parseInt($(this).children(".more").html().length);var $increase=($len*4.5);$(this).animate({width:$base+$increase+5});}else{$(this).animate({width:$base});}
$(this).children(".elipses").toggle();$(this).children(".more").toggle();});$("#tc-right").load("getImages.php",function(){$('#top-content #tc-right').cycle({fx:'fade',timeout:6000,pause:1});});var $linksLeft="<ul class='navboxLinks' style='padding-top: 0px;'>";var $linksRight="<ul class='navboxLinks' style='padding-top: 0px;'>";$("#dept-links .links .leftC .navboxLink").each(function(){$linksLeft+="<li class='navboxLink'>"+($(this).html())+"</li>";});$linksLeft+="</ul>";$("#dept-links .links .rightC .navboxLink").each(function(){$linksRight+="<li class='navboxLink'>"+($(this).html())+"</li>";});$linksRight+="</ul>";$("#perm-deptLinks #left-deptLinks").html($linksLeft);$("#perm-deptLinks #right-deptLinks").html($linksRight);$("#dept-links .navboxLink a").mouseover(function(){$("#dept-image img").prop("src","Images/Department-Images/"+$(this).attr("id")+"-Image.jpg");});$(".navLink,.navboxLink a").on("click",function(ev){$("#nalist").children("li").css('backgroundColor','');if(!($(this).attr("class"))||($(this).hasClass("navLink")&&$(this).attr("id")=="portal")){updateLastSeen();return;}
ev.preventDefault();ev.stopPropagation();$theId=$(this).attr("id");$page="";switch($theId){case"aboutus":$page="Aboutus.php";break;case"psychology":$page="Departments/Psychology.php";break;case"contact":$page="Contact.php";break;case"documentation":$page="Documentation.php";break;case"location":$page="Location.php";break;case"parentinfo":$page="ParentInfo.php";break;case"pupilinformation":$page="PupilInfo.php";break;case"pressrelease":$page="PressRelease.php";break;case"sixthform":$page="SixthForm.php";break;case"survey":$page="Survey.php";break;case"videos":$page="Videos.php";break;case"exam":$page="ExamTimetables.php";break;case"clubs":$page="ClubsAndCompetitions.php";break;case"revisionguidance":$page="RevisionGuidance.php";break;case"lettershome":$page="Letters-Home.php";break;case"newsletters":$page="Newsletters.php";break;case"interfaceA":$page="Interface.php";break;case"parentsForum":$page="ParentsForum.php";break;case"pupilParliament":$page="PupilParliament.php";break;case"pressRelease":$page="PressRelease.php";break;case"policies":$page="Policies.php";break;case"studySupport":$page="StudySupport.php";break;case"options":$page="Options.php";break;case"careersupport":$page="CareerSupport.php";break;case"vacancies":fullScreen();$(this).parent("li").css('backgroundColor','#71bbe3');$page="Vacancies.php";break;case"sixthformdept":$page="Departments/SixthForm.php";break;case"art":$page="Departments/Art.php";break;case"business":$page="Departments/Business.php";break;case"careers":$page="Departments/Careers.php";break;case"parentAdvice":$page="ParentAdvice.php";break;case"construction":$page="Departments/Construction.php";break;case"dance":$page="Departments/Dance.php";break;case"designtechnology":$page="Departments/DesignTechnology.php"
break;case"drama":$page="Departments/Drama.php";break;case"english":$page="Departments/English.php";break;case"foodtechnology":$page="Departments/FoodTechnology.php";break;case"geography":$page="Departments/Geography.php";break;case"healthandsocialcare":$page="Departments/HealthSocialCare.php";break;case"history":$page="Departments/History.php";break;case"ict":$page="Departments/ICT.php";break;case"inclusion":$page="Departments/Inclusion.php";break;case"maths":$page="Departments/Mathematics.php";break;case"media":$page="Departments/Media.php";break;case"mfl":$page="Departments/MFL.php";break;case"pe":$page="Departments/PE.php";break;case"public":$page="Departments/PublicServices.php";break;case"salon":$page="Departments/Salon.php";break;case"science":$page="Departments/Science.php";break;case"values":$page="Departments/Values.php";break;case"music":$page="Departments/Music.php";break;case"website":$page="Website.php";break;case"curriculum":$page="Curriculum.php";break;case"canteen":$page="Canteen.php";break;}
$("#main-content").load($page);$("div.drop").hide();if($(this).hasClass("fullscreen"))fullScreen();else if($(this).hasClass("short"))defaultScreen();else if($(this).hasClass("departmentscreen"))departmentScreen($(this).attr("id"));updateLastSeen();});function fullScreen(){if($currentPage=="fullscreen")return;$("#top-content").slideUp();$("#main-content").animate({height:701});$(".holder").slideUp();$("#selection-bar").css({height:20});if($currentPage=="department"){changeSlideImages("0");}
$currentPage="fullscreen";}
function departmentScreen($id){$("#tc-right").html("<img src='Images/SlideImages/Departments/"+$id+".jpg' height='200' width='490' alt='Department Image' />").children().show();if($currentPage=="department")return;$("#perm-deptLinks").show();$(".holder").slideUp();$("#selection-bar").css({height:20});$("#main-content").animate({height:500});$("#top-content").show();$("#calendar").hide();$("#upcoming").hide();$("#news-balloon").hide();$currentPage="department";}
function defaultScreen(){if($currentPage=="default")return;$("#calendar").show();$("#upcoming").show();$("#perm-deptLinks").hide();$("#selection-bar").css({height:80});$(".holder").slideDown();$("#main-content").animate({height:440});$("#top-content").slideDown();if($currentPage=="department"){changeSlideImages("0");}
$currentPage="default";}
$.ajax({url:"GetCalDates.php",dataType:"json",error:function(xml,status,error){alert("Failed: "+status+"\nRequest: "+xml.responseText+"\nError: "+error);},success:function(calendarEvents){$("#calendar").datepicker({numberOfMonths:[1,1],showCurrentAtPos:0,beforeShowDay:function(date){for(i=0;i<calendarEvents.length;i++){if(date.getMonth()==calendarEvents[i][0]-1&&date.getDate()==calendarEvents[i][1]&&date.getFullYear()==calendarEvents[i][2]){var month;var day;if(calendarEvents[i][0]<10){month="0"+(calendarEvents[i][0]).toString();}else{month=(calendarEvents[i][0]).toString();}
if(calendarEvents[i][1]<10){day="0"+(calendarEvents[i][1]).toString();}else{day=(calendarEvents[i][1]).toString();}
var $ename=month+"/"+day+"/"+(calendarEvents[i][2]).toString();$events[$ename]=calendarEvents[i][3];return[true,'ui-datepicker-event'];}}
return[true,"ui-datepicker-unselectable"];},onSelect:function(dateText,inst){var $balloon=$("#news-balloon");var $balloonTitle=$("#news-balloon .newsTitle");var $balloonNews=$("#news-balloon .newsItem");var theDate=new String();var dateSplit=new Array();var shownDate=new String();theDate=dateText.toString()
dateSplit=dateText.split("/");shownDate=dateSplit[1]+"/"+dateSplit[0]+"/"+dateSplit[2];$balloonTitle.html(shownDate);$balloonNews.html($events[theDate]);$balloon.show().animate({width:220},"fast",function(){$balloon.children().show();});$cal=$("#calendar");var $o=$cal.offset();var newoffset=$o.left+$cal.width();$balloon.offset(({left:newoffset-1}));}})}});$("#news-balloon #close").on("click",function(event){var $balloon=$(this).parent();$balloon.children().fadeOut('fast',function(){$balloon.animate({width:0},"fast",function(){$balloon.hide();});});});$(function(){$('#display').load('QuickNews.php',function(){loopNews();});});function loopNews(){var $count=$("div#display").children().length;if($count==1){return;}
var $i=1;for($i=1;$i<=$count;$i++){$("div#display #item"+$i).hide();}
$i=1;$("div#display #item1").show();nextNews($count,$i);}
function nextNews($count,$i){$("div#display #item"+$i).delay(7000).fadeOut('fast',function(){$("div#display #item"+(($i+1>$count)?1:$i+1)).fadeIn();nextNews($count,(($i+1>$count)?1:$i+1));});}
function changeSlideImages($dir){$("#tc-right").load("getImages.php?dir="+$dir,function(){$('#top-content #tc-right').cycle({fx:'fade',timeout:6000,pause:1});});}
$("div.top-content #left #upcoming #item").mouseenter(function(){$(this).animate({width:352},"slow",function(){$(this).children("span.elipses").hide(0);$(this).children("span.more").show(0);});});$("div.top-content #left #upcoming #item").mouseleave(function(){$(this).children("span.more").hide(0);$(this).children("span.elipses").show(0);$(this).delay(500).animate({width:247},"fast",function(){$(this).children("span.more").hide(0);$(this).children("span.elipses").show(0);});})
$(".holder").hover(function(){$(this).find(".inner-bottom").slideDown('fast');},function(){$(this).find(".inner-bottom").slideUp('fast');});$(function(){var $navbar=$("div#container div#navbarback div#navbar > ul > li");var $out=$("div#content");var $ldiv=null;var tid=-1;var hoverH=function(){var $div=$(this).children('div.drop');tid=window.setTimeout(function(){if($ldiv){$ldiv.hide().parent('li').css('backgroundColor','');}
$ldiv=$div;$div.parent('li').css('backgroundColor','#71bbe3');$div.show();},300);};var hoverOutH=function(){window.clearTimeout(tid);};var hideDiv=function(){if($ldiv)$ldiv.hide().parent('li').css('backgroundColor','');}
$navbar.mouseover(hoverH);$navbar.mouseout(hoverOutH);$out.mouseover(function(){window.setTimeout(hideDiv,300);});});function refreshPage(){$("#main-content").load($page);}
function updateLastSeen(){$.ajax({url:'updateLastSeen.php'});}});
