function isemail(src){
	if(src.search(/^\w[\.\w]*\w@([\w\-]+\w\.)+[a-z]{2,4}$/i)<0)
		return false;
	else return true;
}
function isinteger(src){
	if(src.search(/^\d+$/)<0)
		return false;
	else return true;
}
function ismoney(src){
	if(src.search(/^(\d+)\.(\d{1,2})$|^(\d+)$/i)<0)
		return false;
	else return true;
}
function warn(f,o,msg){
	if (!msg) msg='You should enter all required fields.';
	alert(msg);
	o.focus();
	//f['submitter'].disabled = false;
	return false;
}

function set_select (cd,val)
{cb=eval(cd);
  for (c=0; c<cb.length; c++){
   if (cb.options[c].value == val)
	   {cb.options[c].selected=true;
	   return true;}
   }
 return false;
}

function require(f){
	disableSubmit(f);
	if(!isemail(f.af_email.value)) return warn(f,f.af_email,"E-Mail field is very important!\nYou need to enter fully qualified email address.\nIt will be used only for communication with you.");
	if(!f.af_password.value) return warn(f,f.af_password,"Please, choose your password.\nIt cannot exceed 12 characters in length.");
	if(f.af_password.value!=f.repassword.value) {f.af_password.value = ''; f.repassword.value = ''; return warn(f,f.af_password,"Warning!\nYou must type your password twice to ensure there is no mistypes.\nValue you enter in 'Retype Password' is not equal with 'Password'!"); };
	if(!f.af_fname.value) return warn(f,f.af_fname);
	if(!f.af_lname.value) return warn(f,f.af_lname);
	if(!f.af_payableto.value) return warn(f,f.af_payableto);
	if(!f.af_address.value) return warn(f,f.af_address);
	if(!f.af_city.value) return warn(f,f.af_city);
	if(!f.af_state.value) return warn(f,f.af_state);
	if(!f.af_zip.value) return warn(f,f.af_zip);
	if(!f.af_country.value) return warn(f,f.af_country);
	return;
}
function disableSubmit(f) {
	//f['submitter'].disabled = true;
	return true;
}
