function CheckEditForms() {
	for (a=0;a<arguments.length;a++) {//cycle through passed arguments
		var ProblemField = AlertMessage = false;
		var ThisField = document.getElementById(arguments[a]);
		cleanText = ThisField.name.replace(/_/g," ");//show text box name cleanly (greedy)
		
		if ( ThisField.value == '' ) {//if empty
			AlertMessage = "Please complete the '" + cleanText + "' Field.";
			ProblemField = true;
		}
		//if email field and no '.' or '@'
		if ( ThisField.name == 'Email' && ( ThisField.value.indexOf('@') == -1 || ThisField.value.indexOf('.') == -1 || ThisField.value.indexOf(' ') != -1 ) ) {
			AlertMessage = "Please enter a valid Email Address.";
			ProblemField = true;
		}
		if ( ThisField.name == 'Email_Verification' && ( ThisField.value.indexOf('@') == -1 || ThisField.value.indexOf('.') == -1 || ThisField.value.indexOf(' ') != -1 || ThisField.value != document.getElementById('Email').value ) ) {
			AlertMessage = "Your email addresses do not match.";
			ProblemField = true;
		}
		if ( ThisField.name == 'Password_Verification' && ThisField.value != document.getElementById('Password').value ) {
			AlertMessage = "Your passwords do not match.";
			ProblemField = true;
		}
		if ( ThisField.type == 'checkbox' && !ThisField.checked ) {
			AlertMessage = "You must tick the '" + cleanText + "' box.";
			ProblemField = true;
		}
		
		if ( ProblemField ) {
			alert( AlertMessage );//display warning
			ThisField.focus();//go to field
			return false;//fail
		}
	}//end for
	return true;//if all ok exec
}//end CheckEditForms

function attachEvents( ElementID , Event , FunctionName ) {
	var el = document.getElementById( ElementID );

	if ( el.addEventListener ){
		el.addEventListener( Event , FunctionName , false);
		return true;
	} else if ( el.attachEvent ){
		var r = el.attachEvent( 'on' + Event , FunctionName );
		return r;
	} else {
		eval( "el.on" + Event + " = " + FunctionName + ";" );
		return true;
	}
	return false;
}
function attachEventByName( ElementID , Event , FunctionName ) {
	el = document.getElementsByName( ElementID );

	for ( e=0; e<el.length; e++ ) {
		if ( el[e].addEventListener ){
			el[e].addEventListener( Event , FunctionName , false);
			return true;
		} else if ( el[e].attachEvent ){
			var r = el[e].attachEvent( 'on' + Event , FunctionName );
			return r;
		} else {
			eval( "el[e].on" + Event + " = " + FunctionName + ";" );
			return true;
		}
	}
	return false;
}

//repeat calling a function until the ID appears
function pollC( id, functionToExec ) {
	if ( document.getElementById(id) ) {
		eval( functionToExec );
		return;
	} else {
		setTimeout("pollC('"+id+"', '"+functionToExec+"')", 60);
	}
}
