var rotatorTimeout = 5000;

jQuery(function () {
	var BACKGROUND_COOKIE = 'background';
	var background = jQuery.cookie(BACKGROUND_COOKIE);
	var body = jQuery('body');
	if (background != null && body.hasClass(background) == false)
		body.addClass(background);
		
  	jQuery('div.left-nav').accordion({
  		header: 'h2', collapsible: true, event: 'click', active:'.open'
  	});
  	
	jQuery('.footer-images').jKwick({min: 222, max: 534, mid: 326});
	jQuery(".footer-images li").hover(function(){
		jQuery(this).children('div').animate({bottom:28},100);
		jQuery(this).children('p.copy').fadeTo('fast', 0.9);
		},function(){
		jQuery(this).children('div').animate({bottom:0},100);
		jQuery(this).children('p.copy').fadeTo('fast', 0.0);
	});
	jQuery(".footer-images li").click(function(){
		var url = jQuery(this).children('div').children('p.title').children('a').attr('href');
		window.location.href=url;
		return false;
	});
			
/**
Adds a class with the same name as the id of the selected element to the body element of the page 
*/
	jQuery('.colorChanger').click(function(){
		var background = jQuery(this).attr('id');
		jQuery('.colour-changer > ul > li > a').each(function(){
			var className = jQuery(this).attr('id');
			if (className != background && body.hasClass(className))
				body.removeClass(className)
		});
		if ((body).hasClass(background) == false){
			body.addClass(background);
		}
		jQuery.cookie(BACKGROUND_COOKIE, background, { path: '/', expires: 365 });
		return false;
  	});
	
	
});

//Returns anchor from link string
function getHash(a_sLink){
   // Check for anchor and select active image from nav
   var hash = '';
   if((a_sLink.match(/#(\w.*)/) != null)){
       hash = a_sLink.match(/#(\w.*)/)[1];
   }
  return hash;
}