/* Check form input
 *
 * Usage: <form onSubmit="javascript:return check_form(this);">
 */


function _check_form_mark_field(check) {
	
	check.focus(); // put the prompt in the name field 
	
	// if the browser is Netscape 6 or IE
	if (document.all || document.getElementByID) {
		// change the color of text field
		check.style.background = "#ddddff";
	}
}


function check_form_item_filled(check, text) {
	
	// Blank test is not allowed, that is multiply spaces and tabs.
	re = check.value
	if (check.value.length == 0 || re.match(/^\s+$/)) {

		alert(text);
		
		_check_form_mark_field(check);
		
		// make sure the form is not submitted
		return false;
	}
	
	return true;
}


function check_form_item_email(check, text) {
	
	if (!check_email(check.value) && check.value.length > 0) {
		alert(text);
		
		_check_form_mark_field(check);
		
		// make sure the form is not submitted
		return false;
	}
	
	return true;
}

function check_form_item_only_digits(check, text) {
 
 
 re = check.value
 if (re.match(/^\D+$/)) {
  alert(text);
  
  _check_form_mark_field(check);
  
  // make sure the form is not submitted
  return false;
 }
 
 return true;
}

