function form_submit(ie_offset,formname,formlayer) {

	formloc = 'this.document.';

	if (formlayer != '' && ns4) {

		formloc = formloc + formlayer + '.document.' + formname;

	} else {

		formloc = formloc + formname;

	}

	anchorloc = 'this.';

	if (formlayer != '' && ns4) {

		anchorloc =  anchorloc + 'document.' + formlayer + '.document';

	} else {

		anchorloc =  anchorloc + 'document';

	}

	errorflag = 0;

	element = 0;

	anchor = 0;

	eval('anchor_offset = parseInt('+formloc+'.contentanchor.value)');

	if (ns6 && anchor_offset != 0) {

		anchor_offset++;

	}

	if (ie4) {

		anchor_offset = anchor_offset + ie_offset;

	}

	//variable needed to buffer selected item texts in pulldowns in case the next text field is an 'OTHER' field

	s_buffer = '';

	

//alert(eval(anchorloc+'.anchors.length'));

	

	//loop over all the input fields in contentform

	while (eval(formloc+'.elements[element].name!="contentanchor"')) { 

		//grab a new job and parse it

		eval('job = '+anchorloc+'.anchors[anchor+anchor_offset].name');

		if (job != 'NOCHECK' && job.indexOf(',') != -1 ) {

			i = job.indexOf(',');

			//instruction

			job_inst = job.substr(0,i);

			job = job.substring(i+1,job.length);

			i = job.indexOf(',');

			//parameter (this is usually 0, only used for MINCHAR)

			job_para = job.substr(0,i);

			//error text add-on (this will be added to the error message in place of the 'XXX')

			job_text = job.substring(i+1,job.length);

			//save the parameter to verify in 'input' (makes the script look nicer)

			//also, we have to check if we are currently looking at the right input field (ATG creates weird hidden ones)

			while (eval(formloc+'.elements[element].type == "hidden"')) {

				element++;

			}

			//ok, the hidden fields are now behind us. now lets find out what kind of form element we are dealing with.

			//if the instruction is SELECTED, we are dealing with a selector...

			if (job_inst.indexOf('SELECTED') != -1) {

				eval('ix = '+formloc+'.elements[element].selectedIndex');

				// ...so lets see which option is selected right now

				eval('input = '+formloc+'.elements[element].options[ix].value');

				// the text of the selected option is saved in case we need it for a following 'OTHER' field.

				// in that case this field has to be checked if the option 'Other' (we check for the text of the option!!!) was actually selected.

				eval('s_buffer = '+formloc+'.elements[element].options[ix].text');

			} else {

				// ...otherwise, it must be a text input field

				eval('input = '+formloc+'.elements[element].value');

				//if instruction is SAVE, then keep the data in the buffer for comparison

				if (job_inst.indexOf('SAVE') != -1) {

					s_buffer = input;

				}

			}

//alert(input+' x '+job_inst+' x '+element)

			//now lets call the function to actually perform the check required

			if (job_inst.indexOf('NOTEMPTY') != -1)

				errorflag = veri_notempty(input,job_text);

			if (job_inst.indexOf('NOSPECIAL') != -1 && errorflag == 0)

				errorflag = veri_nospecial(input,job_text);

			if (job_inst.indexOf('DIGIT') != -1 && errorflag == 0)

				errorflag = veri_digit(input,job_text);

			if (job_inst.indexOf('NOTZERO') != -1 && errorflag == 0)

				errorflag = veri_notzero(input,job_text);

			if (job_inst.indexOf('MONEY') != -1 && errorflag == 0)

				errorflag = veri_money(input,element,job_text);

			if (job_inst.indexOf('MINCHAR') != -1 && errorflag == 0)

				errorflag = veri_minchar(input,job_para,job_text);

			if (job_inst.indexOf('MINCHARNOREQ') != -1 && errorflag == 0)

				errorflag = veri_mincharnoreq(input,job_para,job_text);

			if (job_inst.indexOf('MAXCHAR') != -1 && errorflag == 0)

				errorflag = veri_maxchar(input,job_para,job_text);

			if (job_inst.indexOf('MULTI_EMAILS') != -1 && errorflag == 0)

			    errorflag = veri_multi_emails(input,job_text);

			else if (job_inst.indexOf('EMAIL') != -1 && errorflag == 0)

				errorflag = veri_email(input,job_text);

			if (job_inst.indexOf('ZIPCODE') != -1 && errorflag == 0)

				errorflag = veri_zipcode(input,job_text);

			if (job_inst.indexOf('SELECTED') != -1 && errorflag == 0)

				errorflag = veri_selected(input,job_text);

			if (job_inst.indexOf('OTHER') != -1 && errorflag == 0)

				errorflag = veri_other(input,s_buffer,job_text);

			if (job_inst.indexOf('COMPARESAME') != -1 && errorflag == 0)

				errorflag = veri_comparesame(input,s_buffer,job_text);

		}

		//we had an error this time around, let's quit

		if (errorflag != 0) {

			//but first, let's highlight the field that created the error - if it is not a selector (IE5 Mac doesn't like that)

			if (job_inst.indexOf('SELECTED') == -1) {

				alert('Input Error: '+(eval(formloc+'.elements[element].name')));

				eval(formloc+'.elements[element].focus()');

				eval(formloc+'.elements[element].select()');

			}

			//done, let's go

			break;

		}

		if (job != '' && job.indexOf(',') != -1) { //ie sometimes has empty anchors in the list, don't advance through elements

			element++;

		}

		if (job == 'NOCHECK') {

			element++;

		}

		//if there are multiple NOCHECK fields with hidden fields between them (ATG creates weird hidden ones),

		//we have to skip the hidden fields to keep in sync with the anchor instructions

		while (eval(formloc+'.elements[element].type == "hidden"  &&  '+formloc+'.elements[element].name != "contentanchor"')) {

			element++;

		}

		anchor++;

	}

	//if there are no errors, submit the form

	if (errorflag == 0)

		eval(formloc+'.submit()');

}



//our own isNaN() function (that's isNotaNumber) - the built-in one (isNaN) doesn't work the same on all browsers

//returns 1 for no number and 0 for number

function isnoNumber(whatisit) {

	itsnot=0;

	for (i=0;i<whatisit.length;i++) {

		j = whatisit.charCodeAt(i);

		if (!(j>=48 && j<=57))

			itsnot=1;

	}

	return itsnot;

}



//check if the input field was empty

function veri_notempty (input,error_text) {

	if (input=='') {

		error_show(6,error_text);

		return 1;

	} else {

		return 0;

	}

}



//check if the input field contains special characters (outside a-z,A-Z,0-9,_)

function veri_nospecial (input,error_text) {

	k=0;

	for (i=0;i<input.length;i++) {

		j = input.charCodeAt(i);

		if (!((j>=65 && j<=90) || (j>=97 && j<=122) || (j>=48 && j<=57) || j==95))

			k=1;

	}

	if (k!=0) {

		error_show(7,error_text);

		return 1;

	} else {

		return 0;

	}

}



//check if the input field contains digits only

function veri_digit (input,error_text) {

	if (isnoNumber(input) == 1) {

		error_show(1,error_text);

		return 1;

	} else {

		return 0;

	}

}



//check if the input field is not equal 0

function veri_notzero (input,error_text) {

	if (input == 0) {

		error_show(8,error_text);

		return 1;

	} else {

		return 0;

	}

}



//check if the input field is a correct money field (contains digits only, leading $ will be stripped out if necessary)

function veri_money (input,field_number,error_text) {

	if (input.charAt(0)=='$') {

		//There was actually a $ sign in the field. We strip it out and save the value again in the input field.

		input = input.substr(1,input.length-1);

		eval(formloc+'.elements[field_number].value = input');

	}

	if (isnoNumber(input) == 1) {

		error_show(1,error_text);

		return 1;

	} else {

		return 0;

	}

}



//check if the input field contains min. numb of chars

function veri_minchar (input,numb,error_text) {

	if (input.length < numb) {

		error_show(9,error_text);	//error message is specific for 6 chars!

		return 1;

	} else {

		return 0;

	}

}



//check if the input field contains min. numb of chars

function veri_mincharnoreq (input,numb,error_text) {

	if (input.length > 0 && input.length < numb) {

		error_show(9,error_text);	//error message is specific for 6 chars!

		return 1;

	} else {

		return 0;

	}

}



//check if the input field contains max. numb of chars

function veri_maxchar (input,numb,error_text) {

	if (input.length > numb) {

		error_show(10,error_text);

		return 1;

	} else {

		return 0;

	}

}



// perform email validation for coma delimited multiple addresses

function veri_multi_emails(input,error_text){

  	  var addresses = input.split(/,\s?/);

	  var valid = 0;



	  for(i=0;i<addresses.length;i++){

		if(!addresses[i].match(/^\w+([.-]\w+)*@\w+([.-]\w+)+$/)){

		  error_text += ": "+(i+1);

		  error_show(3,error_text);

		  valid = 1;

		  break;

		}

	  }

	  return valid;

}		



//check if the input field resembles a real email address ('stuff@stuff.stuff'), don't allow spaces

function veri_email (input,error_text) {

  if(!input.match(/^\w+([.-]\w+)*@\w+([.-]\w+)+$/)){

	error_show(3,error_text);	  

	return 1;

  } else {

	return 0;

  }

}



//check if the input field resembles a real zip code ('00000-0000')

function veri_zipcode (input,error_text) {

	k=0;

	if (input.length<5) {

		k=1;

	} else {

		if (input.length==5 && isNaN(input)) {

			k=1;

		} else {

			if (input.length>5)

				if (input.length!=10 || input.charAt(5)!='-' || isnoNumber(input.replace(/(-)/g,0))==1)

					k=1;

		}

	}

	if (k==1) {

		error_show(3,error_text);

		return 1;

	} else {

		return 0;

	}

}



//check if an item was selected - all none-items in the selector have to have the value "-1"

function veri_selected (input,error_text) {

	if (input == '-1') {

		alert('Input Error: '+(eval(formloc+'.elements[element].name')));

		error_show(11,error_text);

		return 1;

	} else {

		return 0;

	}

}



//check if the input field was empty AND the last selected option had the text 'Other'

function veri_other (input,opt_text,error_text) {

	if (input == '' && opt_text.toLowerCase() == 'other') {

		error_show(12,error_text);

		return 1;

	} else {

		return 0;

	}

}





//check if the input field is the same as the text in the buffer

function veri_comparesame (input,buffer_text,error_text) {

	if (input != buffer_text) {

		error_show(13,error_text);

		return 1;

	} else {

		return 0;

	}

}