// home/reward_profile_data.cfm
function checkContactForm(f) {
	
	var i;
	var currfieldval = true;
	var formvalid = true;
	var focusfield = "";
	var tempFormName;

	var errormsg = "The following errors were found when attempting to submit the form:\n\n";

	// Loop through entire form of input fields.
	for (i = 0; i < f.elements.length; i++) {
		
		currfield = f.elements[i].name;
		currfield = currfield.toLowerCase();
		
		// If input type is a "text", "textarea" or "password", do this test.
		if ((f.elements[i].type == "text" ) ||  
			//(f.elements[i].type == "password" ) ||
			(f.elements[i].type == "textarea" ) ) {
		
			//currfieldval2 = checktest(f.elements[i].value);
			
			
			if ((currfield.indexOf("firstname") != -1) || 
				(currfield.indexOf("lastname") != -1) ||
				(currfield.indexOf("companyname") != -1) ||
				(currfield.indexOf("comments") != -1) ) {
				
				currfieldval = checkfield(f.elements[i]);
				//alert( currfield + ": " +  currfieldval);
				
			}
			
			else if (currfield.indexOf("email") != -1) {
			
				currfieldval = checkemail(f.elements[i]);

			}
			
			
			else {
				currfieldval = true;
			}
			
			if ( !currfieldval ) {
				formvalid = false;
				focusfield = f.elements[i];
				tempFormName = f.elements[i].name;
				errormsg = errormsg + '  - ' + tempFormName.toUpperCase() + ' is missing or invalid. \n';
			}
		}
			
		if ( (f.elements[i].type == "select-one")) {
		
				currfield = f.elements[i].name;
				currfield = currfield.toLowerCase();
				
				if (( currfield.indexOf("subject") != -1) ||
					( currfield.indexOf("countrystate") != -1) ){
					currfieldval = checkoption(f.elements[i]); 
				}
				else{
					currfieldval = true
					}
				

				if ( !currfieldval ) {
					formvalid = false;
					focusfield = f.elements[i];
					tempFormName = f.elements[i].name;
					errormsg = errormsg + '  - ' + tempFormName.toUpperCase() + ' is missing or invalid. \n';
				}
			}

	}
	
	if ( formvalid ) {
		return true; 		// Should return true
	} else {
		//errormsg = errormsg + '  \n  - text fields special characters:  \'.#()-_@,:&';
		//errormsg = errormsg + '  \n  - numeric fields do not permit special characters \n';
		alert(errormsg);
		focusfield.focus();
		return false;
	}
}


function test(){

	alert("test");

}