// JavaScript Document
var height = 0;
var timeout;
$(document).ready( function() {
	$(".tweet").tweet({
		username: "AnsleyParkside",
		join_text: "auto",
		avatar_size: 0,
		count: 1,
		auto_join_text_default: "we said:",
		auto_join_text_ed: "we",
		auto_join_text_ing: "we were",
		auto_join_text_reply: "we replied to",
		auto_join_text_url: "we were checking out",
		loading_text: "loading tweets..."
	});
	panelHeight();
	if( $('#slider').size() != 0 )
		{
			$('#slider').append('<div></div>');
			var scrollLinkDiv = $('#slider').children('div').eq(0);
			scrollLinkDiv.addClass('scrollLinks');
			var i = 0;
			$('.scrollImg').each( function() {
				scrollLinkDiv.append('<img src="img/blank.gif" alt="" class="scrollLink" />')
			});
			$('.scrollLinks').css('left', (710 - $('.scrollLinks').width()) + 'px');
			$('.scrollLink').eq(0).addClass('activeLink');
			timeout = setTimeout('changeImg()',5000);
			$('.scrollLink').click( function() {
				changeImg($('.scrollLink').index($(this)));
			});
		}
	
});

function panelHeight() {
	$('.float').each( function() {
		if( $(this).height() > height )
			height = $(this).height();
	});
	$('.float').height(height);
}
function changeImg() {
	clearTimeout(timeout);
	if( arguments[0] == null)
		{
			var itm = $('.activeImg');
			var pos = $('.scrollImg').index(itm);
			pos++;
			if( pos == $('.scrollImg').size() )
				pos = 0;
			$('.scrollLink').removeClass('activeLink');
			$('.scrollLink').eq(pos).addClass('activeLink');
			$('.scrollImg').fadeOut(350);
			$('.scrollImg').eq(pos).fadeIn(500, function() {
				$('.scrollImg').removeClass('activeImg');
				$('.scrollImg').eq(pos).addClass('activeImg');
				timeout = setTimeout('changeImg()',4500);
			});
		}
		else
			{
				pos = arguments[0];
				$('.scrollLink').removeClass('activeLink');
				$('.scrollLink').eq(pos).addClass('activeLink');
				$('.scrollImg').fadeOut(350);
				$('.scrollImg').eq(pos).fadeIn(500, function() {
					$('.scrollImg').removeClass('activeImg');
					$('.scrollImg').eq(pos).addClass('activeImg');
					timeout = setTimeout('changeImg()',4500);
				});
			}
}
