//####################################################################################

function click() {
if (event.button==2||event.button==3) {
 oncontextmenu='return false';
  }
}
document.onmousedown=click
document.oncontextmenu = new Function("return false;")

//####################################################################################

function abrirchat(URL) {
   var larg = screen.width 
   var alt = screen.height 
   var res = (larg+'x'+alt) 
   
   if (res == "800x600") {                   
     var width = 790;
     var height = 535;
   } 
   else {
     var width = 1015;
     var height = 702;
   }

   var left = 0;
   var top = 0;
   window.open(URL,'Chat', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');    
}

//####################################################################################

function popup(URL, nome, largura, altura, scroll) {

   var width = largura;
   var height = altura;
   var scroll = scroll;
   var left = 230;
   var top = (screen.height - height)/2;

   window.open(URL,nome, 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars='+scroll+', status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}

function flash_popup(arquivo, largura, altura, topdist, leftdist) {

   var objeto = arquivo;
   var width = largura;
   var height = altura;
   var left = leftdist;//(screen.width - width)/2;
   var top = topdist; //((screen.height - height)/2) - 30;
   
   if((navigator.appName=="Microsoft Internet Explorer")&& (parseInt(navigator.appVersion) >= 4 )){

     document.write('<DIV id=social style="Z-INDEX: 28; LEFT: '+left+'px; POSITION: absolute; TOP: '+top+'px">');
     document.write('<OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0 height='+height+' width='+width+' classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000>');
     document.write('<PARAM NAME="movie" VALUE="'+objeto+'">');
     document.write('<PARAM NAME="quality" VALUE="high">');
     document.write('<PARAM NAME="wmode" VALUE="transparent">');
     document.write('<embed src="'+objeto+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" height='+height+' width='+width+'></embed>');
     document.write('</OBJECT>');
     document.write('</DIV>');
   
   }else{
   
     window.open('javascript/popup.php?arquivo='+objeto+'&width='+width+'&height='+height+'', 'POPUP', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
   
   }

}

function floatbanner(arquivo, largura, altura, topdist, leftdist) {
   var objeto = arquivo;
   var width = largura;
   var height = altura;
   var left = leftdist;//(screen.width - width)/2;
   var top = topdist;//((screen.height - height)/2) - 30;
   //if((navigator.appName=="Microsoft Internet Explorer")&& (parseInt(navigator.appVersion) >= 4 )){
     document.write('<DIV id="floatbanner" style="Z-INDEX: 50; LEFT: '+left+'; POSITION: absolute; TOP: '+top+'; visibility: show;">');
     document.write('<OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0 height='+height+' width='+width+' classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000>');
     document.write('<PARAM NAME="movie" VALUE="'+objeto+'">');
     document.write('<PARAM NAME="quality" VALUE="high">');
     document.write('<PARAM NAME="wmode" VALUE="transparent">');
     document.write('<embed src="'+objeto+'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" height='+height+' width='+width+'></embed>');
     document.write('</OBJECT>');
     document.write('</DIV>');
   //}else{
   //  window.open('javascript/popup.php?arquivo='+objeto+'&width='+width+'&height='+height+'', 'POPUP', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
   //}
}
function fechafloatbanner(){
  document.getElementById("floatbanner").style.visibility='hidden';
}

function ap(){
  document.getElementById("floatbanner").style.visibility='hidden';
}

//function OASFechar(){
  //document.getElementById("floatbanner").style.visibility='hidden';
//}

//####################################################################################

function statuss() {
window.status = ".:: Jornal dos Sports :: O melhor do esporte também na internet ::.";
setTimeout("statuss()", 10); 
}
statuss();

//####################################################################################

function data(){
var now = new Date();
var mName = now.getMonth() + 1;
var dName = now.getDay() + 1;
var dayNr = now.getDate();
var yearNr = now.getYear();
var yearNrx = now.getYear();
if(dName==1) Day = "Domingo";
if(dName==2) Day = "Segunda";
if(dName==3) Day = "Terça-feira";
if(dName==4) Day = "Quarta-feira";
if(dName==5) Day = "Quinta-feira";
if(dName==6) Day = "Sexta-feira";
if(dName==7) Day = "Sábado";
if(mName==1) mes = "Janeiro";
if(mName==2) mes = "Fevereiro";
if(mName==3) mes = "Março";
if(mName==4) mes = "Abril";
if(mName==5) mes = "Maio";
if(mName==6) mes = "Junho";
if(mName==7) mes = "Julho";
if(mName==8) mes = "Agosto";
if(mName==9) mes = "Setembro";
if(mName==10) mes = "Outubro";
if(mName==11) mes = "Novembro";
if(mName==12) mes = "Dezembro";
if(yearNr < 2000) Year = 1900 + yearNr;
else Year = yearNr;
var hoje =(Day + ", " + dayNr + " de " + mes + " de " + Year + ".");
return hoje;
}

//####################################################################################

function ativo(src, cor) {
  if (!src.contains(event.fromElement)) {
    src.bgColor = cor;
  }
}
function inativo(src, cor) {
  if (!src.contains(event.toElement)) {
    src.bgColor = cor;
  }
}

//####################################################################################

function Refresh(url) {
  opener.location.href = url;
} 

//####################################################################################

function fechar() {
  window.close();
}

//####################################################################################

function toprincipal(){
  location.href = 'processa.php?modulo=principal';
}

//####################################################################################

function delay(funcao, time) {
setTimeout(funcao, time); 
}

//####################################################################################

function refreshNews() {
  if(window.close){
    opener.location.href = "../?modulo=principal";
    setTimeout("fechar()", 3000); 
  }
}

//####################################################################################

function votarEnquete(x, y){
  var i 
  var v 
  for (i=0;i<document.enquete.resposta.length;i++){ 
    if (document.enquete.resposta[i].checked) {
      v = 1
      break; 
    }else {
      v = 0
    }
  } 
  if(v == 1){
    popup('includes/parciais.php?idpergunta='+document.enquete.idpergunta.value+'&idresposta='+document.enquete.resposta[i].value+'', "PARCIAIS", 200, 300, 'yes');
    document.enquete.reset()
    return false;
  }else{
    alert ('Por favor, selecione uma opção.');
    return false;
  }
}
function votarEnqueteInterna(x, y){
  var i 
  var v 
  for (i=0;i<document.enqueteinterna.resposta.length;i++){ 
    if (document.enqueteinterna.resposta[i].checked) {
      v = 1
      break; 
    }else {
      v = 0
    }
  } 
  if(v == 1){
    popup('includes/parciaisinterna.php?idsecao='+document.enqueteinterna.idsecao.value+'&idpergunta='+document.enqueteinterna.idpergunta.value+'&idresposta='+document.enqueteinterna.resposta[i].value+'', "PARCIAISINTERNA", 200, 300, 'yes');
    document.enqueteinterna.reset()
    return false;
  }else{
    alert ('Por favor, selecione uma opção.');
    return false;
  }
}
function verParciais(x, y){
    popup('includes/parciais.php?idpergunta='+document.enquete.idpergunta.value+'', 'PARCIAIS', 200, 300, 'yes');
}
function verParciaisInterna(x, y){
    popup('includes/parciaisinterna.php?idpergunta='+document.enqueteinterna.idpergunta.value+'', 'PARCIAISINTERNA', 200, 300, 'yes');
}
function verUltima(x, y){
    var id = document.enquete.idpergunta.value - 1
    popup('includes/resultado.php?idpergunta='+id+'', 'RESULTADO', 200, 300, 'yes');
}
function verUltimaInterna(x, y){
    var id = document.enqueteinterna.idperguntaant.value
    popup('includes/resultadointerna.php?idpergunta='+id+'', 'RESULTADOINTERNA', 200, 300, 'yes');
}

//####################################################################################

function cadmailnews(){
  window.open('includes/cadastranews.php?email='+document.newsletter.email.value,'CADASTRANEWS','resizable=no,width=220,height=240,scrollbars=no');
  document.newsletter.reset()
}
function limpanews() {
  document.newsletter.email.value=''
}

//####################################################################################


function MsgAlert(msg){
  var titulo = ':::::::::::::::::::: SISTEMA ADMINISTRATIVO JS ::::::::::::::::::::\n\n'               
  alert(titulo+msg);           
}

function validaContato(){
    var error = 0 
    if (document.contato.nome.value.length == 0 || document.contato.nome.value.indexOf (' ',0) == -1 ) {
      alert('Por favor, informe o seu nome completo.');
	  document.contato.nome.select();
      document.contato.nome.focus();
      error = 1
      return false;
    }
    if (document.contato.email.value.indexOf ('@',0) == -1 || document.contato.email.value.indexOf ('.',0) == -1) {
      alert ('Por favor, preencha seu e-mail corretamente.');
      document.contato.email.select();
      document.contato.email.focus();
      error = 1
      return false;
    }
    if (document.contato.assunto.value.length == 0) {
      alert('Por favor, informe o assunto da mensagem.');
      document.contato.assunto.focus();
      error = 1
      return false;
    } 
    if (document.contato.assjsonline[0].checked!=true && document.contato.assjsonline[1].checked!=true) {
      alert('Por favor, marque se você é ou não é assinante do JS.');
      error = 1
      return false;
    }	   
    if (document.contato.mensagem.value.length == 0) {
      alert('Por favor, digite a sua mensagem.');
	  document.contato.mensagem.select();
      document.contato.mensagem.focus();
      error = 1
      return false;
    }
    if ( error == 0) {
	  return true;
	}
}

//####################################################################################

// OBJETO DE VERIFICAÇÃO DE DADOS
var regra = new Object();
// REGRA PARA VALIDAR O EMAIL
regra.email = /^([._-]?[0-9a-zA-Z]+)([._-]([0-9a-zA-Z]+)?)*[@]([0-9a-zA-Z]+)([._-]([0-9a-zA-Z]+))*[.]([a-zA-Z]){2,3}([0-9a-zA-Z])?$/; 
// REGRA PARA VALIDAR A SENHA
regra.senha = /^[a-z0-9]{0,8}$/;
// REGRA PARA VALIDAR O NOME COMPLETO
regra.nome = /^([A-Za-zÁÉÍÓÚÂÊÔáéíóúâêôÃãçÇ]+)([ ]+)([A-Za-zÁÉÍÓÚÂÊÔáéíóúâêôÃãçÇ]+)(([ ]+)([A-Za-zÁÉÍÓÚÂÊÔáéíóúâêôÃçÇã ]+))?$/;
// REGRA PARA VALIDAR MENSAGENS
regra.mensagem = /^([A-Za-zÁÉÍÓÚÂÊÔáéíóúâêôÃãçÇ0-9$%@!?,\(\)/]+)([ ]+)?$/;
// REGRA PARA VALIDAR O ENDEREÇO
regra.endereco = /^([0-9A-Za-zÁÉÍÓÚÂÊÔáéíóúâêôÃãçÇ,-]+)(([ ]+)([0-9A-Za-zÁÉÍÓÚÂÊÔáçÇéíóúâêôÃã ,-]+))?$/;
// REGRA PARA VALIDAR O COMPLEMENTO
regra.complemento = /^([0-9A-Za-zÁÉÍÓÚÂÊÔáéíóúâêçÇôÃã ,-]+)?$/;
// REGRA PARA VALIDAR O NÚMERO DA RESIDÊNCIA
regra.numerores = /^([0-9A-Za-z]+)(([ ]+)([0-9A-Za-z]+))?$/;
// REGRA PARA VALIDAR O BAIRRO
regra.bairro = /^([0-9A-Za-zÁÉÍÓÚÂÊÔáéíóçÇúâêôÃã,-]+)(([ ]+)([0-9A-Za-zÁÉÍÓÚÂÊÔáéíçÇóúâêôÃã ,-]+))?$/;
// REGRA PARA VALIDAR A CIDADE
regra.cidade = /^([0-9A-Za-zÁÉÍÓÚÂÊÔáéíóúâêôÃçÇã,-]+)(([ ]+)([0-9A-Za-zÁÉÍÓÚÂÊÔáéçÇíóúâêôÃã ,-]+))?$/;
// REGRA PARA VALIDAR O CEP
regra.cep = /^[0-9]{5}-[0-9]{3}$/i;
// REGRA PARA VALIDAR O TELEFONE
regra.telefone = /^[0-9]{4}-[0-9]{4}$/i;

function valida(string, tipo){
   var expreg = regra[tipo];
   var ver = expreg.exec(string);
   if(ver){ return true; }else{ return false; }
}

function validaCadastro(){ 
    var error = 0 
    if (document.cadastro.email.value.length == 0) {
      MsgAlert('O e-mail deve ser preenchido.');
      document.cadastro.email.select();
      document.cadastro.email.focus();
      error = 1
      return false;
    }else{
	  if(valida(document.cadastro.email.value, 'email')==false){
        MsgAlert('O email deve ser preenchido no formato válido. \nExemplo: usuario@dominio.com');
        document.cadastro.email.select();
        document.cadastro.email.focus();
        error = 1
		return false;	  
	  }    	  
	}       
    if (document.cadastro.confirmaemail.value.length == 0) {
      MsgAlert('A confirmação do e-mail deve ser preenchido.');
      document.cadastro.confirmaemail.select();
      document.cadastro.confirmaemail.focus();
      error = 1
      return false;
    }else{  	        
      if (document.cadastro.email.value != document.cadastro.confirmaemail.value) {
        MsgAlert('O e-mail e a sua confirmação não são idênticos. \nPor favor digite novamente.');
        document.cadastro.confirmaemail.select();
        document.cadastro.confirmaemail.focus();
        error = 1
        return false;
      }
    }
    if (document.cadastro.senha.value.length == 0) {
      MsgAlert('A senha deve ser preenchida.');
      document.cadastro.senha.select();
      document.cadastro.senha.focus();
      error = 1
      return false;
    }else{
      if (document.cadastro.senha.value.length < 4 || document.cadastro.senha.value.length > 8) {
	    MsgAlert('A senha precisa ter no mínimo quatro e no máximo oito caracteres.');
        document.cadastro.senha.select();
        document.cadastro.senha.focus();
        error = 1
	    return false;
      }    
	  if(valida(document.cadastro.senha.value, 'senha')==false){
        MsgAlert('A senha deve conter apenas letras minúsculas e/ou números.');
        document.cadastro.senha.select();
        document.cadastro.senha.focus();
        error = 1
		return false;	  
	  }
    }
    if (document.cadastro.confirmasenha.value.length == 0) {
      MsgAlert('A confirmação da senha deve ser preenchida.');
      document.cadastro.confirmasenha.select();
      document.cadastro.confirmasenha.focus();
      error = 1
      return false;
    }else{	         
      if (document.cadastro.senha.value != document.cadastro.confirmasenha.value) {
        MsgAlert('A senha e a sua confirmação não são idênticas. \nPor favor digite novamente.');
        document.cadastro.confirmasenha.select();
        document.cadastro.confirmasenha.focus();
        error = 1
        return false;
      }
    }
    if (document.cadastro.nome.value.length == 0) {
      MsgAlert('O nome completo deve ser preenchido.');
	  document.cadastro.nome.select();
      document.cadastro.nome.focus();
      error = 1
      return false;
    }else{
	  if(valida(document.cadastro.nome.value, 'nome')==false){
        MsgAlert('Seu nome não está completo ou possui caracteres inválidos.');
        document.cadastro.nome.select();
        document.cadastro.nome.focus();
        error = 1
		return false;	  
	  }    
    }
    if (document.cadastro.nascdia.options[document.cadastro.nascdia.selectedIndex].value=='null') {
	  MsgAlert('Por favor, selecione o dia do seu nascimento.');
      document.cadastro.nascdia.focus();
      error = 1
	  return false;
    }
    if (document.cadastro.nascmes.options[document.cadastro.nascmes.selectedIndex].value=='null') {
	  MsgAlert('Por favor, selecione o mês do seu nascimento.');
      document.cadastro.nascmes.focus();
      error = 1
	  return false;
    }
    if (document.cadastro.nascano.options[document.cadastro.nascano.selectedIndex].value=='null') {
	  MsgAlert('Por favor, selecione o ano do seu nascimento.');
      document.cadastro.nascano.focus();
      error = 1
	  return false;
    }
    if (document.cadastro.estadocivil.options[document.cadastro.estadocivil.selectedIndex].value.length == 0) {
      MsgAlert('Por favor, selecione o seu estado civil.');
      document.cadastro.estadocivil.focus();
      error = 1
      return false;
    } 
    if (document.cadastro.sexo[0].checked!=true && document.cadastro.sexo[1].checked!=true) {
      MsgAlert('Por favor, selecione o seu sexo.');
      error = 1
      return false;
    }  
    if (document.cadastro.endereco.value.length == 0) {
      MsgAlert('Por favor, informe o endereço onde se localiza a sua residência.');
	  document.cadastro.endereco.select();
      document.cadastro.endereco.focus();
      error = 1
      return false;
    }else{		  
      if (valida(document.cadastro.endereco.value, 'endereco')==false) {
        MsgAlert('O endereço está preenchido incorretamente ou possui caracteres inválidos.');
	    document.cadastro.endereco.select();
        document.cadastro.endereco.focus();
        error = 1
        return false;
      }
    }
    if (document.cadastro.numero.value.length == 0) {
      MsgAlert('Por favor, informe o número da sua residência.');
	  document.cadastro.numero.select();
      document.cadastro.numero.focus();
      error = 1
      return false;
    }else{		  
      if (valida(document.cadastro.numero.value, 'numerores')==false) {
        MsgAlert('No número da residêcia deve conter apenas letras e/ou números.');
	    document.cadastro.numero.select();
        document.cadastro.numero.focus();
        error = 1
        return false;
      }
    }
    if (document.cadastro.complemento.value.length > 0) {	  
      if (valida(document.cadastro.complemento.value, 'complemento')==false) {
        MsgAlert('O complemento possui caracteres inválidos.');
	    document.cadastro.complemento.select();
        document.cadastro.complemento.focus();
        error = 1
        return false;
      }
    }    
    if (document.cadastro.bairro.value.length == 0) {
      MsgAlert('Por favor, informe o bairro onde se localiza a sua residência.');
	  document.cadastro.bairro.select();
      document.cadastro.bairro.focus();
      error = 1
      return false;
    }else{		  
      if (valida(document.cadastro.bairro.value, 'bairro')==false) {
        MsgAlert('O bairro está preenchido incorretamente ou possui caracteres inválidos.');
	    document.cadastro.bairro.select();
        document.cadastro.bairro.focus();
        error = 1
        return false;
      }
    }
    if (document.cadastro.cidade.value.length == 0) {
      MsgAlert('Por favor, informe a cidade onde se localiza o seu bairro.');
	  document.cadastro.cidade.select();
      document.cadastro.cidade.focus();
      error = 1
      return false;
    }else{		  
      if (valida(document.cadastro.cidade.value, 'cidade')==false) {
        MsgAlert('A cidade está preenchida incorretamente ou possui caracteres inválidos.');
	    document.cadastro.cidade.select();
        document.cadastro.cidade.focus();
        error = 1
        return false;
      }
    }   
    if (document.cadastro.estado.options[document.cadastro.estado.selectedIndex].value.length == 0) {
      MsgAlert('Por favor, selecione o Estado onde se localiza a sua cidade.');
      document.cadastro.estado.focus();
      error = 1
      return false;
    } 
    if (document.cadastro.cep.value.length == 0) {
      MsgAlert('Por favor, informe o Código de Endereçamento Postal (CEP).');
      document.cadastro.cep.select();
      document.cadastro.cep.focus();     
      error = 1
      return false;
    }else{		  
      if (valida(document.cadastro.cep.value, 'cep')==false) {
        MsgAlert('O CEP está preenchido incorretamente ou possui caracteres inválidos. \nFormato: xxxxx-xxx');
	    document.cadastro.cep.select();
        document.cadastro.cep.focus();
        error = 1
        return false;
      }
    }   
    if (document.cadastro.comprajornal.options[document.cadastro.comprajornal.selectedIndex].value.length == 0) {
      MsgAlert('Por favor, responda se é leitor do Jornal dos Sports impresso.');
      document.cadastro.comprajornal.focus();
      error = 1
      return false;
    }    
    if (document.cadastro.frequecompra.options[document.cadastro.frequecompra.selectedIndex].value.length == 0) {
      MsgAlert('Por favor, responda com que frequência ler o Jornal dos Sports impresso.');
      document.cadastro.frequecompra.focus();
      error = 1
      return false;
    }     
    if (document.cadastro.comprainternet.options[document.cadastro.comprainternet.selectedIndex].value.length == 0) {
      MsgAlert('Por favor, responda se você já comprou na internet.');
      document.cadastro.comprainternet.focus();
      error = 1
      return false;
    }
	if(document.cadastro.tipoproduto.options[document.cadastro.tipoproduto.selectedIndex].value == 0 ){   
      MsgAlert('Por favor, responda que tipo de produto você já comprou na internet.');
      document.cadastro.tipoproduto.focus();
      error = 1
      return false;
	}   
    if (document.cadastro.timefavorito.options[document.cadastro.timefavorito.selectedIndex].value.length == 0) {
      MsgAlert('Por favor, responda qual o seu time favorito.');
      document.cadastro.timefavorito.focus();
      error = 1
      return false;
    }     
    if (document.cadastro.esportefavorito.options[document.cadastro.esportefavorito.selectedIndex].value.length == 0) {
      MsgAlert('Por favor, responda qual o seu esporte favorito.');
      document.cadastro.esportefavorito.focus();
      error = 1
      return false;
    }     
    if ( error == 0) {
	  return true;
	}
}

function validaLogin(){
    var error = 0 
    if (document.login.email.value.length == 0) {
      MsgAlert('O e-mail deve ser preenchido.');
      document.login.email.select();
      document.login.email.focus();
      error = 1
      return false;
    }else{
	  if(valida(document.login.email.value, 'email')==false){
        MsgAlert('O email deve ser preenchido no formato válido. \nExemplo: usuario@dominio.com');
        document.login.email.select();
        document.login.email.focus();
        error = 1
		return false;	  
	  }    	  
	}    
    if (document.login.senha.value.length > 0) {
	  if(valida(document.login.senha.value, 'senha')==false){
        MsgAlert('A senha deve conter apenas letras minúsculas e/ou números.');
        document.login.senha.select();
        document.login.senha.focus();
        error = 1
		return false;	  
	  }    	  
	} 
    if ( error == 0) {
	  return true;
	}
}
function validaEmailNews(){
    var error = 0 
	if(valida(document.newsletter.email.value, 'email')==false){
      alert ('O email deve ser preenchido no formato válido (usuario@dominio.com).');
      MsgAlert('O email deve ser preenchido no formato válido. \nExemplo: usuario@dominio.com');
      document.newsletter.email.select();
      document.newsletter.email.focus();
      error = 1
	  return false;	  
	}      
    if ( error == 0) {
	  return true;
	}
}
function validaCadNews(){
    var error = 0 
    if (document.cadnews.nome.value.length == 0) {
      MsgAlert('O nome deve ser preenchido.');
	  document.cadnews.nome.select();
      document.cadnews.nome.focus();
      error = 1
      return false;
    }else{
	  if(valida(document.cadnews.nome.value, 'nome')==false){
        MsgAlert('Seu nome não está completo ou possui caracteres inválidos.');
        document.cadnews.nome.select();
        document.cadnews.nome.focus();
        error = 1
		return false;	  
	  }    
    }    
    if (document.cadnews.email.value.length == 0) {
      MsgAlert('O e-mail deve ser preenchido.');
      document.cadnews.email.select();
      document.cadnews.email.focus();
      error = 1
      return false;
    }else{
	  if(valida(document.cadnews.email.value, 'email')==false){
        MsgAlert('O email deve ser preenchido no formato válido. \nExemplo: usuario@dominio.com');
        document.cadnews.email.select();
        document.cadnews.email.focus();
        error = 1
		return false;	  
	  }    	  
	}     
    if (document.cadnews.time.options[document.cadnews.time.selectedIndex].value.length == 0) {
      MsgAlert('Por favor, selecione o seu time favorito.');
      document.cadnews.time.focus();
      error = 1
      return false;
    } 
    if ( error == 0) {
	  return true;
	}
}





function validaEnviarMateria(){
    var error = 0 
    if (document.enviarmateria.nome.value.length == 0) {
      alert('Por favor, informe o seu nome.');
	  document.enviarmateria.nome.select();
      document.enviarmateria.nome.focus();
      error = 1
      return false;
    }
    if (document.enviarmateria.email.value.indexOf ('@',0) == -1 || document.enviarmateria.email.value.indexOf ('.',0) == -1  || document.enviarmateria.email.value.indexOf (';',0) == 1 || document.enviarmateria.email.value.indexOf (',',0) == 1) {
      alert ('Por favor, informe seu e-mail corretamente.');
      document.enviarmateria.email.select();
      document.enviarmateria.email.focus();
      error = 1
      return false;
    }
    if (document.enviarmateria.destinome.value.length == 0) {
      alert('Por favor, informe o nome do seu amigo.');
	  document.enviarmateria.destinome.select();
      document.enviarmateria.destinome.focus();
      error = 1
      return false;
    }
    if (document.enviarmateria.destiemail.value.indexOf ('@',0) == -1 || document.enviarmateria.destiemail.value.indexOf ('.',0) == -1  || document.enviarmateria.destiemail.value.indexOf (';',0) == 1 || document.enviarmateria.destiemail.value.indexOf (',',0) == 1) {
      alert ('Por favor, informe o e-mail do seu amigo corretamente.');
      document.enviarmateria.destiemail.select();
      document.enviarmateria.destiemail.focus();
      error = 1
      return false;
    }     
    if ( error == 0) {
	  return true;
	}
}

function printFlashElement(swf, width, height, posx, posy){
  document.write('<DIV style="Z-INDEX: 100; POSITION: absolute; LEFT: '+posx+'px; TOP: '+posy+'px; visibility: visible;">');
  document.write('<OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0 width="'+width+'" height="'+height+'" classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000>');
  document.write('<PARAM NAME="movie" VALUE="'+swf+'">');
  document.write('<PARAM NAME="quality" VALUE="high">');
  document.write('<PARAM NAME="wmode" VALUE="transparent">');
  document.write('<embed src="'+swf+'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"  width="'+width+'" height="'+height+'"></embed>');
  document.write('</OBJECT>');
  document.write('</DIV>');
}

function lerCookie(name){
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0){
    offset = document.cookie.indexOf(search);
    if(offset != -1){
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if(end == -1) end = document.cookie.length;
        cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

function servUser(){
  var login = lerCookie("user[email]");
  if(login.length > 0){
    document.write('<FONT CLASS="texto"><B><A HREF="processa.php?modulo=meucadastro" CLASS="link">Meu Cadastro</A> | <A HREF="logout.php" CLASS="link">Logout</A> &nbsp;</B></FONT><BR>');
  }else{
    document.write('<FONT CLASS="texto"><B><A HREF="processa.php?modulo=cadastro" CLASS="link">Cadastre-se</A> | <A HREF="processa.php?modulo=login" CLASS="link">Login</A> &nbsp;</B></FONT><BR>');
  }
}

function linkCad(){
  var login = lerCookie("user[email]");
  if(login.length > 0){
    document.write('<FONT CLASS="texto"><B><A HREF="processa.php?modulo=meucadastro" CLASS="link">Meu Cadastro</A></FONT>');
  }else{
    document.write('<FONT CLASS="texto"><B><A HREF="processa.php?modulo=cadastro" CLASS="link">Cadastre-se</A></FONT>');
  }
}

function limpa_campo_busca() {
	if (document.getElementsById("buscar").value == "Buscar...") {
		document.getElementsById("buscar").value = "";
	}
}

function trim(str){
	str=str.replace(/\s+/g," ");
	str=str.replace(/^ /,"");
	str=str.replace(/ $/,"");
	return str;
}

function valida_busca() {
	var texto = trim(document.getElementById("buscar").value);
	if (texto == "" || texto == "Buscar...") {
		alert("POR FAVOR, DIGITE O TEXTO A SER PESQUISADO");
		document.getElementById("buscar").value = "";
		document.getElementById("buscar").focus();
	} else {
		location.href("processa.php?modulo=showresultados&buscar="+texto);
	}
}
