validator = {
	isEmpty: function (value) {
		return (value.length == 0)
	},
	isName: function (value) {
		var Regex = /^[\wÀ-ÿ]|[\W\d\s][\&\*]{1,100}$/;

		return Regex.test(value);
	},
	isPassword: function (value) {
		var Regex = /^[\wÀ-ÿ]|[\W\d\s][\&\*]{1,20}$/;

		return Regex.test(value);
	},
	isEmail: function (value) {
		var Regex = /^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$/;

		return Regex.test(value);
	},
	isUsername: function (value) {
		var Regex = /^([a-z]|[A-Z]|[ .çãáéíóúÃÁÉÍÓÚ])*$/;

		return Regex.test(value);
	},
	isDate: function (value) {
		var Regex = /^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$/;

		return Regex.test(value);
	},
	isCPF: function (cpf) {
		var filtro = /^\d{3}.\d{3}.\d{3}-\d{2}$/i;
		if (!filtro.test(cpf) || cpf == "") {
			return false;
		}

		cpf = cpf.replace(/[.-]/g, "");

		if (cpf.length != 11 || cpf == "00000000000" || cpf == "11111111111" ||
		cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" ||
		cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" ||
		cpf == "88888888888" || cpf == "99999999999") {
			return false;
		}

		soma = 0;
		for (i = 0; i < 9; i++) soma += parseInt(cpf.charAt(i)) * (10 - i);
		resto = 11 - (soma % 11);
		if (resto == 10 || resto == 11) resto = 0;
		if (resto != parseInt(cpf.charAt(9))) {
			return false;
		}

		soma = 0;
		for (i = 0; i < 10; i++) soma += parseInt(cpf.charAt(i)) * (11 - i);
		resto = 11 - (soma % 11);
		if (resto == 10 || resto == 11) resto = 0;
		if (resto != parseInt(cpf.charAt(10))) {
			return false;
		}
		return true;
	},
	isCNPJ: function (value) {
		var filtro = /^\d{2}.\d{3}.\d{3}\/\d{4}-\d{2}$/i;
		var cnpj = value;

		if (!filtro.test(cnpj)) {
			return false;
		}

		cnpj = cnpj.replace(/[.\/-]/g, "");

		if (cnpj.length != 14 || cnpj == "00000000000000" || cnpj == "11111111111111" ||
		cnpj == "22222222222222" || cnpj == "33333333333333" || cnpj == "44444444444444" ||
		cnpj == "55555555555555" || cnpj == "66666666666666" || cnpj == "77777777777777" ||
		cnpj == "88888888888888" || cnpj == "99999999999999") {
			return false;
		}

		var a = [];
		var b = new Number;
		var c = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
		for (i = 0; i < 12; i++) {
			a[i] = cnpj.charAt(i);
			b += a[i] * c[i + 1];
		}
		if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11 - x }
		b = 0;
		for (y = 0; y < 13; y++) {
			b += (a[y] * c[y]);
		}
		if ((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11 - x; }
		if ((cnpj.charAt(12) != a[12]) || (cnpj.charAt(13) != a[13])) {
			return false;
		}
		return true;
	}
}
