$(document).ready(function(){
	function hhh(){
		alert($('#iframe_content_height'));
		$("#fancybox-content").height($('#iframe_content_height'));
	}

	$('.head ul li:last,.news .date span:last,.connent_list li:last,.blog_list_item li .date span:last').css({'padding-right':'0','background':'none'});
	$('#footer ul li:odd').css('margin-right','0');
	
	$('.foto_list li').each(function(i){
		if(i%3 == 2)$(this).css('margin-right','0');
	});
	
	$('.news_list_news li div').each(function(i){
		$(this).children('span:last').css({'padding-right':'0','background':'none'});
	});
	
	$('.blog_list_item li div.date').each(function(i){
		$(this).children('span:last').css({'padding-right':'0','background':'none'});
	});
	
	$('.pager a:last').prev('a').css({'background':'none'})
	$('.pager span').prev('a:not(a.prev)').css({'background':'none'})
	
	// FOTO
	$('.list_foto li').each(function(i){
		if(i%3 == 2)$(this).css('margin-right','0');
	});
	
	$('.list_foto li').hover(function(){
		$(this).addClass('hover');
		//$(this).animate({backgroundPosition:'(100% 0px)'},{duration:300});
	},function(){
		$(this).removeClass('hover');
		//$(this).animate({backgroundPosition:'(0px 0px)'},{duration:300});
	});
	
	$('.list_blogs li').each(function(i){
		if(i%3 == 2)$(this).css('margin-right','0');
	});
	
	$('.list_blogs li').hover(function(){
		$(this).addClass('hover');
	},function(){
		$(this).removeClass('hover');
	});
	
	//$('.window').hide();
	
	/*$('.list_foto li').click(function(e){
        e.preventDefault();
		var scrOfY = scr();
		var rMinus = $('#content').height()-scrOfY;
		var rPlus = $('.window').height()-rMinus+150;
		if (rPlus<0) rPlus = 0;
		$('#popup').height($('#content').height()+rPlus).show();
		$('.window').css("top", scrOfY + 50 + 'px').fadeIn();
	});*/
	
	function scr(){
        var scrOfY = 0;
       	if( typeof( window.pageYOffset ) == 'number' ) {
               //Netscape compliant
               scrOfY = window.pageYOffset;
       	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
               //DOM compliant
               scrOfY = document.body.scrollTop;
       	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
               //IE6 Strict
               scrOfY = document.documentElement.scrollTop;
       	}
		return scrOfY;
	}
	
	$('.window .close,#popup').click(function(e) {
		e.preventDefault();
		$('#popup').fadeOut(300);
		$('.window').hide();
	});
	
	$('#footer ul li:even').css('width','90px');
	
/*----------------------VKLADKI------------------------
	$('.left_vk').each(function(i){
		$(this).children('div.vkl_content:first').show();
	});

	$('ul.vkl li').click(function(e){
		e.preventDefault();
		var num = $(this).children('a').attr('rel').replace(/num/,"");
		$(this).parent('ul').children('li').removeClass('active');
		$(this).addClass('active');
		if (num == 0) {
			$(this).parent('ul').removeClass('too');
			$(this).parent('ul').addClass('one');
		}
		if (num == 1) {
			$(this).parent('ul').addClass('too');
			$(this).parent('ul').removeClass('one');
		}
		$(this).parent('ul').parent('div').children('div.vkl_content').hide();
		var massDivCont = $(this).parent('ul').parent('div').children('div.vkl_content');
		for(var i=0; i<massDivCont.length;i++){
			if (i==num){
				$(massDivCont[i]).slideDown(300);
			}
		}
	});
	*/
	
	
	//NEWS
	$('.news_t_list li').hover(function(){
		$('.nc').hide();
		$(this).children('div.nc').show();
	});
	
	$('.news img').each(function(i){
		var position = $(this).attr('align');
		var src = $(this).attr('src');
		var w = $(this).width();
		var h = $(this).height();
		var autor = $(this).attr('alt').replace(/Автор: /,'');
		var place = $(this).attr('title').replace(/Источник: /,'');
		if (position == 'left'){
			$(this).before('<div class="img_left"><img src="'+src+'" alt="" width="'+w+'" height="'+h+'" /><div style="width:'+w+'px;"><span class="author">'+autor+'</span><span><a href="http://'+place+'">'+place+'</a></span></div>');
		}if (position == 'right'){
			$(this).before('<div class="img_right"><img src="'+src+'" alt="" width="'+w+'" height="'+h+'" /><div style="width:'+w+'px;"><span class="author">'+autor+'</span><span><a href="http://'+place+'">'+place+'</a></span></div>');
		}if (position == 'middle'){
			$(this).before('<div class="img_center"><img src="'+src+'" alt="" width="'+w+'" height="'+h+'" /><div style="width:'+w+'px;"><span class="author">'+autor+'</span><span><a href="http://'+place+'">'+place+'</a></span></div>');
		}
		$(this).remove();
	});
	
	var maxZ = Math.max.apply(null,$.map($('.news_img'), function(e,n){
			return parseInt($(e).css('height'))||1 ;
	   })
	);
	$('.news_img').height(maxZ);
	
	$('.vivid iframe').attr('allowtransparency','true');
	
	$('.left_c .vid iframe').attr('width','320');
	$('.left_c .vid iframe').attr('height','240');

	$('.right_big .video_preview iframe').attr('width','320');
	$('.right_big .video_preview iframe').attr('height','240');
	
	$('.rasp ul li').click(function(e){
		e.preventDefault();
		$('.rasp ul li').removeClass('active');
		$(this).addClass('active');
		id = $(this).attr('id').replace(/v/,'');
		$('.rasp .vc').hide();
		$('.rasp #vc'+id).show();
	});
	
});


