/* Criacao de Rules*/
/* Vefifica c e numero				*/ function Rules_Numero(c) { return (((c >=-99999999*9999999) && (c <=99999999*9999999)) || (c.indexOf(",")>=0)) }
/* Vefifica { } ( ) < > [ ] | \ /  	*/ function Rules_Esp1(c) { return ((c.indexOf("{")>=0) || (c.indexOf("}")>=0) || (c.indexOf("(")>=0) || (c.indexOf(")")>=0) || (c.indexOf("<")>=0) || (c.indexOf(">")>=0) || (c.indexOf("[")>=0) || (c.indexOf("]")>=0) || (c.indexOf("|")>=0) || (c.indexOf("}")>=0)) }
/* Vefifica & * $ % ? ! ^ ~ ` ' "  	*/ function Rules_Esp2(c) { return ((c.indexOf("&")>=0) || (c.indexOf("*")>=0) || (c.indexOf("$")>=0) || (c.indexOf("%")>=0) || (c.indexOf("?")>=0) || (c.indexOf("!")>=0) || (c.indexOf("^")>=0) || (c.indexOf("~")>=0) || (c.indexOf("`")>=0) || (c.indexOf("\"")>=0) || (c.indexOf("`")>=0) || (c.indexOf("'")>=0)) }
/* Vefifica , ; : = #  				*/ function Rules_Esp3(c) { return ((c.indexOf(",")>=0) || (c.indexOf(";")>=0) || (c.indexOf(":")>=0) || (c.indexOf("=")>=0) || (c.indexOf("#")>=0)) }
/* Vefifica @ .  					*/ function Rules_Email(c) { return ((c.indexOf("@")>=0) && (c.indexOf(".")>=0)); }
/* Verifica se o valor e Nulo       */ function Rules_Vazio(c) { return ((c == null) || (c.length == 0)); }
/* Verifica se o valor e Nulo       */ function Rules_Pequeno(c) { return ((c.length < 6)); }


/* -------------------------------------------------- */
function nome() {
	txt = '';
	form = document.getElementById("nome");
	erro = 0;
	if (Rules_Vazio(form.value)) {
		txt = 'Por favor, o campo não pode ser vazio.';
		erro ++;
	} else if (Rules_Esp1(form.value) || Rules_Esp2(form.value) || Rules_Esp3(form.value)) {
		txt = 'Por favor, não utilize caracteres especiais.';
		erro ++;
	} else if (Rules_Numero(form.value)) {
		txt = 'Por favor, não utilize números.';
		erro ++;
	} else if (form.value.length < 4) {
		txt = 'Deve ter no mínimo de 4 caracteres.';
		erro ++;
	} else {
		txt = '';
	}
	listar = texto (txt);
	if (document.all) {
		document.all.p_nome.innerHTML = listar;
	} else {
		document.getElementById("p_nome").innerHTML = listar;
	}
	return erro;
}
function empresa() {
	txt = '';
	form = document.getElementById("empresa");
	erro = 0;
	if (Rules_Vazio(form.value)) {
		txt = 'Por favor, o campo não pode ser vazio.';
		erro ++;
	} else if (Rules_Esp1(form.value) || Rules_Esp2(form.value) || Rules_Esp3(form.value)) {
		txt = 'Por favor, não utilize caracteres especiais.';
		erro ++;
	} else if (form.value.length < 4) {
		txt = 'Deve ter no mínimo de 4 caracteres.';
		erro ++;
	} else {
		txt = '';
	}
	listar = texto (txt);
	if (document.all) {
		document.all.p_empresa.innerHTML = listar;
	} else {
		document.getElementById("p_empresa").innerHTML = listar;
	}
	return erro;
}
function email() {
	txt = '';
	form = document.getElementById("email");
	erro = 0;
	if (Rules_Vazio(form.value)) {
		txt = 'Por favor, o campo não pode ser vazio.';
		erro ++;
	} else if (Rules_Esp1(form.value) || Rules_Esp2(form.value) || Rules_Esp3(form.value)) {
		txt = 'Por favor, não utilize caracteres especiais.';
		erro ++;
	} else if (form.value.length < 6) {
		txt = 'E-mail muito curto.';
		erro ++;
	} else if (Rules_Email(form.value) == false) {
		var field = document.getElementById("email"); // email field
		var str = field.value; // email string
		var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
		var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
		if (!reg1.test(str) && reg2.test(str)) { 
			// valido
		} else {
			// invalido
			txt = 'E-mail inválido, por favor digite seu e-mail corretamente.';
		}
		erro ++;
	} else {
		txt = '';
	}
	
	listar = texto (txt);
	if (document.all) {
		document.all.p_email.innerHTML = listar;
	} else {
		document.getElementById("p_email").innerHTML = listar;
	}
	return erro;
}
function senha() {
	txt = '';
	form = document.getElementById("senha");
	erro = 0;
	if (Rules_Vazio(form.value)) {
		txt = 'Por favor, o campo não pode ser vazio.';
		erro ++;
	} else if (Rules_Esp1(form.value) || Rules_Esp2(form.value) || Rules_Esp3(form.value)) {
		txt = 'Por favor, não utilize caracteres especiais.';
		erro ++;
	} else if (form.value.length < 6) {
		txt = 'Deve ter no mínimo de 6 caracteres.';
		erro ++;
	} else {
		txt = '';
	}
	listar = texto (txt);
	if (document.all) {
		document.all.p_senha.innerHTML = listar;
	} else {
		document.getElementById("p_senha").innerHTML = listar;
	}
	return erro;
}
function senha_confirmacao() {
	txt = '';
	form = document.getElementById("senha_confirmar");
	form2 = document.getElementById("senha");
	erro = 0;
	if (Rules_Vazio(form.value)) {
		txt = 'Por favor, o campo não pode ser vazio.';
		erro ++;
	} else if (Rules_Esp1(form.value) || Rules_Esp2(form.value) || Rules_Esp3(form.value)) {
		txt = 'Por favor, não utilize caracteres especiais.';
		erro ++;
	} else if (form.value.length < 6) {
		txt = 'Deve ter no mínimo de 6 caracteres.';
		erro ++;
	} else if (form.value != form2.value) {
		txt = 'As senhas devem ser idênticas.';
		erro ++;
	} else {
		txt = '';
	}
	listar = texto (txt);
	if (document.all) {
		document.all.p_senha_confirmacao.innerHTML = listar;
	} else {
		document.getElementById("p_senha_confirmacao").innerHTML = listar;
	}
	return erro;
}
function input_combo(qual) {
	txt = '';
	form = document.getElementById(qual);
	erro = 0;
	if (form.options[0].selected) {
		txt = 'Por favor, selecione um item.';
		erro ++;
	} else {
		txt = '';
	}
	listar = texto (txt);
	if (document.all) {
		document.all["p_" + qual].innerHTML = listar;
	} else {
		p = "p_" + qual;
		document.getElementById(p).innerHTML = listar;
	}
	return erro;
}
function input_texto(qual, qtde, especiais, numeros, vazio) {
	form = document.getElementById(qual);
	if (qtde == null) { qtde = 4 }
	if (especiais == null) { especiais = true } else { especiais = false }
	if (numeros == null) { numeros = true } else { numeros = false }
	if (vazio == null) { vazio = true } else { vazio = false }
	txt = '';
	erro = 0;
	if (vazio && Rules_Vazio(form.value)) {
		txt = 'Por favor, o campo não pode ser vazio.';
		erro ++;
	} else if (form.value.length < qtde) {
		txt = 'Deve ter no mínimo de ' + qtde + ' caracteres.';
		erro ++;
	} else if (especiais == true) {
		if (Rules_Esp1(form.value) || Rules_Esp2(form.value) || Rules_Esp3(form.value)) {
		txt = 'Por favor, não utilize caracteres especiais.';
		erro ++;
		}
	} else if (numeros == true) {
		if (Rules_Numero(form.value)) {
		txt = 'Por favor, não utilize números.';
		erro ++;
		}
	} else {
		txt = '';
	}
	listar = texto (txt);
	if (document.all) {
		document.all["p_" + qual].innerHTML = listar;
	} else {
		p = "p_" + qual;
		document.getElementById(p).innerHTML = listar;
	}
	return erro;
}
function link_akamai(qual) {
	txt = '';
	form = document.getElementById(qual);
	erro = 0;
	if (Rules_Vazio(form.value)) {
		txt = 'Por favor, o campo não pode ser vazio.';
		erro ++;
	} else if (form.value.length < 85) {
		txt = 'Deve ter no mínimo de 85 caracteres.';
		erro ++;
	} else {
		txt = '';
	}
	listar = texto (txt);
	if (document.all) {
		document.all["p_" + qual].innerHTML = listar;
	} else {
		p = "p_" + qual;
		document.getElementById(p).innerHTML = listar;
	}
	return erro;
}
function input_numero(qual, qtde) {
	if (qtde == null) { qtde = 4 }
	txt = '';
	form = document.getElementById(qual);
	erro = 0;
	if (Rules_Vazio(form.value)) {
		txt = 'Por favor, o campo não pode ser vazio.';
		erro ++;
	} else if (Rules_Esp1(form.value) || Rules_Esp2(form.value) || Rules_Esp3(form.value)) {
		txt = 'Por favor, não utilize caracteres especiais.';
		erro ++;
	} else if (form.value.length < qtde) {
		txt = 'Deve ter no mínimo de ' + qtde + ' caracteres.';
		erro ++;
	} else if (Rules_Numero(form.value) == false) {
		txt = 'Somente números são permitidos.';
		erro ++;
	} else {
		txt = '';
	}
	listar = texto (txt);
	if (document.all) {
		document.all["p_" + qual].innerHTML = listar;
	} else {
		p = "p_" + qual;
		document.getElementById(p).innerHTML = listar;
	}
	return erro;
}