﻿// FUNÇÃO PARA MOSTRAR CAMPO DE CADASTRO PARA NOVA PASTA
function nova_pasta(){
  if (document.getElementById('cb_diretorio').value == "NOVO")
  {
    var nomepasta = document.getElementById('tx_data').value;
	nomepasta = nomepasta.replace("/","");
	nomepasta = nomepasta.replace("/","");
	
	document.getElementById('tx_novodir').value = nomepasta;
	document.getElementById('tx_novodir').style.visibility = "";
	
  } else {
	document.getElementById('tx_novodir').value = "";
	document.getElementById('tx_novodir').style.visibility = "hidden";	
  }

  document.getElementById('div_arquivos').innerHTML = '';
  
}

function novo_destaque(){
  if (document.getElementById('cb_destaques').value == "NOVO")
  {   
	this.location.href = "destaques.php";

  } 
  else if (document.getElementById('cb_destaques').value != "")
  {
	this.location.href = "destaques.php?CODIGO="+document.getElementById('cb_destaques').value;
		
  }
}

function novo_registro(){
  if (document.getElementById('cb_eventos').value == "NOVO")
  {   
	this.location.href = "index.php";

  } 
  else if (document.getElementById('cb_eventos').value != "")
  {
	this.location.href = "index.php?CODIGO="+document.getElementById('cb_eventos').value;
		
  }
}

// VALIDAÇÕES PARA DELETAR EVENTO
function deleta_evento(cod_album) {
	
  resposta = confirm ("Tem certeza que deseja excluir esse evento?!?\nTodos os arquivos relacionados as fotos do mesmo serão excluídos.");

  if (resposta) {
	if ((document.getElementById('cb_diretorio').value != "NOVO") && (document.getElementById('cb_diretorio').value != "")) {
      location.href = "index.php?XEVENTO=" + cod_album + "&XDIR=" + document.getElementById('cb_diretorio').value;
	} else {
      location.href = "index.php?XEVENTO=" + cod_album;		
	}	 
  } 
  
}


// VALIDAÇÕES PARA DELETAR DESTAQUE
function deleta_destaque(cod_album) {
	
  resposta = confirm ("Tem certeza que deseja excluir esse destaque?!?");

  if (resposta) {
    location.href = "destaques.php?XDESTAQUE=" + cod_album;		
  } 
  
}

// VALIDAÇÕES PARA CADASTRO DE NOVO EVENTO
function valida_novo_evento() {
	
	nome = document.getElementById('tx_nome').value;
	if ((nome == ' ') || (nome == ''))
	{
	  alert ("O campo NOME não foi preenchido.");
	  return false;
	}
	
	cidade = document.getElementById('tx_cidade').value;
	if ((cidade == ' ') || (cidade == ''))
	{
	  alert ("Selecione a CIDADE de realização do evento.");
	  return false;
	}
	
	estado = document.getElementById('cb_estado').value;
	if ((estado == ' ') || (estado == ''))
	{
	  alert ("Selecione o ESTADO de realização do evento.");
	  return false;
	}
				
	datacad = document.getElementById('tx_data').value;
	if ((datacad == ' ') || (datacad == ''))
	{
	  alert ("O campo DATA DO EVENTO não foi preenchido.");
	  return false;
	}

	diretorio = document.getElementById('cb_diretorio').value;
	novo_diretorio = document.getElementById('tx_novodir').value;			
	if (diretorio == 'NOVO') {
	  if ((novo_diretorio == ' ') || (novo_diretorio == ''))
	  {
	    alert ("Selecione o nome do NOVO DIRETÓRIO a ser criado.");
	    return false;
		
	  }
	}

	document.form_cadastro.submit();
	
}

// VALIDAÇÕES PARA CADASTRO DE NOVO DESTAQUE
function valida_novo_destaque() {
	
	titulo = document.getElementById('tx_titulo').value;
	if ((titulo == ' ') || (titulo == ''))
	{
	  alert ("O campo TITULO não foi preenchido.");
	  return false;
	}
	
	descricao = document.getElementById('tx_descricao').value;
	if ((descricao == ' ') || (descricao == ''))
	{
	  alert ("O campo DESCRICAO não foi preenchido.");
	  return false;
	}
		
	url = document.getElementById('tx_url').value;
	if ((url == ' ') || (url == ''))
	{
	  alert ("O campo URL não foi preenchido.");
	  return false;
	}
	
	img = document.getElementById('tx_img').value;
	if ((img == '') || (img == ' '))
	{
	  alert ("Selecione uma IMAGEM para cadastro.");
	  return false;
	}	
				
	document.form_cadastro.submit();
	
}


// VALIDAÇÕES PARA CADASTRO DE NOVO EVENTO
function valida_novo_email() {

	nome = document.getElementById('tx_nome').value;
	if ((nome == ' ') || (nome == ''))
	{
	  alert ("O campo NOME não foi preenchido.");
	  return false;
	}
	
	email = document.getElementById('tx_email').value;
	if ((email == ' ') || (email == ''))
	{
	  alert ("Digite o seu E-MAIL para responder sua mensagem.");
	  return false;
	}
    if ( (email.length != 0) && (email.indexOf("@") < 1) )
    {
	  alert ("Digite um E-MAIL correto para responder sua mensagem.");
	  return false;
    }		
	
	assunto = document.getElementById('tx_assunto').value;
	if ((assunto == ' ') || (assunto == ''))
	{
	  alert ("Selecione o ASSUNTO de sua mensagem.");
	  return false;
	}
				
	mensagem = document.getElementById('tx_mensagem').value;
	if ((mensagem == ' ') || (mensagem == ''))
	{
	  alert ("Digite uma MENSAGEM a enviar.");
	  return false;
	}


	document.form_contato.submit();	
}

function mascara(l,m,i){
//l: local do objeto --> this;
//m: máscara;
//i: caractere inicial (posição zero da máscara;

var iCount = l.value.length;

//Digite os símbolos especiais que permanecerão em seus locais corretos:
var simbolosEspeciais = "()/-.";    
    
    if (iCount < m.length) {
         //Verificando se foi passado o parâmetro inicial "i":
        if (iCount == 1 && i != ""){
            l.value = i+l.value;    
        } else {
        
            if (simbolosEspeciais.indexOf(m.substr(iCount,1)) != -1) {
                l.value = l.value+m.substr(iCount,1);
            
                if (m.substr(iCount+1,1) == " ") {
                l.value = l.value+" ";
                }
            }
        
            if (m.substr(iCount,1) == " ") {
                l.value = l.value+" ";
            }
        }

    } else {
        l.value = l.value.substr(0,m.length);
    }
}


// VALIDA CADASTRO DE BANNER
function valida_novo_banner() {
	
	arquivo = document.getElementById('arq_banner').value;
	if ((arquivo == ' ') || (arquivo == ''))
	{
	  alert ("Selecione um ARQUIVO para upload.");
	  return false;
	}
	
	document.form_cadastro.submit();
	
}

// PREVIEW DO CADASTRO DE BANNER
function preview(banner){

  var script = "<table cellspacing='0' width='468px'><tr><td><div align='center'>"+
               "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='468' height='60'>"+
        "<param name='movie' value='../layout/banner/"+banner+"' />"+
        "<param name='quality' value='high' />"+
		"<param name='wmode' value='transparent' />"+
        "<embed src='../layout/banner/"+banner+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='468' height='60' wmode='transparent'></embed>"+
               "</object></div></td></tr></table>";

  document.getElementById('div_preview').innerHTML = script;
  
}

// FUNÇÃO PARA ABERTURA DA VISUALIZAÇÃO DAS FOTOS DO DIRETORIO
function preview_pic(foto, largura, altura){

  var script = "<a href='"+foto+"' target='_blank'><img src='"+foto+"' width='"+(largura/2)+"' height='"+(altura/2)+"' /></a>";
  document.getElementById('div_preview').innerHTML = script;
  
}

// FUNÇÃO PARA ADICIONAR PAGINA AOS FAVORITOS
function addFavoritos(){

    var url      = document.location;
    var title    = document.title;
	
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(url, title);}

}

// FUNÇÃO PARA ABERTURA DA VISUALIZAÇÃO DA PAGINA DE FOTOS 
function open_fotos(){
  
  window.open("http://www.rcgomes.com.br/fotos/index.html", "myWindow", "statusbar=1, scrollbars=0, menubar=0, resizable=0, width=855, height=630");
  
}

// FUNÇÃO PARA ABERTURA DA RADIO TD
function open_radios()
{
  window.open("http://www.trancedownloader.ru/webradio/index.php","wind_radio","statusbar=1, scrollbars=0, menubar=0, resizable=0, width=620, height=400");  
}

// FUNÇÃO PARA ABERTURA DA PAGINA DE CONTATO
function open_contato(){
  
  window.open("http://www.rcgomes.com.br/contato/index.php", "myWindow", "statusbar=1, scrollbars=0, menubar=0, resizable=0, width=620, height=530");
  
}