	var $ = jQuery.noConflict();
	
	// Line 396 now powers the hoverover for the LHS panels //
	
$(document).ready(function(){
	$("a.showTandC").fancybox(); 
	$("#loginToTwitter").hide();
	$("#tweetDisplay").show();
	$("#twitter .panelHeader .username").show();
	$("a#feedbackTab").fancybox({ 'hideOnContentClick': false, 'frameHeight': 370, 'frameWidth': 570 }); 
	$("a#mobile").fancybox(); 
	$("a#feedbackTab2").fancybox({ 'hideOnContentClick': false, 'frameHeight': 440, 'frameWidth': 570 }); 
	$("a#aboutUs").fancybox(); 
	$("a.aboutGB").fancybox(); 
	$("a#submitLink").fancybox({ 'hideOnContentClick': false, 'padding': 0}); 
	$("a#aboutUs2").fancybox(); 
	$("a#signUpScreen").fancybox({ 'hideOnContentClick': false}); 
	$("a#letterFrom").fancybox({ 'hideOnContentClick': false, 'frameHeight': 600, 'frameWidth': 800 });
	$("a#privacypolicy").fancybox();
	$("a#terms").fancybox({ 'hideOnContentClick': false, 'margin': 0, 'padding': 24, 'frameHeight': 600, 'frameWidth': 900 });  
	$("input#searchBox").fancybox();
	
	$("#java").removeClass("noJava");
	
	//$("#expandTopTen ul.item:first").removeClass("closed");
	//$("#expandTopTen ul.item:first").addClass("open");
	// $("#expandTopTen div.itemDetail:first").show();
		
	// Dont quite know if the use of .LIVE() is ok 
	$("a.waughSignUp").live('click', function() {
	        $(this).fancybox({ 
			'width'				: '75%',
			'height'			: '75%',
			'autoScale'			: false,
			'type'				: 'iframe'
		
			}); 
		return false;
	});
	
	// Dont quite know if the use of .LIVE() is ok 
	$("a.preview_email").live('click', function() {
	        $(this).fancybox({ 
			'width'				: '75%',
			'height'			: '75%',
			'autoScale'			: false,
			'type'				: 'iframe'
		
			}); 
		return false;
	});
	
	
	$("a.memoExample").live('click', function() {
			$.fancybox(this,{ 
				'width'				: '50%',
			});
		return false;
	});
	
	
	
	/* */
	
	$("#revealVat").click(function(){
			$(".hideVat").toggle();	 
		return false;
	});	
	
	$(".panel01Switch").click(function(){
			$("body").removeClass().addClass("panel01");	 
		return false;
	});
	
	$(".panel02Switch").click(function(){
			$("body").removeClass().addClass("panel02");	 
		return false;
	});
	
	$(".panel03Switch").click(function(){
			$("body").removeClass().addClass("panel03");	 
		return false;
	});
	
	$(".panel04Switch").click(function(){
			$("body").removeClass().addClass("panel04");	 
		return false;
	});


    $(".HelpRoll a").fancybox({ 'hideOnContentClick': false, 'frameHeight': 130, 'frameWidth': 480 });


	$("#vertNav li h4.liteclr").eq(0).parent().addClass("close");
	

	$(".inboxPage .panel.TopTen p.settings").click(function(){
	        $(this).parent().parent().toggleClass('minimise');
            if (window.toggleDashboardTopTen) window.toggleDashboardTopTen();
		return false;
	});	


	//  Minimise storytracker -  created 7.12.10  //
	$("#shrinkGraph").click(function(){
	        $(this).parent().parent().parent().parent().toggleClass('minimise');
            if (window.toggleDashboardStoryTracker) window.toggleDashboardStoryTracker();
		return false;
	});	
	


	// Bottom sticky hide button - created 23.11.10  //
	$("span.hideThis").click(function(){
			$(this).parent().parent().slideToggle();	 
		return false;
	});
	
	// Settings page slider //
	$( "#datepicker" ).datepicker();
    $( "#datepicker" ).bind('change',
			    function(){
                                if (window.onDateSelected)
                                    window.onDateSelected(this.value);
			    }
                           );
    

	// Settings page slider //
	$( ".slider" ).slider({
		value:1,
		min: 1,
		max: 4,
		step: 1,
		slide: function( event, ui ) {
			$( ".amount" ).val( "level " + ui.value );
		}
	});
	$( ".amount" ).val( "level " + $( ".slider" ).slider( "value" ) );
	// ends //


	// paper by paper new page switch - created 4.11.10  //
	$("#PaprImages").click(function(){
			$(this).parent().parent().removeClass();
	        $(this).parent().parent().addClass('pimgs');
		return false;
	});
	$("#Paprlnks").click(function(){
			$(this).parent().parent().removeClass();		
	        $(this).parent().parent().toggleClass('plnks');	
		return false;
	});
	
	
	// New Inbox - to shrink the RHS 10.11.10 //
	$("#hideRHS").click(function(){
	        $(this).parent().parent().parent().parent().toggleClass('shrinkRhs');
		return false;
	});
	
	$("#showRHS").click(function(){
	        $(this).parent().parent().parent().parent().toggleClass('shrinkRhs');
		return false;
	});



	// Allows the Page view buttons to disable the link when in page view //
	function disableLink(e) {
	    e.preventDefault();
	    return false;
	}
	
	

	//  1.Changes the class of the containing div //
	//  2. disables the link  //
	$("#pageViewTrig").click(function(){
			$('body').toggleClass('list');
			$(this).parent().parent().toggleClass('settings');
			$("li a").unbind('click', function() {
					disableLink;
			        $(this).toggleClass('off');
				return false;
			});
	});
	
	$("#listViewTrig").click(function(){
			$('body').toggleClass('list');
			$(this).parent().parent().toggleClass('settings');
			$("li a").bind('click', function() {
					disableLink;
			        $(this).toggleClass('off');
				return false;
			});
	});


	// Sub nav //
	$("#vertNav li.sub em").click(function(){
	        $(this).parent().toggleClass('closed');
		return false;
	});
	
	
	
	// My inbox settings //
	$("#settingsShow").click(function(){
	        $(this).parent().parent().toggleClass('hideSet');
			$(this).parent().next().slideToggle();
		return false;
	});
	
	$("#expandAll").click(function(){
			$(this).toggleClass('expand');	
	        $( "#rollingFeed li").toggleClass('expand');
		return false;
	});

	

	
	$("#vertNav .settings li ").live('click', function() {
	        $(this).toggleClass('off');
		return false;
	});
	
	
	$("li.useful").live('click', function() {
	        $(this).parent().parent().removeClass().addClass('one');
		return false;
	});
	
	$("li.inNumbers").live('click', function() {
	        $(this).parent().parent().removeClass().addClass('two');
		return false;
	});
	
	$("li.topics").live('click', function() {
	        $(this).parent().parent().removeClass().addClass('three');
		return false;
	});
	
	$("li.constit").live('click', function() {
	        $(this).parent().parent().removeClass().addClass('four');
		return false;
	});
	
	
	$('div.carouselBody').live('mouseover mouseout', function(event) {
	  if (event.type == 'mouseover') {
	    $(this).addClass('hoverover');
	  } else {
	    $(this).removeClass('hoverover');
	  }
	});


	$('ul#topImage').cycle({
		fx: 'fade',
		next: '#nextImg',
		prev: '#prevImg',
		containerResize: 0
	});


	$("#vertNav li h4").click(function(){
	        $(this).next().slideToggle();
	 		$(this).parent().toggleClass('close');
		return false;
	});
	

	// Sept 2010 - new nav ends //
	
	

	$('ul#fpCycle').cycle({
		fx: 'fade',
		width: '232px',
		next: '#fpCycleNext',
		prev: '#fpCyclePrev',
		containerResize: '1'
	});

	$("input#chooseTrial ").click(function(){
	        $("div#nonTrial").hide();
			$("div#howMuch").hide();
	
		return false;
	});

	$(".showPay input").click(function(){
	        $("div#nonTrial").show();
			$("#howMuch").show();
		return false;
	});

	$("span#showLiteFrom").click(function(){
			$(this).parent().parent().hide();
			$(this).parent().parent().next().show();
		return false;
	});

	$("h1#GBSettingsTrig").click(function(){
			$(this).next().slideToggle();
		return false;
	});
	
	$("span#GBSettingsClose").click(function(){
			$(this).parent().slideToggle();
		return false;
	});
	
	// Page anchor animated scoller //
	$("a.anchorLink").anchorAnimate();
		
	$("div.HelpRoll a").easyTooltip();

	$(".dashHelpPage span#togOn").click(function(){
	        $(this).toggle();
			$(this).next().toggle();
	        $(this).parent().parent().parent().next().next().addClass("on");
		return false;
	});

	$(".dashHelpPage span#togOff").click(function(){
	        $(this).toggle();
			$(this).prev().toggle();
	        $(this).parent().parent().parent().next().next().removeClass("on");
		return false;
	});
		
//	$(".accordion li.deleteThisFilter").hide(); //
	
	$("#electionNight .panelHeader ").click(function(){
	        $(this).next().slideToggle();
			$(this).toggleClass('open');
		return false;
	});
	
	// Greenbox page //
	
	
	var bigGB= $('span#bigGB');
	var smallGB= $('span#smallGB');
	
	bigGB.click(function(){	
	    $(".GBelement").prependTo("#gbPosTwo"); 
            if(window.greenBoxSuperSized)
                window.greenBoxSuperSized(true);
	    return false;
	});
	
	smallGB.click(function(){	
	    $(".GBelement").prependTo("#gbPosOne"); 
            if(window.greenBoxSuperSized)
                window.greenBoxSuperSized(false);
	    return false;
	});
	
	
    if(!document.getElementById("in_calendar_feed")){
        // don't do this if we're in the calendar
	var GBControl= $('#rollingFeed li');
	var GBcollapse= $('.rollingFeedOptions span#collapse , .GBelement span#collapse');
	var GBexpand= $('.rollingFeedOptions span#expand , .GBelement span#expand' );
	var GBcloseSettings= $(' #GB_Page span#doneEditing , .GBelement span#doneEditing');
	var GBh3Trig= $('#rollingFeed li, .GBelement li');
        
	GBcollapse.live('click', function() {
	    $('.GBelement li h3').removeClass("expand");
	    $(this).parent().removeClass("expand");
	    $(this).parent().parent().removeClass("expand");
	    $(this).parent().parent().next().removeClass("expand");
            
            if(window.greenBoxExpanded)
                window.greenBoxExpanded(false);
	    return false;
	});
	
	
	
	GBh3Trig.live('click', function() {
			$(this).addClass("expand");
		return false;
	});

	GBexpand.live('click', function() {
	        $('.GBelement li').addClass("expand");
			$(this).parent().addClass("expand");
			$(this).parent().parent().next().addClass("expand");
            if(window.greenBoxExpanded)
                window.greenBoxExpanded(true);
	    return false;
	});	
	
	
	$('.GBelement span#GBbigger').click(function(){
			$(this).parent().parent().parent().removeClass('smaller');
		return false;
	});
	
	$('.GBelement span#GBsmaller').click(function(){
			$(this).parent().parent().parent().addClass('smaller');
		return false;
	});
	
	
	$(".GB_page_element h3 em ").click(function(){
	        $(this).addClass('show');
		return false;
	});
	
	$(".GB_page_element h3 em span ").click(function(){
	        $(this).parent().removeClass('show');
		return false;
	});
    }
	// Greenbox page Ends //
	
	// Login //
	
	$("#showLogin").addClass("Jquery");
		
	$(" li#showLogin span ").click(function(){
	        $(' div#loginHolder').toggle();
		return false;
	});
	
	$(" span#close ").click(function(){
	        $(' div#loginHolder').hide().removeClass();
		return false;
	});
	
	// action to expand rolling fed - mainly used on cat pages //
	$(" .wireTitle ").click(function(){
	        $(this).parent().toggleClass('expand');
		return false;
	});
	
	// action fro Live wire tabs //
	
	$(" #showLoginRest a ").click(function(){
	        $(' div#loginHolder').toggle().toggleClass('phiwire');
		return false;
	});
    
//	$('#rollingFeed li.public a').removeAttr('onclick');
	
//	$(" #rollingFeed li.public a ").click(function(){
//	        $(' div#loginHolder').toggle().toggleClass('rolling').toggleClass('phiwire');
//		return false;
//	});

	
	
	$(" #NotAvail").click(function(){
	        $(' div#loginHolder').toggle().toggleClass('lrgGB phiwire');
		return false;
	});
	

	var liteDashTrig= $('#dashNoticeTrig a, #noDash #close ');	
	liteDashTrig.click(function(){
	        $(' div#noDash').toggle();
		return false;
	});	
	
	
	// Top ten //
	var ShowTopTen= $('span#show_topten, .mustRead span.close');
	ShowTopTen.click(function(){
	        $(' .mustRead div.popup').toggle();
		return false;
	});


	$(".accordion .panelHeader").click(function(){
		if( $(this).parent().hasClass('expand') === true) {
			$(this).next().slideUp(200,function(){
				$(this).parent().addClass("contract");
	 	    $(this).parent().removeClass("expand");
			});
		} else {
			$(this).removeClass('hoverover');
			$(this).next().slideDown(200);
				$(this).parent().removeClass("contract");
	 	    $(this).parent().addClass("expand");
		}
		return false;
	});


	$(".filter_box .panelHeader").click(function(){
		if( $(this).parent().hasClass('expand') === true) {
			$(this).next().slideUp(200,function(){
				$(this).parent().addClass("contract");
	 	    $(this).parent().removeClass("expand");
			});
		} else {
			$(this).removeClass('hoverover');
			$(this).next().slideDown(200);
				$(this).parent().removeClass("contract");
	 	    $(this).parent().addClass("expand");
		}
		return false;
	});

	$(function () {
	    var tabContainers = $('.storytracker div.tabs > div');

	    $('.storytracker div.tabs ul.tabNavigation.jq a').click(function () {
	        tabContainers.hide().filter(this.hash).show();

	        $('.storytracker div.tabs ul.tabNavigation.jq a').removeClass('selected');
	        $(this).addClass('selected');

	        return false;
	    }).filter(':first').click();
	});


	// Storytracker pages //
	$("#glanceTab").click(function(){
			$(this).parent().parent().removeClass().addClass("glance");
		return false;
	});
	
	$("#minuteTab").click(function(){
			$(this).parent().parent().removeClass().addClass("minute");
		return false;
	});
	
	$("#relatedTab").click(function(){
			$(this).parent().parent().removeClass().addClass("related");
		return false;
	});
	
	$("#discussTab").click(function(){
			$(this).parent().parent().removeClass().addClass("discuss");
		return false;
	});



	
	
	// add a new story/newsmaker/categorie //
	$("#filters .filterControls span.add").click(function(){
		$(this).next().next().slideToggle();
	});
	
	// front page top ten //
	
	// this script wraps the text if its too long //
	$("#expandTopTen ul.item li a").each(function() {
	    var count = $(this).text().length;
	    if ( count >= 48 ) {
	        $(this).parent().addClass("too-big-overflow");
	    }
	});
	
	//$("#expandTopTen ul.item li ").click(function(){
	//        $(this).parent().next().slideToggle(200);
	//        $(this).parent().toggleClass('closed');
	//        $(this).parent().toggleClass('open');
	//	return false;
	//});
	
	gbLink.init();
	
	signUpHovers.init();
		
	additionalStoryHover.init();
	
	classChange.init();	

	storytrackerPageVersion.init();
		
	$("#twitterLogin").click(function(){
		$("#loginToTwitter").toggle();
		$("#twitter .panelHeader .username").toggle();
		$("#tweetDisplay").toggle();
		$(".tweet").toggle();
		return false;
	});
	
		
	$("ul.proEmailSettings li span.edit").click(function(){
		$(this).parent().parent().parent().next().slideToggle();
	});
	
	$("ul.proEmailSettings span.doneEditing").click(function(){
		$(this).parent().slideToggle();
	});
	
	$(".container.green span#doneEditing").click(function(){
		$('#editMain').slideToggle();
	});



	// Hover over effect for the 'On the board' feature on the front page //
	var magTrigger= $('div.magnet span.trigger');
	var magTriggerLrg= $('div.magnet span.triggerLrg');

    // this rotates the background on the page load //
	$("div.magnet span.background").each(function() {
        $(this)
            .css({
                "-webkit-transform": 'rotate(' + (Math.floor(Math.random()*2)-1) + 'deg)',
                "-moz-transform": 'rotate(' + (Math.floor(Math.random()*2)-1) + 'deg)'
            })     
    });

    // this rotates the background of the wide magnet on the page load //
	$("div.magnet span.backgroundLrg").each(function() {
        $(this)
            .css({
                "-webkit-transform": 'rotate(' + (Math.floor(Math.random()*2)-1) + 'deg)',
                "-moz-transform": 'rotate(' + (Math.floor(Math.random()*2)-1) + 'deg)'
            })
    });

	// laying over the trigger Hover //		
    magTrigger.hover(function() {
    	$(this).next().css({
	            "-webkit-transform": 'rotate(' + (Math.floor(Math.random()*2)-1) + 'deg) scale(1.02)',
	            "-moz-transform": 'rotate(' + (Math.floor(Math.random()*2)-1) + 'deg) scale(1.02)'
	
	        })
	     }, function() {
	        $(this).next().css({
	            "-webkit-transform": 'rotate(' + (Math.floor(Math.random()*2)-1) + 'deg) scale(1)',
	            "-moz-transform": 'rotate(' + (Math.floor(Math.random()*2)-1) + 'deg) scale(1)'
	        })
	});
	
	// laying over the trigger Hover //		
    magTriggerLrg.hover(function() {
    	$(this).next().css({
	            "-webkit-transform": 'rotate(' + (Math.floor(Math.random()*2)-1) + 'deg) scale(1.02)',
	            "-moz-transform": 'rotate(' + (Math.floor(Math.random()*2)-1) + 'deg) scale(1.02)'
	
	        })
	     }, function() {
	        $(this).next().css({
	            "-webkit-transform": 'rotate(' + (Math.floor(Math.random()*2)-1) + 'deg) scale(1)',
	            "-moz-transform": 'rotate(' + (Math.floor(Math.random()*2)-1) + 'deg) scale(1)'
	        })
	});
	
	// end of magnet code //
		
	// using .live script to spo elements work after they have been adjusted using ajax //			
	$('li.linkTypeHover , #rollingFeed li , .panel').live('mouseover mouseout', function(event) {
	  if (event.type == 'mouseover') {
	    $(this).addClass('hoverover');
	  } else {
	    $(this).removeClass('hoverover');
	  }
	});


	// Taken from info_slides - by Phillip Davies //	

	// Start //
	$('#infoSlideHolder1').cycle({
	    fx:    'scrollHorz',
	    timeout:  12000,
	    speed: "fast",
	    nowrap: true,
	    end: call_tab,
	    next:'#next_1',
	    prev:'#prev_1'
	});

	$('#infoSlideHolder2').cycle({
	    fx:    'scrollHorz',
	    timeout:  12000,
	    speed: "fast",
	    nowrap: true,
	    end: call_tab,
	    next:'#next_2',
	    prev:'#prev_2'
	});

	$('#infoSlideHolder3').cycle({
	    fx:    'scrollHorz',
	    timeout:  12000,
	    speed: "fast",
	    nowrap: true,
	    next:'#next_3',
	    prev:'#prev_3',
	    end: call_tab
	});

	//fire();

	// info_slides  END    //
	
	
	// taken from Account_settings.js   //
			// Feb 2011 - not sure if this is need anymore? //	
	$('span#showPassword').click(function () {
		$(this).toggle();
		$(this).next().toggle();
		$(this).next().next().toggle();
		$('ul#currentPassword').toggle();
		$('ul#editPassword').slideToggle();
	});	
	
	$('span#hidePassword').click(function () {
		$(this).toggle();
		$(this).prev().toggle();
		$(this).next().toggle();
		$('ul#currentPassword').toggle();
		$('ul#editPassword').slideToggle();
	});
	

	$('span#showUsername').click(function () {
		$(this).toggle();
		$(this).next().toggle();
		$(this).next().next().toggle();
		$('.changeAccount span').toggle();
		$('.changeAccount input').toggle();
	});
	
	$('span#hideUsername').click(function () {
		$(this).toggle();
		$(this).prev().toggle();
		$(this).next().toggle();
		$('.changeAccount span').toggle();
		$('.changeAccount input').toggle();
	});
	
	$('span#showAccount').click(function () {
		$(this).toggle();
		$(this).next().toggle();
		$(this).next().next().toggle();
		$('#editAccount ul span').toggle();
		$('#editAccount ul input').toggle();
		$('#editAccount ul select').toggle();
	});
	
	$('span#hideAccount').click(function () {
		$(this).toggle();
		$(this).prev().toggle();
		$(this).next().toggle();
		$('#editAccount ul span').toggle();
		$('#editAccount ul input').toggle();
		$('#editAccount ul select').toggle();
	});
	
	// taken from Account_settings.js  END  //	
	
	
	// taken from ui-features.js  //	
	carouselFooter.init();
	videoInfo.init();
	iconTips.init();
	subIconTips.init();
	//newsTicker.init({auto: true, timer: 10000});
	ticker.init();
	livewire.init();
	carousels.init();
	$('.view-front-page').fancybox();
	proOnly.init();
	$('li.proOnly div').hide();

	// taken from ui-features.js  END  //	

});




additionalStoryHover = function(){
	var o = this;
	function init(){
		o.items = $('.storyColumn li.additional');
		events();
	}
	function events(){
		o.items.hover(
			function (){
				$(this).addClass('hover');
			},
			function (){
				$(this).removeClass('hover');
			}
		);
	}
	return { init: init }
}();



classChange = function(){
	var o = this;
	function init(){
		o.items = $('.panelHeader');
		events();
	}	
	function events(){
		o.items.hover(
				function (){
					if ( $(this).parent().hasClass("contract") )
					       $(this).addClass('hoverover');
				},
			function (){
				$(this).removeClass('hoverover');
			}
		);
	}
	return { init: init }
}();





gbLink = function(){
	var o = this;
	function init(){
		o.items = $('.GB_page_element li h3 a');
		events();
	}
	function events(){
		o.items.hover(
			function (){
				$(this).parent().parent().addClass('gbLink');
			},
			function (){
				$(this).parent().parent().removeClass('gbLink');
			}
		);
	}
	return { init: init }
}();




storytrackerPageVersion = function(){
	var o = this;
	function init(){
		o.items = $('div.pullLink');
		events();
	}
	function events(){
		o.items.click(
			function (){
				window.open(this.href = $(this).children().children().next().children().attr('href'));
			}
		);
	}
	return { init: init }
}();


// Page anchor animated scoller //
jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 1100
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}


signUpHovers = function(){
	var o = this;
	function init(){
		o.items = $('#signUpTab .publicBox , #signUpTab .liteBox , #signUpTab .proBox');
		events();
	}
	function events(){
		o.items.hover(
			function (){
				$(this).addClass('hover');
			},
			function (){
				$(this).removeClass('hover');
			}
		);
	}
	return { init: init }
}();


// This remembers the expand/collapse settings for the greenbox //
function expandGreenBox(){
	$('.GB_page_element li , #GB_Page .settings , .frontPage .GBelement .header ').addClass('expand'); 
}

function showLoginBox(){
	$(' div#loginHolder').toggle();
}

function fullwidthGB(){
	$(".GBelement").prependTo("#gbPosTwo");
}

// 

// This is for the info slides //
function call_tab()
{
    if(tar == 3)
    {
	tar2 = 1;
    }
    else
    {
	tar2 = tar+1;
    }

    $('#infoSlideHolder'+tar).cycle(0);
    $('#infoSlideHolder'+tar).cycle('pause');
    $('#infoSlideHolder'+tar2).cycle('resume');
    $('#tab'+tar).hide();
    $('#tab'+tar2).css("display","block");
    tar++;
    if(tar == 4)
    {
	tar = 1;
    }

	$('#tab_cont'+tar).addClass('active');
	$(old_active).removeClass('active');
	old_active = "#tab_cont"+tar;
};

// This is for the info slides  END  //



// Taken from ui-features.js //
ticker = function(){
	var self = this;
	function init(){
		self.widget = $('#NewsTicker');
		self.itemsList = $('ul.headlines');
		self.pauseButton = $('.play-pause',self.widget);
		self.itemsList.cycle({
		fx: 'blindY',
      	startingSlide: 		0,  // start on the slide that was in the markup
		fastOnEvent: 			1,
      	timeout:  				1,
      	speed:    				3000,
		speedIn: 				500,
		speedOut: 				500,
      	prev:    					'#Controls .previous',
      	next:    					'#Controls .next',
		pause: 						true,
		sync: 						1
    });
		events();
	}
	function events(){
		self.pauseButton.click(function(){
			if ( $(this).hasClass('paused') === false){
				$(this).addClass('paused');
				self.itemsList.cycle('pause');
			} else {
				$(this).removeClass('paused');
				self.itemsList.cycle('resume');
			}
		});
	}
	return { init:init }
}();

carouselFooter = function(){
	var o = this;
	function init(){
		o.widget = $('.carouselFooter');
		o.items = $('li a', o.widget);
		o.itemParents = $('li',o.widget);
		o.overlayHideTimeout; // holds the timeout return value of the function to close the overlay
		inject();

		if(!o.widget.hasClass('carouselFooterBubble')) {
			render();
		}
		events();

		if (o.widget.hasClass('carouselFooterBubble')) {
			o.widget.live('mouseenter', function(){
				clearTimeout(o.overlayHideTimeout);
			});
			o.widget.live('mouseleave', function(){
				hideOutput();
			});
		}
	}
	function inject(){
		o.widget.append('<div id="carouselFooterOutput"></div>');
		o.output = $('#carouselFooterOutput',o.widget);
		o.output.css({
			width: '523px',
			height: '30px',
			padding: '9px',
			color: '#ffffff',
			display: 'none',
			position: 'absolute',
			zIndex: '40',
			top: '-47px',
			left: '0px',
			borderTop: '1px #474948 solid',
			borderBottom: '1px #2a2b2b solid',
			background: 'url(\'/graphics/new/ui-features/dark-opacity-bg.png\') 0 0 repeat'
		});
	}
	function render(){
		o.itemParents.eq(0).addClass('hover');
		//o.output.html('<a href="' + $('a:first', o.widget).attr('href') + '">' + $('a:first', o.widget).attr('title') + '</a>');
		o.output.html($('.tip-content',o.itemParents.eq(0)).html());
		o.output.show();
	}
	function events(){
		o.items.hover(
			function (){
				o.output.hide();
				o.itemParents.removeClass('hover');
				var $parent = $(this).parent();
				$parent.addClass('hover');
				o.output.html($('.tip-content',$parent).html());
				o.output.show();
			},
			function (){}
		);
	}
	function hideOutput () { // will set a timeout to hide the output
		o.overlayHideTimeout = setTimeout(function(){
			o.output.hide();
			o.itemParents.removeClass('hover');
		}, 1000);
	}
	return { init: init }
}();

videoInfo = function(){
	var o = this;
	function init(){
		o.widget = $('.featureBody');
		o.items = $('li', o.widget);
		events();
	}
	function events(){
		o.items.hover(
			function (){
				$('.timeStamp',this).hide();
				$('.videoInfo',this).show();
			},
			function (){
				$('.timeStamp',this).show();
				$('.videoInfo',this).hide();
			}
		);
	}
	return { init: init }
}();
proOnly = function(){
	var o = this;
	function init(){
		o.items = $('li.proOnly');
		events();
	}
	function events(){
		o.items.hover(
			function (){
				$(this.children).next().show();
			},
			function (){
				$(this.children).next().hide();
			}
		);
	}
	return { init: init }
}();
iconTips = function(){
	var o = {};
	function init(){
		o.items = $('.icon-tip');

		o.items.each(function(i, el){
			//if ($(this).parent().hasClass)
		});

		events();
		render();

		$('.icon-tip-list-bubble .icon-tip-content').live('mouseleave', function(){
			hideOutput($(this).parent());
		});
	}
	function render(){
		$('.story').each(function(){
			$('.icon-tip-list').each(function(){
				if (!$(this).hasClass('icon-tip-list-bubble')) {
					$('.icon-tip', this).eq(0).addClass('icon-tip-hover');
				}
			});
		});
	}
	function events(){
		o.items.hover(
			function(){
				var offset = $(this).position();
				var $sectionItems = $('.icon-tip',$(this).parent());

				$sectionItems.removeClass('icon-tip-hover');
				$(this).addClass('icon-tip-hover');
				var $storyParent = $(this).parent().parent();
				$('.icon-tip-content',this).css({left: '-'+ offset.left + 'px'});

				if ($(this).parent().hasClass('icon-tip-list-bubble')) {
					$(this).parent().one('mouseoveroutside', function(){
						hideOutput($sectionItems);
					});
				}
			},
			function(){
			}
		);
	}
	function hideOutput (item) { // will set a timeout to hide the output
		item.removeClass('icon-tip-hover');
	}
	return { init:init }
}();


subIconTips = function(){
	var o = {};
	function init(){
		o.items = $('.subIcon-tip');
		o.items.append('<div class="arrow"></div>');
		events();
	}
	function events(){
		o.items.hover(
			function(){
				var offset = $(this).position();
				var $sectionItems = $('.subIcon-tip',$(this).parent());

				$sectionItems.removeClass('subIcon-tip-hover');
				$(this).addClass('subIcon-tip-hover');
				var $storyParent = $(this).parent().parent();
				$('.subIcon-tip-content',this).css({left: '-'+ offset.left + 'px'});
			},
			function(){
				o.items.removeClass('subIcon-tip-hover');
			}
		);
	}
	return { init:init }
}();
livewire = function(){
	var o = {};
	function init(){
		o.widget = $('#livewire_content');
		o.items = $('li',o.widget);
		events();
	}
	function events(){
		o.items.click(function(){
			window.location($('a.divlink',this).attr('href'));
		});
	}
	return { init: init }
}();
newsTicker = function(){
	var o = {};
	var animateRunning = 0;
	function init(options){
		o.config = options;
		o.widget = $('#NewsTicker');
		o.itemsList = $('ul.headlines li', o.widget);
		o.itemsListLinks = $('ul.headlines li a', o.widget);
		o.itemsTotal = (o.itemsList.size() - 1); //Array adjust
		o.current = 0;
		o.paused = false;
		o.nextButton = $('.next', o.widget);
		o.prevButton = $('.previous', o.widget);
		o.playPauseButton = $('.play-pause', o.widget);
		o.widget.append('<div id="UnravelBar"><img src="/graphics/new/ui-features/underscore.gif" alt=""/></div>');
		o.unravelBar = $('#UnravelBar',o.widget);
		o.unravelBarImg = $('img',o.unravelBar);
		o.offset = '40';
		render();
		if(options.auto === true) {
			var timer = function(){ if(options.timer) { return options.timer; } else { return false; } }();
			startScroll(timer);
		}
		events();
	}
	function render(){
		o.unravelBar.css({background: '#1a1a1a', position: 'absolute', zIndex: '1000', top: '0', left: o.offset +'px', height: '24px', width: '1000px', display: "block"});
		o.unravelBarImg.css({position: 'absolute', bottom: '5px', left: '2px', zIndex: '1001'});
		o.itemsList.css({width: '700px'});
	}
	function startScroll(length){
		if (o.interval) {
			window.clearInterval(o.interval);
			o.interval = window.setInterval(function(){
			if (animateCheck()) { next({effects: true}); } },length);
		}
		else {
			if (animateCheck()) { next({effects: true}); }
			o.interval = window.setInterval(function(){ if (animateCheck()) { next({effects: true}); } },length);
		}
	}
	function pause(){
		//Stop auto scroll once UI clicked
		if (o.interval) {
			window.clearInterval(o.interval);
			o.paused = true;
			o.playPauseButton.addClass('play-pause-play');
		}
	}
	function events(){
		o.nextButton.click(function(){ pause(); clearAnimations(); next({effects: false}); });
		o.prevButton.click(function(){ pause(); clearAnimations(); prev({effects: false}); });
		o.playPauseButton.click(function(){ pauseCheck(); });
		o.itemsListLinks.hover(
			function(){
				pause();
				clearAnimations();
			},
			function(){
				pauseCheck();
			}
		);
	}
	function pauseCheck(){
		if (o.paused === false) {
			//pause
			o.playPauseButton.addClass('play-pause-play');
			pause();
			o.paused = true;
		} else {
			var timer = function(){
				if(o.config.timer) { return o.config.timer; } else { return false; }
			}();
			startScroll(timer);
			o.playPauseButton.removeClass('play-pause-play');
			o.paused = false;
		}
	}
	function animateCheck(f){
		//Do not run if any animations are currently running
		if (animateRunning > 0) {
			return true;
		} else {
			return true;
		}
	};
	function clearAnimations(){
		o.itemsList.stop(true,false);
		o.unravelBar.stop(true,true);
	}
	function runAnimation(settings){
		o.animateRunning = 2;
		resetUnravelBar();
		o.previous = o.current;
		if (settings.next === true){
			//Going forwards/next
				if (o.current >= o.itemsTotal){
					//Loop back to beginning if at last image
					o.targetItem = 0;
					o.current = 0;
				} else {
					o.targetItem = o.current + 1;
					o.current++;
				}
		} else {
			//Going backwards/previous
			if (o.current == 0){
				//Loop from the end if at the start and going backwards
				o.current = o.itemsTotal;
				o.targetItem = o.current;
			} else {
				o.current--;
				o.targetItem = o.current;
			}
		}

		if (settings.effects === true){
			//Hide current headline to make way for the next
			o.itemsList.eq(o.previous).animate({opacity: 'hide'},500,function(){
				 	o.animateRunning--;
					//Set headline object
					o.headline = {};
					o.headline._item = o.itemsList.eq(o.targetItem);
					o.headline._time = $('.headline-time',o.headline._item);
					o.headline._text = $('a',o.headline._item);

					//Hide headline items to fade in later, time, text etc
					o.headline._time.hide();
					o.headline._text.hide();
					o.headline._item.show();
					//Fade the time in then render the headline out
					o.headline._time.show();
					window.setTimeout(function(){ runHeadline();},2000);
					function runHeadline(){
						o.headline._text.show();
						o.textLength = parseInt($('a',o.itemsList.eq(o.targetItem)).width());
						o.unravelBar.show();
						o.unravelBar.animate({left: (o.textLength + parseInt(o.offset)) + 'px'},(o.textLength * 10),function(){
							o.animateRunning--;
							o.unravelBar.animate({opacity: 'hide'},1000);
						});
					}
			});
		} else {
			console.log('tester');
			o.itemsList.eq(o.previous).hide();
			o.itemsList.eq(o.current).show();
			o.unravelBar.hide();
		}

	}
	function resetUnravelBar(){
		o.unravelBar.hide();
		o.unravelBar.css({left: o.offset + 'px'});
		o.unravelBar.stop(false,false);
	}
	function next(options){
		if(o.current < o.imagesTotal) {
			runAnimation({loop: false, next: true, effects: options.effects});
		} else {
			runAnimation({loop: true, next: true, effects: options.effects});
		}
	}
	function prev(options){
		if(o.current > 0) {
				runAnimation({loop: false, next: false, effects: options.effects});
			} else {
				runAnimation({loop: true, next: false, effects: options.effects});
		}
	}
	return { init:init, animateRunning: animateRunning }
}();
carousels = function(){
	var o = {};
	function init(){
		o.current =
		$('.scrollable').serialScroll({
				items:'div.scrollable-item',
				prev:'.prevPage',
				next:'.nextPage',
				offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
				start:0, //as we are centering it, start at the 2nd
				duration:300,
				force:true,
				stop:true,
				lock:false,
				cycle:false, //don't pull back once you reach the end
				jump: false, //click on the images to scroll to them
				step: 6,
				onBefore: function(){
					o.items.removeClass('scrollable-item-hover');
					$('img',o.items).css({border: '1px #ffffff solid'});
					o.output.html('');
				},
				onAfter: function(e,ui){
					var $first = $(e);
					$first.addClass('scrollable-item-hover');
					$('img',$first).css({border: '1px #282828 solid'});
					o.output.html($('.hover-content',$first).html());
				}
			});
		o.items = $('.videoContent .scrollable-item');
		o.output = $('.output');
		events();
	}
	function events(){
		o.items.hover(
			function() {
				//clear other items
				o.items.removeClass('scrollable-item-hover');
				$('img',o.items).css({border: '1px #F0F0F0 solid'});
				o.output.html('');

				$(this).addClass('scrollable-item-hover');
				$('img',this).css({border: '1px #48A0D7 solid'});
				o.output.html($('.hover-content',this).html());

			},
			function() {
				//do nothing
			}
		)
	}
	return { init: init }
}();

// Taken from ui-features.js END //







