var $h = 
{
	slide: function(){return $("#en-spectacle-items");}
	,width:371
	,init: function()
	{
		$h.items = $(".en-spectacle-item");
		$h.arrows();
		if($h.items.length==0) return this;
		$h.slide().width($h.items.length*$h.width);//.css({left:'-'+($h.scroll_to_first*608)+'px'});
		return this;
	},
	anime_left: function()
	{
		$(".en-spectacle-arrow-left")
			.unbind('click')
			.bind('click',function(){return false;});
		$h.slide().animate({marginLeft:'+='+$h.width+'px'},300,'',$h.arrows);
		return false;
	},
	anime_right: function()
	{
		$(".en-spectacle-arrow-right")
			.unbind('click')
			.bind('click',function(){return false;});
		$h.slide().animate({marginLeft:'-='+$h.width+'px'},300,'',$h.arrows);
		return false;
	},
	arrows: function()
	{
		var container = $h.slide();
		var length = $h.items.length;
		var left = parseInt(container.css('marginLeft').replace('px',''));

		if(left == 0 || length == 1 || isNaN(left))
		{
			$(".en-spectacle-arrow-left")
				.unbind('click',$h.anime_left)
				.bind('click',function(){return false;})
				.css({opacity:0.7});
		}
		else if(length>1)
		{
			$(".en-spectacle-arrow-left").bind('click',$h.anime_left).css({opacity:1});
		}

		if(left == -((length-1)*$h.width) || length == 1)
		{
			$(".en-spectacle-arrow-right")
				.unbind('click',$h.anime_right)
				.bind('click',function(){return false;})
				.css({opacity:0.7});
		}
		else if(length>1)
		{
			$(".en-spectacle-arrow-right").bind('click',$h.anime_right).css({opacity:1});
		}

		var current = $h.items.removeClass('slide-active').eq(-left/$h.width).addClass('slide-active');
		//$h.new_cal(current.data('configs'));
		return this;
	}
};

ol($h.init);




var $v = 
{
	init: function()
	{
		$v.items = $(".box-videos-slide");
		$v.navs = 
		{
			left: $(".videos-arrow-left"),
			right: $(".videos-arrow-right")
		};
		
		$v.arrows();
		if($v.items.length==0) return this;
		
		
		$('.box-videos-thumb .video-overlay').bind("click",function(e){location.href = $(e.currentTarget).find('a').attr('href');});
		
		return this;
	},
	arrows: function(e)
	{
		
		$v.navs.left.unbind('click').bind('click',function(){return false;}).css({opacity:0.7});;
		$v.navs.right.unbind('click').bind('click',function(){return false;}).css({opacity:0.7});;
		
		var active = 0;
		if(e)
		{
			var direction = $(e.currentTarget).hasClass('videos-arrow-left')? -1 : 1;
			var active = $v.items.index($(".active-slide").get(0))+(1*direction);
		}
		
		var length = $v.items.length;
		 $v.items.addClass('videos-hidden').removeClass("active-slide")
		 	.eq(active).removeClass("videos-hidden").addClass("active-slide");
		  
		if(length < 2)return false;
		
		if(active != 0)
			$v.navs.left.unbind('click').bind('click',$v.arrows).css({opacity:1});
		
		if(active != length-1)
			$v.navs.right.unbind('click').bind('click',$v.arrows).css({opacity:1});
		return false;
	}
};

ol($v.init);

/*
*/

