	UI = {};
	UI.cpf_format = "___.___.___-__";
	UI.cep_format = "__.___-___";
	UI.date_format = "__/__/____";
	UI.fone_format = "(__)____-____";
	UI.time_format = "__:__:__";
	UI.cnpj_format = "__.___.___/____-__";

	UI.Validate = new function () {
		this.email = function (node) {
			node.addEventListener("blur", function () {ov_email(this)}, false);
			node.addEventListener("focus", function () {setValue(this)}, false);
		};
		this.cpf = function (node) {
			node.addEventListener("blur", function () {ov_cpf(this);if (!this.value)this.value=UI.cpf_format;}, false);
			node.addEventListener("focus", function () {setValue(this);this.value=this.value.getNumber()}, false);
			//node.addEventListener("keypress", function () {return verify_char(event, '1234567890', this, 11)}, false);
			node.onkeypress = function () {return verify_char((arguments.length?arguments[0]:event), '1234567890', this, 11)};

			if (!node.value)
				node.setAttribute("value", UI.cpf_format);
		};
		this.cpf_cnpj = function (node) {
			node.addEventListener("blur", function () {ov_cpf_cnpj(this)}, false);
			node.addEventListener("focus", function () {setValue(this);this.value=this.value.getNumber()}, false);
			//node.addEventListener("keypress", function () {return verify_char(event, '1234567890', this, 14)}, false);
			node.onkeypress = function () {return verify_char((arguments.length?arguments[0]:event), '1234567890', this, 14)};
		};
		this.cnpj = function (node) {
			node.addEventListener("blur", function () {ov_cnpj(this);if (!this.value)this.value=UI.cnpj_format;}, false);
			node.addEventListener("focus", function () {setValue(this);this.value=this.value.getNumber()}, false);
			//node.addEventListener("keypress", function () {return verify_char(event, '1234567890', this, 14)}, false);
			node.onkeypress = function () {return verify_char((arguments.length?arguments[0]:event), '1234567890', this, 14)};

			if (!node.value)
				node.setAttribute("value", UI.cnpj_format);
		};
		this.cep = function (node) {
			node.addEventListener("blur", function () {ov_cep(this);if (!this.value)this.value=UI.cep_format;}, false);
			node.addEventListener("focus", function () {setValue(this);this.value=this.value.getNumber()}, false);
			//node.addEventListener("keypress", function () {return verify_char(event, '1234567890', this, 8)}, false);
			node.onkeypress = function () {return verify_char((arguments.length?arguments[0]:event), '1234567890', this, 8)};

			if (!node.value)
				node.setAttribute("value", UI.cep_format);
		};
		this.date = function (node) {
			node.addEventListener("blur", function () {ov_date(this);if (!this.value)this.value=UI.date_format;}, false);
			node.addEventListener("focus", function () {setValue(this);this.value=this.value.getNumber()}, false);
			//node.addEventListener("keypress", function () {return verify_char(event, '1234567890', this, 8)}, false);
			node.onkeypress = function () {return verify_char((arguments.length?arguments[0]:event), '1234567890', this, 8)};

			if (!node.value)
				node.setAttribute("value", UI.date_format);
		};
		this.time = function (node) {
			node.addEventListener("blur", function () {ov_time(this);if (!this.value)this.value=UI.time_format;}, false);
			node.addEventListener("focus", function () {setValue(this);this.value=this.value.getNumber()}, false);
			//node.addEventListener("keypress", function () {return verify_char(event, '1234567890', this, 8)}, false);
			node.onkeypress = function () {return verify_char((arguments.length?arguments[0]:event), '1234567890:', this, 8)};

			if (!node.value)
				node.setAttribute("value", UI.time_format);
		};
		this.float = function (node) {
			node.addEventListener("blur", function () {ov_float(this)}, false);
			node.addEventListener("focus", function () {setValue(this);this.value=this.value.replace(/\./g, '')}, false);
			//node.addEventListener("keypress", function () {return verify_char(event, '1234567890,')}, false);
			node.onkeypress = function () {return verify_char((arguments.length?arguments[0]:event), '1234567890,')};
		};
		this.number = function (node) {
			node.addEventListener("focus", function () {setValue(this);this.value=this.value.getNumber()}, false);
			//node.addEventListener("keypress", function () {return verify_char(event, '1234567890')}, false);
			node.onkeypress = function () {return verify_char((arguments.length?arguments[0]:event), '1234567890')};
		};
		this.integer = function (node) { this.number(node); };

		this.fone = function (node) {
			node.addEventListener("blur", function () {ov_fone(this);if (!this.value)this.value=UI.fone_format;}, false);
			node.addEventListener("focus", function () {setValue(this);this.value=this.value.getNumber()}, false);
			node.onkeypress = function () {return verify_char((arguments.length?arguments[0]:event), '1234567890')};
			//node.addEventListener("keypress", function () {return verify_char((arguments.length?arguments[0]:event), '1234567890')}, false);
			//node.attachEvent("onkeypress", function () {return verify_char(event, '1234567890')});

			if (!node.value)
				node.setAttribute("value", UI.fone_format);
		};
		this.telefone = function (node) { this.fone(node); };

		this.parse = function () {
			if (typeof doc == "undefined")
				doc = document;

			var listNode = doc.getElementsByTagName("input");

			for (var x = 0; x < listNode.length; x++) {
				var __item = listNode.item(x);
				if (validate = __item.getAttribute("validate")) {
					if (!document.addEventListener || document.attachEvent)// testa idiota
						__ini_object(__item);

					func_name = validate.toLowerCase();

					UI.Validate[func_name](__item);

					__item.removeAttribute("validate");
				}
			}
		}
	};

	if (window.attachEvent) {
		window.attachEvent('onload', function () {
			UI.Validate.parse();
		});
	}
	else {
		window.addEventListener("load", function () {
			UI.Validate.parse();
		}, false);
	}