function errorCheck(){
        if(error)
		{
			msg += "_______________________________________________\n\n";
			msg += "The form was not submitted, please check\nthat all required fields are completed and valid.\n";
			msg += "_______________________________________________\n\n\n";
			alert(msg + error);
			return false;
		}

        return true;


}

/*
*Following are the functions you can call for form validation
*grep for '- functionname' to jump down to the explanation
*
* - notBlank(obj, fieldname) -
* expects two arguments of object and fieldname
* checks to see if the field is blank
* returns an error if no data is entered into the filed
*
* - isAnyNumber(obj, fieldname) -
* expects two arguments of object and fieldname
* checks that a number has been entered into the field
* returns an error if no number is found
*
* - isNumber(obj, num, fieldname) -
* expects three arguments of object, number of digits required and fieldname
* checks the value is a digit and there are "num" number of digits
* returns an error if it is not a digit with the specified places
*
* - isSelected(obj, fieldname)-
* expects two arguments of object and fieldname
* checks that they have selected any value other than the first one
* returns an error if the first selection is selected
* Special note ---- only use this option if the first value in the drop down is not allowed!!!!
*
* - isExpire(obj, fieldname) -
* expects two arguments of object and fieldname
* checks that the user has entered a date as mm/yy, will automatically replace any "-" with a "/"
* returns error if date is not formatted as mm/yy
*
* - isEmail(obj, fieldname) -
* expects two arguments of object and fieldname
* checks that the user has entered a properly formatted email address in the form of someone@somewhere.somewhere
* Does not check that it is a valid email address, only checks for formatting
* returns an error if the email is not correctly formatted
*
* - numberFormat(obj) -
* expects one argument of the object to format
* replaces any non digits with nothing
* does not error
*
* - phoneFormat(obj) -
* expect one argument of the object to format
* if the length of the field is greater than ten, it deletes any non digit characters and then
* formats the remaining numbers to (...) ...-....
* (could be buggy as I can't see what he does if the remaining numbers are not ten)
* does not error
*
* - isDate(obj, fieldname) -
* expects two arguments of object and fieldname
* replaces any "-" with a "/"
* checks that the remaining value matches the mm/dd/yy format
* returns error if the formatting doesn't match
* (could be improved by checking for a "valid" date, as in the month field being between 01-12 etc)
*
* - id Time(obj, fieldname) -
*  expects two arguments of object and fieldname
* replaces any "-" with a ":"
* replace any non digit characters with nothing
* checks that the remaining value is formatted as hh:mm
* returns error if the formatting doesn't match
*
* - confirmation(msg) -
* expects one argument of the message to populate the confirmation box with
* returns false if they don't agree
*/

function confirmation(msg)
{
	if (confirm(msg))
	{
		return("");
	}else{
		return("We cannot submit this form without your agreement to the confirmation\n");
	}
}

function notBlank(obj, fieldname)
{
	var msg;
	if((obj.value == null) || (!obj.value.match(/\w/)))
	{
		return("Please enter a value for \"" + fieldname + "\".\n");
	}
	return("");
}

function isAnyNumber(obj, fieldname)
{
  var results = obj.value.match(/\d/g);
  if(!results || results.length == 0){
      return("Please enter a number for \"" + fieldname + "\".\n");
  }
  return("");
}

function isNumber(obj, num, fieldname)
{
  var results = obj.value.match(/\d/g);
  if(!results || results.length != num){
      return("Please enter a " + num + " digit number for \"" + fieldname + "\".\n");
  }
  return("");
}

// Only use isSelected if the first value in the list is not a valid option
function isSelected(obj, fieldname)
{
	if(obj.selectedIndex == 0) {
		return("Please make a selection for \"" + fieldname + "\".\n");
  	}

	return("");
}

function isExpire(obj, fieldname){
  obj.value = obj.value.replace(/-/g, "/");
  if(!obj.value.match(/\d{2}\/\d{2}/)){
    return("Please enter a valid date ex: mm/yy for \"" + fieldname + "\".\n");
  }
  return("");
}

function isEmail(obj, fieldname) {
	if (!obj.value.match(/.+\@.+\..../)){
		return("Please enter a properly formatted email addres ex: someone\@somewhere.com for \"" + fieldname + "\".\n");
	}
	return("");

}
function numberFormat(obj) {
  obj.value = obj.value.replace(/\D/g, "");
}

function phoneFormat(obj) {
  var results;

  results = obj.value.match(/\d/g);
  if(results.length >= 10) {
    numberFormat(obj);
  }
  else return;

  while(obj.value.length > 10) {
    obj.value = obj.value.replace(/\d/, "");
  }

  obj.value = obj.value.replace(/(\d{3})(\d{3})(\d{4})/, "($1) $2-$3");
}

function isDate(obj, fieldname){
  obj.value = obj.value.replace(/-/g, "/");
  if(!obj.value.match(/\d{2}\/\d{2}\/\d{2}/)){
    return("Please enter a valid date ex: mm/dd/yy for \"" + fieldname + "\".\n");
  }
  return("");
}

function isTime(obj, fieldname){
  obj.value = obj.value.replace(/-/g, ":");
  if(!obj.value.match(/\d{2}:\d{2}/)){
    return("Please enter a valid time ex: hh:mm for \"" + fieldname + "\".\n");
  }
  return("");
}


function dateFormat(obj){
  var i;
  var date = "";
  var results;

  if(results = obj.value.match(/\d{1,}/g)){
    obj.value = "";
    for(i=0;i<results.length;i++){
      if(results[i].length < 2){
         results[i] = "0" + results[i];
      }
      if(i!=0){obj.value += "/"}
      obj.value += results[i];
   }
  }
}

