/*
		INTEGRATIVA - Internet Results	-	http:// www.integrativa.com.br 	: info@integrativa.com.br
		Ryan R. de Azevedo - tecnologia02@integrativa.com.br [Web Developer]
		Administradores
		26.11.03	
*/

function valida_login() {

  if (!text_validate('formcadastro','usuario','Usuário')) { 
   		return false;
  }
  
  if (!text_validate('formcadastro','senha','Senha')) { 
   		return false;
  }
	return true;
}

function valida_contato() {

  if (!text_validate('formcontato','nome','Nome')) { 
   		return false;
  }
  
  if (!checkMail('formcontato','email', 'E-MAIL')) { 
  		return false; 
  }

  if (!text_len_validate('formcontato','ddd','DDD',2,2)){
   		return false;
  }

  if (!text_len_validate('formcontato','telefone','Telefone',7,9)){
   		return false;
  }

  if (!text_validate('formcontato','cidade','Cidade')) { 
   		return false;
  }

  if (!select_validate('formcontato','estado','Estado')) { 
   		return false;
  }
 
  if (!text_validate('formcontato','mensagem','Mensagem')) { 
   		return false;
  }
  return true;
}

function valida_anuncie() {

  if (!text_validate('formcontato','empresa','Empresa')) { 
   		return false;
  }

  if (!valida_contato()){
  	return false;
  }
  return true;
}


function valida_pedido() {

   if (!text_validate('formpedido','contrato','Contrato: Apenas valores numéricos')) { 
   		return false;
  }
  
  if (!text_validate('formpedido','nome','Nome')) { 
   		return false;
  }
  
  if (!checkMail('formpedido','email', 'E-MAIL')) { 
  		return false; 
  }
  
  if (!text_validate('formpedido','numero','Número do Boleto: Apenas valores numéricos',2,2)){
   		return false;
  }

  if (!text_validate('formpedido','datapagto','Data',2,2)){
   		return false;
  }

  if (!text_validate('formpedido','valor','Valor: Apenas valores numéricos',2,2)){
   		return false;
  }

  if (!text_validate('formpedido','endereco','Endereço',7,9)){
   		return false;
  }

  if (!text_validate('formpedido','cidade','Cidade')) { 
   		return false;
  }

  if (!select_validate('formpedido','estado','Estado')) { 
   		return false;
  }
  
   if (!text_validate('formpedido','cep','CEP',7,9)){
   		return false;
  }
 
  if (!text_validate('formpedido','mensagem','Mensagem')) { 
   		return false;
  }
  return true;
}

 function valueFormat(Obj,lengLimit,Event) {
     var keypress = Event.keyCode;
     var val = Obj.value;
     var minusFlag = false;

     while (val.indexOf(" ") != -1) { val = val.replace(" ",""); }
     while (val.indexOf(",") != -1) { val = val.replace(",",""); }
     while (val.indexOf(".") != -1) { val = val.replace(".",""); }
     while (val.indexOf("-") != -1) { val = val.replace("-",""); minusFlag = true;}
     len = val.length;

     if (len < lengLimit && keypress != 8) { len++; }
     if (keypress == 8 ) {	len--; }    
     if (keypress == 8 || keypress >= 48 && keypress <= 57 || keypress >= 96 && keypress <= 105 ) {
       if ( len <= 2 ) { Obj.value = val; }
       else {
         val = insert(val,1,',');
         len = val.length;
         for (pos=5; pos < len; pos += 3) {
           val = insert(val,pos,'.');
           len = val.length;
           pos++;
         }
         if (minusFlag) { val = "-" + val; }
         Obj.value = val;
       }
     }   
   }

   function insert(str,pos,chr) {
     leng = str.length
     return str.substr(0,leng - pos) + chr + str.substr(leng - pos,len);
   }