
// This variable is introduced to identify if the form has already been submitted for some action
// and to prevent any other action on the form till the page is refreshed.
var isFormSubmitted = false;

function ValidateForm()
{
	if(isFormSubmitted)
	{
		return false;
	}
	
	//Empty Check for Sender Name
	if(trim(document.forms[0].SenderName.value)== "")
	{
		alert("Your First Name cannot be empty.");
		document.forms[0].SenderName.focus();
		return false;
	}
	//Empty Check for Sender Email ID
	if(trim(document.forms[0].SenderEmailID.value)== "")
	{
		alert("Your E-mail Address cannot be empty.");
		document.forms[0].SenderEmailID.focus();
		return false;
	}
	//Validate Check for Sender Email ID
	 if(trim(document.forms[0].SenderEmailID.value).length > 60 )
	{
		alert("Your Email address should not be greater than 60 characters.");
		document.forms[0].SenderEmailID.focus();
		return false;
	}		
	if(!CheckEmailFormat(trim(document.forms[0].SenderEmailID.value)))
	{
		alert("Your E-mail Address is invalid. Please re-enter the E-mail Address.");
		document.forms[0].SenderEmailID.focus();
		return false;
	}
	//Empty Check for Recepient Name
	if(trim(document.forms[0].RecepientName.value)== "")
	{
		alert("Your Friend or Relative Name cannot be empty.");
		document.forms[0].RecepientName.focus();
		return false;	
	}
	//Empty Check for Recepient Email ID
	if(trim(document.forms[0].RecepientEmailID.value)== "")
	{
		alert("Your Friend or Relative E-mail Address cannot be empty.");
		document.forms[0].RecepientEmailID.focus();
		return false;
	}
	//Validate Check for Recepient Email ID
	 if(trim(document.forms[0].RecepientEmailID.value).length > 60 )
	{
		alert("Recepient Email address should not be greater than 60 characters.");
		document.forms[0].SenderEmailID.focus();
		return false;
	}		
	if(!CheckEmailFormat(trim(document.forms[0].RecepientEmailID.value)))
	{
		alert("Your Friend or Relative E-mail Address is invalid. Please re-enter the E-mail Address.");
		document.forms[0].RecepientEmailID.focus();
		return false;
	}
	//Function to check for Special Characters
	if( !checkSpecialCharacters() )
		return false;
		
	isFormSubmitted = true;	
	return true;
}