$(document).ready(function(){
$(".post h2").before('
');
$(".post h2").css("margin-top","-10px");
$(".post h2").each(function(){
$(this).html($(this).children().html());
});
var content;
$(".type div").click(function(){
$(this).siblings().removeClass("active");
$(this).addClass("active");
content = $(this).parents(".post").find(".content");
});
$(".short").click(function(){
$(content).animate({opacity:0},function(){
$.get('',{'p':$(content).attr("id").substring(1),'type':'short'},function(short){
$(content).empty().html(short);
$(content).animate({opacity:1});
});
});
});
var offset;
$(".long").click(function(){
$(content).animate({opacity:0},function(){
$.get('',{'p':$(content).attr("id").substring(1),'type':'long'},function(long){
$(content).empty().html(long);
if ( $(content).find(".scroll").height() > $(window).height()-150 ) {
$(content).find(".scroll").height($(window).height()-150).css("overflow","auto");
}
$(content).animate({opacity:1},function(){
offset = $(content).offset().top+$(content).height();
if ( offset > $(window).scrollTop()+$(window).height() ) $("body,html").animate({scrollTop:offset+50-$(window).height()},2000);
});
});
});
});
$(".comments").click(function(){
$(content).animate({opacity:0},function(){
$.get('',{'p':$(content).attr("id").substring(1),'type':'comments'},function(comments){
$(content).empty().html(comments);
if ( $(content).find(".scroll").height()+$(content).find(".padding").height() > $(window).height()-150 ) {
$(content).find(".scroll").height($(window).height()-150-$(content).find(".padding").height()).css("overflow","auto");
}
$(content).animate({opacity:1},function(){
offset = $(content).offset().top+$(content).height();
if ( offset > $(window).scrollTop()+$(window).height() ) $("body,html").animate({scrollTop:offset+50-$(window).height()},2000);
});
});
});
});
});