window.status="Vale Sul"

function toggleColor(objElement)
{
  if (objElement.className=='normal')
    objElement.className='focus';
  else
    objElement.className='normal';
}

function validar(Form) 

 {

   if ( document.form1.Razao_Social.value.length <= 1 )
      { alert( "Informe a Razão Social...")
    	document.form1.Razao_Social.focus() 
	    return false }

   if ( document.form1.Nome_Fantasia.value.length <= 1 )
      { alert( "Informe o Nome Fantasia...")
    	document.form1.Nome_Fantasia.focus() 
	    return false }

   if ( document.form1.Pessoa_Contato.value.length <= 1 )
      { alert( "Informe a Pessoa para Contato...")
    	document.form1.Pessoa_Contato.focus() 
	    return false }

  
  if ( document.form1.Endereco.value.length <= 1 )
      { alert( "Informe o Rua/Av. ...")
    	document.form1.Endereco.focus() 
	    return false }

  if ( document.form1.Bairro.value.length <= 1 )
      { alert( "Informe o Bairro...")
    	document.form1.Bairro.focus() 
	    return false }

  if ( document.form1.Cep.value.length <= 8 )
      { alert( "Informe o Cep...")
    	document.form1.Cep.focus() 
	    return false }

  if ( document.form1.Cidade.value.length <= 2 )
      { alert( "Informe a Cidade...")
    	document.form1.Cidade.focus() 
	    return false }

   if (document.form1.UF.selectedIndex == 0) 
    { alert('Informe a UF...');
	  document.form1.UF.focus()
      return false;
	}

  if ( document.form1.Ponto_Referencia.value.length <= 2 )
      { alert( "Informe um Ponto de Referência...")
    	document.form1.Ponto_Referencia.focus() 
	    return false 
	  }

  if ( document.form1.Telefone.value.length <= 12 )
      { alert( "Informe o Telefone...\n Formato: (xx) xxxx-xxxx")
    	document.form1.Telefone.focus() 
	    return false 
	  }

if ( document.form1.E_mail.value.length <= 3 )
      { alert( "Informe o E-mail")
    	document.form1.E_mail.focus() 
	    return false 
	  }

//Valida e-mail se estiver preenchido
	if (document.form1.E_mail.value != "")
	{
		prim = document.form1.E_mail.value.indexOf("@")
		if(prim < 2) {
			alert("O e-mail informado parece não estar correto.");
			document.form1.E_mail.focus();
			document.form1.E_mail.select();
			return false;
		}
		if(document.form1.E_mail.value.indexOf("@",prim + 1) != -1) {
			alert("O e-mail informado parece não estar correto.");
			document.form1.E_mail.focus();
			document.form1.E_mail.select();
			return false;
		}
		if(document.form1.E_mail.value.indexOf(".") < 1) {
			alert("O e-mail informado parece não estar correto.");
			document.form1.E_mail.focus();
			document.form1.E_mail.select();
			return false;
		}
		if(document.form1.E_mail.value.indexOf(" ") != -1) {
			alert("O e-mail informado parece não estar correto.");
			document.form1.E_mail.focus();
			document.form1.E_mail.select();
			return false;
		}
		if(document.form1.E_mail.value.indexOf("zipmeil.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			document.form1.E_mail.focus();
			document.form1.E_mail.select();
			return false;
		}
		if(document.form1.E_mail.value.indexOf("hotmeil.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			document.form1.E_mail.focus();
			document.form1.E_mail.select();
			return false;
		}
		if(document.form1.E_mail.value.indexOf(".@") > 0) {
			alert("O e-mail informado parece não estar correto.");
			document.form1.E_mail.focus();
			document.form1.E_mail.select();
			return false;
		}
		if(document.form1.E_mail.value.indexOf("@.") > 0) {
			alert("O e-mail informado parece não estar correto.");
			document.form1.E_mail.focus();
			document.form1.E_mail.select();
			return false;
		}
		if(document.form1.E_mail.value.indexOf(".com.br.") > 0) {
			alert("O e-mail informado parece não estar correto.");
			document.form1.E_mail.focus();
			document.form1.E_mail.select();
			return false;
		}
		if(document.form1.E_mail.value.indexOf("/") > 0) {
			alert("O e-mail informado parece não estar correto.");
			document.form1.E_mail.focus();
			document.form1.E_mail.select();
			return false;
		}
		if(document.form1.E_mail.value.indexOf("[") > 0) {
			alert("O e-mail informado parece não estar correto.");
			document.form1.E_mail.focus();
			document.form1.E_mail.select();
			return false;
		}
		if(document.form1.E_mail.value.indexOf("]") > 0) {
			alert("O e-mail informado parece não estar correto.");
			document.form1.E_mail.focus();
			document.form1.E_mail.select();
			return false;
		}
		if(document.form1.E_mail.value.indexOf("(") > 0) {
			alert("O e-mail informado parece não estar correto.");
			document.form1.E_mail.focus();
			document.form1.E_mail.select();
			return false;
		}
		if(document.form1.E_mail.value.indexOf(")") > 0) {
			alert("O e-mail informado parece não estar correto.");
			document.form1.E_mail.focus();
			document.form1.E_mail.select();
			return false;
		}
		if(document.form1.E_mail.value.indexOf("..") > 0) {
			alert("O e-mail informado parece não estar correto.");
			document.form1.E_mail.focus();
			document.form1.E_mail.select();
			return false;
		}
	return true;
	}

}
 


function Transforma_Minuscula(Texto)
 {
  var minuscula = Texto.value.toLowerCase()
  Texto.value = minuscula
 }

function Transforma_Maiuscula(Texto)
 {
  var maiuscula = Texto.value.toUpperCase()
  Texto.value = maiuscula
 }

function Formata_Cep(e,src,mask) {
    if(window.event) { _TXT = e.keyCode; } 
    else if(e.which) { _TXT = e.which; }
    if(_TXT > 47 && _TXT < 58) { 
 var i = src.value.length; var saida = mask.substring(0,1); var texto = mask.substring(i)
 if (texto.substring(0,1) != saida) { src.value += texto.substring(0,1); } 
    return true; } else { if (_TXT != 8) { return false; } 
 else { return true; }
    }
}


function validaNumero()
 {
  var tecla = window.event.keyCode;
   if ((tecla != 8 ) && (tecla !=46) && (tecla !=13) && (tecla !=9))  //codigo da tabela ASCII Backspace=8 delete=46  enter=13 tab=9
    { if ((tecla < 48 ) || (tecla > 57))
       { if ((tecla < 96 ) || (tecla > 105))
          { event.returnValue = false; }
       }
    }
 } 

function FormataCNPJ_mascara(Campo, teclapres){

   if(window.event){
    var tecla = teclapres.keyCode;
   }else  tecla = teclapres.which;

   var vr = new String(Campo.value);
   vr = vr.replace(".", "");
   vr = vr.replace(".", "");
   vr = vr.replace("/", "");
   vr = vr.replace("-", "");

   tam = vr.length + 1;

   
   if (tecla != 9 && tecla != 8){
      if (tam > 2 && tam < 6)
         Campo.value = vr.substr(0, 2) + '.' + vr.substr(2, tam);
      if (tam >= 6 && tam < 9)
         Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,tam-5);
      if (tam >= 9 && tam < 13)
         Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,tam-8);
      if (tam >= 13 && tam < 15)
         Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4)+ '-' + vr.substr(12,tam-12);
      }
}



// Máscara de CNPJ, CPF, Data e Telefone em JavaScript
// <input name="cpf" type="text" maxlength="14" onKeyPress="Mascara('CPF',this,event);"> 
function Mascara(tipo, campo, teclaPress) {
	if (window.event)
	{
		var tecla = teclaPress.keyCode;
	} else {
		tecla = teclaPress.which;
	}
 
	var s = new String(campo.value);
	// Remove todos os caracteres à seguir: ( ) / - . e espaço, para tratar a string denovo.
	s = s.replace(/(\.|\(|\)|\/|\-| )+/g,'');
 
	tam = s.length + 1;
 
	if ( tecla != 9 && tecla != 8 ) {
		switch (tipo)
		{
		case 'CPF' :
			if (tam > 3 && tam < 7)
				campo.value = s.substr(0,3) + '.' + s.substr(3, tam);
			if (tam >= 7 && tam < 10)
				campo.value = s.substr(0,3) + '.' + s.substr(3,3) + '.' + s.substr(6,tam-6);
			if (tam >= 10 && tam < 12)
				campo.value = s.substr(0,3) + '.' + s.substr(3,3) + '.' + s.substr(6,3) + '-' + s.substr(9,tam-9);
		break;
 
		case 'CNPJ' :
 
			if (tam > 2 && tam < 6)
				campo.value = s.substr(0,2) + '.' + s.substr(2, tam);
			if (tam >= 6 && tam < 9)
				campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,tam-5);
			if (tam >= 9 && tam < 13)
				campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,3) + '/' + s.substr(8,tam-8);
			if (tam >= 13 && tam < 15)
				campo.value = s.substr(0,2) + '.' + s.substr(2,3) + '.' + s.substr(5,3) + '/' + s.substr(8,4)+ '-' + s.substr(12,tam-12);
		break;
 
		case 'TEL' :
			if (tam > 2 && tam < 4)
				campo.value = '(' + s.substr(0,2) + ') ' + s.substr(2,tam);
			if (tam >= 7 && tam < 11)
				campo.value = '(' + s.substr(0,2) + ') ' + s.substr(2,4) + '-' + s.substr(6,tam-6);
		break;
 
		case 'DATA' :
			if (tam > 2 && tam < 4)
				campo.value = s.substr(0,2) + '/' + s.substr(2, tam);
			if (tam > 4 && tam < 11)
				campo.value = s.substr(0,2) + '/' + s.substr(2,2) + '/' + s.substr(4,tam-4);
		break;
		}
	}
}




//valida tel no firefox

function txtBoxFormat(objeto, sMask, evtKeyPress) {
    var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;


if(document.all) { // Internet Explorer
    nTecla = evtKeyPress.keyCode;
} else if(document.layers) { // Nestcape
    nTecla = evtKeyPress.which;
} else {
    nTecla = evtKeyPress.which;
    if (nTecla == 8) {
        return true;
    }
}

    sValue = objeto.value;

    // Limpa todos os caracteres de formatação que
    // já estiverem no campo.
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( " ", "" );
    sValue = sValue.toString().replace( " ", "" );
    fldLen = sValue.length;
    mskLen = sMask.length;

    i = 0;
    nCount = 0;
    sCod = "";
    mskLen = fldLen;

    while (i <= mskLen) {
      bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))
      bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

      if (bolMask) {
        sCod += sMask.charAt(i);
        mskLen++; }
      else {
        sCod += sValue.charAt(nCount);
        nCount++;
      }

      i++;
    }

    objeto.value = sCod;

    if (nTecla != 8) { // backspace
      if (sMask.charAt(i-1) == "9") { // apenas números...
        return ((nTecla > 47) && (nTecla < 58)); }
      else { // qualquer caracter...
        return true;
      }
    }
    else {
      return true;
    }
  }
