
var moving = null;

var _ypos = 0;
var _margin = 3;
var _duration = .5;

function startMoveUp(){
	moving = new PeriodicalExecuter(moveUp, .1);
	moveUp();
}
function startMoveDown(){
	moving = new PeriodicalExecuter(moveDown, .1);
	moveDown()
}
function stopMoving(){
	moving.stop();
}
//
function moveUp(){
	//if ( cimage > 0) {
		_moveImages( 0 );
	//}
}
function moveDown(){
	//if ( cimage < images.length ) {
		_moveImages( 1 );
	//}
}
//
function _moveImages( dir ){
	var ypos = -1*parseInt($('images').offsetTop,10);
	var h = $('images').offsetHeight;
	var move = false;
	var height = $('image-mask').offsetHeight;

	if ( dir == 1 ) {
		y = -20
		cimage++;
	}else{
		cimage--;
		y = 20
	}
	
	if ( ypos >= 0 && dir == 0 ){
		move = true;
	}else if ( ypos  <= h - height && dir == 1 ){
		move = true;
	}
	if ( move ) {
		new Effect.Move($('images'), {y:y ,x: 0 ,duration:0, mode: 'relative'});
	}
}


function showImage(obj){
	new Ajax.Updater('photo',obj._href);
	return false;
}