$().ready(function() {			
	toolStart();
    
    $('.indent').each(function(i){
        if($(this).height()>200) {
            $(this).after('<div name="indent'+i+'" class="details hover pointer">Прочитать остальное</div>');
            $(this).attr("id", "indent"+i).css("overflow", "hidden").height(180).addClass('short_indent');
            
        }
    });
    var ind;
    $('.details').click(function(){
        ind = $('#'+$(this).attr('name'));
        if($(this).html()=="Скрыть") {
            $(this).html("Прочитать остальное");
            $(ind).height(180).addClass('short_indent');
        } else {
            $(ind).css("height", "100%").removeClass('short_indent');
            $(this).html('Скрыть');
        }
    });
});
var w, h, tw, th, content, tooltip;
function toolStart() {
	$('.tool').hover(toolOn, function(){
		tooltip.fadeOut(400);
	});
	$('.tool').mousemove(function(e){
		w = $(window).width();
		h = $(window).height();		
		if(w<e.clientX+tw+40) l = -tw-10;
		else l = 10;
		if(h<e.clientY+th+35) l2 = -th-25;
		else l2 = 25;
		tooltip.css({left:e.pageX+l, top:e.pageY+l2});
	});
}

function toolOn() {
	tw = $('.tooltip', this).width();
	th = $('.tooltip', this).height();
	tooltip = $('.tooltip', this);
	if(tooltip.is(':hidden')) tooltip.fadeIn(400);
}
