function Validate(){}


Validate.isOfAge = function(age,birthdate){
	
	var currentTime = new Date();
	var yearDiff = currentTime.getFullYear() - birthdate.getFullYear();
	var monthDiff = currentTime.getMonth() - birthdate.getMonth();
	var dayDiff = currentTime.getDate() - birthdate.getDate();
		
	if(yearDiff < age){
		return false;
	}else if(yearDiff == age){
		if(monthDiff < 0){
			return false;
		}else if(monthDiff == 0){
			if(dayDiff < 0){
				return false;
			}
		}
	}
	return true;
}

Validate.isString = function(str, opt){
	
	if(opt.min != undefined){
		if(str.length < opt.min) {
			return false;
		}
	}

	if(opt.max != undefined){
		if(str.length > opt.max) {
			return false;
		}
	}

	if(opt.regexp != undefined){
		if(!opt.regexp.test(str)) {
			return false;
		}
	}
	return true;
}

Validate.isEmail = function(val){
	var e = /^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/;
	return Validate.isString(val,{regexp:e, max:120});
}


Validate.isPostal = function(val){
	var e = /^[0-9\.\-\s]*$/;
	return Validate.isString(val,{regexp:e,max:15});
}