var CStudio = new Class(
{
	initialize: function(num)
	{
		this.num = x;

		this.initEvents();
	},
	
	initEvents: function()
	{
		var this_parent = this;
		var num = this_parent.num;
		var cb = $('center_bottom_' + num);
		
		var trans = new Fx.Scroll("center_bottom_" + num);
		var current_pos = 0;
		var width = $("center_bottom_" + num).getScrollSize().x;
		var offset = 60;
		
		/*$('left_bottom_trans').addEvent('click', function(){
			if ((current_pos) > 0) 
				current_pos -= offset;
			trans.start(current_pos, 0);
		});
		
		$('right_bottom_trans').addEvent('click', function(){
			if ((current_pos + offset) < width - offset * 5) 
				current_pos += offset;
			trans.start(current_pos, 0);
		});*/
		
		
		var trans2 = new Fx.Scroll("center_big_" + num);
		var current_pos2 = 0;
		var width2 = $("center_big_" + num).getScrollSize().x;
		var offset2 = 436;
		
		/*$('left_big_trans').addEvent('click', function(){
			if ((current_pos2) > 0) 
				current_pos2 -= offset2;
			trans2.start(current_pos2, 0);
		});
		
		$('right_big_trans').addEvent('click', function(){
			if ((current_pos2 + offset2) < (width2 - offset2)) 
				current_pos2 += offset2;
			trans2.start(current_pos2, 0);
		});*/
		
		var cb = $('center_bottom_' + num);
		
		var imgs = cb.getElements('img');
		
		imgs.each(function(e, i)
		{
			var img = e;
				
			e.addEvent('click', function()
			{
				var ccb = $('child_center_big_' + num);
				var oib = ccb.getElements('.outer_img_big');
				var k = 0;
				var res = 0;
				oib.each(function(e, i)
				{
					var item = e;
					//var bd = $(img.id + '_div_big');
			
					k++;
					if (item.id == (img.id + '_div_big'))
					{
						res = k;
					}
					//var left = bd.getPosition().x;
				});
				
				//alert(left)
				current_pos2 = offset2 * (res - 1);
				trans2.start(current_pos2, 0);
			});
		});
		this_parent.timer = null;
		
		cb.addEvent('mouseover', function(event)
		{
			event.stop();
			var cb_width = cb.getWidth();
			var cb_left = this.getLeft() + this.getScroll().x;
			var cb_center = cb_width / 2;
			var mouse_x = event.page.x - cb_left;
			var const_anim = 1;

			if (mouse_x <= cb_center)
			{
				if (mouse_x < 51)
				 	const_anim = 6;
				else
					const_anim = Math.floor((50 / mouse_x) * 10);
			}
			else
				const_anim = Math.ceil(((mouse_x - cb_center) / 50));
			
			const_anim *= 1.2;
			const_anim *= ((mouse_x <= cb_center) ? -1 : 1);
			
			if (this_parent.timer) 
			{
				clearInterval(this_parent.timer);
				this_parent.timer = null;
			}
			//alert(current_pos + '  ' + this.getScroll().x)
			if (this_parent.timer == null) 
			{
				this_parent.timer = setInterval(function()
				{
					if ((((current_pos) > 0) && (const_anim < 0)) || (((current_pos) < (width - offset * 6)) && (const_anim > 0))) 
					{
						current_pos += const_anim;
						trans.set(current_pos, 0);
					}
				}, 15);
			}			
		});
		
		cb.addEvent('mouseout', function(event)
		{
			if (this_parent.timer) 
			{
				clearInterval(this_parent.timer);
				this_parent.timer = null;
			}
		});
	}
	
});
	
