// JavaScript Document
function fn_validateFieldIsEmpty(formDOMObj, fieldname, identifier){
	/* this function validates a form field, basically it checks to 
	see if a parameter sent to it is empty and if it is, return false */
	
	
	if(formDOMObj[fieldname].value.length < 1){
		
		
		alert('Please enter your ');
		return false;
	}
	return true;
}

function fn_validateFieldsMatch(formDOMObj, fieldname1, fieldname2, identifier){
	/* this function compares two strings sent as parameters.  These strings represent 
	two fields in a form, eg. password and password confirm fields.
	If the fields do not match, return false
	*/
	if(formDOMObj[fieldname1].value != formDOMObj[fieldname2].value){
		formDOMObj.formAlert.value=identifier + ' fields do not match';
		return false;
	}
	return true;
}

function onSubmitForm(formDOMObj){
	
	
	//write validation for the form 'ContactForm'
	if(formDOMObj.name =='ContactForm'){
		
 
		 /*this condidtional statement uses "or" arguments.  If a is false, or b is false or c is false, return false
		 If any of the validation functions called evaluate to false, the form will not be submitted. */
		 if(fn_validateFieldIsEmpty(formDOMObj, 'name', 'name') == false
			|| fn_validateFieldIsEmpty(formDOMObj, 'email', 'email address') == false)
		 	return false;
		
		//otherwise return true
		return true;
	}
	
	
			

}
