<?php
session_start();
if($_SESSION['logInSucces'] == NULL){
	?><script type="text/javascript">window.location.href="index"</script><?
}
?>
			<div class="content-box">
				<div class="content-config">
					<div class="header-conf">
						<p>Nova Categoria</p>
					</div>
					<div class="conteudo-config">
						<div class="input-group">
							<span>Titulo</span>
							<input type="text"  value="" id="nome" placeholder="Titulo da Categoria" required="">
						</div>
						
						<div class="input-group">
							<button class="cad-success">Cadastrar</button>
						</div>
					</div>
				</div>
			</div>	
<script type="text/javascript">
	$('.cad-success').click(function(){
		var nome = $('#nome').val();

		if(nome != 0){ $('#nome').css('border','1px solid rgba(0,0,0,.3)');
				$.ajax({
						  type: "POST",
						  url: 'function/api.php?action=addCategory',
						  data: {
						  	'titulo' : nome,
							},
						  success: function(data,status){
						  	if(data == 'E1'){
						  		$('.status').css('display','block');
					  			$('.status').css('color','white');
					  			$('.status').css('background','rgba(215,50,50,1)');
						  		$('.status p').html('Email já existente.');
						  		status_close();
						  	}else if(data == 'S1'){
						  		$('.status').css('display','block');
						  		$('.status').css('color','white');
					  			$('.status').css('background','rgba(50,215,50,1)');
						  		$('.status p').html('Cadastrado Com Sucesso.');
						  		status_close();
						  	}
						  },
						  
						});
				
		}else{
			$('#nome').css('border','1px solid red');
		}
				
				
	});	

</script>