
/*
------------------------------
Created by: Anupam Ojha
Created date: 13 Oct 2008
File description: Validation of Comment Post
Special instructions-notes: Javascript Validation
Tables used: none
Stored procedures: none
Triggers used: none
--------------------------------
*/

function Validate(theForm)
{
	//alert('tasdf'); return false;
	if (isWhitespace(theForm.name.value))
	{
		alert("Please enter your name.");
		theForm.name.focus();
		return false;
	}
	else if(!isCharsInBag(theForm.name.value, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' "))
	{
		alert("Your name contains invalid characters.");
		theForm.name.focus();
		return false;
	}
	var email_1 = trimAll(theForm.email.value);
	if (isWhitespace(email_1))
	{		
		alert("Please enter your e-mail address.");
		theForm.email.focus();
		return false;
	}		
	else if(!isEmail(email_1))
	{
	   alert("Please enter your e-mail address in the correct format.");
	   theForm.email.focus();
	   return false;	   
	}	
	else if(!isCharsInBag(email_1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@._-"))
	{
		alert("Your e-mail address contains invalid characters.");
	    theForm.email.focus();
		return false;
	}	
	if (isWhitespace(theForm.comments.value))
	{
		alert("Please enter your comments.");
		theForm.comments.focus();
		return false;
	}
	if (isWhitespace(theForm.name2.value))
	{
		alert("Please enter characters in the image below.");
		theForm.name2.focus();
		return false;
	}
	return true;
}

//Post the form
function postYourComment(formName){
	if(!Validate(document.blog_comment_form)){
		return false;	
	}
	document.getElementById('secured').value='secured';
	//alert(document.getElementById('secured').value);
	document.blog_comment_form.submit();
	return true;
}