<?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>Novo Video</p>
					</div>
					
					
					<div class="conteudo-config filme" >
						<div class="input-group">
							<span>TMDB ID</span>
							<input type="text" id="idtmdb" placeholder="Digite o id do filme ou Série">
						</div>
						<div class="input-group">
							<span>Trailer</span>
							<input type="text" placeholder="Trailer" name="trailer" id="trailer">
						</div>
						<div class="input-group">
							<span>Esse video é?</span>
							<div class="option-radio">
  								<input type="radio" name="tv_movie" id="vidTip" class="vidTip" checked="checked" value="movie"> <p>Filme</p>
  								<input type="radio" name="tv_movie" id="vidTip" class="vidTip" value="tv"> <p>Série</p>
							</div>
						</div>
						<div class="input-group">
							<span>Classificação de idade?</span>
							<select id="pg">
								<option>L</option>
								<option>10</option>
								<option>12</option>
								<option>14</option>
								<option>16</option>
								<option>18</option>
							</select>
						</div>
						<div class="filmCamp" >
						<div class="input-group">
							<span>Link 1</span>
							<input type="text" id="vidLink" placeholder="Digite o link ">
						</div>
						<div class="input-group">
							<span>Link 2</span>
							<input type="text" id="videLink2" placeholder="Digite o link ">
						</div>
						
						<div class="input-group">
							<span>Crianças podem assistir?</span>
							<div class="option-radio">
  								<input type="radio" name="child" id="child"  value="1"> <p>Sim</p>
  								<input type="radio" name="child" id="child"  checked="checked" value="0"> <p>Não</p>
							</div>
						</div>
						<div class="input-group">
							<span>Servidor 1</span>
							<div class="option-radio">
  								<input type="radio" name="lang" id="lang" checked="checked"  value="0"> <p>Padrao</p>
  								<input type="radio" name="lang" id="lang"   value="1"> <p>Onedrive</p>
  								<input type="radio" name="lang" id="lang"   value="2"> <p>Iframe</p>
  								
							</div>
						</div>
						<div class="input-group">
							<span>Servidor 2</span>
							<div class="option-radio">
  								<input type="radio" name="lang1" id="lang1" checked="checked"  value="0"> <p>Padrao</p>
  								<input type="radio" name="lang1" id="lang1"   value="1"> <p>Onedrive</p>
  								
  								<input type="radio" name="lang1" id="lang1"   value="2"> <p>Iframe</p>
  								
							</div>
						</div>
						</div>

						<div class="input-group">
							<button class="cad-success">Adicionar Video</button>
						</div>
					</div>
				</div>
			</div>	
		<script type="text/javascript">
			$('.cad-success').click(function(){
				var idtmdb = $('#idtmdb').val();
				var vidTip = $('#vidTip:checked').val();
				var pg	   = $('#pg').val();
				var child  = $('#child:checked').val();
				var vidLink  = $('#vidLink').val();
				var vidLinkLEG  = $('#videLink2').val();
				var lang  = $('#lang:checked').val();
				var lang1  = $('#lang1:checked').val();
				var trailer =$('#trailer').val();

				if(idtmdb != '' || titletv != ''){
					$('.loading').css('display','block');
						$('.loading').css('opacity','1');

					$('#idtmdb').css('border','1px solid rgba(0,0,0,.3)');
					$.ajax({
						  type: "POST",
						  url: 'function/api.php?action=addVid',
						  data: {
						  		'vidTipo' : vidTip,
						  		'child'   : child,
						  		'idtmdb'  : idtmdb,
						  		'vidLink' : vidLink,
						  		'vidLink2' : vidLinkLEG,
						  		'gdrive'    : lang,
						  		'gdrive1'    : lang1,
						  		'pg'		: pg,
						  		'trailer'	: trailer
							},
						  success: function(data,status){
						  	console.log(data);
						  	if(data == 'E1'){
						  		$('.loading').css('display','none');
								$('.loading').css('opacity','0');
						  		$('.status').css('display','block');
					  			$('.status').css('color','white');
					  			$('.status').css('background','rgba(215,50,50,1)');
						  		$('.status p').html('Filme Já Existente.');
						  		status_close();
						  	}else if(data == 'S1'){
						  		$('.loading').css('display','none');
								$('.loading').css('opacity','0');
						  		$('.status').css('display','block');
						  		$('.status').css('color','white');
					  			$('.status').css('background','rgba(50,215,50,1)');
						  		$('.status p').html('Adicionado Com Sucesso.');
						  		status_close();
						  	}

						  },
						  
						});
				}else{
					$('#idtmdb').css('border','1px solid red');
				}
			});
			$('.vidTip').click(function(){
				var vidTip = $('.vidTip:checked').val();
				if(vidTip == "movie"){
					$('.filmCamp').fadeIn('slow').show();
				}else{
					$('.filmCamp').fadeOut('slow').hide();
				}
			});
		</script>