// JS for Comments

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;
}

jQuery(document).ready(function() {
  jQuery(window).load(function() {
		
				$('#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;
					}
				});
				
			});	
		});


window.onload=function(){
$(document).ready(function(){
		
	$("div.trigger").toggle(function(){
		$(this).addClass("active"); 
		}, function () {
		$(this).removeClass("active");
	});
	
	$("div.trigger").click(function(){
		$(this).next(".commentBlock").slideToggle("slow,");
	});

});
}


