$(document).ready(function(){
	var currentPosition = 0;
	var slideWidth = 860;
	var slides = $('.slide');
	var numberOfSlides = slides.length;
	/* Remove scrollbar in JS */	$('#slidesContainer').css('overflow', 'hidden');
	/* Wrap all .slides with #slideInner div */	slides.wrapAll('<div id="slideInner"></div>').css({		'float' : 'left',		'width' : slideWidth	});
	/* Set #slideInner width equal to total width of all slides */	$('#slideInner').css('width', slideWidth * numberOfSlides);
	/* Insert controls in the DOM */	$('#slideshow')	.prepend('<span class="control" id="leftControl">Clicking moves left</span>')	.append('<span class="control" id="rightControl">Clicking moves right</span>');
	/* Create event listeners for .controls clicks */	$('.control').bind('click', function(){		/* Determine new position */		if($(this).attr('id')=='rightControl')		{			moveRight();		}		else		{			moveLeft();		}	});
	function moveRight(){		if(currentPosition == numberOfSlides-1)		{			currentPosition = 0;		}		else		{			currentPosition = currentPosition+1;		}		/* Move slideInner using margin-left */		$('#slideInner').animate({			'marginLeft' : slideWidth*(-currentPosition)		});		}
	function moveLeft(){		if(currentPosition == 0)		{			currentPosition = numberOfSlides-1;		}		else		{			currentPosition = currentPosition-1;		}
		/* Move slideInner using margin-left */		$('#slideInner').animate({		  'marginLeft' : slideWidth*(-currentPosition)		});	}
	/* THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL */    var autoscrolling = true;
    $('#slideshow').mouseover(function () {        autoscrolling = false;    }).mouseout(function () {        autoscrolling = true;    });
    setInterval(function () {        if (autoscrolling) {            moveRight();        }    }, 5000);	/* Full Caption Sliding (Hidden to Visible)  */	$('.captionfull').hover(function(){		$(".cover", this).stop().animate({top:'132px'},{queue:false,duration:160});	}, function() {		$(".cover", this).stop().animate({top:'260px'},{queue:false,duration:160});	});
	/* Tooltips */	$("#links_section a[title]").tooltip({tip: '#tooltip', effect: 'bouncy'}); 	/*	var _config = {        username: 'obrienjoe',        count: 5,        period: 'recenttracks',        defaultthumb: 'http://cdn.last.fm/flatness/catalogue/noimage/2/default_album_large.png'    };	lastFmRecords.init(_config);	*/
});
