// Updated the file for a word validation and for the check box validation  specefic to the page.

function FormSubmit(btn) {
	var formObj = btn.form

	with (formObj)
	{
		if (isEmpty(fname, "", fname_val.value)) return;
		if (charCheck(fname, langMsg_val.value)) return;

		if (isEmpty(lname, "", lname_val.value)) return;
        if (charCheck(lname, langMsg_val.value)) return;

		if (isEmpty(email, "", email_val.value)) return;
		if (notEmail(email, "", emailnotvalid_val.value)) return;

		if (typeof emailconfirm != "undefined" && typeof emailconfirm_req != "undefined") {
			if (email.value != emailconfirm.value) {
				alert(emailreconfirm_val.value)
				emailconfirm.focus() 
				return
			}
		}

		

		if (CompAnswer.value == "")  {
			alert("Enter your answer.");
			CompAnswer.focus();
			return;
		}

		if (count_words(CompAnswer.value,50 ) == false) 
		{	
			alert("Please enter only 50 words")
			CompAnswer.focus();
			return;
		}
	}
	


	
	with (formObj)
	{
		if (typeof iaccept != "undefined") {
			if (!iaccept.checked) {
				alert("You have not indicated your acceptance of the Hotelclub Membership Terms and Conditions. Please Click the checkbox and then Proceed.");
				iaccept.focus();
				return;
			}
		}
		if(typeof compTNC != "undefined") {
			if(!compTNC.checked) {
				alert("You have not indicated your acceptance of the awardscomp08 Terms and Conditions. Please Click the checkbox and then Proceed.");
				compTNC.focus();
				return;
				}
			}
			
			
		
	}
	 
	//Validation to count the number of words in the Answer text area not to exceed 50 WORDS
	//( accepts the text entered and the number of words to be validated  ) 
	function count_words(text,number)
		{   
		    // variable to access the text entered in the text area
			var inputText = text;
			//array to hold the split words
			var wordCount = new Array();
			
			//split the words depending on the spaces
			wordCount = inputText.split(" ");
			
			//variable to hold the number of actual words entered excluding the spaces
			actualWordCount = 0;
			
			//Loop variable decleration
	        var i; 
			for ( i = 0; i < wordCount.length; i++ )
				{
				//Condition to check for the spaces and remove from the actual count
					if( wordCount[i] != "" )
						{
							actualWordCount ++;		
						}
				}    
	    
			if ( actualWordCount > number)
				{
					return false;    
				}
		}	
		
	
	

	formObj.submit()
}

