var speed = 400; // px/sec

function goLeft(id) 
{
	var width  = parseInt($('#'+id).css('width').substring(0, $('#'+id).css('width').length-2));
	var margin = parseInt($('#'+id).css('margin-left').substring(0, $('#'+id).css('margin-left').length-2));
	$('#'+id).animate({
		marginLeft: '0px'
	}, -margin / speed * 1000, 'linear', function () {
		//showHideAllButtons();
	});
	//setTimeout('showHideAllButtons()', 100);
}

function goRight(id) 
{
	var width  = parseInt($('#'+id).css('width').substring(0, $('#'+id).css('width').length-2));
	var margin = parseInt($('#'+id).css('margin-left').substring(0, $('#'+id).css('margin-left').length-2));
	$('#'+id).animate({
		marginLeft: -(width - 900) + 'px'
	}, (margin + (width - 900)) / speed * 1000, 'linear', function () {
		//showHideAllButtons();
	});
	//setTimeout('showHideAllButtons()', 100);
}

function stopLeft(id) {
	$('#'+id).stop();
	//showHideAllButtons();
}
function stopRight(id) {
	$('#'+id).stop();
	//showHideAllButtons();
}

setTimeout('showHideAllButtons()', 100);
function showHideAllButtons()
{
	showHideButtons('slider1');
	showHideButtons('slider2');
	showHideButtons('slider3');
	setTimeout('showHideAllButtons()', 100);
}
function showHideButtons(id)
{
	if ($('#'+id).css('width') != null) {
		var width  = parseInt($('#'+id).css('width').substring(0, $('#'+id).css('width').length-2));
		var margin = parseInt($('#'+id).css('margin-left').substring(0, $('#'+id).css('margin-left').length-2));
		if (width + margin <= 900) {
			$('#'+id+'right').css('visibility', 'hidden');
		} else {
			$('#'+id+'right').css('visibility', 'visible');
		}
		if (margin >= 0) {
			$('#'+id+'left').css('visibility', 'hidden');
		} else {
			$('#'+id+'left').css('visibility', 'visible');
		}
	}
	//setTimeout('showHideButtons("' + id + '")', 2000);
}

