var validate = function(){ return this };

validate.prototype.isElementInsideFormTag = function( input ){
	if( !input.form ){return false}else{return true}
}

/* DATA TYPE VALIDATION */
	validate.prototype.isMoney = function( inputValue ){
		inputValue = inputValue.replace(/\.(?=[0-9]{2})$/,'');
		inputValue = inputValue.replace(/^\$/,'');
		inputValue = inputValue.replace(/,/g,'');
		inputValue = inputValue.replace(/^-/,'');
		return isInteger( inputValue );
	}

	validate.prototype.isInteger = function( inputValue ){
		if( isNaN(inputValue) ){
			return false;
		}
		return true;
	}

	validate.prototype.isPositiveInt = function( inputValue ){
	  // check to make sure the current value is greater then zero
	  if( parseInt(inputValue) < 1 ){
		// here's the error message to display
		return false;
	  }
	  return true;
	}

	validate.prototype.isBasicDate = function( dateValue , alertErrors ) { 
		var v_dash1 = dateValue.indexOf('/',1);
		var v_dash2 = dateValue.indexOf('/',v_dash1 + 1);
		var v_days = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	
		if( typeof(alertErrors) == 'undefined' ){ var alertErrors=false }
		
		if ( v_dash1 == 0 || v_dash2 == 0 )return false;
		
		var v_month = dateValue.substr(0,v_dash1);
		var v_day = dateValue.substr( v_dash1+1 , v_dash2 - v_dash1 - 1);
		var v_year = dateValue.substr(v_dash2 + 1);
		var v_leap_year = false;
		
		if (v_year >= 1890){
			if (v_year % 4 == 0){v_leap_year = true}
		}else{
			if( alertErrors ){alert("Invalid Year.\nPlease re-enter.")}
			return false;
		}
		
		if (v_month >= 1 && v_month <= 12) {	
			if (v_month == 2 && v_leap_year){v_days[1] = 29}
		}else{
			if( alertErrors ){alert("Invalid Month.\nPlease re-enter.")}
			return false;
		}
		
		if(
			!(
				v_day >= 1
			&&
				v_day <= v_days[v_month - 1]
			)
		){
			if( alertErrors ){alert("Invalid Day.\nPlease re-enter.")}
			return false;
		}
		
		return true;
	}
	
	validate.prototype.isEmail = function( string ){
		var regX = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/gi
		return regX.test( string )
	}
	
	validate.prototype.isDate = validate.prototype.isBasicDate;
/* END */

if( OlOs == null ){
	document.write("<script type=\"text/javascript\" src=\"OlOs.js\"></script>");
}
OlOs.attachTo( new validate() , "validate" );
