var fname = new Array(
  "A","B","C","D",
	"E","F","G","H",
	"I","J","K","L");
var ftype = new Array(
  "check","check","check","check",
  "check","check","check","check",
  "check","check","check","check"
	);
var msg_field = new Array(
	"","","","","","","","","","","","",""
	);

function otherCheck(which) {
  return((which.other.checked==true) && (which.message.value!=""))
}

function validate(which) {
	var pass=true;
	var checked=false;
	var checkbox_exist=false;
	var msg_fields = "";
	var nextobj = null;
	if (document.images) {
		for (j=0;j<fname.length;j++) {
			for (i=0;i<which.length;i++) {
				var t=which.elements[i];
				if (t.name==fname[j]) {
					if ((ftype[j]=="string") && (t.value=="")) {
					  msg_fields = msg_fields + "\n" + msg_field[j];
						if (pass) nextobj = which.elements[i];
						pass=false;
					} else if ((ftype[j]=="email") && (!validEmail(t.value))) {
					  msg_fields = msg_fields + "\n" + msg_field[j];
						if (pass) nextobj = which.elements[i];
						pass=false;
					} else if (ftype[j]=="check") {
					  if (!checkbox_exist && pass) nextobj = which.elements[i];
					  checkbox_exist=true;
					  if (t.checked)
  					  checked=true;
					}
				}
			}
		}
	}
	if ((!pass) || ((checkbox_exist) && (!checked))) {
	  if ((checkbox_exist) && (!checked))
  	  msg_fields = msg_fields + "\n" + msg_check;
		alert(msg_validation + "\n" + msg_fields);
 		nextobj.focus();
		return false;
	} else
    return true;
}

function validEmail(email) {
	return ((email.indexOf("@") == -1) ||
			(email.charAt(0) == ".") ||
			(email.charAt(0) == "@") ||
			(email.length < 6) ||
			(email.indexOf(".") == -1) ||
			(email.charAt(email.indexOf("@")+1) == ".") ||
			(email.charAt(email.indexOf("@")-1) == "."))
	? false : true;
}

function validRef(ref) {
	if ((ref.value.length==19) && (ref.value.charAt(4)=='-') && (ref.value.charAt(9)=='-') && (ref.value.charAt(14)=='-')) {
		return true;
	} else {
		alert(invalidRef);
		ref.focus();
		return false;
	}
}

function validInvoice(fm) {
	if ((fm.item_number.value.length==0) ||
			(fm.invoice.value.length==0) ||
			(fm.custom.value.length==0)) {
		return false;
	} else {
		return true;
	}
}ü
