// JavaScript Document
var currentPosition = 0;
var stepMotion = 112;
var visibleArea = 0;
var maxMotion = 0;
var Tips;

window.addEvent('domready', function() {

	if ($('rightcenter-bar')) {
		visibleArea = parseInt($('rightcenter-bar').getStyle('width'));
	}

	if ($('lg-container')) {
		maxMotion = (parseInt($('lg-container').getStyle('width'))-visibleArea);
	}
	
	if ($('move-left')) {
		$('move-left').addEvent('click', function(event) { moveList('left'); });
	}

	if ($('move-right')) {
		$('move-right').addEvent('click', function(event) { moveList('right'); });
		if ((maxMotion+visibleArea) <= 567) { $('move-right').setStyle('visibility', 'hidden'); } // 567 is not precise, but needed to cope with IE6
	}
	
	Lightbox.init();
	
});

function moveList(direction) {

	if (direction == "right") {
		x = currentPosition;
		if(x == "" || isNaN(x)){ x = 0; }
		if((x - stepMotion) == (0-parseInt(maxMotion))){ return; }
		$('lg-container').effect('left',{ duration: 600, transition: Fx.Transitions.Quad.easeInOut, wait:true }).start(x, x - stepMotion );
		var nextMove = (x - stepMotion);
		var moveResult = (0-parseInt(maxMotion));
		if ((nextMove-10) <= moveResult) { // -10 is not precise, but needed to cope with IE6
			$('move-right').setStyle('visibility','hidden');
		} else if ((x + stepMotion) > 0) {
			$('move-left').setStyle('visibility','visible');
		}
		currentPosition = (x - stepMotion);
	} else if (direction == "left") {
		x = currentPosition;
		if(x == "" || isNaN(x)){ x = 0; }
		if(x == 0){ return; }		
		$('lg-container').effect('left',{ duration: 600, transition: Fx.Transitions.Quad.easeInOut, wait:true }).start(x, x + stepMotion );
		if ((x + stepMotion) == 0) {
			$('move-left').setStyle('visibility','hidden');
		} else if ((x + stepMotion) > (0-parseInt(maxMotion))) {
			$('move-right').setStyle('visibility','visible');
		}
		currentPosition = (x + stepMotion);		
	}
}