/* Global Effects and Helpers */
jQuery(document).ready(function($) {

	/* Image Sliders */
	$('.ImageSlider').ImageSlider({'iconColor': '#e5e5e7', 'iconColorHighlight': '#931c52','pauseTime': 4000});

	/* Image Slider - Go through each slide and move the alt text into a seperate span */
	$('.ImageSlider_Slides li').each(
		function(){
			var alt = $(this).find('img').first().attr('alt');
			var aList = $(this).find('a');
			if(aList.length > 0){
				$($(aList[0])).append('<span>' + alt + '</span>');
			}else{
				$(this).append('<span>' + alt + '</span>');
			}
		}								 
	);

	/* The bars on the School Nav - Fade in and out */
	$('#Nav_Schools a').addClass('NoHover');
	$('#Nav_Schools a').hover(
		function(){
			$(this).find('.Bar').first().fadeIn();
		},
		function(){
			$(this).find('.Bar').first().fadeOut();
		}
	);

	/* Clear Search Box on Click */
	$('#Tmp_Search').focus(
		function(){
			if($(this).val() == "SEARCH"){
				$(this).val('');
			}
		}
	);

	/* News Box Fades */
	$('#Tmp_News li a').addClass('NoHover');
	$('#Tmp_News li a').hover(
		function(){
			$(this).animate({backgroundColor: '#eeeeee'});

		},
		function(){
			$(this).animate({backgroundColor: '#ffffff'});
		}
	);

	/* Scrollers */
//	$('#Tmp_News ul, #Tmp_Noticeboard ul, #Tmp_Twitter ul, #Tmp_HCNoticeboard ul').jScrollPane({maintainPosition: false, dragMaxHeight: 50});
	$('#Tmp_News ul, #Tmp_Noticeboard ul, #Tmp_HCNoticeboard ul').jScrollPane({maintainPosition: false, dragMaxHeight: 50});

	/* Add the updated arrow beside updated things */
	$('.Updated').each(
		function(){
			$(this).append("<div class=\"UpdatedArrow\"> </div>");
		}				   
	);
	
	/* Do Nice Fade-ins on the social share buttons */
	$('#Tmp_SocialMedia a').each(
		function(){
			// Add the nohover class which overrides the base css :hover state
			$(this).addClass('NoHover');
			// Add the hover state
			$(this).append('<span class="Hover" />');
		}
	);


	$('#Tmp_SocialMedia a').hover(
		function(){
			$(this).find('span.Hover').css({'opacity':0,'display':'block'});
			$(this).find('span.Hover').animate({opacity: 1},200,'swing');
		},
		function(){
			$(this).find('span.Hover').animate({opacity: 0},250,'swing');	
		}
	);

});
