function slideSwitch() {
	
	var $active = $('#slider img.active');
	var $next =  $active.next().length ? $active.next() : $('#slider img:first');
	$next.addClass('active');
	$active.removeClass('active');
	
	var $focused = $('#sliderselector li.focused');
	var $nextfocus =  $focused.next().length ? $focused.next() : $('#sliderselector li:first');
	$nextfocus.addClass('focused');
	$focused.removeClass('focused');
	
};

function SwitchSlide() {
	
	if(($('#sliderbox').css('left') != '-1920px')){
		$('#sliderbox').animate({left:'-=640'}, 1050);
	}
	else{
		$('#sliderbox').animate({left:'+=1920'}, 1050);
	}
	
};

$(document).ready(function(){
	
    var Interval = setInterval( "SwitchSlide()", 8000 );
		
	$('#sliderarrowright').bind('click', slideRight);
		function slideRight(e){
			clearInterval(Interval);
			if(($('#sliderbox').css('left') != '-1920px')){
				e.preventDefault();
				$('#sliderarrowright').unbind();
				$('#sliderbox').animate({left:'-=640'}, 1050, function(){
					$('#sliderarrowright').bind('click', slideRight);
				});
			}
	};
	
	$('#sliderarrowleft').bind('click', slideLeft);
		function slideLeft(e){
			clearInterval(Interval);
			if(($('#sliderbox').css('left') != '0px')){
				e.preventDefault();
				$('#sliderarrowleft').unbind();
				$('#sliderbox').animate({left:'+=640'}, 1050, function(){
					$('#sliderarrowleft').bind('click', slideLeft);
				});
			}
	};
	
	// set your twitter id
   	var user = 'finishfirstgame';

   	// using jquery built in get json method with twitter api, return only one result
   	$.getJSON('http://twitter.com/statuses/user_timeline.json?screen_name=' + user + '&count=5&callback=?', function(data)      {

       	// result returned
       	var tweet = data[0].text;

       	// process links and reply
       	tweet = tweet.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, function(url) {
           	return '<a href="'+url+'">'+url+'</a>';
       	}).replace(/B@([_a-z0-9]+)/ig, function(reply) {
           	return  reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>';
       	});

       	// output the result
       	$("ul.socialfeedstwitter > li").html(tweet);
   	});
	
});
