function mostPopularComments() {

	$("#mostPopularPicks").css("display","none");
	$("#mostPopularComments").css("display","block");
	$("#mostPopularPicksLink").removeClass("active");
	$("#mostPopularCommentsLink").addClass("active");
	return void(0);

}

function mostPopularPicks() {

	$("#mostPopularComments").css("display","none");		
	$("#mostPopularPicks").css("display","block");
	$("#mostPopularCommentsLink").removeClass("active");
	$("#mostPopularPicksLink").addClass("active");
	return void(0);
}

function pageClick(pageNo,pageUrl) {

	var myDate=new Date();

	$("#commentblock").load("/getLatestBlogComments.do?postId="+postId+"&page="+pageNo+"&paginationUrl="+pageUrl + "&dt="+escape(myDate));

	return false;
}


var COMMENT_LENGTH_LIMIT = 500;
function textLimit(field,cntfield,maxlimit) {
	var matches = field.value.match(/\n/g);
	var count = 0;
	
	if (matches != null) {
		count = matches.length;
	}
	
	var textLength = field.value.length + count;

	if (textLength > maxlimit)
		field.value = field.value.substring(0, maxlimit - count);
	else
		cntfield.value = maxlimit - textLength;
}

function clearFormData() {
	document.commentForm.authorName.value = '';
	document.commentForm.email.value = '';
	document.commentForm.subject.value = '';
	document.commentForm.commentBody.value = '';
	document.commentForm.authorName.focus();
	document.commentForm.remainingChars.value = COMMENT_LENGTH_LIMIT;
}

function createCommentToggle() {

	$('#formComment').click(function(){
		if($('[name="commentBody"]').val() == "") {
			alert("Please enter your comment");
			return false;
		}
		if($('[name="authorName"]').val() == "") {
			alert("Please enter your name");
			return false;
		}
	});
	$('#formPost').click(function(){
		if($('[name="postBody"]').val() == "") {
			alert("Please enter your comment");
			return false;
		}
		if($('[name="authorName"]').val() == "") {
			alert("Please enter your name");
			return false;
		}
	});

	$("div.trigger").toggle(function(){
		$(this).addClass("active"); 
		}, function () {
		$(this).removeClass("active");
	});

	$("div.trigger").click(function(){
		$(this).next(".commentBlock").slideToggle("slow,");
	});

}