var NavigareContent = Class.create();
NavigareContent.prototype = {
	initialize: function(options)
	{
		this.curent = 1;
		this.options = options;
		this.make_events();
		this.options.nav_buttons = this.options.nav_buttons!=undefined?this.options.nav_buttons:1;
		this.auto_nav = this.options.auto_nav?this.options.auto_nav:0;
		this.timeout = 0;
		if(this.auto_nav==1) this.go_auto_nav();
	},
	go_nav: function()
	{
		if(this.options.direction=="v")
		{
			new Effect.Move($(this.options.myclass+'_cnt'), {y: this.vnew,queue: { position: 'end', scope: 'slider'}});
		}
		else if(this.options.direction=="h")
		{
			new Effect.Move($(this.options.myclass+'_cnt'), {x: this.vnew,queue: { position: 'end', scope: 'slider'}});
		}
	},
	make_events: function()
	{
		if($(this.options.myclass+'_left')!=undefined)
		{
			Event.observe($(this.options.myclass+'_left'),'click',function(){
				this.auto_nav = 0;
				this.calc_nav('down');
			}.bind(this));
		}
		if($(this.options.myclass+'_right')!=undefined)
		{
			Event.observe($(this.options.myclass+'_right'),'click',function(){
				this.auto_nav = 0;
				this.calc_nav('up');
			}.bind(this));
		}
		for(i=1;i<=this.options.total;i++)
		{
			if($(this.options.myclass+'_'+i)!=undefined)
			{
				Event.observe($(this.options.myclass+'_'+i),'click',function(e){
					this.auto_nav = 0;
					this.calc_nav(e.target.id.substr(e.target.id.lastIndexOf('_')+1));
				}.bind(this));
			}
		}
	},
	calc_nav: function(a)
	{
		go_to = 0;
		if(a=='down' && this.curent>1)
		{
			go_to = this.curent-1;
			this.vnew = this.options.item_width;
		}
		else if (a=='up' && this.curent<this.options.total)
		{
			go_to = this.curent+1;
			this.vnew = -this.options.item_width;
		}
		else if (a!='down' && a!='up')
		{
			go_to = parseInt(a);
			if(go_to>this.curent) this.vnew = (this.curent-a)*this.options.item_width;
			else if(go_to<this.curent) this.vnew = (this.curent-a)*this.options.item_width;
		}
		if(go_to<1 || go_to>this.options.total || this.curent==go_to) return;
		this.curent = go_to;
		if(this.options.nav_buttons) this.redraw_nav();
		this.go_nav();
	},
	redraw_nav: function()
	{
		if(this.curent==1)
			$(this.options.myclass+'_left').src = '/images/casete/video_left_scroll.gif';
		else
			$(this.options.myclass+'_left').src = '/images/casete/video_left_scroll_act.gif';
		if(this.curent==this.options.total)
			$(this.options.myclass+'_right').src = '/images/casete/video_right_scroll.gif';
		else
			$(this.options.myclass+'_right').src = '/images/casete/video_right_scroll_act.gif';
		for(i=1;i<=this.options.total;i++)
		{
			$(this.options.myclass+'_'+i).src = '/images/casete/video_bull_1_scroll.gif';
			$(this.options.myclass+'_'+i).className = 'bull_1';
		}
		$(this.options.myclass+'_'+this.curent).src = '/images/casete/video_bull_2_scroll.gif';
		$(this.options.myclass+'_'+this.curent).className = 'bull_2';
	},
	go_auto_nav: function()
	{
		if(this.auto_nav!=1) return;
		if(this.curent<this.options.total && this.timeout!=0)
			this.calc_nav('up');
		else if(this.timeout!=0)
			this.calc_nav(1);
		this.timeout = setTimeout(function(){this.go_auto_nav()}.bind(this),5000);
	}
}
