<?php
	require('ferramentas.php');
	$ncadastro = $_REQUEST['cad'];
	if (!cnpjcpf_valido($ncadastro)) {
		echo("<h3><font face='Arial' color='#FF0000' >CNPJ/CPF inválido ! </font></h3>");
		exit("<script>location.href = 'index.php'</script>");
	}
	if (strlen($ncadastro)==12) {
		$campo_cpfreg = '<label for="cCPFRegEmp">CPF/CNPJ bol. reg.</label>'.
				'<input type="text" name="tCPFRegEmp" id="cCPFRegEmp" size="23" maxlength="14" placeholder="CPF/CNPJ p/ boleto registrado" onblur="if (this.value != \'\')  { if (!valida_cpf_cnpj(this.value)) {  Msg(\'CNPJ/CPF invalido\'); this.focus();}}" value="" required/>';
	} else {
		$campo_cpfreg = '';
	}
?>
<!DOCTYPE html>
<html lang="pt-br">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="favicon.ico">

    <title>Cadastro</title>
	
    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="css/sticky-footer.css" rel="stylesheet">
	
	<link href="css/uploadfile.css" rel="stylesheet">
	
    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="js/ie-emulation-modes-warning.js"></script>
	
	<script type="text/javascript" src="js/jquery-2.1.3.min.js"></script>
	<script type="text/javascript" src="js/jquery.mask.min.js"></script>
	<script type="text/javascript" src="js/script2.js?6"></script>
	<script type="text/javascript" src="js/valida_cpf_cnpj.js"></script>

	<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>

  <!--<body onload="$('#cNomeEmp').focus(); $('#btnenviar').prop('disabled', true); ">-->
	<body onload="$('#cNomeEmp').focus();">
    <!-- Begin page content -->
    <div class="container">
      <div class="page-header">
        <h1>Cadastro</h1>
      </div>
      
	  <form method="post" id="fCadastro" action="confirma.php" onsubmit="" enctype="multipart/form-data" >
		  <fieldset id="fEmpresa"><legend>Empresa</legend>			
			<li>				
				<label for="cCNPJEmp">CNPJ/CPF/CEI</label>
				<input type="text" name="tCNPJEmp" id="cCNPJEmp" size="17" maxlength="20" placeholder="CNPJ Empresa"  value="<?php if ( strlen($ncadastro) == 14) { echo mask($ncadastro,'##.###.###/####-##'); } else { echo $ncadastro; } ?>" disabled />			
				<label for="cNomeEmp">Empresa</label>
				<input type="text" name="tNomeEmp" id="cNomeEmp" size="50" maxlength="50" placeholder="Razão Social" value="" onblur="maiusculo(this);" required/>			
				<input type="text" name="tCNPJEmpresa" id="cCNPJEmpresa" hidden value="<?php echo $ncadastro; ?>" />
			</li>
			<li>
				<label for="cFantasiaEmp">Fantasia</label>
				<input type="text" name="tFantasiaEmp" id="cFantasiaEmp" size="40" maxlength="50" placeholder="Nome Fantasia" onblur="maiusculo(this);" value="" />	
				<?php echo $campo_cpfreg; ?>
			</li>
			<li>
				<label for="cCepEmp">CEP</label>
				<input type="text" name="tCEPEmp" id="cCepEmp" class="cep" size="9" maxlength="9" placeholder="CEP" onBlur=" if (this.value != '')  { buscaCep(this.value,'empresa'); }  " value="" required/>			
				<input type="text" name="tbuscacepemp" id="cBuscaCepEmp" hidden value ="n" />
				<label for="cEstado">Estado</label>
				<select name="tEstado" id="cEstado" style="width:50px" onBlur=" if ( this.value !='UF' &&  $('#cBuscaCepEmp').val() =='n' )  { buscaCidade(this.value, 'empresa'); } " required/>
					<option selected disabled value=''>UF</option>
					<?php echo estados(); ?>
				</select>
				<label for="cCidade">Cidade</label>
				<select name="tCidade" id="cCidade" style="width:400px"  required>					
					<option selected disabled value=''>Escolha a cidade</option>
				</select>
				<input type="text" name="tDescricaoCidade" id="cDescricaoCidade" hidden  />
			</li>
			<li>
				<label for="cEnderecoEmp">Endereço</label>
				<input type="text" name="tEnderecoEmp" id="cEnderecoEmp" size="50" maxlength="50" placeholder="Rua, Avenida, etc..." value="" onblur="maiusculo(this);" required/>						
				<label for="cNumeroEmp">Número</label>
				<input type="text" name="tNumeroEmp" id="cNumeroEmp" size="10" maxlength="10" placeholder="Número" value="" required/>						
			</li>
			<li>
				<label for="cComplementoEmp">Complemento</label>
				<input type="text" name="tComplementoEmp" id="cComplementoEmp" size="30" maxlength="30" placeholder="Complemento" onblur="maiusculo(this);" value=""/>						
				<label for="cBairroEmp">Bairro</label>
				<input type="text" name="tBairroEmp" id="cBairroEmp" size="40" maxlength="40" placeholder="Bairro" value="" onblur="maiusculo(this);" required/>						
			</li>
			<li>
				<label for="cTelefoneEmp">Telefone</label>
				<input type="text" name="tTelefoneEmp" id="cTelefoneEmp" class="phone_with_ddd" size="15" maxlength="15" placeholder="Telefone" value="" required/>	
				<label for="cCelularEmp">Celular</label>
				<input type="text" name="tCelularEmp" id="cCelularEmp" size="15" maxlength="15" placeholder="Celular" value="" required/>
				<label for="cContatoEmp">Contato</label>
				<input type="text" name="tContatoEmp" id="cContatoEmp" size="30" maxlength="30" placeholder="Contato" value="" onblur="maiusculo(this);" required/>
			</li>
			<li>
				<label for="cEmailEmp">E-Mail</label>
				<input type="email" name="tEmailEmp" id="cEmailEmp" size="60" maxlength="60" placeholder="e-mail@e-mail.com.br" value="" required/>
			</li>
			<li>
				<label for="cCategoria">Categoria</label>
				<select name="tCategoria" id="cCategoria" style="width:400px" onblur="$('#cDescricaoCategoria').attr('value',$('#cCategoria option:selected').text());" required>					
					<option selected disabled value=''>Escolha a categoria</option>
					<?php echo categorias(); ?>
				</select>
				<input type="text" name="tDescricaoCategoria" id="cDescricaoCategoria" hidden  />
			</li>
			<li>
				<label for="cObs">Observação</label>
				<textarea name="tObs" id="cObs" cols="85" rows="3" placeholder="Deixe aqui sua mensagem" ></textarea>
			</li>
		  </fieldset>	
		  </br>		
		  <fieldset id="fEscritorio"><legend>Escritório</legend>
			<li>				
				<label for="cCNPJEsc">CNPJ/CPF</label>
				<input type="text" name="tCNPJEsc" id="cCNPJEsc" size="20" maxlength="20" placeholder="CNPJ/CPF"  value="" onBlur="if (this.value != '')  { if (valida_cpf_cnpj(this.value)) {  buscaEscritorio(this.value); marcaRequiridoEscritorio(this.value);} else {  Msg('CNPJ/CPF invalido'); this.focus();}}" />
				<label for="cNomeEsc">Escritório</label>
				<input type="text" name="tNomeEsc" id="cNomeEsc" size="50" maxlength="50" placeholder="Razão Social/Nome" onblur="maiusculo(this); " value="" />			
				<input type="text" name="tCodigoEsc" id="cCodigoEsc" hidden  />
			</li>
			<li>
				<label for="cFantasiaEsc">Fantasia</label>
				<input type="text" name="tFantasiaEsc" id="cFantasiaEsc" size="50" maxlength="50" placeholder="Nome Fantasia" onblur="maiusculo(this);" value="" />						
			</li>
			<li>
				<label for="cCepEsc">CEP</label>
				<input type="text" name="tCEPEsc" id="cCEPEsc" class="cep" size="9" maxlength="9" placeholder="CEP" value="" onBlur=" if (this.value != '')  { buscaCep(this.value,'escritorio'); }  " />						
				<input type="text" name="tbuscacepemp" id="cBuscaCepEsc" value="n" hidden  />
				<label for="cEstadoEsc">Estado</label>
				<select name="tEstadoEsc" id="cEstadoEsc" style="width:50px" onBlur="if (this.value !='UF' && $('#cBuscaCepEsc').val() =='n') { buscaCidade(this.value,'escritorio'); } " />
					<option selected disabled value=''>UF</option>
					<?php echo estados(); ?>
				</select>
				<label for="cCidadeEsc">Cidade</label>
				<select name="tCidadeEsc" id="cCidadeEsc" style="width:400px" >					
					<option selected disabled value=''>Escolha a cidade</option>
				</select>
				<input type="text" name="tDescricaoCidadeEsc" id="cDescricaoCidadeEsc" hidden  />
			</li>
			<li>
				<label for="cEnderecoEsc">Endereço</label>
				<input type="text" name="tEnderecoEsc" id="cEnderecoEsc" size="50" maxlength="50" placeholder="Rua, Avenida, etc..." onblur="maiusculo(this);" />						
				<label for="cNumeroEsc">Número</label>
				<input type="text" name="tNumeroEsc" id="cNumeroEsc" size="10" maxlength="10" placeholder="Número" value="" />						
			</li>
			<li>
				<label for="cComplementoEsc">Complemento</label>
				<input type="text" name="tComplementoEsc" id="cComplementoEsc" size="30" maxlength="30" placeholder="Complemento" onblur="maiusculo(this);" value=""/>						
				<label for="cBairroEsc">Bairro</label>
				<input type="text" name="tBairroEsc" id="cBairroEsc" size="40" maxlength="40" placeholder="Bairro" onblur="maiusculo(this);" />						
			</li>
			<li>
				<label for="cTelefoneEsc">Telefone</label>
				<input type="text" name="tTelefoneEsc" id="cTelefoneEsc" size="15" maxlength="15" placeholder="Telefone" value="" />	
				<label for="cCelularEsc">Celular</label>
				<input type="text" name="tCelularEsc" id="cCelularEsc" size="15" maxlength="15" placeholder="Celular" value="" />
				<label for="cContatoEsc">Contato</label>
				<input type="text" name="tContatoEsc" id="cContatoEsc" size="30" maxlength="30" placeholder="Contato" value="" onblur="maiusculo(this);" />
			</li>
			<li>
				<label for="cEmailEsc">E-Mail</label>
				<input type="email" name="tEmailEsc" id="cEmailEsc" size="60" maxlength="60" placeholder="e-mail@e-mail.com.br" value="" />
			</li>
			<li>
				<label for="cObsEsc">Observação</label>
				<textarea name="tObsEsc" id="cObsEsc" cols="85" rows="3" placeholder="Deixe aqui sua mensagem" ></textarea>
			</li>
		  </fieldset>
		  </br>
	
		  </br>
		  <input type="submit" id="btnenviar" value="Enviar" />
	  </form>
      <p></p>
    </div>
    <footer class="footer">
      <div class="container">
        <!--<p class="text-muted">SITICOM - Sindicato dos Trabalhadores nas Industrias da Construção e Mobiliário de São José do Rio Preto.</p>-->
		<p class="text-muted"><?php echo NOME;?></p>
      </div>
    </footer>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="js/ie10-viewport-bug-workaround.js"></script>
  </body>
<script type="text/javascript" src="js/examples.js"></script>	
</html>