	var pressquote_timeout = 5000;
	var pressquote_timer = 0;

	var tweet_timeout = 5000;
	var tweet_timer = 0;

	function DisplayPressQuote() {
		var quotes = $('li:hidden', '#ip_pressquotes');
		var ran = Math.floor(Math.random()*quotes.length);
		$('li.current', '#ip_pressquotes').removeClass('current');

		var newquote = quotes.eq(ran);

		newquote.addClass('current');
		if ($('img', newquote).length > 0) {
			$('h6', '#ip_pressquotes').hide();
		} else {
			$('h6', '#ip_pressquotes').show();
		}
	}

	function StartPressTimer() {
		pressquote_timer = window.setInterval(DisplayPressQuote, pressquote_timeout);
	}

	function StopPressTimer() {
		window.clearInterval(pressquote_timer);
	}



	function DisplayTweet() {
		var quotes = $('li:hidden', '#ip_latesttweet');
		var ran = Math.floor(Math.random()*quotes.length);
		$('li.current', '#ip_latesttweet').removeClass('current');

		quotes.eq(ran).addClass('current');
	}

	function StartTweetTimer() {
		tweet_timer = window.setInterval(DisplayTweet, tweet_timeout);
	}

	function StopTweetTimer() {
		window.clearInterval(tweet_timer);
	}




	function ChangeYTVideo(link_element, autoplay) {
		$('#ytplayer_placeholder').html(
			'<embed width="425" height="344" flashvars="" pluginspage="http://www.adobe.com/go/getflashplayer" '+
			'src="http://www.youtube.com/v/'+link_element.attr('href').replace(/^[^v]+v.(.{11}).*/,"$1")+'&&autoplay='+(autoplay?'1':'0')+'&&rel=0&border=0" '+
			'type="application/x-shockwave-flash" wmode="transparent">'
		);

		$('a.current', '#ytvideo_list').removeClass('current');
		link_element.addClass('current');
	}






	$(document).ready(function() {
		// Start the Press Quotes ticker
		DisplayPressQuote();
		StartPressTimer();
		$('#ip_pressquotes').bind('mouseover', StopPressTimer);
		$('#ip_pressquotes').bind('mouseout', StartPressTimer);

		// Start the Tweets ticker
		DisplayTweet();
		StartTweetTimer();
		$('#ip_latesttweet').bind('mouseover', StopTweetTimer);
		$('#ip_latesttweet').bind('mouseout', StartTweetTimer);



		// Lets listen to the tabs clicks and change them accordingly
		$('a', '#tabwindow_tabs').click(function() {
			var el = $(this);

			$('a.current', '#tabwindow_tabs').removeClass('current');
			$('.tabwindow_tab').hide();

			el.addClass('current');
			$(el.attr('href')).show();

			el.blur();

			return false;
		});



		// Lets find the first video link and place it in the container right away
		ChangeYTVideo($('a:first', '#ytvideo_list'));

		// We need to bind the YT links to play the video in the container
		$('a', '#ytvideo_list').click(function() {
			var el = $(this);
			ChangeYTVideo(el, true);
			el.blur();
			return false;
		});

	});
