YAHOO.namespace("YAHOO.fotoloupe.TodayPick");

YAHOO.fotoloupe.TodayPick = function() {	
	this.init() ;
};


YAHOO.fotoloupe.TodayPick.prototype = {
	container:null,
	children:null,
	image_list:null,
	total_image:0, 
	curr_idx:null,
	max_idx:3,
	isPause:false ,
	container_width:700,
	container_height:500,	
	anim:null,
	interval_id:null ,
	init:function () {
		this.curr_idx = 0 ;
		this.container = YAHOO.util.Dom.get('large-photo-list' ) ;

		this.children = YAHOO.util.Dom.getChildren ( this.container ) ;

		// one second
		if ( this.children.length > 1 ) {
			YAHOO.util.Event.on ( this.container, 'mouseover', this.onMouseOverHandler, this, true ) ;
			YAHOO.util.Event.on ( this.container, 'mouseout', this.onMouseOutHandler, this, true ) ;
			
			this.anim = new YAHOO.util.Anim(this.container, {left: { to: -600, unit:'px'} }, 1, YAHOO.util.Easing.easeOut) ;
			this.anim.onComplete.subscribe( this.onAnimComplete, this, true ) ;

			if ( !this.isPause ) {
				this.interval_id = setInterval (this.refresh, 10000, this) ;
			}
		}
	},
	refresh:function (obj) {
		obj.anim.animate() ;

	},
	onAnimComplete:function () {
		var first_item = YAHOO.util.Dom.getFirstChild( this.container) ;
		var last_item = YAHOO.util.Dom.getLastChild( this.container) ;
		YAHOO.util.Dom.insertAfter ( first_item, last_item ) ;
		YAHOO.util.Dom.setStyle ( this.container, 'left','0px') ;
	},
	onMouseOverHandler:function () {
		this.isPause = true ;
		clearInterval ( this.interval_id ) ;
	},
	onMouseOutHandler:function () {
		this.isPause = false ;
		this.interval_id = setInterval ( this.refresh, 10000, this ) ;
	}

}
