﻿var PROCESS_ERROR='Sorry, but there was an error processing your request. Please refresh the page and try again.';
var defaults=[];

function checkForm(id){
	$(id + ' .required-field').each(function(e){ $(this).blur(); });
	var errors=$('span.error:visible').length;
	return errors==0;
}
function throwError(e){ $(e).next('.error').show(); }
function hideError(e){$(e).next('.error').hide();}

function validateEmail(f) {
	if($(f).attr('id').indexOf('email') < 0) return true;
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($.trim($(f).val()))) return true;
	return false;
}
function validateField(e, i){
    if ($.trim($(e).val()) == '' || !validateEmail($(e)) || $(e).val() == defaults[i]) return false;
    else return true;
}
function onSubmitComplete(e, formId){
	if (e.success == 1) $(formId).html(e.message);
	else $(formId).html(PROCESS_ERROR+"<br/>"+e.message);
}
