// JavaScript Document
// valida cadastro de frases


function VerificaCaracteres(caracter) {

	if(window.event) { // Internet Explorer
  	var tecla = event.keyCode;
 	}
 	else { // Firefox
  	var tecla = caracter.which;
 	}

 	if((tecla == 35) || (tecla == 60) || (tecla == 62) || (tecla == 92) || (tecla == 124) || (tecla == 47)) { 
  	alert("Você não pode usar esse caracter");
  	return false;
 	}
 	else 
 	{ 
 		return true; 
 	}
}

	
//funçao onblur para exibir o aviso	de erro				
function erro(){
		if (document.form1.text_nome.value.length < 3){
			if(document.getElementById('conteudo').style.display=="none") {
				document.getElementById('conteudo').style.display = "inline";}
			document.getElementById('conteudo').innerHTML= "Este campo deve ser preenchido com mais de 3 letras";
			document.getElementById('conteudo').style.background="red";
			document.getElementById('txtHint').style.visibility	='hidden';
			document.form1.text_nome.value = "";
			document.form1.text_nome.value.focus();
			return false;}		
}
//funçao onfocus para exibir o aviso	de exemplo						
function exibe() {
	if(document.getElementById('conteudo').style.display=="none") {
		document.getElementById('conteudo').style.display = "inline";
	}
	else {document.getElementById('conteudo').innerHTML="(ex: Huxley, Aldous Leonard)";
		document.getElementById('conteudo').style.background="";}
}
//funçao onChange para ocultar o aviso	de exemplo
function esconde(){document.getElementById('conteudo').innerHTML="";
}

//funçao onfocus para exibir o aviso	de exemplo						
function exibe_ref() {
	if(document.getElementById('ref').style.display=="none") {
		document.getElementById('ref').style.display = "inline";
	}
	else {document.getElementById('ref').innerHTML="(ex: filosofo inglês (1894 - 1963))";
		document.getElementById('ref').style.background="";}
}
//funçao onChange para ocultar o aviso	de exemplo
function esconde_ref(){document.getElementById('ref').innerHTML="";}

//funçao onfocus para exibir o aviso	de exemplo						
function exibe_bib() {
	if(document.getElementById('bib').style.display=="none") {
		document.getElementById('bib').style.display = "inline";
		document.getElementById('bib2').style.display = "inline";
	}
	else {document.getElementById('bib').innerHTML="(obra, página)";
			document.getElementById('bib2').innerHTML="(obra, página)";
			document.getElementById('bib').style.background="yelow";
			document.getElementById('bib2').style.background="yelow";}
}
//funçao onChange para ocultar o aviso	de exemplo
function esconde_bib(){document.getElementById('bib').innerHTML="";}
//abrea popup detalhe card
function WinOpen() {
       msg=open("detalhe_card.php","DisplayWindow","toolbar=no,directories=no,scrollbars=no,menubar=no,width=810,height=610");
     }
// abre  popup busca
function WinOpen2() {
       msg=open("TABELA_DE_CORES.html","DisplayWindow","toolbar=no,directories=no,scrollbars=no,menubar=no,lovation=no,status=no,width=520,height=100");
     }
	//busca envia para a pagina do autor
function consulta(cod){
	with (document.form1){
	hiddenField.value= cod;
	}
	document.form1.submit();
}

function display_frase(cod,frase) {
	// passa a frase para o formulario
	window.parent.document.form1.frase_cod.value= cod;
	window.parent.document.form1.frase.value= frase;
}
function display_bak(bak){
	//passa o bakbroud para o formulario
	window.parent.document.form1.bak.value = bak;
	window.parent.document.getElementById('bak_div').innerHTML = "<img src='lad/lad_"+bak+".jpg'>";
	window.parent.parent.document.getElementById('baktab').style.background = 'url(lad/lad_'+bak+'.jpg)';
}
function mostra_bak(){
	window.parent.document.getElementById('bakdiv').style.display='inline-block';	
	window.parent.parent.document.getElementById('escudo').appear({duration: 2.0});
	}
function display_foto(pasta,foto){
	//passa o bakbroud para o formulario
	window.parent.document.form1.pasta.value = pasta;
	window.parent.document.form1.foto.value = foto;
	window.parent.document.getElementById('amostra').innerHTML="<img src='foto/"+pasta+"/"+foto+"_2.jpg'>";
	window.parent.parent.document.getElementById('foto_div').style.background="url(../card/foto/"+pasta+"/"+foto+".jpg)";
}	
function mostra_foto(){
	window.parent.document.getElementById('foto_div').style.display='inline-block';
	window.parent.parent.document.getElementById('escudo').appear({duration: 2.0});	
	}
//"<img src='foto/"+pasta+"/"+foto+".jpg'>";
function card(){
	dn = document.form1
	var foto 		= dn.foto.value;
	var pasta 		= dn.pasta.value;
	var frase		= dn.frase_cod.value;
	
	if (document.getElementById("fonte_0").checked)
	{fonte = 'serif'}
	if (document.getElementById("fonte_1").checked)
	{fonte = 'sans-serif'}
	if (document.getElementById("fonte_2").checked)
	{fonte = 'monospace'}
	if (document.getElementById("fonte_3").checked)
	{fonte = 'cursive'}
	if (document.getElementById("fonte_4").checked)
	{fonte = 'fantasy'}
	
	if (document.getElementById("size_0").checked)
	{size = 'x-small'}
	if (document.getElementById("size_1").checked)
	{size = 'small'}
	if (document.getElementById("size_2").checked)
	{size = 'medium'}
	if (document.getElementById("size_3").checked)
	{size = 'large'}
	if (document.getElementById("size_4").checked)
	{size = 'x-large'}
	
	var cor_fonte	= dn.cor_fonte.value;	
	var cor_fundo	= dn.cor_fundo.value;
	var cor_borda	= dn.cor_borda.value;
	var bak			= dn.bak.value;
cartao=window.open
("card.php?foto="+foto+"&pasta="+pasta+"&frase_cod="+frase+"&bak="+bak+"&cor_fonte="+cor_fonte+"&cor_fundo="+cor_fundo+"&cor_borda="+cor_borda+"&fonte="+fonte+"&size="+size,"","toolbar=no,directories=no,scrollbars=no,menubar=no,width=820,height=630");
	window
}
function display_card(){
	card()}
function edit_frase(cod){
		with (document.edit_form){
	edit.value= cod;
	}
	document.edit_form.submit();
}
function exclui(cod){
with (document.form2) {
hiddenField2.value= cod;
}
conf=window.confirm("Tem certeza que deseja excluir esta frase "+cod+"?")
if(conf == 1){
document.form2.submit();}
}
function detalhe_card(){
	msg=open("detalhe_card.php","DisplayWindow","toolbar=no,directories=no,scrollbars=no,menubar=no,width=810,height=610"); ;menu.action(menu.currentButton);}

	
	
	function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}