/* ---------------------------------
Made by: Nikolai Khilkovsky
E-mail: khilkovn@gmail[dot]com
URL: http://www.himself.pp.ua
--------------------------------- */
Cufon.replace('#siteName span.strong', { fontFamily: 'LogoFontB' });
Cufon.replace('#siteName span.reg', { fontFamily: 'LogoFont' });
//Общие переменные
var imgPath='img/';			//Путь к каталогу с фоновыми картинками
//Функции разметки и функционала страницы
function topReitingAlign(){
	$('.reiting-content table tr').eq(1).find('td').css('padding-top','21px');
	var	HeitL=$('#top-reiting').height(),
			HeitR=$('.reiting-content table').height();
	if (HeitL<HeitR) {$('#top-reiting ul').height(HeitR-29)}
	else {$('.reiting-content table tr:last').find('td').css('padding-bottom',HeitL-HeitR+7+'px')};
};
function BuildPage(){
	if (document.getElementById('new-sites') && $.browser.opera) {
		if ($('#new-sites > sup').length>0) {$('#new-sites').css('margin-top','-3px')}
	};
	if (document.getElementById('rubriki')) {$('#rubriki .item:odd').after('<div class="clear"></div>')};
	if (document.getElementById('popular-links') && document.getElementById('random_sait')) {
		var	heit1=$('#popular-links').height(),
				heit2=$('#random_sait').height();
		if (heit1<heit2+66) {$('#popular-links').height(heit2+66)}
		else {$('#random_sait').height(heit1-66)}
	};
	if (document.getElementById('category')) {
		var	linkW=0,
				linlP=0,
				linkBlW=634;
		$('#category li').each(function(i){if (linkW<$(this).width()){linkW=$(this).width()}});
		linkP=Math.floor((linkBlW-linkW*2)*0.25);
		$('#category li').css({'padding':'0px '+linkP+'px','width':linkW+'px'})
	};
	if (document.getElementById('top-reiting')) {
		topReitingAlign();
		if ($.browser.msie && $.browser.version == 6) {
			$('.reiting-content table tr th div').hover(
				function(){$(this).addClass('jqhover')},
				function(){$(this).removeClass('jqhover')}
			)
		};
		$('#show-reiting').click(function(){
			$('#show-voises div').removeClass('current');
			$('.reiting-content table .voice').hide();
			$('#show-hits div').removeClass('current');
			$('.reiting-content table .hits-show').hide();
			$(this).find('div').addClass('current');
			$('.reiting-content table .reiting').show();
		});
		$('#show-hits').click(function(){
			$('#show-voises div').removeClass('current');
			$('.reiting-content table .voice').hide();
			$('#show-reiting div').removeClass('current');
			$('.reiting-content table .reiting').hide();
			$(this).find('div').addClass('current');
			$('.reiting-content table .hits-show').show();
		});
		$('#show-voises').click(function(){
			$('#show-reiting div').removeClass('current');
			$('.reiting-content table .reiting').hide();
			$('#show-hits div').removeClass('current');
			$('.reiting-content table .hits-show').hide();
			$(this).find('div').addClass('current');
			$('.reiting-content table .voice').show();
		})
	};
	RemadeFooter()
};
function RemadeFooter(){
//	Перерисовываем футер в старых IE
	if (($.browser.msie && $.browser.version == 6) || ($.browser.msie && $.browser.version == 7)) {
		$('#footer').hide(0);
		$('#footer').show(0)
	}
};
$(document).ready(function(){BuildPage()});
if (window.addEventListener) window.addEventListener('load', function () {
	if (document.getElementById('news-block') && document.getElementById('recl1') && document.getElementById('recl2')) {
		var	heit3=$('#news-block').height(),
				heit4=$('#recl1').height(),
				heit5=$('#recl2').height();
		if (heit3<heit4+heit5+8) {$('#news-block').height(heit4+heit5+8)}
		else {$('#recl2').height(heit3-heit4-8)}
	};
}, false)
else window.attachEvent('onload', function () {
	if (document.getElementById('news-block') && document.getElementById('recl1') && document.getElementById('recl2')) {
		var	heit3=$('#news-block').height(),
				heit4=$('#recl1').height(),
				heit5=$('#recl2').height();
		if (heit3<heit4+heit5+8) {$('#news-block').height(heit4+heit5+8)}
		else {$('#recl2').height(heit3-heit4-8)}
	};
});

