function radio() {
	url = 'radio.php';
	window.open(url, 'janRadio', 'menubar=no,scrollbars=no,resizable=yes,width=320,height=300');	
};

var menuAtual = 0;
var menuPausado = false;
function menuCat(cat, status) {
	$('#mnu_mostrador').attr('src', 'imgs/categorias/' + String(cat) + '.gif');
	menuAtual = cat;
	menuPausado = status;
};

function animaMenu() {
	window.setTimeout(animaMenu, 4500);	
	if (menuPausado) return;
	menuAtual++;
	if (menuAtual > 5) {
		menuAtual = 1;
	};	
	menuCat(menuAtual);
}

$(function() {
	animaMenu();
	img = new Array();
	for(i=1; i<=5; i++) {
		img[i] = new Image();
		img[i].src = 'imgs/categorias/' + String(i) + '.gif'
	};
});


function menuClique(src) {
	cat = src.replace(/[^0-9]/g, '');
	location.href = "index.php?pag=video&Cat=" + cat;
}

function comentarVideo(cod) {
	$('#CodVideo').val(cod);
	$('#div_player').hide();
	$('#comente').show();	
};

function cancelarComentario() {
	$('#comente').hide();	
	$('#div_player').show();
}


function enviarComentario() {
	_Nome = $('#Nome').val();
	_Email = $('#Email').val();
	_Telefone = $('#Telefone').val();
	_Comentario = $('#Comentario').val();
	_CodVideo = $('#CodVideo').val();
	if (_Nome.length == 0) {
		alert('Por favor informe seu nome.');
		return false;
	};
	if (_Comentario.length == 0) {
		alert('Por favor informe seu comentario.');
		return false;
	};	
	Dados = {Nome: _Nome, Email: _Email, Telefone: _Telefone, Comentario: _Comentario, CodVideo: _CodVideo};	
	$('#comente').html('<p class="style1"><img src="imgs/loading.gif">Enviando...</p>');	
	$.post("enviar_comentario.php", Dados, function(data){
	  	$('#comente').html('<p class="style1">Coment&aacute;rio enviado com sucesso.</p>');	
		setTimeout(cancelarComentario, 5000);
	});	
};


function enviarContato() {
	_Nome = $('#Nome').val();
	_Email = $('#Email').val();
	_Telefone = $('#Telefone').val();
	_Mensagem = $('#Mensagem').val();
	if (_Nome.length == 0) {
		alert('Por favor informe seu nome.');
		return false;
	};
	if (_Mensagem.length == 0) {
		alert('Por favor informe seu comentario.');
		return false;
	};	
	Dados = {Nome: _Nome, Email: _Email, Telefone: _Telefone, Mensagem: _Mensagem};	
	$('#contato').html('<p class="style1"><img src="imgs/loading.gif">Enviando...</p>');	
	$.post("enviar_contato.php", Dados, function(data){
	  	$('#contato').html('<p class="style1">Contato enviado com sucesso.</p>');
	});	
};


function enviarVideo() {
	_Nome = $('#Nome').val();
	_Email = $('#Email').val();
	_Telefone = $('#Telefone').val();
	_Mensagem = $('#Mensagem').val();
	if (_Nome.length == 0) {
		alert('Por favor informe seu nome.');
		return false;
	};
	if (_Mensagem.length == 0) {
		alert('Por favor informe seu comentario.');
		return false;
	};	
	$('#seuvideo > form').hide();	
	$('#seuvideo').append('<p class="style1"><img src="imgs/loading.gif">Enviando...</p>');
	document.fmEnviarVideo.submit();
};




function abrirFoto(url) {
	$('#fotosFoto').html($('#aguarde').html());;
	$('#fotosFoto').html('<img src="' + url + '" border=0>');
};

function galeriaFotos(urlFotos, fotos) {
	this.urlFotos = urlFotos;
	this.fotos = fotos;
	this.paginaAtual = 0;
	this.fotoAtual = 0;
	this.fotosPorPagina = 12;	
	this.qtdPaginas = Math.ceil(this.fotos.length / this.fotosPorPagina);	
	
	
	this.montarPaginacao = function () {
		if (this.fotos.length > this.fotosPorPagina) {
			str = '<div id="paginacaoFotos">P&aacute;gina: ';
			str += '<select id="paginas" onChange="galeria.exibirPaginaThumbs(this.value)">';
			for (i=0; i < this.qtdPaginas; i++) {
				str += '<option value="' + i + '">' + (i+1) + '</option>';				
			};
			str += '</select> / ' + this.qtdPaginas;
			str += '</div>';
			$('#fotosLista').append(str);
		};
	}
	
	this.exibirPaginaThumbs = function (pag) {
		$('.fotoBox').remove();
		str = '';
		foto = 0;
		for (i=0; i < this.fotosPorPagina; i++) {		
			foto = i + this.fotosPorPagina * pag;
			if (foto < this.fotos.length) {
				str += '<div class="fotoBox">';
				str += '<img src="' + this.urlFotos + this.fotos[foto] + '_tb.jpg" border="0" onClick="galeria.exibirFoto(' + foto + ');" class="tbFoto">';
				str += '</div>';
			};
		};
		$('#fotosLista').prepend(str);
		this.paginaAtual = pag;
	}
	
	this.exibirFoto = function (foto) {
		$('#fotoGrande').html('<img src="' +this.urlFotos + this.fotos[foto] + '.jpg" border="0" width="420">');
		this.fotoAtual = foto;
		if (foto == 0) {
			$('#fotosPaginaAnt').hide();
		} else {
			$('#fotosPaginaAnt').show();
		};
		if (foto < this.fotos.length - 1) {
			$('#fotosPaginaProx').show();
		} else {
			$('#fotosPaginaProx').hide();
		};
	}
	
	this.proximaFoto = function () {
		proxima = this.fotoAtual + 1;
		if (this.fotos.length >= proxima) {			
			this.exibirFoto(proxima);
		};
	}
	
	this.fotoAnterior = function () {
		anterior = this.fotoAtual - 1;
		if (anterior >= 0) {			
			this.exibirFoto(anterior);
		};		
	}	
	
	if (this.fotos.length > 0) {
		this.exibirPaginaThumbs(0);
		this.exibirFoto(0);
	};
}


isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
function mascara(campo, Mascara, evtKeyPress) {
      var i, nCount, Texto, tCampo, tMascara,bolMask, retTexto, codTecla;
      if(isIE) { // Internet Explorer
        codTecla = evtKeyPress.keyCode; }
      else if(isNN) { // Nestcape
        codTecla = evtKeyPress.which;
      };
  if (codTecla != 8) { // backspace
      Texto = campo.value;
      // Limpa todos os caracteres de formatação que
      // já estiverem no campo.
	  re = /[^A-Z0-9]/gi
	  Texto = Texto.toString().replace( re, "");
      tCampo = Texto.length;
      tMascara = Mascara.length;
      i = 0;
      nCount = 0;
      retTexto = "";
      tMascara = tCampo;

      while (i <= tMascara) {
		bolMask = ((Mascara.charAt(i) == ":") || (Mascara.charAt(i) == "-") || (Mascara.charAt(i) == ".") || (Mascara.charAt(i) == "/"))
        bolMask = bolMask || ((Mascara.charAt(i) == "(") || (Mascara.charAt(i) == ")") || (Mascara.charAt(i) == " "))
        if (bolMask) {
          retTexto += Mascara.charAt(i);
          tMascara++; 
		} else {
          retTexto += Texto.charAt(nCount);
          nCount++;
        }
        i++;
      }

      campo.value = retTexto;
		if (Mascara.charAt(i-1) == "9") { // so numero
			return ((codTecla > 47) && (codTecla < 58)); // números de 0 a 9
		} else { // livre
			return true;
		};

  } else {
	return true;
  };	
};
