// JavaScript Document							
function enviar(nome){
//document.formAD.submit;
document.forms[nome].submit();
//var theForm=document.getElementById("formAD");
  //theForm.submit;
}


function escolheEnvia(op,nome){
	if(op=="ant"){
		document.getElementById('posicao').value='anterior';
	}
	if(op=="prox"){
		document.getElementById('posicao').value='proximo';
	}
	document.forms[nome].submit();	
}

function escolhe(tipo, codigo){
	var tipo,formulario, codigo, input,ok;
	ok='nao';
	this.tipo=tipo;
	this.codigo=codigo;

	formulario= document.getElementById('formu');

	if (tipo=='imagem'){
		formulario.setAttribute('action','imagem_pg_principal.asp');
		ok='sim';
		//formulario.setAttribute('action','painellog.asp');
	}

	if (tipo=='dados'){
		formulario.setAttribute('action','edita_filme_conteudo.asp');
		ok='sim';
	}

	if (tipo=='excluir'){
		formulario.setAttribute('action','apaga_dados_filme.asp');
		ok='sim';
	}

	if (tipo=='gerenciamento_comentario'){
		formulario.setAttribute('action','gerenciamento_comentario.asp');
		ok='sim';
	}

	if (tipo=='excluir_comentario'){
		formulario.setAttribute('action','apaga_comentario.asp');
		ok='sim';
	}

	if (tipo=='aceitar_comentario'){
		formulario.setAttribute('action','exibir_comentario.asp');
		ok='sim';
	}

	if (tipo=='trailer'){
		formulario.setAttribute('action','novo_trailer.asp');
		ok='sim';
	}
	
	if (tipo=='comtrailer'){
		//alert("este filme já possue trailer.");
		formulario.setAttribute('action','edita_trailer.asp');
		ok='sim';
	}
	


 	input = document.createElement('input');   
    input.setAttribute('type','hidden');   
    input.setAttribute('value',codigo);   
	input.setAttribute('name','codigo');   
	input.setAttribute('id',codigo); 
    formulario.appendChild(input);  
	//formulario.submit();
	if(ok=='sim')
	document.forms['formu'].submit();	

}


function verifica_campo(nome){
	var titulo,diretor,elenco,idioma,legenda,continua,mestre,nome,i,check_legenda,check_idioma;
	check_legenda=false;
	check_idioma=false;	
	this.nome=nome;
	continua="s"
	titulo=document.getElementById("titulo");
	diretor=document.getElementById("diretor");
	elenco=document.getElementById("elenco");
	
	for (i=1;i<=5;i++){
		el=document.getElementById("idioma_0"+i);
		if(el.checked==true)
			check_idioma=true;
	}

	for (i=1;i<=5;i++){
		el=document.getElementById("legenda_0"+i);
		if(el.checked==true)
			check_legenda=true;
	}

	//mestre=document.getElementById("mestre");

	if ((titulo.value=="") || (diretor.value=="") || (elenco.value=="")|| (check_idioma==false) || (check_legenda==false)  ) {
		continua="n"
	}


	/*if (isNaN(mestre.value)){
		continua="n";
		alert("O código deve ser um número")
	}*/

	if (continua=="n") alert("Os campos com * devem ser preenchidos.");
	else document.forms[nome].submit();

}

function comBordas(num,cor){
	var imagem=document.getElementById(num);
	imagem.style.borderWidth="2px";
	imagem.style.borderStyle="solid";
	imagem.style.borderColor=cor;
}

function semBordas(num){
var imagem=document.getElementById(num);
	imagem.style.borderWidth="2px";
	imagem.style.borderStyle="solid";
	imagem.style.borderColor="#363636";

}

	function maxLength(limit) {
		var textAreaComentario = document.getElementById("comentario");
		var inputRegressivo=document.getElementById("inputRegressivo")
		inputRegressivo.value=limit - textAreaComentario.value.length;
		if (inputRegressivo.value <= 0) {
			inputRegressivo.value =0;
			textAreaComentario.value = textAreaComentario.value.substring(0, limit);
		}
	}

function verificaEmail(campo,formulario,obrigatorio){
		var mail = document.getElementById(campo).value;
		if (mail.length > 0){
			var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
			if ( (er.test(mail)) && (document.getElementById("seguranca").value.length <1) )
				document.forms[formulario].submit();
			else
				if (obrigatorio!="sim")
					alert("Forneça um e-mail válido ou deixe em branco.");
				else	
					alert("O campo e-mail é obrigatório.");
		}
		if ((mail.length ==0) && (obrigatorio!="sim") && (document.getElementById("seguranca").value.length <1))
			document.forms[formulario].submit();
}

function limpar(el){
document.getElementById(el).value="";
}

function regerar(){
	var nome_figura=document.getElementById("nome_figura");
	var randomNumber=1 + Math.floor(Math.random()*19);
	nome_figura.src="figuras/" + randomNumber + ".jpg";
	document.getElementById("figura_gerada").value=randomNumber;
}

function paginacao(caminho,formulario){
	if (caminho=="continuar"){
		document.getElementById(formulario).action="busca_02.asp";
	}
	document.forms[formulario].submit();
}

function verifica_tamanho(nome){
var tam=document.getElementById('titulo').value.lenght;
if (tam<3)
	alert('mínimo de 3 letras para a busca');
else
	document.forms[nome].submit();		
}


function mostraMensagem(){
	document.getElementById('mensagem_humana').style.display='block';
}

function escondeMensagem(){
	document.getElementById('mensagem_humana').style.display='none';
}
