var $h = 
{
	slide: function(){return $("#en-spectacle-items");},
	init: function()
	{
		$h.items = $(".en-spectacle-item");
		$h.arrows();
		if($h.items.length==0) return this;
		$h.slide().width($h.items.length*600);//.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:'+=600px'},300,'',$h.arrows);
		return false;
	},
	anime_right: function()
	{
		$(".en-spectacle-arrow-right")
			.unbind('click')
			.bind('click',function(){return false;});
		$h.slide().animate({marginLeft:'-=600px'},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;})
				.addClass('inactive');
		}
		else if(length>1)
		{
			$(".en-spectacle-arrow-left").bind('click',$h.anime_left).removeClass("inactive");
		}

		if(left == -((length-1)*600) || length == 1)
		{
			$(".en-spectacle-arrow-right")
				.unbind('click',$h.anime_right)
				.bind('click',function(){return false;})
				.addClass('inactive');
		}
		else if(length>1)
		{
			$(".en-spectacle-arrow-right").bind('click',$h.anime_right).removeClass("inactive");
		}

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

$($h.init);





var $v = 
{
	slide: function(){return $("#box-videos-slides");},
	width: 314,
	init: function()
	{
		$v.items = $(".box-videos-slide");
		if($v.items.length == 0) return;
		$v.navs = 
		{
			left: $(".box-videos-navs .left-nav"),
			right: $(".box-videos-navs .right-nav"),
			both:  $(".box-videos-navs .nav"),
			wrapper:  $("#box-videos-footer")
		};
		
		$v.arrows();
		if($v.items.length==0) return this;
		$v.slide().width($v.items.length*$v.width);
		
		
		$('.box-videos-thumb .video-overlay')
			.bind("click",function(e){location.href = $(e.currentTarget).find('a').attr('href');});
		
		return this;
	},
	anime_left: function()
	{
		$v.navs.left
			.unbind('click')
			.bind('click',function(){return false;});
		$v.slide().animate({marginLeft:'+='+$v.width+'px'},200,'',$v.arrows);
		return false;
	},
	anime_right: function()
	{
		$v.navs.right
			.unbind('click')
			.bind('click',function(){return false;});
		$v.slide().animate({marginLeft:'-='+$v.width+'px'},200,'',$v.arrows);
		return false;
	},
	arrows: function()
	{
		var container = $v.slide();
		var length = $v.items.length;
		var left = parseInt(container.css('marginLeft').replace('px',''));

		if(left == 0 || length == 1 || isNaN(left))
		{
			$v.navs.left
				.unbind('click',$v.anime_left)
				.bind('click',function(){return false;})
				.addClass('inactive');
		}
		else if(length>1)
		{
			$v.navs.left.bind('click',$v.anime_left).removeClass("inactive");
		}

		if(left == -((length-1)*$v.width) || length == 1)
		{
			$v.navs.right
				.unbind('click',$v.anime_right)
				.bind('click',function(){return false;})
				.addClass('inactive');
		}
		else if(length>1)
		{
			$v.navs.right.bind('click',$v.anime_right).removeClass("inactive");
		}

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

$($v.init);


