/** Class Validator v1.1.5.@20040329 */

var bln_Validator_Proto_Called = false;

function Validator() {

	if(!bln_Validator_Proto_Called) {
		bln_Validator_Proto_Called = true;
		var _this = Validator.prototype;

		_this.isDefined = function(x) {
			if(typeof(x) == "undefined") {
				this._setStatusCode(this.NOT_OK);
				return false;
			}
			
			this._setStatusCode(this.OK);
			return true;
		};

		_this.isEmail=function(x) {
			var reg = "^[A-Za-z0-9]+([_\\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\\.-][A-Za-z0-9]+)*\\.([A-Za-z]){2,4}$";
			if(x.test(reg,"i")) {
				this._setStatusCode(this.OK);
				return true;
			}
			
			this.setStatusCode(this.NOT_OK);
			return false;
		};
	
		_this.isInteger = function(x) {
			x = "" + x;
			
			var intNumber = parseInt(x);
			
			if(!isNaN(intNumber)) {
				x = x.remove("^(0*)");/*0012==octal(12)*/
				if(x=="") x = 0;
			}
			
			intNumber = parseInt(x);
			if((!isNaN(intNumber)) && ((""+intNumber)==x)) {
				this._setStatusCode(this.OK);
				return true;
			}
			
			this._setStatusCode(this.NOT_OK);
			return false;
		};
	
		_this.isFloat = function(x) {
			x = "" + x;
			
			if(!isNaN(parseFloat(x.remove("^(0*)")))) {
				this._setStatusCode(this.OK);
				return true;
			}
			
			this._setStatusCode(this.NOT_OK);
			return false;
		};
	
		_this.isString = function(x) {
			
			if(typeof(x) == "string") {
				this._setStatusCode(this.OK);
				return true;
			}
			
			this._setStatusCode(this.NOT_OK);
			return false;
		};
		
		_this.isDate = function(intYear, intMonth, intDay) {
			if(intYear=="") {
				this._setStatusCode(this.YEAR_IS_EMPTY);
				return false;
			}
			
			if(intMonth=="") {
				this._setStatusCode(this.MONTH_IS_EMPTY);
				return false;
			}
			
			if(intDay=="") {
				this._setStatusCode(this.DAY_IS_EMPTY);
				return false;
			}
			
			var arMonths = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

			
			
			if((parseInt(intMonth) % 4) == 0) {
				arMonths[1]=29;
			}
			else {
				arMonths[1]=28;
			}
			
			var intMaxDay = arMonths[parseInt(intMonth)-1];
			
			if(parseInt(intDay) > intMaxDay) {
				this._setStatusCode(this.DAY_NOT_VALID);
				return false;
			}
			
			this._setStatusCode(this.OK);
			return true;
		};
		
		_this.getStatusCode = function() {
			return this._intStatusCode;
		};
		
		_this._setStatusCode = function(intCode) {
			this._intStatusCode=intCode;
		};
		
	}/* end if */

	/** 000000 */
	this.OK = 0
	/** 000001 */
	this.NOT_OK =1
	/** 000011 */
	this.DAY_IS_EMPTY = 3
	/** 000101 */
	this.MONTH_IS_EMPTY = 5
	/** 001001 */
	this.YEAR_IS_EMPTY = 9
	/** 010001 */
	this.DAY_NOT_VALID = 17
	/** 000000 */
	this._intStatusCode=this.OK;

}/* end Class */

