function validate(frm){
	//all-purpose form validation function
	//give form elements class="validate" to perform validation
	//could be enhanced to display label text instead of form name, perhaps?
	//would need to get reference to label first, then form
	//for the moment, name form elements as you would like them to be displayed, but with underscore, e.g. full_name
	//does this element need validating?
	for(i=0;i<frm.elements.length;i++){
		el=frm.elements[i];
		str=el.value;
		strDisplayName=el.name.replace('_',' ')
		aryV=el.className.split('_');
		if(aryV[0]=='validate'){
			//first, check presence
			if(str.length<1){
				alert('Please provide ' + strDisplayName);
					  //name.replace('_',' '));
				return false;
			}else{
				switch(aryV[1]){
					case 'number':
						//spaces, brackets,+ and  - are allowed
						re=/[\s()+-]/g;
						str=el.value.replace(re,'');
						re=/^\d+$/;
					break;
					case 'email':
						//nothing fancy, just checks for presence of @ and . with at least one character between each
						//1@2.3 is valid, for example
						re=/.+@.+\..+/gi;
					break;
					default:
						re='';
					break;
				}
				if(re!=''){
					if(str.search(re)==-1){
						alert('Please provide a valid ' + strDisplayName);
						return false;
					}	
				}
			}
		}	
	}
	return true;
}

function attachEvents(){
	var oBack=document.getElementById('back');
	if(oBack){
		oBack.href='javascript:history.go(-1)';
	}	

}

//this is outside all functions
if(document.getElementById){
	window.onload=attachEvents;
}