var validate = {
	Trim: function (Str) {
		if (Str) {
			if (Str.length > 0)
				while (Str.substring(0,1) == " ")
					Str = Str.substring(1);
			if (Str.length > 0)
				while (Str.substring(Str.length-1,Str.length) == " ")
					Str = Str.substring(0,Str.length-1);
			return Str;
		}
		return "";
	},

	IsNull: function (Val) {
		return (this.Trim(Val) == "");
	},

	IsInt: function (Val) {
		return (Val == parseInt(Val));
	},

	IsAllDigits: function (Val) {
		for (var i=0; i<Val.length; i++)
			if (!this.IsInt(Val.charAt(i)))
				return false;
		return true;
	},

	IsNumeric: function (Val) {
		return (!this.IsNull(Val) && this.Trim(Val)-0 == this.Trim(Val));
	},

	ValidateNumeric: function(Elem, Label, E, CheckEmpty) {
		if (!this.IsNumeric(Elem.value) && (CheckEmpty || Elem.value.length) && (!E || E.keyCode != 13)) {
			alert('Please enter Numeric value in "' + Label + '"!');
			Elem.focus();
			return false;
		}
			
		return true;
	},
	
	MoveNext: function (Elem, NextElem, Label, Size, E) {
		if (this.ValidateNumeric(Elem, Label, E) && Elem.value.length == Size)
			NextElem.focus();
	},

	ValidateEmail: function(Elem) {
		var emailRe = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|tv|dk|se|ca))$/;
		
		if (!emailRe.test(Elem.value)) {
			alert('Please enter valid "Email" address!');
			Elem.focus();
			return false;
		}
	
		return true;
	}
}
