/*
 * $Id: visionneuse.js,v 1.1 2009-02-16 17:44:55 fma Exp $
 */


boxposarray = new Array(0,0);
nb_boxes_arr = new Array();

function goLeft(pixel,maxnum,index){
	if(typeof index == "undefined"){
		var index = 0;
	}
	boxposarray[index]--;
	goGo(pixel,maxnum,index);
}
function goRight(pixel,maxnum,index){
	if(typeof index == "undefined"){
		var index = 0;
	}
	//alert('index '+index);
	boxposarray[index]++;
	goGo(pixel,maxnum,index);
}
function goZero(pixel,maxnum,index){
	if(typeof index == "undefined"){
		var index = 0;
	}
	boxposarray[index] = 0;
	goGo(pixel,maxnum,index);
}

function goVisible(pixel,maxnum,index){
	if(typeof index == "undefined"){
		var index = 0;
	}
	if(typeof maxnum == "undefined" || !maxnum){
		maxnum = 4;
	}
	if(index){
		nb_boxes = nb_boxes_arr[index];
	}
	if(boxposarray[index] > nb_boxes - maxnum){
		if(nb_boxes - maxnum > 0){
			boxposarray[index] = nb_boxes - maxnum;
		} else {
			boxposarray[index] = 0;
		}
	}
	goGo(pixel,maxnum,index);
}

function goGo(pixel,maxnum,index){
	if(typeof index == "undefined"){
		var index = 0;
	}

	suffix = "";
	if(typeof index != "undefined") {
		suffix = index;
	}

	var myFx = new Fx.Tween('conteneur'+suffix);
	myFx.start('margin-top', -1 * pixel * boxposarray[index]);

	checkArrows(maxnum,index);
}

function checkArrows(maxnum,index){

	if(typeof maxnum == "undefined" || !maxnum){
		maxnum = 4;
	}

	suffix = "";
	if(typeof index != "undefined") {
		nb_boxes = nb_boxes_arr[index];
		suffix = index;
	}

	if(boxposarray[index] > 0 && $('arrow_left'+suffix)) {
		$('arrow_left'+suffix).style.visibility = 'visible';
	} else  {
		$('arrow_left'+suffix).style.visibility = 'hidden';
	}

	if(nb_boxes - boxposarray[index] > maxnum && $('arrow_right'+suffix))
		$('arrow_right'+suffix).style.visibility = 'visible';
	else
		$('arrow_right'+suffix).style.visibility = 'hidden';
}

