<!--

var IE = false;
if(navigator.appName == "Microsoft Internet Explorer")IE = true;

//alert("IE = "+IE);

// Classe de fotos
function Fotos(num, path, id){

	this.idFoto = id;
	this.local = path;
	this.num = num;
	this.objPrev = null;
	this.objNext = null;

	this.foto = 1;

	this.next = function(){

		this.objPrev = document.getElementById("fotoPrev");
		this.objNext = document.getElementById("fotoNext");

		if(this.foto == this.num){
			alert("acabou");
			return false;
		}

		this.foto++;
		$(this.objPrev).show();
		if(this.foto == this.num)$(this.objNext).hide();
		document.getElementById(this.idFoto).innerHTML = "<img src=\""+this.local + this.foto + ".jpg\" />";

	}

	this.prev = function(){
		if(this.foto == 1)return false;

		if(this.foto > 1){
			this.foto--;

			if(this.foto == 1)$(this.objPrev).hide();
			document.getElementById(this.idFoto).innerHTML = "<img src=\""+this.local + this.foto + ".jpg\" />";
			$(this.objNext).show();
		}else{
			$(this.objNext).show();
			$(this.objPrev).hide();
		}
	}
}

$(document).ready(
	function() {
		$('#fotoPrev').hide();
	}
);

// Objeto que manipula as agendas do espaço
function AgendaMac(array, conteudo, autor, nome1, id){
	this.vetor = array;
	this.id = document.getElementById(id);
	this.foto = 0;
	this.nome;
	this.prevA;
	this.nextA;
	this.c;
	this.big;
	this.close;
	this.grande;
	this.lupa;
	this.site = "http://www.vidaeconsciencia.com.br/";

	this.start = function(nome){

		this.nome = nome;

		// Botão anterior
		this.prevA = document.createElement("div");
		$(this.prevA).click(function(){ nome.prev()});
		$(this.prevA).css("background","url('"+this.site+"views/imgs/lojavirtual/icones/anterior.jpg') no-repeat");
		$(this.prevA).css("width","25px");
		$(this.prevA).css("height","28px");
		$(this.prevA).css("position","absolute");
		$(this.prevA).css("left","0px");
		$(this.prevA).css("top","127px");
		$(this.prevA).css("cursor","pointer");
		$(this.prevA).css("z-index","102");

		// Botão próximo
		this.nextA = document.createElement("div");
		$(this.nextA).click(function(){ nome.next()});
		$(this.nextA).css("background","url('"+this.site+"views/imgs/lojavirtual/icones/proxima.jpg') no-repeat");
		$(this.nextA).css("width","25px");
		$(this.nextA).css("height","28px");
		$(this.nextA).css("position","absolute");
		$(this.nextA).css("right","0px");
		$(this.nextA).css("top","127px");
		$(this.nextA).css("cursor","pointer");
		$(this.nextA).css("z-index","102");

		// Blackout
		this.big = document.createElement("div");
		$(this.big).css("position","absolute");
		$(this.big).css("background","#000");
		$(this.big).css("width","100%");
		$(this.big).css("height","730px");
		$(this.big).css("top","0px");
		$(this.big).css("left","0px");
		$(this.big).css("opacity","0.5");
		$(this.big).css("filter","alpha(opacity=50)");
		$(this.big).css("z-index","101");

		// Cartaz pequeno
		this.c = document.createElement("div");
		$(this.c).css("position","absolute");
		$(this.c).css("background","#000");
		$(this.c).css("width","198px");
		$(this.c).css("height","274px");
		$(this.c).css("top","0px");
		$(this.c).css("left","30px");
		$(this.c).css("z-index","101");
		$(this.c).css("cursor","pointer");
		$(this.c).click(function(){ nome.show()});

		// Cartazgrande
		this.grande = document.createElement("div");
		$(this.grande).css("position","absolute");
		$(this.grande).css("background","#fff");
		$(this.grande).css("width","415px");
		$(this.grande).css("height","566px");
		$(this.grande).css("top","30px");
		$(this.grande).css("left","30px");
		$(this.grande).css("z-index","102");

		var texto_conteudo = "";
		this.texto_conteudo = document.createElement("label");
		$(this.texto_conteudo).css("position","absolute");
		$(this.texto_conteudo).css("font","14px Arial, helvetica, sans-serif");
		$(this.texto_conteudo).css("text-align","justify");
		$(this.texto_conteudo).css("color","#FFFFFF");
		$(this.texto_conteudo).css("top","327px");
		$(this.texto_conteudo).css("left","50%");
		$(this.texto_conteudo).css("width","370px");
		$(this.texto_conteudo).css("margin-left","-185px");
		$(this.texto_conteudo).css("z-index","103");

		var texto_conteudo_p = "";
		this.texto_conteudo_p = document.createElement("div");
		$(this.texto_conteudo_p).css("position","absolute");
		$(this.texto_conteudo_p).css("font","7px Arial, helvetica, sans-serif");
		$(this.texto_conteudo_p).css("text-align","justify");
		$(this.texto_conteudo_p).css("color","#FFFFFF");
		$(this.texto_conteudo_p).css("top","140px");
		$(this.texto_conteudo_p).css("left","50%");
		$(this.texto_conteudo_p).css("height","90px");
		$(this.texto_conteudo_p).css("overflow-y","hidden");
		$(this.texto_conteudo_p).css("width","166px");
		$(this.texto_conteudo_p).css("cursor","pointer");
		$(this.texto_conteudo_p).css("margin-left","-83px");
		$(this.texto_conteudo_p).css("z-index","200");

		var texto_autor = "";
		this.texto_autor = document.createElement("label");
		$(this.texto_autor).css("position","absolute");
		$(this.texto_autor).css("font","22px Arial, helvetica, sans-serif");
		$(this.texto_autor).css("color","#FFFFFF");
		$(this.texto_autor).css("text-align","center");
		$(this.texto_autor).css("top","498px");
		$(this.texto_autor).css("left","50%");
		$(this.texto_autor).css("width","370px");
		$(this.texto_autor).css("margin-left","-185px");
		$(this.texto_autor).css("z-index","103");

		var texto_autor_p = "";
		this.texto_autor_p = document.createElement("label");
		$(this.texto_autor_p).css("position","absolute");
		$(this.texto_autor_p).css("font","12px Arial, helvetica, sans-serif");
		$(this.texto_autor_p).css("color","#FFFFFF");
		$(this.texto_autor_p).css("text-align","center");
		$(this.texto_autor_p).css("top","242px");
		$(this.texto_autor_p).css("left","50%");
		$(this.texto_autor_p).css("width","198px");
		$(this.texto_autor_p).css("margin-left","-99px");
		$(this.texto_autor_p).css("z-index","200");

		var texto_nome = "";
		this.texto_nome = document.createElement("label");
		$(this.texto_nome).css("position","absolute");
		$(this.texto_nome).css("font","26px Arial, helvetica, sans-serif");
		$(this.texto_nome).css("color","#FFFFFF");
		$(this.texto_nome).css("text-align","center");
		$(this.texto_nome).css("top","262px");
		$(this.texto_nome).css("left","50%");
		$(this.texto_nome).css("width","370px");
		$(this.texto_nome).css("margin-left","-185px");
		$(this.texto_nome).css("z-index","103");

		var texto_nome_p = "";
		this.texto_nome_p = document.createElement("label");
		$(this.texto_nome_p).css("position","absolute");
		$(this.texto_nome_p).css("font","12px Arial, helvetica, sans-serif");
		$(this.texto_nome_p).css("color","#FFFFFF");
		$(this.texto_nome_p).css("text-align","center");
		$(this.texto_nome_p).css("top","120px");
		$(this.texto_nome_p).css("left","50%");
		$(this.texto_nome_p).css("width","198px");
		$(this.texto_nome_p).css("margin-left","-99px");
		$(this.texto_nome_p).css("z-index","200");

		// Botão fechar
		this.close = document.createElement("label");
		$(this.close).click(function(){nome.hide()} );
		$(this.close).css("position","absolute");
		$(this.close).css("font","bold 14px Arial");
		$(this.close).css("color","#000");
		$(this.close).css("top","10px");
		$(this.close).css("left","330px");
		$(this.close).css("z-index","103");
		$(this.close).css("cursor","pointer");
		this.close.innerHTML = "Fechar";

		// Lupa para ampliação
		this.lupa = document.createElement("div");
		$(this.lupa).css("position","absolute");
		$(this.lupa).css("cursor","pointer");
		$(this.lupa).css("font","bold 12px Arial");
		$(this.lupa).css("color","#666");
		$(this.lupa).css("left","20px");
		$(this.lupa).css("top","280px");
		$(this.lupa).click(function(){ nome.show()});
		this.lupa.innerHTML = "<img src='images/lojavirtual/icones/amplia.jpg' />"+
			"Clique na imagem para ampliar.";

		// Adiciona o Fechar no cartaz grande
		this.grande.appendChild(this.close);

		// Adiciona Label para o div grande
		this.grande.appendChild(this.texto_conteudo);
		this.grande.appendChild(this.texto_autor);
		this.grande.appendChild(this.texto_nome);

		// Adiciona Label para o div pequeno
		this.c.appendChild(this.texto_conteudo_p);
		this.c.appendChild(this.texto_autor_p);
		this.c.appendChild(this.texto_nome_p);

		// Adiciona os botões de ação e o cartaz pequeno no ID
		this.id.appendChild(this.prevA);
		this.id.appendChild(this.nextA);
		this.id.appendChild(this.c);
		this.id.appendChild(this.lupa);


		// configura o elemento html AgendaMac "DIV"
		$(this.id).css("position","absolute");
		$(this.id).css("z-index","100");
		$(this.id).css("width","258px");
		$(this.id).css("height","274px");

		if(this.vetor.length == 0){
			$(this.c).css("background","url('"+this.site+"views/imgs/agendas/0_0.jpg') no-repeat");
			$(this.prevA).hide();
			$(this.nextA).hide();
		}else{
			$(this.c).css("background","url('"+this.site+"images/agendas/"+this.vetor[this.foto]+"_0.jpg') no-repeat");
			$(this.grande).css("background","url('"+this.site+"images/agendas/"+this.vetor[this.foto]+"_1.jpg') no-repeat");
			$(this.prevA).hide();
			if(this.vetor.length == 1)$(this.nextA).hide();
		}

			this.texto_conteudo.innerHTML = conteudo[this.foto];
			this.texto_autor.innerHTML = autor[this.foto];
			this.texto_nome.innerHTML = nome1[this.foto];
			this.texto_conteudo_p.innerHTML = conteudo[this.foto];
			this.texto_autor_p.innerHTML = autor[this.foto];
			this.texto_nome_p.innerHTML = nome1[this.foto];

	}

		this.next = function(){
			if(this.foto < this.vetor.length -1){
			this.foto = this.foto + 1;
			if(this.foto == this.vetor.length -1)$(this.nextA).hide();
		}

		$(this.c).css("background","url('"+this.site+"images/agendas/"+this.vetor[this.foto]+"_0.jpg') no-repeat");
		$(this.grande).css("background","url('"+this.site+"images/agendas/"+this.vetor[this.foto]+"_1.jpg') no-repeat");
		this.texto_conteudo.innerHTML = conteudo[this.foto];
		this.texto_autor.innerHTML = autor[this.foto];
		this.texto_nome.innerHTML = nome[this.foto];
		this.texto_conteudo_p.innerHTML = conteudo[this.foto];
		this.texto_autor_p.innerHTML = autor[this.foto];
		this.texto_nome_p.innerHTML = nome[this.foto];

		if(this.foto != 0)$(this.prevA).show();
	}

	this.prev = function(){
		if(this.foto > 0){
			this.foto = this.foto - 1;
			if(this.foto == 0)$(this.prevA).hide();
		}
		$(this.c).css("background","url('"+this.site+"images/agendas/"+this.vetor[this.foto]+"_0.jpg') no-repeat");
		$(this.grande).css("background","url('"+this.site+"images/agendas/"+this.vetor[this.foto]+"_1.jpg') no-repeat");
		this.texto_conteudo.innerHTML = conteudo[this.foto];
		this.texto_autor.innerHTML = autor[this.foto];
		this.texto_nome.innerHTML = nome[this.foto];
		this.texto_conteudo_p.innerHTML = conteudo[this.foto];
		this.texto_autor_p.innerHTML = autor[this.foto];
		this.texto_nome_p.innerHTML = nome[this.foto];

		if(this.foto < this.vetor.length -1)$(this.nextA).show();
	}

	this.show = function(){
		if(this.vetor.length == 0)return false;
		var doc = document.getElementsByTagName("body");
		doc[0].appendChild(this.big);
		doc[0].appendChild(this.grande);
	}

	this.hide = function(){
		var doc = document.getElementsByTagName("body");
		doc[0].removeChild(this.big);
		doc[0].removeChild(this.grande);
	}

}

function FotosAgenda(fotosArray, path, id){

	this.idFoto = id;
	this.local = path;
	this.fotoList = fotosArray;

	this.foto = 0;

	this.next = function(){
		if(this.foto < this.fotoList.length -1){
			this.load();
			this.foto = this.foto + 1;
			document.getElementById(this.idFoto).innerHTML = "<img src=\""+this.local + this.fotoList[this.foto] + "_0.jpg\" />";
		}
	}

	this.prev = function(){
		if(this.foto > 0){
			this.load();
			this.foto = this.foto - 1;
			document.getElementById(this.idFoto).innerHTML = "<img src=\""+this.local + this.fotoList[this.foto] + "_0.jpg\" />";
		}
	}

	this.load = function(){
		document.getElementById(this.idFoto).innerHTML = "<img src=\"views/imgs/carregando.gif\" />";
	}
}

/* Variável que guarda o menu */
var menu_item = new Array(

					//0
				new Array("<a href='egvc.espacosp.logic' target='_parent'>Espa&ccedil;oSP</a>",
						  "<a href='egvc.espacorj.logic' target='_parent'>Espa&ccedil;oRJ</a>",
						  "<a href='metacenter.home.logic' target='_parent'>Metacenter</a>"),
					//1
				new Array("<a onclick=''>Sobre</a>",
						  "<a onclick=''>Associe-se</a>",
						  "<a onclick=''>Contrato</a>",
						  "<a onclick=''>Sala de Confer&ecirc;ncia</a>"),
					//2
				new Array("<a href='editora.home.logic'>In&iacute;cio</a>",
						  "<a href='editora.sobre.logic'>Hist&oacute;rico</a>",
						  //"<a onclick='execRequestGet(\"editora.equipe.logic\",\"sessao\")'>Equipe Vida &amp; Consci&ecirc;ncia</a>",
						  //"<a href='editora.autores.logic'>Autores</a>",
						  //"<a href='editora.maisvendidos.logic'>Mais Vendidos</a>",
						  "<a href='lojavirtual.store.logic?lojavirtual.busca.logic?busca.keySearch=&busca.pageSize=10&busca.tipoBusca=22&busca.filtroBusca=lanca' target='_blank'>Lan&ccedil;amentos</a>"),
						  //"<a href='editora.fotos.logic'>Fotos</a>"),
					//3
				new Array("<a href='grafica.home.logic'>In&iacute;cio</a>",
						  "<a href='grafica.sobre.logic'>Hist&oacute;rico</a>",
						  "<a href='grafica.equipe.logic'>Equipe Vida &amp; Consci&ecirc;ncia</a>",
						  "<a href='grafica.orcamento.logic'>Or&ccedil;amento</a>",
						  "<a href='grafica.servicos.logic'>Equipamentos e Servi&ccedil;os</a>",
						  "<a href='canalcliente.home.logic'>Canal do Cliente</a>",
						  "<a href='grafica.curriculo.logic'>Trabalhe Conosco</a>",
						  "<a href='grafica.localizacao.logic'>Localiza&ccedil;&atilde;o</a>"),
					//4
				new Array("<a href='lojavirtual.home.logic'>In&iacute;cio</a>",
						  "<a href='lojavirtual.maisvendidos.logic'>Mais Vendidos</a>",
						  //"<a href='lojavirtual.ofertas.logic'>Ofertas Especiais</a>",
						  "<a href='lojavirtual.perfil.logic?autor.id=1'>Z&iacute;bia Gasparetto</a>",
						  "<a href='lojavirtual.perfil.logic?autor.id=2'>Luiz Gasparetto</a>",
						  "<a href='editora.autores.logic'>Todos os Autores</a>",
						  "<a href='lojavirtual.cadastro.logic'>Cadastro</a>",
						  "<a href='cestacompra.carrinho.logic'>Cesta de Compras</a>",
						  "<a href=\"javascript:void(window.open('http://atendimento.vidaeconsciencia.com.br/chat/livezilla.php','','width=600,height=550,left=0,top=0,resizable=yes,menubar=no,location=yes,status=yes,scrollbars=no'))\")'>Atendimento on-line</a>",
						  "<a href='lojavirtual.logout.logic'>Sair</a>"),
					//5
				new Array("<a href='midia.mundial.logic'>R&aacute;dio Mundial</a>",
						  "<a href='midia.vivamais.logic'>Revista Viva Mais</a>",
						  "<a href='midia.anamaria.logic'>Revista Ana Maria</a>"),
					//6
				new Array("<a href='metacenter.home.logic'>In&iacute;cio</a>",
						  "<a href='metacenter.sobre.logic'>Hist&oacute;rico</a>",
						  "<a href='metacenter.tratamentos.logic'>Tratamentos</a>",
						  //"<a href='metacenter.equipe.logic'>Equipe Metacenter</a>",
						 "<a href='metacenter.agenda.logic'>Agenda</a>",
						  "<a href='metacenter.fotos.logic'>Fotos</a>",
						  "<a href='metacenter.localizacao.logic'>Localiza&ccedil;&atilde;o</a>"),
						 // "<a href='metacenter.profissionais.logic'>Profissionais</a>"),
					//7
				new Array(),

					//8
				new Array("<a href='espacosp.home.logic'>In&iacute;cio</a>",
						  "<a href='espacosp.sobre.logic'>Sobre</a>",
						  "<a href='espacosp.agenda.logic'>Programa&ccedil;&atilde;o de Cursos</a>",
						  "<a href='espacosp.fotos.logic'>Fotos</a>",
						  "<a href='espacosp.local.logic'>Localiza&ccedil;&atilde;o</a>",
						  "<a href='colegiado.objetivo.logic' target='_parent'>Colegiado</a>",
						  "<a href='espacosp.locacoes.logic'>Loca&ccedil;&otilde;es</a>"),
					//9
				new Array("<a href='espacorj.home.logic'>In&iacute;cio</a>",
						  "<a href='espacorj.sobre.logic'>Sobre</a>",
						  "<a href='espacorj.agenda.logic'>Programa&ccedil;&atilde;o de Cursos</a>",
						  "<a href='espacorj.fotos.logic'>Fotos</a>",
						  "<a href='espacorj.local.logic'>Localiza&ccedil;&atilde;o</a>",
						  //"<a href='espacorj.colegiado.logic'>Colegiado</a>",
						  "<a href='espacorj.locacoes.logic'>Loca&ccedil;&otilde;es</a>"),
					//10
				new Array("<span class='small_white'>Clique no menu acima para navegar pelo portal</a>")
				);


function changeTo(opt){
	var sub_menu = document.getElementById("sub_menu");
	var code = "<table cellpadding='2' border='0' align='center' cellspacing='3' height='20'>";
	var i = 0;

	/* se a opção for diferente de -1 ele desativa todos os botões, e ativa o
	o botão selecionado */
	if(opt != -1){
		for(i=0; i<8; i++){
			var bt = document.getElementById("bt"+(i+1));
			if(i != opt ){
				bt.className = "menu_bt";
			}else{
				bt.className = "menu_down";
			}
		}

		if(menu_item[opt].length > 0 ){
			code += "<tr>";

			for(i=0; i< menu_item[opt].length; i++){
				if(i == menu_item[opt].length - 1){
					code += "<td class='sub_menu'> "+menu_item[opt][i]+" </td>";
				}else{
					code += "<td class='sub_menu'> "+menu_item[opt][i]+" </td>" +
					"<td><span class='small_white'> | </span></td>";
				}
			}

			code += "</tr></table>";
			sub_menu.innerHTML = code;
		}else{
			sub_menu.innerHTML = "";
		}
	}
}

function openLink(url, target){
	window.open(url, target);
}

function mudaProdutoTipo(){
	tipo = document.getElementById("produto_tipo").value;

	switch(tipo){
		case "CD" :
			document.getElementById("produto_genero").disabled = "disabled";
			document.getElementById("produto_capa").disabled = "disabled";

			document.getElementById("pagina_faixa").innerHTML = "Faixas:";
			document.getElementById("produto_pagina_faixa").name = "produto.faixas";

			document.getElementById("isbn_registro").innerHTML = "Registro:";

			break;

		case "LIVRO" :
			document.getElementById("produto_genero").disabled = "";
			document.getElementById("produto_capa").disabled = "";

			document.getElementById("pagina_faixa").innerHTML = "P&aacute;ginas";
			document.getElementById("produto_pagina_faixa").name = "produto.paginas";

			document.getElementById("isbn_registro").innerHTML = "ISBN:";

			break;
	}
}

function checkKey(e, func, p1, p2){
	var e = e || event;
	var k = e.keyCode || e.which;

	if(k == 13){
		func(p1, p2);
	}
}

function checkKeyNumero(e){
	var e = e || event;
	var k = e.keyCode || e.which;

	//alert(k);
	if(k == 8 || k == 37 || k == 38 || k == 39 || k == 40 || k == 9) return true;
	if(k > 57 || k < 48){
		return false;
	}
}

function checkKeySubmit(e,id){
	var e = e || event;
	var k = e.keyCode || e.which;

	//alert(k);
	if(k == 13){
		getById(id).submit();
	}
}


function agendaZoom(black, cartaz, path, Foto){

	this.path = path;
	this.black = black;
	this.cartaz = cartaz;

	this.blackEned = function(){
			this.bk = document.getElementById(this.black);
			this.cz = document.getElementById(this.cartaz);
			this.close = document.getElementById("agenda_close");


		var x = screen.width;
		//alert(x);
		/*switch(x){

			case 800:
				this.cz.style.right = "70px";
				this.close.style.right = "77px";
				break;

			case 1024:
				this.cz.style.right = "300px";
				this.close.style.right = "310px";
				break;

			case 1280:
				this.cz.style.right = "450px";
				break;

			default :
				this.cz.style.right = "300px";

		}*/

		this.bk.style.width = "1200px";
		this.bk.style.height = "1000px";
		this.bk.style.visibility = "visible";
		this.cz.style.visibility = "visible";
		this.close.style.visibility = "visible";
		var img = "<img src=\""+path+Foto.fotoList[Foto.foto]+"_1.jpg\" />";
		this.cz.innerHTML = img;

		try{
			this.bk.style = "z-index: 30";
			this.cz.style =  "z-index: 31";
		}catch(e){
		}

	}

	this.hide = function(){
		this.bk = document.getElementById(this.black);
		this.cz = document.getElementById(this.cartaz);
		this.close = document.getElementById("agenda_close");

		this.bk.style.width = "0";
		this.bk.style.height = "0";
		this.bk.style.visibility = "hidden";
		this.close.style.visibility = "hidden";
		this.cz.style.visibility = "hidden";
	}
}


/* -------- Classe que controla a AGENDA de EVENTOS ----------*/
// Recebe como parametro um vetor com os códigos das agendas a serem exibidas
function Agenda(agendaCodigos){

	this.foto = 0;
	this.vetor = agendaCodigos;
	this.blackout = document.createElement("div");
	this.cartaz = document.createElement("div");
	this.close = document.createElement("div");

	//Inicializa
	this.blackout.id = "AgendaBlackout";
	this.cartaz.id   = "AgendaCartaz";
	this.close.id    = "AgendaClose";

	this.show = function(){
		var doc = document.getElementById("page");

		this.setInit();

		//Adiciona os DIVs na página
		doc.appendChild(this.blackout);
		doc.appendChild(this.cartaz);
		doc.appendChild(this.close);
	}

	this.setInit = function(){
		//Inicializa o CSS
		this.blackout.style.position = "absolute";
		this.blackout.style.top = "0px";
		this.blackout.style.left = "0px";
		this.blackout.style.width = "1200px";
		this.blackout.style.height = "1000px";
		this.blackout.style.background = "#000";
		this.blackout.style.filter = "alpha(opacity=50)";
		this.blackout.style.opacity = "0.5";

		this.cartaz.style.position = "absolute";
		this.cartaz.style.top      = "300px";
		this.cartaz.style.width    = "398px";
		this.cartaz.style.height   = "557px";

		this.close.style.position = "absolute";
		this.close.style.font = "bold 13px Arial";
		this.close.style.color = "#fff";
		this.close.style.cursor = "pointer";
		this.close.style.top = "310px";

		// Posiciona o Cartaz de acordo com a Resolução da tela
		var x = screen.width;
		switch(x){

			case 800:
				this.cartaz.style.right = "70px";
				this.close.style.right = "77px";
				break;

			case 1024:
				this.cartaz.style.right = "300px";
				this.close.style.right = "310px";
				break;

			case 1280:
				this.cartaz.style.right = "450px";
				this.close.style.right = "460";
				break;

			default :
				this.cartaz.style.right = "300px";
		}


		// Inicializa InnerHtml
		this.close.innerHTML = "<div onclick=\"agenda.hide()\">Fecha X</div>";

		this.cartaz.innerHTML = "<img src=\"views/imgs/agenda/"+this.vetor[this.foto]+"_1.jpg\" />";

	}

	this.hide = function(){
		var doc = document.getElementById("page");
		doc.removeChild(this.blackout);
		doc.removeChild(this.cartaz);
		doc.removeChild(this.close);
	}

	/* ---  Controle das Fotos ---- */

	this.next = function(){
		if(this.foto < this.vetor.length -1){
			this.foto = this.foto + 1;
		}
	}

	this.prev = function(){
		if(this.foto > 0){
			this.foto = this.foto - 1;
		}
	}
}

/* ----------------------------------------------------------*/


/*----- Validação de formularios ------*/

function ValidaForm(){

	this.regNumDec = /^\d+$/;
	this.regData = /((0?[1-9]|[12]\d)\/(0?[1-9]|1[0-2])|30\/(0?[13-9]|1[0-2])|31\/(0?[13578]|1[02]))\/(19|20)?\d{2}$/;
	this.regEmail = /^[\w-]+(\.[\w-]+)*@(([\w-]{2,63}\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}3\])$/;

	this.isNumero = function(num, size){
		if(size != null && size != ""){
			if(num.length != size)return false;
			return this.regNumDec.test(num);
		}else{
			return this.regNumDec.test(num);
		}
	}

	this.isData = function(data){
		return this.regData.test(data);
	}

	this.isEmail = function(email){
		return this.regEmail.test(email);
	}

	this.isCPF = function(cpf){
		if(!this.isNumero(cpf, 11))return false;

		// Corpo do CPF
		var cpf_body1 = cpf.substr(0,9);
		var cpf_body2 = cpf.substr(0,10);

		// Dígito 1
		var cod1 = cpf.charAt(9);
		// Dígito 2
		var cod2 = cpf.charAt(10);

		var v1 = new Array(10,9,8,7,6,5,4,3,2);
		var v2 = new Array(11,10,9,8,7,6,5,4,3,2);
		var soma1 = 0;
		var soma2 = 0;


		for(i=0; i< 9; i++){
			soma1 = soma1 + (cpf_body1.charAt(i) * v1[i]);
		}

		for(i=0;i<10; i++){
			soma2 = soma2 + (cpf_body2.charAt(i) * v2[i]);
		}

		if((soma1 % 11) >= 2){
			if( (11 - (soma1 % 11)) != cod1)return false;
		}else{
			if(cod1 != 0 ) return false;
		}

		if( (soma2 % 11) >= 2){
			if( (11 - (soma2 % 11)) != cod2)return false;
		}else{
			if( cod2 != 0)return false;
		}

		return true;
	}
}

var validaForm = new ValidaForm();

function validaNewsForm(){
	var form = document.getElementById("newsForm");
	var email = document.getElementById("newsFormEmail");

	if(!validaForm.isEmail(email.value)){
		alert("Email inválido, verifique se digitou corretamente!");
		return false;
	}

	form.submit();

}


function mudaNewsLista(){
	var select 	= document.getElementById("newsFormEstado");
	var sub		= document.getElementById("newsFormLista");

	switch(select.value){

		case "1":
			sub.name="subscribe[668]";
			break;

		case "2":
			sub.name="subscribe[670]";
			break;

		case "3":
			sub.name="subscribe[695]";
			break;

		case "4":
			sub.name="subscribe[671]";
			break;

		case "5":
			sub.name="subscribe[672]";
			break;

		case "6":
			sub.name="subscribe[673]";
			break;

		case "7":
			sub.name="subscribe[674]";
			break;

		case "8":
			sub.name="subscribe[675]";
			break;

		case "9":
			sub.name="subscribe[676]";
			break;

		case "10":
			sub.name="subscribe[677]";
			break;

		case "11":
			sub.name="subscribe[678]";
			break;

		case "12":
			sub.name="subscribe[679]";
			break;

		case "13":
			sub.name="subscribe[680]";
			break;

		case "14":
			sub.name="subscribe[682]";
			break;

		case "15":
			sub.name="subscribe[681]";
			break;

		case "16":
			sub.name="subscribe[683]";
			break;

		case "17":
			sub.name="subscribe[684]";
			break;

		case "18":
			sub.name="subscribe[684]";
			break;

		case "19":
			sub.name="subscribe[686]";
			break;

		case "20":
			sub.name="subscribe[687]";
			break;

		case "21":
			sub.name="subscribe[689]";
			break;

		case "22":
			sub.name="subscribe[688]";
			break;

		case "23":
			sub.name="subscribe[690]";
			break;

		case "24":
			sub.name="subscribe[691]";
			break;

		case "25":
			sub.name="subscribe[692]";
			break;

		case "26":
			sub.name="subscribe[693]";
			break;

		case "27":
			sub.name="subscribe[694]";
			break;
	}

	//alert(sub.name);
}

// document.getElementById() --- resumido
function getById(id){
	return document.getElementById(id);
}

function checkDate(date, e){
	var e = e || event;
	var k = e.keyCode || e.which;

	//alert(k);

	if(k == 9)return true;

	if(k >= 48 && k <= 57){
		if(date.value.length == 10)return false;
			if(date.value.length == 2 || date.value.length == 5)date.value = date.value + "/";
			return true;
	}else if(k == 8 || k == 37 || k == 38 || k == 39 || k == 40){
		return true;
	}

	return false;
}

// banner rotativo
function tvMachine(idCtrl){
	this.n = new Array();

	this.point = 0;
	this.tempo = null;
	this.func = null;
	this.idCtrl = idCtrl;
	this.intervalo = 5000;

	this.next = function(){
		this.stop();
		this.point == this.n.length -1 ? this.point = 0 : this.point++;
		var cod = 0;
		this.point == 0 ? cod = this.n.length -1 : cod = this.point -1;
		$(this.n[cod]).fadeOut('slow');
		$(this.n[this.point]).fadeIn('slow');

		// Se o tempo estiver parado e a Função setada, ele inicia o Intervalo
		if(this.tempo == null && this.func != null)this.startInterval();

		this.chColor();
	}

	this.prev = function(){
		this.stop();
		this.point == 0 ? this.point = this.n.length -1 : this.point--;
		var cod = 0;
		this.point == this.n.length -1 ? cod = 0 : cod = this.point +1;
		$(this.n[cod]).fadeOut('slow');
		$(this.n[this.point]).fadeIn('slow');

		// Se o tempo estiver parado e a Função setada, ele inicia o Intervalo
		if(this.tempo == null && this.func != null)this.startInterval();

		this.chColor();
	}

	this.stop = function(){
		clearInterval(this.tempo);
		this.tempo = null;
	}

	this.setTimeOut = function(func){
		this.func = func;
		this.startInterval();
	}

	this.startInterval = function(){
		this.tempo = setInterval(this.func,this.intervalo);
	}

	this.setTempo = function(tempo){
		this.intervalo = tempo;
	}

	//funcao paginar banners
	this.setControle = function(tvName){
		var ctrl = document.getElementById(this.idCtrl);

		for(i=0; i< this.n.length; i++){
			var a = document.createElement('a');
			$(a).attr("id","p_"+i);
			$(a).css("color","#333");
			$(a).css("margin","0px 10px 0px 10px");
			$(a).css("cursor","pointer");
			$(a).css("font","bold 13px Arial");
			$(a).css("text-decoration","none");
			$(a).attr("href","javascript:"+tvName+".setBanner("+i+")");
			a.innerHTML = (i+1);
			ctrl.appendChild(a);
		}

		this.chColor();
	}

	this.setBanner = function(i){
		this.stop();
		var cod = this.point;
		this.point = i;
		$(this.n[cod]).fadeOut('slow');
		$(this.n[this.point]).fadeIn('slow');

		// Se o tempo estiver parado e a Função setada, ele inicia o Intervalo
		if(this.tempo == null && this.func != null)this.startInterval();

		this.chColor();
	}

	this.chColor = function(){
		try{
			for(i=0;i< this.n.length; i++){
				var a = document.getElementById("p_"+i);
				if(i == this.point){
					$(a).css("color","#f00");
				}else{
					$(a).css("color","#333");
				}
			}

		}catch(e){
			// Não existe controle!!

		}
	}

	this.add = function(id){
		this.n.push(id);
	}

	function paginas(){
		for(i=0; i< totalAgenda; i++){

		}
	}

}
-->
