$(function(){	function logoupdate(){
			var windoww=$("#container").width();
			var logo=$("#logo");
			var logoimg=$("#logo img").get(0);
			if (windoww>1100) { 
				// logo.css("top","27px").fadeIn(50);
				logoimg.src="/i/f2pro_logo_new.gif";
				} else {
				// logo.css("top","8px").fadeIn(50);
				logoimg.src="/i/f2pro_logo_new_notitle.gif";
				}
		}
		
	logoupdate();
			div_images=$("div.images");
	if (div_images.length) {		var offset = $("div.images").offset();
		$("div.images div:first").show();
		$("div.images div").slice(1).fadeTo(1,0);
		$("#arrow_right a").click(function(){			nextImg();
			return false;
			})
		$("#arrow_left a").click(function(){
			prevImg();
			return false;
			})
			
		img_max_h=10;
		$("img", div_images).each(function(){
			if (this.height>img_max_h) img_max_h=this.height;
		});
		if (img_max_h==10) img_max_h=500;
		if (div_images.hasClass("videos")) {			$("div.single", div_images).each(function(){				var this_height=$(this).height();
    			if (this_height>img_max_h) img_max_h=this_height;
    		});
		    }
		if (img_max_h<570) {			img_max_h=img_max_h+10;			div_images.css("height",img_max_h+"px");
			$("div#arrows").css("height",img_max_h+"px");
			$("div#arrows div div").css("marginTop",((img_max_h/2)-25)+"px");
			}
		if ($("div", div_images).length>1) {
			$("div#arrows").css("top",offset.top+"px").show();
			}
		}
		
		window.onresize=logoupdate;
		var readmore = "Читать далее"
		
		$(".hide").each(function(){		    var div = $(this);		    div.before(" <a href='#' class='readmore' onclick='return false;'>" + ( div.attr("title") || readmore ) + "</a>");
	    })
	    
		$("a.readmore").click(function(){			$(this).next().show();
			$(this).hide();
			});
		
})

function nextImg(){	var current=$("div.images div:visible");
	if (current.length) {		var next=current.next("div");
		if (next.length==0) {			next=$("div.images div:first");
		}
		current.fadeOut(200, function(){			next.show().fadeTo(200,1);
			});
	}
}

function prevImg(){
	var current=$("div.images div:visible");
	if (current.length) {
		var prev=current.prev("div");
		if (prev.length==0) {
			prev=$("div.images div:last");
		}
		current.fadeOut(200, function(){
			prev.show().fadeTo(200,1);
			});
	}
}
