var slidenav = function() {
	$(".subnavcol").animate({"width": "toggle"}, { duration: "slow" });
	$(".subnav:hidden:first").fadeIn("slow");
	$(".scrollnews").css("bottom", "0");
};

$(document).ready(function(){
// used for home pages news flicker
	$(".newslink").mouseover(function() {
		$(".newslink").removeClass("current");	
		$(this).addClass("current");
		$("#newsimage").attr("src", "/UserFiles/Image/news/" + $(this).attr("rel") + "news.jpg");
	});
	if($('#ticker')[0]){
		$().newsTicker({newsList: "#ticker", startDelay: 10, placeHolder1: "", placeHolder2: ""});
	}

// used for Queen's at a glance in footer
	$(".glancelink").click(function () {
	  	$("#glanceinfo").slideToggle("slow");
		return false;
	});
	
// simple accordion used on sub pages	
// IMPORTANT: the following line has been added to the function to allow elements without children to be handled as links....
// It is the last part of the clickHandler function before the return....  LINE 238
// if($(event.target).siblings().length > 0) return false; //REPLACES return false;

	$('#navigation').accordion({ 
		active: false, 
		header: '.head', 
		navigation: true, 
		event: 'click',  
		animated: 'easeslide'
	});
	
// Form element focus/blur logic
	$('input,textarea').focus(function(){$(this).val($(this).attr('title') == $(this).val() ? '' : $(this).val());});
	$('input,textarea').blur(function(){$(this).val($(this).val() === '' ? $(this).attr('title') : $(this).val());});
	

// handle events (event those called after ajax updates).
	$('body').click(function(event){
		var $headline = $('h1:first');
		$(document).ajaxSend(function() {
			$('#ajaxind').slideDown();
		});
		$(document).ajaxStop(function() {
			$('#ajaxind').slideUp();
		});
		switch($(event.target).attr('id')){
			case 'launchcal':
				if(!$('#divclosecal')[0]){
					$('#subnavcol').css('zIndex', 10);
					$('#bigpic .subnav').css('zIndex', 11);
					$('#calbit')
						.after('<div id="calinner"></div><input type="hidden" id="divclosecal" value="0">')
						.css({overflow:'hidden'});
					$('#calinner').load('/cal.php?sec=' + $('#sectionid').val(), function(){
						$('a.tooltip').Tooltip({
							showURL: false,
							loadURL: true
						});																	  
					});
					$('#calinner')
						.css({textAlign:'center'})
						.html('&nbsp;&nbsp;<span style="color:#ffffff;">Loading Calendar...</span><br /><img src="/images/ajaxind2.gif" alt="Loading" />')
						.css({width:'756px',height:'230px',margin:'0 10px 10px 190px',color:'#ffffff'})
						.fadeIn('slow');
					$('#calbit').animate({width:'936px'}, 1000);
				}else{
					$('#calinner').fadeOut('slow');
					$('#calbit').animate({width:'0px'}, 1000, function(){
						$('#divclosecal').remove();
					});
				}
				break;
			case 'closecal':
				$('#calinner').fadeOut('slow');
				$('#calbit').animate({width:'0px'}, 1000, function(){
					$('#divclosecal').remove();
				});
				break;
			case 'cal_next':
			case 'cal_prev':
				$('#calinner').load('/cal.php?' + $('#' + $(event.target).attr('id') + '_id').val(), function(){
					$('a.tooltip').Tooltip({
						showURL: false,
						loadURL: true
					});
				});
				break;
		}
	});
});