﻿/*$(function() {
	$("#comments-inside").hide();
	$("#comment-invite a").click(function() {
		if($("#comments-inside").hasClass('active')) {
			$("#comments-inside").slideUp('slow');
			$("#comments-inside").removeClass('active');
			$("#comment-invite a").text("Join the disscussion!");
		} else {
			$("#comments-inside").slideDown('slow');
			$("#comments-inside").addClass('active');
			$("#comment-invite a").text("Close discussion");
		}
		//$("#comments-inside").slideDown('slow');
		return false
	});
});*/

$(document).ready(function () {
	var commHeight = $("#comments").height();
	if(!window.location.hash) {
		$("#comments").hide();
	} else {
		$("#comment-panel").css("height", commHeight);
		$("#comment-invite").hide();
	}
	$("#comment-invite a").click(function() {
		$("#comment-invite").fadeOut(200, function() {
			$("#comment-panel").animate({ height: commHeight }, 400, function() {
				$("#comments").fadeIn(500);
			});
		});
		return false;
	});
	$("#close-comments").click(function() {
		$("#comments").fadeOut(500, function() {
			$("#comment-panel").animate({ height: "84px" }, 400, function() {
				$("#comment-invite").fadeIn(500);
			});
		});
		return false;
	});
	
	$("#toc .excerpt").hide();
	$("#toc li .item").click(function() {
		$(this).css('outline','none'); 
		if($(this).parent().hasClass("current")) {
			$(this).siblings(".excerpt").slideUp('350', function() {
				$(this).parent().removeClass('current');
			});
		} else {
			$("#toc li.current .excerpt").slideUp('350',function() {
				$(this).parent().removeClass('current');
			});
			$(this).siblings(".excerpt").slideToggle('350',function() {
				$(this).parent().toggleClass('current');
			});
		}
		return false;
	});
});
