function validateFunction() {
	this.val   = "";
	this.elmObj = "";	
	
	this.isBlank = function() {
		var newval = this.val.replace(/^\s*|\s*$/g, '');		
		if(newval == "")  return "cannot be blank"; else return false ;
	}
	this.isName = function() {
		if (this.val.length < 4) {
		   return "should be more that four characters.";
		} else if(!this.val.match(/^[a-z0-9 ]+$/i)) {
			return "can contain only letters and numbers and space";
		} else {
			return false;
		}		
	}
	this.isEmail = function(){
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (!filter.test(this.val))	return "should be valid email."; else return false;		
	}
	this.isPassword = function() {
		 var illegalChars = /\s/; // no space allowed
		if (this.val.length < 4) {
		   return "should be more than five characters.";
		} else if (illegalChars.test(this.val)) {
		  return "should not contain space";
		} else if(varifyPass = document.getElementById("varifyPass")) {
			if(varifyPass.value != this.val) {
				return "Both passwords should be equal";
			}
		} else {
			return false;
		}
	}
	this.isLogin = function() {
		var illegalChars = /\W/; // allow letters, numbers, and underscores
		if (this.val.length < 4) {
		   return "should be more that 4 characters.";
		} else if (illegalChars.test(this.val)) {
			return "can contain only letters, numbers, and underscores";
		} else {
			return false;
		}
	}
	this.isNumber = function() {
		if(isNaN(this.val)) return "should be number[0-9]"; else return false;				
	}
	this.isChecked = function() {
		if (this.elmObj.checked) return false; else return "should be checked";
	}
	this.isDuplicate = function() {
		return false;
	}	
}
var objValidate = new validateFunction();

function validateForm(frm){
	
	if(frm) {
				
		var strMsg = "";
		
		for(i=0; i<frm.length; i++) {
			var obj   = frm.elements[i];			
			
			if(obj) {
				
				if(obj.type != "submit" && obj.type != "button" && obj.type != "hidden" && obj.type!="reset") {
					var oClass = obj.className;
					
					if(oClass) {
						
						var arrValidate = oClass.split(",");
						
						if(arrValidate.length > 0) { 
							objValidate.elmObj = obj;
							objValidate.val = obj.value;
							var msgs = "";
							var pre = "";
							for(j=0; j<arrValidate.length; j++) {									
								eval("var msg =objValidate."+arrValidate[j]+"();");								
								if(msg) { msgs += pre+msg; pre = ", ";}
								
							}							
							if(msgs) strMsg +="<p><b>"+obj.title+":</b> "+msgs+"</p>";
							//alert(obj.type+"\n"+strMsg);
						}
					}
				}
			}						
		}	
		
		if(strMsg) {
			showAlert(frm.Submit,strMsg);
			return false;			
		}
	}	
}