num_cols = 0;
active_col = 0;

function set_nav() {
	if(num_cols != 0) {
		$("nav-sx").style.left = (active_col == 0) ? "-950px" : "950px";
		$("nav-dx").style.left = (active_col == num_cols-1) ? "-970px" : "970px";
		$("nav-sx-sotto").style.left = (active_col == 0) ? "-950px" : "950px";
		$("nav-dx-sotto").style.left = (active_col == num_cols-1) ? "-970px" : "970px";
	}
}

function hide_nav() {
	$("nav-sx").style.left = "-950px";
	$("nav-dx").style.left = "-970px";
	$("nav-sx-sotto").style.left = "-950px";
	$("nav-dx-sotto").style.left = "-970px";
}

function nav_sx_clicked() {
	hide_nav();
	new Effect.Move("inner-all", {x:225,y:0,duration:0.5, afterFinish:set_nav});
	//left = parseInt($("inner-all").style.left) + 225 + "px";
	//$("inner-all").style.left = left;
	active_col--;
}

function nav_dx_clicked() {
	hide_nav();
	new Effect.Move("inner-all", {x:-225,y:0,duration:0.5, afterFinish:set_nav});
	//left = parseInt($("inner-all").style.left) - 225 + "px";
	//$("inner-all").style.left = left;
	active_col++;
}

function set_nav_and_width() {
	if($$("#inner-all").length!=0) { //se no dà errore in caso no-video
		active_col = Math.floor(pos_active_video/3); //istanziata in production.php e project.php
		num_cols = $$(".inner-col").length;
		if(active_col+1 > num_cols)
			active_col--;
		$("inner-all").style.width = ((num_cols+1) * 225 + 10) + "px"; //+10 per sicurezza
		$("inner-all").style.left = (-225*active_col) + "px"; //parte dalla posizione "giusta"
		set_nav();
		Event.observe($("nav-sx"), 'click', nav_sx_clicked);
		Event.observe($("nav-dx"), 'click', nav_dx_clicked);
		Event.observe($("nav-sx-sotto"), 'click', nav_sx_clicked);
		Event.observe($("nav-dx-sotto"), 'click', nav_dx_clicked);
	}
}

Event.observe(window, 'load', set_nav_and_width);


