// FACEBOOK
window.fbAsyncInit = function() {FB.init({appId: '122232821147507', status: true, cookie: true,xfbml: true});};
(function() {var e = document.createElement('script');e.type = 'text/javascript';e.src = document.location.protocol +'//connect.facebook.net/en_GB/all.js';e.async = true;document.getElementById('fb-root').appendChild(e); }());
var storeMe;
$(function(){
	// THIS IS FOR THE DEMO!
	// IT HIDES KENSIE'S CORNER
	$('#menu h2 a.LS_nav7').parent().parent().css('display','none');
	
	
	// CHECK && INIT NEWSREADER
	if( $('#newsReader').length > 0 ){ NEWSREADER.init(); }
	// VIDEO DISPLAY
	if( $('#flashClose').length > 0 ){ $('#flashClose').click(function(){$('#videoBox').fadeOut()});}
	if( $('#latestEp').length > 0 ){
		$('#latestEp').click(
			function()
			{
				$('#videoBox').fadeIn('500',function(){
					if(storeMe)
					{
						console.log('storeMe: ' + storeMe);
						$('#flash2').html(storeMe)
						
						if($('#flash2').offset().top < '20')
						{
							$('#flash2').css({'top':'20px','margin-top':'0'});
							$('#flashClose').css({'top':'2px','margin-top':'0 !important'});
						}
					}

				});
				if(NEWSREADER.intID)
				{
					NEWSREADER.autoPlay(false);
					$(NEWSREADER.navPlay).addClass(NEWSREADER.pause);
				}
			}
		);
	}
	// EMAIL && SEARCH FORMS
	var s = $('#search').val();var e = $('#email').val();
	$('#search, #email').focus(function(){if((this.id == 'search' && $(this).val() == s) || (this.id == 'email' && $(this).val() == e)){ this.value = ''; }}).blur(function(){if(this.id == 'search' && this.value == ''){ this.value = s; }if(this.id == 'email' && this.value == ''){this.value = e;}});
	$('#subNav a:first').attr('href','#search').click(function(){$("input[type='text']#search").focus()});
});

NEWSREADER = {
	timerID:		0,
	topLevel:		100,
	lowLevel:		98,
	loaderGiflocale:'#newsReader',
	slide: 			'#newsReader article',
	slideMeta: 		'#newsReader article > div',
	navName:		'#newsReaderControls',
	navNext:		"#nextNews",
	navPrevious:	"#previousNews",
	navPlay:		"#newsReaderPlay",
	pause:			"paused",
	liActiveName:	's',
	slideDelay:		7000,
navHeight:1,intID:null,slideCount:0,tempSlide:null,currentSlide:1,slideCount:0,nextSlide:1,previousSlide:0,lock:false,init:function(){NEWSREADER.navHeight+=$(NEWSREADER.navName).height();$(NEWSREADER.slide+":first").css('z-index',NEWSREADER.topLevel).fadeIn('slow',function(){$(NEWSREADER.slide).not(':first').css({'z-index':NEWSREADER.lowLevel,'display':'none'});$(NEWSREADER.navName+' li:first').addClass(NEWSREADER.liActiveName);$(NEWSREADER.loaderGiflocale).css('background','none');});NEWSREADER.slideCount=$(NEWSREADER.slide).size();if(NEWSREADER.slideCount > 1){NEWSREADER.autoPlay(true);}
$(NEWSREADER.navPlay).click(function()
{if(NEWSREADER.intID)
{NEWSREADER.autoPlay(false);$(this).addClass(NEWSREADER.pause);}
else
{NEWSREADER.autoPlay(true);$(this).removeClass(NEWSREADER.pause);}});$(NEWSREADER.navNext).click(function(){NEWSREADER.fader('n');});$(NEWSREADER.navPrevious).click(function(){NEWSREADER.fader('p');});NEWSREADER.sort();$(NEWSREADER.slide+' , '+NEWSREADER.navName).mouseenter(function()
{if(NEWSREADER.timerID!=0)
{clearTimeout(NEWSREADER.timerID);NEWSREADER.timerID=0;}
else
{$(NEWSREADER.slideMeta+' , '+NEWSREADER.navName).animate({bottom:'+='+NEWSREADER.navHeight},'fast',function(){});}}).mouseleave(function(){NEWSREADER.timerID=setTimeout("NEWSREADER.slider()",1000);});$(NEWSREADER.navName+' li').click(function(){NEWSREADER.nextSlide=$(NEWSREADER.navName+' li').index(this)+1;NEWSREADER.fader('n');$(NEWSREADER.navName+' li').removeClass();$(this).addClass(NEWSREADER.liActiveName);});},slider:function(){clearTimeout(NEWSREADER.timerID);NEWSREADER.timerID=0;if($(NEWSREADER.slideMeta+" , "+NEWSREADER.navName).css('bottom')!='-'+NEWSREADER.navHeight)
{$(NEWSREADER.slideMeta+" , "+NEWSREADER.navName).animate({bottom:'-='+NEWSREADER.navHeight},'fast',function(){});}},fader:function(dir){if(NEWSREADER.lock==false)
{NEWSREADER.lock=true;$(NEWSREADER.slide+":nth-child("+NEWSREADER.currentSlide+")").css('z-index',NEWSREADER.topLevel-1);if(dir=='n')
{NEWSREADER.tempSlide=NEWSREADER.nextSlide;NEWSREADER.currentSlide=NEWSREADER.nextSlide;}
else
{NEWSREADER.tempSlide=NEWSREADER.previousSlide;NEWSREADER.currentSlide=NEWSREADER.previousSlide;}
NEWSREADER.sort();$(NEWSREADER.slide+":nth-child("+NEWSREADER.tempSlide+")").css('z-index',NEWSREADER.topLevel).fadeIn('slow',function(){$(NEWSREADER.slide).not($(this)).css({'z-index':NEWSREADER.lowLevel,'display':'none'});NEWSREADER.lock=false;});$(NEWSREADER.navName+' li').removeClass();$(NEWSREADER.navName+' li:nth-child('+NEWSREADER.currentSlide+')').addClass(NEWSREADER.liActiveName);}},sort:function(){NEWSREADER.next();NEWSREADER.prev();},next:function(){if(NEWSREADER.currentSlide==NEWSREADER.slideCount){NEWSREADER.nextSlide=1;}else{NEWSREADER.nextSlide=eval(NEWSREADER.currentSlide+1);}},prev:function(){if(NEWSREADER.currentSlide!=1){NEWSREADER.previousSlide=eval(NEWSREADER.currentSlide-1);}else{NEWSREADER.previousSlide=NEWSREADER.slideCount;}},autoPlay:function(dir){if(dir!=false){NEWSREADER.intID=setInterval(function(){NEWSREADER.fader('n')},NEWSREADER.slideDelay);}else{clearInterval(NEWSREADER.intID);NEWSREADER.intID=null;}}
}
function hairball(e){barf = e}
