$(document).ready(function() {
	

	$("#back_to_top").click(function(){
		$('html, body').animate({
			scrollTop: $("header").offset().top
			}, 500);
	});
	
	$('a.anchor').remove().prependTo('body');
	var myFile = document.location.toString();
	if (myFile.match('#comments')) { 
	 	scrollToComments();
	}
	
	$("#view_comments_link").click(function() {
		scrollToComments();
	});
	
	$("#new_comment_form").validate();
	$("#contact_form").validate();
	
	$(".panel").hide();
	$(".panel").fadeIn("fast");	
	
	$("#new_comment_form").hide();
	$('#comment_link').click( function() {
				
			$('#comment_link').removeClass("a");
			
			$("#new_comment_form").slideDown();
			$('#comment_link').html("Add your comment");

			$('html, body').animate({
				scrollTop: $("#new_comment_form").offset().top
				}, 1000);	
	});
	
});

function scrollToComments() {
	$('html, body').animate({
		scrollTop: $("#comments").offset().top
		}, 1000);
}