/* ************************************************************************** */
/*    F U N C O E S    B L O G                                                */
/* ************************************************************************** */

function abaFotos(item) {
	document.getElementById("itemFoto").style.display = "none";
	document.getElementById("itemBau").style.display = "none";
	document.getElementById("itemVideo").style.display = "none";
	document.getElementById(item).style.display = "block";
}


/* EFEITO ROLAGEM -----------------------------------------*/
var rolagem;
function rolagemDireita() {
   var c = document.getElementById("menuRolagem");
   var maximo = c.scrollWidth;
   c.scrollLeft = c.scrollLeft + 10;
   if (c.scrollLeft >= maximo) {
     exit();
   }else{
     rolagem = setTimeout("rolagemDireita()",50);
   }  
}

function rolagemEsquerda() {
   var c = document.getElementById("menuRolagem");
   var maximo = c.scrollWidth;
   c.scrollLeft = c.scrollLeft - 10;
   if (c.scrollRight >= maximo) {
     exit();
   }else{
     rolagem = setTimeout("rolagemEsquerda()",50);
   }  
}  

function rolagemParar() {
 clearTimeout(rolagem);
}


function blocTexto(valor) {
    quant = 2000;
    total = valor.length;
    if(total <= quant) {
        resto = quant - total;
        document.getElementById('cont').innerHTML = resto;
    }else{
        document.getElementById('texto').value = valor.substr(0,quant);
    }
}


function jAbreChat() {
	janela=window.open("chat/index.php","","width=700,height=535,scrollbars=no")
	//interceptacao de erro na abertura da janela
	text = "Se a janela nao estava abrindo\ntalvez seja porque voce tenha um\nprograma bloqueador de pop-up!\nObservacao » O windows XP service pack 2\nbloqueia pop-ups!";
	if(janela == null) { alert(text); return; }
	//fim
	janela.moveTo(100,0);
}

function abrePlayer() {
	janela=window.open("som/som_do_minhoca.php","","width=301,height=450,scrollbars=yes")
	//interceptacao de erro na abertura da janela
	text = "Se a janela nao estava abrindo\ntalvez seja porque voce tenha um\nprograma bloqueador de pop-up!\nObservacao » O windows XP service pack 2\nbloqueia pop-ups!";
	if(janela == null) { alert(text); return; }
	//fim
	janela.moveTo(100,50);
}

function abreRadio() {
	janela=window.open("http://www.radioviaonline.com.br/modulos/radio/radio.php","","width=350,height=370,scrollbars=yes")
	//interceptacao de erro na abertura da janela
	text = "Se a janela nao estava abrindo\ntalvez seja porque voce tenha um\nprograma bloqueador de pop-up!\nObservacao » O windows XP service pack 2\nbloqueia pop-ups!";
	if(janela == null) { alert(text); return; }
	//fim
	janela.moveTo(100,50);
}

function enviarSenha(formulario){
  retorno = true;
  if ($("form-apelido").value == '') {
    retorno = false;
  }
  
  if (retorno) {  
    parametros = $(formulario).serialize();
    postHTML('esqueci_a_senha',parametros,'ajaxConteudo',0);
  }else{
    alert('Você deve preencher seu Apelido.');
  }
  	 
}

function enviarIndique(formulario){
  retorno = true;
  if ($("form-nome_remetente").value == '') {
    retorno = false;
  }else
  if ($("form-email_remetente").value == '') {
    retorno = false;
  }
  
  if (retorno) {  
    parametros = $(formulario).serialize();
    postHTML('indique',parametros,'ajaxConteudo',0);
  }else{
    alert('Você deve preencher as informações básicas: Seu nome e e-mail e pelo menos um amigo de destino.');
  }
  	 
}


function confirmarInteratividade(formulario,pagina){
  retorno = true;
  if ($("form-titulo").value == '') {
    retorno = false;
  }else
  if ($("form-texto").value == '') {
    retorno = false;
  }
  
  if (retorno) {  
    parametros = $(formulario).serialize();
    postHTML(pagina,parametros,'ajaxConteudo',0);
    alert('Obrigado por contribuir, seu comentário apareceu logo abaixo, assim que aprovado.');
  }else{
    alert('Você deve preencher as informações básicas: Título, Descrição.');
  }
}  	 

function confirmarDicionario(formulario,pagina){
  retorno = true;
  if ($("form-titulo").value == '') {
    retorno = false;
  }else
  if ($("form-texto").value == '') {
    retorno = false;
  }
  
  if (retorno) {  
    parametros = $(formulario).serialize();
    postHTML(pagina,parametros,'ajaxConteudo',0);
    alert('Obrigado por contribuir. Sua sugestão passará por uma aprovação dos moderadores e ficará disponível em breve.');
  }else{
    alert('Você deve preencher as informações básicas: Verbete/Expressão, Descrição.');
  }
}  	 


function confirmarCadastro(formulario){
  retorno = true;
  if ($("form-apelido").value == '') {
    retorno = false;
  }else
  if ($("form-nome").value == '') {
    retorno = false;
  }else
  if ($("form-telefone").value == '') {
    retorno = false;
  }else
  if ($("form-email").value == '') {
    retorno = false;
  }else
  if ($("form-senha1").value == '') {
    retorno = false;
  }
  
  if (retorno) {  
    if ($("form-senha1").value != $("form-senha2").value) {
      alert('As senhas não conferem, por favor repita a digitação.');
      return false;
    }else{
      parametros = $(formulario).serialize();
      postHTML('cadastro_usuario',parametros,'ajaxConteudo',0);
    }
  }else{
    alert('Você deve preencher as informações básicas: Apelido, Nome, Telefone, E-mail e Senha.');
  }
  	 
}


function previewComentario(formulario) {

  if ($("form-comentario").value != '') {
    var texto = $("form-comentario").value;
    while (texto.indexOf('\n')>=0) {
       texto = texto.replace('\n','<br>');
    }
  }else{
    alert('Preencha seu comentário.');
    return false;
  }	 
  
  var mes=new Array(12);
  mes[0]="01";
  mes[1]="02";
  mes[2]="03";
  mes[3]="04";
  mes[4]="05";
  mes[5]="06";
  mes[6]="07";
  mes[7]="08";
  mes[8]="09";
  mes[9]="10";
  mes[10]="11";
  mes[11]="12";  

  var data  = new Date();
  data_dia  = data.getDate();
  data_mes = mes[data.getMonth()];
  data_ano  = data.getFullYear();
  data_hora = data.getHours();
  data_min  = data.getMinutes();

  tag = '<div class="balao comentarios preview">';
  tag = tag + '<p class="msgm_confirmacao">Você ainda não confirmou seu comentário, clique no botão <strong>Enviar comentário</strong></p>';
  tag = tag + '<div class="post_comentarios">';
  tag = tag + '<span>'+data_dia+'/'+data_mes+'/'+data_ano+' <br /> '+data_hora+':'+data_min+'</span><span>';		
	tag = tag + '</div><p class="pessoa">'+$("form-mostrar").value+'</p>';
	tag = tag + '<p><i>'+texto+'</i></p>';
	tag = tag + '<div style="clear:both"></div><span class="rodape_balao rodape_preview"></span>';
  tag = tag + '</div>';
  
  $('ajaxPreview').innerHTML = tag;
}

function confirmarComentario(formulario){

  if ($("form-comentario").value != '') {
    //parametros = 'noticia='+noticia+'&'; 
    //parametros = parametros + $(formulario).serialize();
    //postHTML('noticia',parametros,'ajaxComentarios',0);
    return true;
  }else{
    alert('Antes de enviar, preencha seu comentário.');
    return false;
  }	 
}

function desconectar(pagina,saida){
  postHTML(pagina,'sair=1',saida,1);
}

function logar(formulario,pagina,saida){
  parametros = $(formulario).serialize();
  postHTML(pagina,parametros,saida,1);
}

function mostrar(elemento){
  document.getElementById(elemento).style.display = (document.getElementById(elemento).style.display == 'block' ? 'none' : 'block');
}

function fechar(elemento){
  document.getElementById(elemento).style.display = (document.getElementById(elemento).style.display == 'none' ? 'block' : 'none');
}
