$(document).observe("dom:loaded", function() {
	if(!document.getElementById("blog-slider")) return false;
	var $blogSlider = $('blog-slider');
	$blogSlider .setStyle({
  		overflow: 'hidden'
	});
	var contentWidth  = $$('#inner-container div.story').length * 450;
	$('inner-container').setStyle({
  		width: contentWidth + 'px'
	});	
	$blogSlider .insert('<a id="slide_right_button" href="#"></a><a id="slide_left_button" href="#"></a>');
	$('slide_right_button').observe('click', scrollright);
	$('slide_left_button').observe('click', scrollleft);


function scrollright(e) {
	Event.stop(e);
	var newPosition = $('inner-container').positionedOffset();
	var contentWidth = $('inner-container').getWidth();
	var negContentWidth = (contentWidth - 450) * -1;
	if(newPosition[0]!== negContentWidth){
		if(newPosition[0] % 450 == 0){
			new Effect.Move('inner-container', {x:-450,y:0,duration:.75});
		}
		else {
			return false;
		};
	}
	else {
		return false;
	};
};

function scrollleft(e) {
	Event.stop(e);
	var newPosition = $('inner-container').positionedOffset();
	if(newPosition[0]!==0){
		if(newPosition[0] % 450 == 0){
			new Effect.Move('inner-container', {x:450,y:0,duration:.75});
		}
		else {
			return false;
		};
	}
	else {
		return false;
	};
};

});