//check if a mandatory field is empty
function isEmpty(field,msg,fldFocus){
	if(isBlank(field.value)){
		alert(msg);
		fldFocus.focus();

		return true;
	}
	return false;
}

function isBlank(str){
	if(str=='' || str.length==0) return true;
	for(i=0;i<str.length;i++)
	 if (str.charAt(i)!=' ') return false;
	return true;
}
//validating Email
function validateEmail(email, msg, optional) 
		{
		if (!email.value && optional) 
		{ 
		return true;
		 }
		 var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/; 
		 if (!re_mail.test(email.value)) 
		 {
		  alert(msg); 
		  email.focus(); 
		  email.select();
		  return false; 
		  }
		   
		   return true; 
		  }