$(document).ready(function() {
	
	/*
		Aleksey Skubaev

		askubaev@gmail.com
		icq - 322253350
		���������� �������� ��� DLE � ��������������� �������
		------------------
		����������� jQuery �������.
	
	*/
	
	getTitleWidth();
	
	getQality();
	
	getQalityFullNews();
	
	// ������� �������� ������ ������
	function getTitleWidth() {
		var heightElements = $('.main-center-block .content-table');
		
		for (i=0; i<heightElements.length; i++)
		{
			var correntHeight = $(heightElements[i]).height();
			$(heightElements[i]).find('.title-link').css({'height':correntHeight});
		}
	};
	
	// ������� ������������ �������� ������
	function getQality() {
		var kinoElements = $('.main-center-block .kino-news');
		
		for (i=0; i<kinoElements.length; i++)
		{
			var correntKino = $(kinoElements[i]);
			var correntQuality = correntKino.find('.kino-quality').text();
			correntKino.find('.quality').addClass(correntQuality);
			correntKino.find('h2').addClass(correntQuality);
		}
	};
	
	function getQalityFullNews() {
		var fullKinoElement = $('.kino-full-news');
		var correntQuality = fullKinoElement.find('.kino-quality').text();
		fullKinoElement.find('.quality').addClass(correntQuality);
		
	};
	
	// ��������� ��������� �� �������� �������
	$('div.bdrip').attr({
		title : 'A BDRip is a multimedia file that contains content that was sourced from a Blu-ray Disc product. As the "rip" part of the name applies, the copy is generally not a 1:1 copy, but instead is usually re-encoded. Most of the time Blu-ray disc rips (BDRips) contain AVC video that has a lower bitrate to the original content. Sometimes the creator of a BDRip may choose to lower the video resolution from Full HD 1080p content to 720p. The most common multimedia container used for BDRips is the Matroska (MKV) container, which would be used for its suitability. '
	});
	
	$('div.dvdrip').attr({
		title : 'DVDrip - A final retail version of a film, typically released before it is available outside its originating region. Often after one group of pirates releases a high-quality DVD-Rip, the "race" to release that film will stop. Because of their high quality, DVD-Rips generally replace any earlier copies that may already have been circulating.'
	});
	
	$('div.camrip').attr({
		title : 'Camrip - A pirated movie made by sneaking a digital video camera into a theater and taping the movie.Usually poor quality with people walking in front of the camera, shaking, poor resolution & contrast etc.'
	});
	
	$('div.ts').attr({
		title : 'TS - A professional bootleg camera job with direct sound. Wherein a VCD pirating group sends a cammer to a cinema with camera and wireless mics. Cammer attaches wireless mics to speakers, videotapes the image off the cinema screen and goes and rips a/v to his computer and encodes and disseminates through the internet.'
	});
	
	
	// ����������� ���������
	$('a, img, div').tooltip({ 
		track: true, 
		delay: 0, 
		showURL: false, 
		fade: 250 
	});
	
	// ���������� ��������� � ������ ��� ��������
	$('.music-news').hover(
		function() {
			$(this).find('h2').show(100);
		}, function() {
			$(this).find('h2').hide(100);
	});
	
	// �������� ������ �������������
	$('.clips-news-preview').hover(
		function() {
			$(this).addClass('clips-news-preview2');
		}, function() {
			$(this).removeClass('clips-news-preview2');
	});
	
	// ����������� ���� � ������
	$('.clips-news-preview').click(function(){
		$('.dark').fadeIn(200);
		var correntClip = $(this).parent().parent().find('.clips-news-content');
		var correntClipWidth = correntClip.width();
		var correntClipHeight = correntClip.height();
		correntClip.fadeIn(200);
		correntClip.css({'margin-left':-((correntClipWidth)/2)});
		correntClip.css({'margin-top':-((correntClipHeight)/2)});
	});
	
	// ������� ��� ����
	$('.clips-news-content-close, .dark').click(function(){
		$('.dark').fadeOut(200);
		$('.clips-news-content').fadeOut(200);
	});
	
	$('.on-line-news').hover(
		function() {
			$(this).find('.on-line-news-content').fadeIn(200);
		}, function() {
			$(this).find('.on-line-news-content').fadeOut(200);
	});
	$('.kino-news').hover(
	function() {
		$(this).find('.on-line-news-content').fadeIn(200);
	}, function() {
		$(this).find('.on-line-news-content').fadeOut(200);
	});
	
	// 
	$('.login-open').click(function(){
		$('.dark').fadeIn(200);
		$('.login-block').fadeIn(200);
	});
	
	// 
	$('.login-close-buttom, .dark').click(function(){
		$('.dark').fadeOut(200);
		$('.login-block').fadeOut(200);
	});
	
});
