Event.observe(window, 'load', function(event){
	
	container = $('bookshelf_module');
	container.style.position = "absolute";
	container.style.left = "0px";
	/*container.style.width = "5000px";*/
	
	var btn_left = $('bookshelf_move_left');
	var btn_left_on = $('bookshelf_move_left_on')
	var btn_right = $('bookshelf_move_right');
	var btn_right_on = $('bookshelf_move_right_on')
	var sourceLeft = $('left_arrow');
	var sourceRight = $('right_arrow');
	Event.observe(btn_right_on, 'click', scrollRight);
	Event.observe(btn_left_on, 'click', scrollLeft);
	
	
	
function scrollLeft(){
	new Effect.Move(container,{x: 200 * Math.round(parseInt(container.style.left) / 200) - 200, y: 0, mode: 'absolute', duration:0.5})
}

function scrollRight(){
	new Effect.Move(container,{x: 200 * Math.round(parseInt(container.style.left) / 200) + 200, y: 0, mode: 'absolute', duration:0.5})
}

function checkWidth() {
  var myWidth = null;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }

	var chicklets = document.getElementsByClassName('cart_container', 'DIV');
	var chickletsWidth = chicklets.length * 205;
	
	if (chickletsWidth - (myWidth - 50) + parseInt(container.style.left) > 0){
		btn_left.style.display = 'none';
		btn_left_on.style.display = 'block';
	}
	else {
		btn_left.style.display = 'block';
		btn_left_on.style.display = 'none';
	}
	
	if (parseInt(container.style.left) < 0){
		btn_right.style.display = 'none';
		btn_right_on.style.display = 'block';
		
	}
	else {
		btn_right.style.display = 'block';
		btn_right_on.style.display = 'none';
	} 
}



window.setInterval(checkWidth, 500);
});