// JavaScript Document
function validateForm( frm, textFields, emailField ) {
	//var error_array = [];
	var error_count = 0;
	var msg = "Please provide the required fields.\n\n";
	
	for(field in textFields) {
		if(WithoutContent( frm[field].value )) {
			//error_array[error_count] = 'Please provide your full name.';
			error_count++;
		}
	}
	
	if(!check_email( frm[emailField].value )) {
		//error_array[error_count] = 'The email address provided has an error, or is not in the form of email@address.com.';
		error_count++;
		msg += "The email address provided is not in the form of email@address.com.\n\n";
	}
	
	if(error_count < 1) {
		return true;
	} else {
		/*
		for(i=0;i<error_count;i++) {
			msg += error_array[i] + "\n\n";
		}
		*/
		alert(msg);
		//error_array = [];
		error_count = 0;
		return false;
	}
	
}
function WithoutContent(ss) {
	if(ss.length > 0) {
		return false;
	}
	return true;
}

//email validation
function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
			return (false);
		}	
	} 

	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);		
		} 

	}

}
