//---------------------------------- Function to validate Contact us form ---------------------------------------

function validateContactUsForm()           // function to validate contact us form
{
	invalidFlag=false;
	var fnL = window.document.ContactUs1.FN.value.length;

	var captchaL = window.document.ContactUs1.captcha.value.length;

	var emL = window.document.ContactUs1.EM.value.length;
	
	var questL = window.document.ContactUs1.quest.value.length;

	if((fnL<2) && (invalidFlag==false))
	{
		alert("Please enter your Full Name");
		invalidFlag=true;
		window.document.ContactUs1.FN.focus();
	}
	
	
//----------- Email validation ------------

	if((emL<6) && (invalidFlag==false))
	{
		alert("Please enter your Email");
		invalidFlag=true;
		window.document.ContactUs1.EM.focus();
	}

	var emailText=window.document.ContactUs1.EM.value;

	var val1=emailText.indexOf("@");              // for existence of @ in email address

	var val2=emailText.indexOf(".");                  // for existence of . in email address

	var val3=emailText.indexOf(" ");                  // for existence of <space> in email address


	if(((val1==-1) || (val2==-1) || (val3!=-1)) && invalidFlag==false)                    // -1 will be returned if @ or . is missing from email address
	{
		alert("Please enter Correct Email Address");
		invalidFlag=true;
		window.document.ContactUs1.EM.focus();
	}

//---------------- Email Validation Ends----------------------




	if((questL<5) && (invalidFlag==false))
	{
		alert("Please enter your question");
		invalidFlag=true;
		window.document.ContactUs1.quest.focus();
	}



	
	
	if((captchaL<5) && (invalidFlag==false))
	{
		alert("Please enter 5 digit CODE");
		invalidFlag=true;
		window.document.ContactUs1.captcha.focus();
	}



	// return either true or false to form tag which will determine wheather to submit form or not
	if(invalidFlag==false)
	{
		var referenceToSendingImage=document.getElementById('sending1');                    // returns reference to passed id sending please wait image as per w3c standards
		referenceToSendingImage.style.visibility="visible";

		return true;            // all entries entered in correct format i.e. form passes client side scripting
	}
	else
	{
		return false;            // one or more entries incorrect. DO NOT submit form
	}
	
	
}          // ------------ function closed


