$(document).ready(function(){
		
	$('.main_item .mi_title li').each(function(index) {
		$(this).hover(
		function() {
				if ($(this).hasClass("active")){return false;}
				$(this).parent().find('.active').removeClass('active');
				$(this).addClass('active');
				if($(this).hasClass('hover')) return false;
				$('.main_item .mi_view img').fadeOut(200);
				$('.main_item .mi_view img:eq(' + index + ')').fadeIn(200);
				$('.main_item .mi_active li').fadeOut(200);
				$('.main_item .mi_active li:eq(' + index + ')').fadeIn(200);
		},
	    function() {}
		);
		$(this).click(
		function() {
				window.location=$(this).find("a").attr("href"); return false;
		});
		
    });
	
	$('.main_item .mi_view img').click(function() {
		window.location=$('.main_item .mi_title').find('li.active').find('a').attr('href'); return false;
    });
	
	$(".mi_view").hover( function(){
		$(this).find('img.play_btn').css('display','block')
		},
	  function() {
		$(this).find('img.play_btn').css('display','none')
	});
	
	$('.main_item .mi_title li').eq(0).addClass('active');
	
	$(".video_item a").hover( function(){
		if ($(this).hasClass("chanel_link")){return false;}
		$(this).find('img.play_btn').css('display','block')
		},
	  function() {
		$(this).find('img.play_btn').css('display','none')
	});
	
	$(".chanel a").hover( function(){
		$(this).find('img.play_btn').css('display','block')
		},
	  function() {
		$(this).find('img.play_btn').css('display','none')
	});
	
	if($(".chanel .filter").height() > 50)
		{
			$(".chanel .filter").height('50px');
			$(".chanel .filter").append('<li class="view_all">... <a href="#">Все темы</a></li>');
		}
	$(".chanel .filter .view_all a").click(function() {
		if($(".chanel .filter").height() > 50) { $(".chanel .filter").height('50px'); }
			else { $(".chanel .filter").height('auto'); }
			return false;
	});
	
	$(".date_time a.wide_screen").click( function(){
		$(".page").toggleClass('player_wide');
		return false;
	});
	
	if($(".rightcol .new_video_channel").height() > 440)
		{$(".rightcol .new_video_channel").addClass('scroll');}
		
});

function window_open(href,name){
 window.open(
   href,
   'window'+name,
   'width=700,height=400,toolbar=yes,location=yes,directories=yes,status=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes'
 );
}
