$index = 1;

function update($offset)
{
	$parent = $('#videos .items ul');
	$width = parseInt($parent.css('width'), 10);
	$count = Math.ceil($width / 568);

	if ($parent.data('disabled')) return;
	
	$parent.data('disabled', true);

	switch ($offset)
	{
		case -1: $index = ($index == 1 ? 1 : $index - 1); break;
		case 1: $index = ($index == $count ? $count : $index + 1); break;
		default: $index = $offset;
	}

	$index = Math.max(1, $index);
	$index = Math.min($count, $index);

	$parent.animate({ marginLeft: -(($index - 1) * 568) + 'px' }, 1000, function() {
		$(this).data('disabled', false);																											 
	});
}


$().ready(function() {
	$flash = new SWFObject("http://www.libertypark.com/assets/swf/videos.swf", 'flash', 645, 442, '8', '#000000');
	$flash.addParam('allowScriptAccess', 'always');
	$flash.addParam('allowFullScreen', 'true');
	$flash.addParam('wmode', 'transparent');
	$flash.addVariable('title', $('#player strong').html());
	$flash.addVariable('url', $('#player span').html());
	$flash.write('player');

	$('#videos .list .button1, #videos .list .button2').click(function() {
		update(($(this).attr('class') == 'button1' ? -1 : 1));
	});
});