// JavaScript Document

//To validate the required fields of the form
function chkRequired()
{
	if (document.frmStory.spm_check.value!='')
	{
		alert("Invalid character in one of the field")
		document.frmStory.spm_check.focus();
		return false;
	}
	if(isBlank(document.frmStory.title.value, "Please choose the title."))
	{
		document.frmStory.title.focus();
		return false;
	}
	if(isBlank(document.frmStory.firstname.value, "Please enter your first name."))
	{
		document.frmStory.firstname.focus();
		return false;
	}
	else if((/<[^>]+>/.test(document.frmStory.firstname.value)) || (/(\[).*(\]).*(\[\/)*(\])/.test(document.frmStory.firstname.value)))
	{
		alert("Please enter valid first name.");
		document.frmStory.firstname.focus();
		return false;	
	}
	if(isBlank(document.frmStory.lastname.value, "Please enter your last name."))
	{
		document.frmStory.lastname.focus();
		return false;
	}
	else if((/<[^>]+>/.test(document.frmStory.lastname.value)) || (/(\[).*(\]).*(\[\/)*(\])/.test(document.frmStory.lastname.value)))
	{
		alert("Please enter valid last name.");
		document.frmStory.lastname.focus();
		return false;	
	}
	if((document.frmStory.town.value != "") && ( (/<[^>]+>/.test(document.frmStory.town.value)) || (/(\[).*(\]).*(\[\/)*(\])/.test(document.frmStory.town.value)) ) )
	{
		alert("Please enter valid Town or City.");
		document.frmStory.town.focus();
		return false;	
	}
	if((document.frmStory.country.value != "") && ( (/<[^>]+>/.test(document.frmStory.country.value)) || (/(\[).*(\]).*(\[\/)*(\])/.test(document.frmStory.country.value)) ) )
	{
		alert("Please enter valid Country.");
		document.frmStory.country.focus();
		return false;	
	}
	if((document.frmStory.tel.value != "") && (validTelephone(document.frmStory.tel.value) == false) )
	{
		alert("Please enter valid Phone No.");
		document.frmStory.tel.focus();
		return false;	
	}
	if(isBlank(document.frmStory.email.value, "Please enter email address."))
	{
		document.frmStory.email.focus();
		return false;
	}
	else if(checkemail(document.frmStory.email.value) == false)
	{
		document.frmStory.email.focus();
		return false;
	}

	if(isBlank(document.frmStory.story.value, "Please enter your story."))
	{
		document.frmStory.story.focus();
		return false;
	}
	else if((/<[^>]+>/.test(document.frmStory.story.value)) || (/(\[).*(\]).*(\[\/)*(\])/.test(document.frmStory.story.value)))
	{
		alert("Please enter valid story.");
		document.frmStory.story.focus();
		return false;
	}
	else if(containBadWord(document.frmStory.story.value))
	{
		alert("Sorry - you can't send story containing offensive language.");
		document.frmStory.story.focus();
		return false;
	}
	return true;
}