function exibe(id, id1) {
	if(document.getElementById(id).style.display=="none") {
		document.getElementById(id).style.display = "inline";		
		document.getElementById(id1).innerHTML = '(-) Ocultar conte&uacute;do';	
	}
	else {
		document.getElementById(id).style.display = "none";
		document.getElementById(id1).innerHTML = '(+) Leia mais';	
	}	
}

function mouseOver(id, img) {
	document.getElementById(id).src = img;
}

function mouseOut(id, img) {
	document.getElementById(id).src = img;
	
}
function SomenteNumeros(evnt){
	if (navigator.appName.indexOf('Microsoft') != -1){
		if (evnt.keyCode < 48 || evnt.keyCode > 57){
			return false;
		}
	}else{
		if ((evnt.charCode < 48 || evnt.charCode > 57) && evnt.keyCode == 0){
			return false;
		}
	}
}

function formatonulo (campo) {
  for (contador=0; contador < campo.length; contador++) {
	  retorno = campo.substring (contador, contador+1);
	  if (retorno!=' ') return (false);
  }
  return (true);
}

function formatointeiro (numero) {
	for (i=0; i<numero.length; i++) {

	  if (((parseInt(numero.substring(i, i+1), 10)>=0)
		   && (parseInt(numero.substring(i, i+1), 10)<=9))) {
	  }
	  else
		return (false);
	} /* fecha for */
	if (parseInt(numero)>=0)
	   return (true);
	else
	   return (false);
}

function validadoc(Numero,Digito)
{
var CGC = Numero
var peso1 = '543298765432';
var peso2 = '654329876543';
var soma1 = 0;
var soma2 = 0;
var digito1 = 0;
var digito2 = 0;

for (i = 1; i < 12 - Numero.length+1; i++) {
	CGC = eval("'" + 0 + CGC + "'")}
for (i = 1; i < CGC.length+1; i++) {
	soma1 += CGC.substring(i, i-1) * peso1.substring(i, i-1);
	}
	soma1 %= 11;
	if (soma1  < 2) {
	   digito1 = 0;}
	else {
	   digito1 = 11 - soma1; }
for (i = 1; i < CGC.length+1; i++) {
	soma2 += CGC.substring(i, i-1) * peso2.substring(i, i-1);
	}
	soma2 += digito1 * 2
	soma2 %= 11;
	if (soma2  < 2) {
	   digito2 = 0;}
	else {
	   digito2 = 11 - soma2; }
if (eval("'" + digito1 + digito2 + "'") != Digito){
	return false;}
else {
	return true;}
 }	

function validacpf(){
		 var i;
		 s = document.all.idCpfCnpj.value;
		 var c = s.substr(0,9);
		 var dv = s.substr(9,2);
		 var d1 = 0;
		 for (i = 0; i < 9; i++){
			  d1 += c.charAt(i)*(10-i);
		 }
		 if (d1 == 0){
			 return false;
		 }
		 d1 = 11 - (d1 % 11);
		 if (d1 > 9) d1 = 0;
		 if (dv.charAt(0) != d1){
			 return false;
		 }
		 d1 *= 2;
		 for (i = 0; i < 9; i++){
			  d1 += c.charAt(i)*(11-i);
		 }
		 d1 = 11 - (d1 % 11);
		 if (d1 > 9) d1 = 0;
		 if (dv.charAt(1) != d1){
			 return false;
		 }
}

function trim(valor){
	if (null==valor)return '';
	if (valor=='')return valor;
	while (valor.indexOf(" ")==0){
		valor=valor.substr(1);
	}
	if (valor=='')return valor;
	while (valor.lastIndexOf(" ")==valor.length-1){
		valor=valor.substr(0,valor.length-1);
	}
	return valor;
}

function checaCadastro(qual, submeter){	
	if (qual=='F'){
		 if(document.form1.idNome.value==''){
			alert("Por favor, informe o seu Nome");
			document.form1.idNome.value.value='';
			document.form1.idNome.focus();
			return false;
		 }

 if( document.form1.tpPessoa[0].checked == true ){
			if(document.form1.idCpfCnpj.value.length!=11){
			   alert("Por favor, informe o seu CPF");
			   document.form1.idCpfCnpj.value.value='';
			   document.form1.idCpfCnpj.focus();
			   return false;
			}				 
 }else{
			if(document.form1.idCpfCnpj.value.length!=14){
			   alert("Por favor, informe o seu CNPJ");
			   document.form1.idCpfCnpj.value.value='';
			   document.form1.idCpfCnpj.focus();
			   return false;
			}				 

 }

		 if(document.form1.idCidade.value==''){
			alert("Por favor, informe a sua Cidade");
			document.form1.idCidade.value.value='';
			document.form1.idCidade.focus();
			return false;
		 }				 
		 if(document.form1.idEstado.value=='--'){
			alert("Por favor, escolha um Estado");
			document.form1.idEstado.value.value='';
			document.form1.idEstado.focus();
			return false;				
		 }
		 if( document.form1.idCep.value.length!=8){
			alert('Por favor, informe o CEP')
			document.form1.idCep.focus();
			return false;
		 }else{
			 if(formatonulo(document.form1.idCep.value)){
				alert('Por favor, informe o CEP')
				document.form1.idCep.focus();
				return false;
			 }				
		 }
		if(document.form1.idEmail.value==''){
			alert("Por favor, informe o seu e-mail");
			document.form1.idEmail.value.value='';
			ddocument.form1.idEmail.focus();
			return false;
		} else {
			//aqui ainda fazer os constraints certos para não deixar que o e-mail seja dummie!!
			if(document.form1.idEmail.value.indexOf('@')<0 || 
			   document.form1.idEmail.value.indexOf('.')<0){
				alert("Por favor, entre com um e-mail válido");
				document.form1.idEmail.focus();
				return false;
			}
			if(document.form1.idEmail.value.length<6){
				alert("Por favor, entre com um e-mail válido");
				document.form1.idEmail.focus();
				return false;
			}
		}
		 if(formatonulo(document.form1.idDDDFixo.value)){
			alert('Por favor, informe o DDD')
			document.form1.idCep.focus();
			return false;
		 }
		 if(formatonulo(document.form1.idFixo.value)){
			alert('Por favor, informe o número do Telefone')
			document.form1.idFixo.focus();
			return false;
		 }
	}
	document.form1.submit();
}



