$(document).ready(function(){ 
});

function checkRequired(){
	var noError = true;
	jQuery.each($("*[req]"), function() {
		if($(this).attr('req')=='yes'&&
			$(this).attr('disabled')==false &&
			$(this).attr('value')==''){
			$(this).addClass('inputError');		
			$('#divError').show();
			noError = false;
		}else{
			$(this).removeClass('inputError');		
		}
		if($(this).attr('req')=='yes'&&
			$(this).attr('disabled')==false&&
			$(this).attr('validateemail')=='yes'){
			var validEmail = isValidEmailAddress($(this).attr('value'));
			if(!validEmail){
				$(this).addClass('inputError');		
				$('#divError').show();				
				noError=false;	
			}else{
				$(this).removeClass('inputError');		
			}
		}		
	});
	if(noError==true){
		document.myForm.submit();
		return true;
	}
		return false;
}
function isValidEmailAddress(emailAddress) { 
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i); 
	return pattern.test(emailAddress); 
}
