function validateEmail(addr,man,db) {
	if(addr == "" && man ==1) {
	   //if(db) 
	  // alert('email address is mandatory');
	   return false;
	}
	var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
	for(i=0; i<invalidChars.length; i++){
	   if(addr.indexOf(invalidChars.charAt(i),0) > -1) {
	     // if(db){
	      	//alert('email address contains invalid characters');
	      	return false;
	   }
	}
	for(i=0; i<addr.length; i++) {
	   if(addr.charCodeAt(i)>127) {
	      //if(db) 
	      //alert("email address contains non ascii characters.");
	      return false;
	   }
	}
	
	var atPos = addr.indexOf('@',0);
	if(atPos == -1) {
	   //if(db) 
	   //alert('email address must contain an @');
	   return false;
	}
	if(atPos == 0) {
	   //if(db) 
	   //alert('email address must not start with @');
	   return false;
	}
	if(addr.indexOf('@', atPos + 1) > - 1) {
	   //if(db) 
	   //alert('email address must contain only one @');
	   return false;
	}
	if(addr.indexOf('.', atPos) == -1) {
	   //if(db) 
	   //alert('email address must contain a period in the domain name');
	   return false;
	}
	if(addr.indexOf('@.',0) != -1) {
	   //if(db) 
	   //alert('period must not immediately follow @ in email address');
	   return false;
	}
	if(addr.indexOf('.@',0) != -1){
	   //if(db) 
	   //alert('period must not immediately precede @ in email address');
	   return false;
	}
	if(addr.indexOf('..',0) != -1) {
	   //if(db) 
	  // alert('two periods must not be adjacent in email address');
	   return false;
	}
	var suffix = addr.substring(addr.lastIndexOf('.')+1);
	if(suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
	   //if(db) 
	   //alert('invalid primary domain in email address');
	   return false;
	}
	return true;
}

function multiEmail(email_field) {
var email = email_field.split(',');
for (var i = 0; i < email.length; i++) {
   if (!validateEmail(email[i], 1, 0)) {
      alert('one or more email addresses entered is invalid');
      return false;
   }
}
return true;
}

	function validate_form(requiredstring,sbmitBt,thisform)
	{
		if(requiredstring != "")
		{
			fieldArray = requiredstring.split("^");
			var thisField = "";
			var thisForm = eval("document.forms."+thisform);
			for(a=0;a<fieldArray.length;a++){
				set_fieldcolour(fieldArray[a],"#FFF");
			}
			for(a=0;a<fieldArray.length;a++){
				thisField = document.getElementById(fieldArray[a]);
				if(thisField.value == "" || thisField.value == " "){
					alert("Please complete ALL fields");
					set_fieldcolour(fieldArray[a],"yellow");
					thisField.focus();
					return false;
				}
				if(fieldArray[a] == "memory_description"){
					var memdescArray = thisField.value.split(" ");
					if(memdescArray.length >200){
						alert("Please describe your keepsake, and the memories associated with it, in no more than 200 words.");
						set_fieldcolour(fieldArray[a],"yellow");
						thisField.select();
						return false;
					}
				}
				if(fieldArray[a] == "repair_or_restore_item"){
					myOption = -1;
					for (i=thisForm.repair_or_restore_item.length-1; i > -1; i--) {
						if (thisForm.repair_or_restore_item[i].checked) {
							myOption = i; 
							i = -1;
						}
					}
					if (myOption == -1) {
						alert("Please indicate if would you want to repair or restore damaged keepsakes if it you were able to");
						return false;
					}
				
				}
				if(fieldArray[a] == "conservation_and_restoration_advice"){
					myOption = -1;
					for (i=thisForm.conservation_and_restoration_advice.length-1; i > -1; i--) {
						if (thisForm.conservation_and_restoration_advice[i].checked) {
							myOption = i;
							 i = -1;
						}
					}
					if (myOption == -1) {
						alert("Please indicate whether you know where to get advice about professional conservation and restoration");
						return false;
					}
				
				}
				if(fieldArray[a] == "email"){
					if(validateEmail(thisField.value,1,0)) {
						//alert('username accepted'); 
						//return false;
					}else{
						alert("Your email address is not formatted correctly, please try again");
						set_fieldcolour(fieldArray[a],"yellow");
						thisField.select();
						return false;
					}
				}
				if(fieldArray[a] == "antibotq"){
					if(thisField.value != "MeM80x") {
						alert("Please enter the characters as shown");
						set_fieldcolour(fieldArray[a],"yellow");
						thisField.select();
						return false;
					}
				}				
			}
		}
		document.getElementById(sbmitBt).disabled = true;
	}

	function set_fieldcolour(fld,fldCol)
	{
		// if the browser is Netscape 6 or IE
		if(document.all || document.getElementById){
			// change the color of text field
			document.getElementById(fld).style.background = ""+fldCol+"";
		}
	}