window.FuncoesGerais = {

	opengrandchase : function (){
		window.open("http://www.levelupgames.com.br/hotsite_gc/index.html", "Hotsite", "width=794 height=584 menubar=no resizable=no scrollbars=no status=yes toolbar=no top=20 left=25"); 
	},
	
	abrir_popup : function (url, altura, largura){
		window.open(url, "LevelUp", "width="+largura+" height="+altura+" menubar=no resizable=no scrollbars=no status=yes toolbar=no top=200 left=200"); 
	},
	
	SwapMenu : function (name,image){
		if (document.getElementById('lbl_img')){
			img = document.getElementById('lbl_img').value;
			if (image!=img){
				if (document.images){ 
					document.images[name].src = image;
				}
			}
		}else{
			document.images[name].src = image;
		}
	},
	
	BuscaParametro : function (parametro){
		valor = '';
		parametros = window.location.search.substr(1);
		array_par = parametros.split('&');
		for(c=0;c<array_par.length;c++){
			array_valor = array_par[c].split('=');
			if(array_valor[0]==parametro){
				valor = array_valor[1];
			}
		}
		return valor;
	},
	
	RetornaNomePagina : function (){
		url = window.location.href;
		parametros = window.location.search;
		url = url.replace(parametros,'');
		url_array = url.split('/');
		url_tamanho = url_array.length;
		url_array2 = url_array[url_tamanho-1].split('#');
		return url_array2[0];
	},
	
	RetornaURL : function (){
		url = window.location.href;
		url_array = url.split('/');
		url_tamanho = url_array.length;
		return url_array[url_tamanho-1];
	},

	tab_campo : function(nome_campo_ta,nome_campo_vai,tamanho){
		if (document.getElementById(nome_campo_ta).value.length==tamanho)
			document.getElementById(nome_campo_vai).focus()
	},
	
	ValidaRadio : function(campo){
	
		tamanho = campo.length;
		valor = 0;
		for(c=0;c<tamanho;c++){
			if(campo[c].checked)
				valor = 1;
		}
		
		return valor;
	
	},
	
	RetornaValorRadio : function(campo){
	
		tamanho = campo.length;
		valor = '';
		for(c=0;c<tamanho;c++){
			if(campo[c].checked)
				valor = campo[c].value;
		}
		
		return valor;
	
	},
	
	RetornaValorCheckUnico : function(campo){
		valor = 0;
		if(campo.checked)
			valor = 1;
				
		return valor;
	
	},
	
	TrocaVazio : function(valor){
	
		if (valor=='')
			return 0;
		else if(isNaN(valor))
			return 0;
		else
			return valor;
	},
	
	
	ValidaEmail : function(email){
	
		if ((email.indexOf("@") == -1) || (email.indexOf(".") == -1))
			return 0;
		else
			return 1;
	
	},
	
	ValidaDataSeparada : function(dia,mes,ano){
	
		retorno=1;
		if(dia=='' || mes=='' || ano==''){
			retorno=0;
		}else if(isNaN(dia) || isNaN(mes) || isNaN(ano)){
			retorno=0;
		}else if(dia<1 || dia>31){
			retorno=0;
		}else if(mes<1 || mes>12){
			retorno=0;
		}else if(ano<1900 || ano>3000){
			retorno=0;
		}
	
		return retorno;
	},
	
	FormataData : function(dia,mes,ano){
		if (dia=='' || mes=='' || ano=='')
			data = '1911-11-11';
		else
			data  = ano + '-' + mes + '-' + dia;
		return data;
	},
	
		
	CarregaEstado : function(){
		Class_cidades.carregaestados(this.CarregaEstado_CallBack);
	},
	
	CarregaEstado_CallBack : function(response){
		if(response.error == null){
			nomecampoestado = document.getElementById("NomeCampoEstado").value;
			var retorno = response.value;
			var ds = retorno;
			if(ds!=null && typeof(ds) == "object" && ds.Tables!=null){
				document.getElementById(nomecampoestado).length =ds.Tables[0].Rows.length+1;
				document.getElementById(nomecampoestado).options[0].text= 'Selecione';
				document.getElementById(nomecampoestado).options[0].value= '';
				
				for(var i=0; i<ds.Tables[0].Rows.length; i++){
					var row = ds.Tables[0].Rows[i];
					document.getElementById(nomecampoestado).options[i+1].text= row.uf;
					document.getElementById(nomecampoestado).options[i+1].value= row.uf;
				}
			} 
		}	
	},
	
	CarregaEstadoNSelecione : function(){
		Class_cidades.carregaestados(this.CarregaEstado_CallBackNSelecione);
		this.CarregaCidade('AC');
	},
	
	CarregaEstado_CallBackNSelecione : function(response){
		if(response.error == null){
			nomecampoestado = document.getElementById("NomeCampoEstado").value;
			var retorno = response.value;
			var ds = retorno;
			if(ds!=null && typeof(ds) == "object" && ds.Tables!=null){
				document.getElementById(nomecampoestado).length =ds.Tables[0].Rows.length;
						
				for(var i=0; i<ds.Tables[0].Rows.length; i++){
					var row = ds.Tables[0].Rows[i];
					document.getElementById(nomecampoestado).options[i].text= row.uf;
					document.getElementById(nomecampoestado).options[i].value= row.uf;
				}
			} 
		}	
	},
	
	CarregaCidade : function(estado){
		Class_cidades.Seleciona(estado,0,this.CarregaCidade_CallBack);
	},
	
	CarregaCidade_CallBack : function(response){
		if(response.error == null){ 
			nomecampocidade = document.getElementById("NomeCampoCidade").value;
			var retorno = response.value;
			var ds = retorno;
			
			if(ds!=null && typeof(ds) == "object" && ds.Tables!=null){
			
				document.getElementById(nomecampocidade).length =ds.Tables[0].Rows.length;
				for(var i=0; i<ds.Tables[0].Rows.length; i++){
					var row = ds.Tables[0].Rows[i];
					document.getElementById(nomecampocidade).options[i].text= row.cidade;
					document.getElementById(nomecampocidade).options[i].value= row.cidade;
				}
			} 
		} 
	
	},
	
	EscreveCookie : function(nome,valor){
		var argv = this.EscreveCookie.arguments;
		var argc = this.EscreveCookie.arguments.length;
		var expires = (argc > 2) ? argv[2] : null;
		var path = (argc > 3) ? argv[3] : null;
		var domain = (argc > 4) ? argv[4] : null;
		var secure = (argc > 5) ? argv[5] : false;
		document.cookie = nome + "=" + escape (valor) +
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
		((path == null) ? "" : ("; path=" + path)) +
		((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");	
	}
	

}




//(nome, email, senha, dica_senha, data_nascimento, veiculo, telefone, endereco As String, numero As String, complemento As String, pais As String, estado As String, cidade As String, bairro As String, cep As String, receber_news As Integer)

window.SalaImprensa = {

	nome : '',
	email : '',
	senha : '',
	dica_senha : '',
	data_nascimento : '',
	veiculo : '',
	telefone : '',
	ramal : '',
	endereco : '',
	numero : '',
	complemento : '',
	pais : '',
	estado : '',
	cidade : '',
	bairro : '',
	cep : '',
	receber_news : '',

	HabilitaEstadoCidade : function(pais){
	
		if(pais=='1'){
			document.getElementById('campo_estado').innerHTML = '<select name="UF" class="input2" onchange="javascript:FuncoesGerais.CarregaCidade(this.value)"></select>';
			document.getElementById('campo_cidade').innerHTML = '<select name="Cidade" class="input2"></select>';
			FuncoesGerais.CarregaEstado();
		}else{
			document.getElementById('campo_estado').innerHTML = '<input name="UF" type="text" class="input2">';
			document.getElementById('campo_cidade').innerHTML = '<input name="Cidade" type="text" class="input2">';
		}
	
	},
	
	Valida : function(){
		NomeForm = FrmSalaImprensaCadastro;
	
		this.nome = NomeForm.Nome.value;
		this.email = NomeForm.Email.value;
		this.senha = NomeForm.Senha.value;
		senha_confirma = NomeForm.ConfirmeSenha.value;
		this.dica_senha = NomeForm.DicaSenha.value;
		
		dia = NomeForm.DiaNasc.value;
		mes = NomeForm.MesNasc.value;
		ano = NomeForm.AnoNasc.value;
		this.data_nascimento = FuncoesGerais.FormataData(dia,mes,ano);
		
		this.veiculo = NomeForm.Veiculo.value;
		this.endereco = NomeForm.Endereco.value;
		
		this.numero = NomeForm.Numero.value;
		this.complemento = NomeForm.Complemento.value;
		
		cep1 = NomeForm.CEPINI.value;
		cep2 = NomeForm.CEPFIM.value;
		this.cep = cep1 + '-' + cep2;
		
		this.pais = NomeForm.Pais.value;
		this.estado = NomeForm.UF.value;
		
		this.cidade = NomeForm.Cidade.value;
		this.bairro = NomeForm.Bairro.value;
		
		ddd = NomeForm.DDD.value;
		telefone = NomeForm.Telefone.value;
		this.telefone = ddd + ' ' + telefone;
		this.ramal = NomeForm.Ramal.value;
		this.receber_news = FuncoesGerais.RetornaValorRadio(NomeForm.Novidades);
			
		if(FuncoesGerais.ValidaEmail(this.email)==0)
			return "Preencha o e-mail corretamente";
		else if (this.VerificaEmail(this.email).value=='existe')
			return "Esse e-mail ja foi cadastrado";
		else if (this.senha=='')
			return "Preencha a senha";
		else if(this.senha!=senha_confirma)
			return "Confirmação de Senha diferente da Senha";
		else if(this.dica_senha=='')
			return "Preencha a dica da senha";
		else if(this.nome=='')
			return "Preencha o nome";
		else if(this.veiculo=='')
			return "Preencha o nome do veículo";
		else if(FuncoesGerais.ValidaDataSeparada(dia,mes,ano)==0)
			return "Preencha a data corretamente";
		else if(this.estado=='')
			return "Preencha/Selecione o estado";
		else if(this.cidade=='')
			return "Preencha/Selecione a cidade";
		else
			return "OK";
	},
	
	VerificaEmail : function(email){
		return Class_sala_imprensa_cadastro.VerificaEmail(email);
	},	

	Postar : function(){
		resposta = this.Valida();
		if (resposta=="OK"){
			Class_sala_imprensa_cadastro.inserir(this.nome, this.email, this.senha, this.dica_senha, this.data_nascimento, this.veiculo, this.telefone, this.ramal, this.endereco, this.numero, this.complemento, this.pais, this.estado, this.cidade, this.bairro, this.cep, this.receber_news,this.Postar_CallBack);
			this.LimparFormulario();
		}else
			alert(resposta);
	},
	
	
	Postar_CallBack : function(response){
		//alert(response.value);
		FuncoesGerais.abrir_popup('pop_imprensa.aspx?msg=cadastro',150,217);
	},
	
	LimparFormulario : function (){
		FrmSalaImprensaCadastro.reset();
	},
	
	Logar : function(){
		NomeForm = FrmSalaImprensaLogin;
		email = NomeForm.Email.value;
		senha = NomeForm.Senha.value;
		var expdate = new Date ();
		expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 31));
		FuncoesGerais.EscreveCookie('LevelUp','',expdate);
		Class_sala_imprensa_cadastro.Logar(email,senha,this.Logar_CallBack);
	},
	
	Logar_CallBack : function(response){
		var expdate = new Date ();
		expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 31));
		//alert(response.value);
		if(response.value==null){
			FuncoesGerais.EscreveCookie('LevelUp','ok',expdate);
			window.location = 'imprensa_clipping.aspx';
		}else{
			FuncoesGerais.EscreveCookie('LevelUp','',expdate);
		alert(response.value);
		}
	},
	
	HabilitaNoticiasLista : function(){
	if (navigator.appName == 'Microsoft Internet Explorer')
		window.location.hash = '';
		imprensa_clipping.lista_clipping(this.HabilitaNoticiasLista_CallBack);
	},
	
	HabilitaNoticiasLista_CallBack: function(response){
		document.getElementById('clipp_lista').style.display='';
		document.getElementById('cabecalho').style.display='';
		document.getElementById('pgns5').style.display='';
		document.getElementById('interna').style.display='none';
		document.getElementById('clipp_lista').innerHTML = response.value;
		Paginacao.Limpar();
		Paginacao.MontaNumeracao();
	},
	
	HabilitaNoticiasInterna : function(id_clipping){
	if (navigator.appName == 'Microsoft Internet Explorer')
			window.location.hash = '?id_clipping=' + id_clipping;
			imprensa_clipping.interna_clipping(id_clipping,this.HabilitaNoticiasInterna_CallBack);
	},
	
	HabilitaNoticiasInterna_CallBack : function(response){
		document.getElementById('clipp_lista').style.display='none';
		document.getElementById('cabecalho').style.display='none';
		document.getElementById('pgns5').style.display='none';
		document.getElementById('interna').style.display='';
		document.getElementById('interna').innerHTML = response.value;
	},
	
	Inicia : function(){
		parametros  = new String();
		parametros = window.location.search;
		if (parametros=='')
			this.HabilitaNoticiasLista();
		else{
			id_clipping = FuncoesGerais.BuscaParametro('id_clipping');
			this.HabilitaNoticiasInterna(id_clipping);
		}
	}

}

window.InformacoesAosPais = {

	HabilitaNoticiasLista : function(){
	if (navigator.appName == 'Microsoft Internet Explorer')
		window.location.hash = '';
		pais_clipping.lista_clipping(this.HabilitaNoticiasLista_CallBack);
	},
	
	HabilitaNoticiasLista_CallBack: function(response){
		document.getElementById('conteudo_clipping').innerHTML = response.value;
		Paginacao.Limpar();
		Paginacao.MontaNumeracao();
	},
	
	HabilitaNoticiasInterna : function(id_clipping){
	if (navigator.appName == 'Microsoft Internet Explorer')
		window.location.hash = '?id_clipping=' + id_clipping;
		pais_clipping.interna_clipping(id_clipping,this.HabilitaNoticiasInterna_CallBack);
	},
	
	HabilitaNoticiasInterna_CallBack : function(response){
		document.getElementById('conteudo_clipping').innerHTML = response.value;
	},

	Inicia : function(){
		parametros  = new String();
		parametros = window.location.search;
		if (parametros=='')
			this.HabilitaNoticiasLista();
		else{
			id_clipping = FuncoesGerais.BuscaParametro('id_clipping');
			this.HabilitaNoticiasInterna(id_clipping);
		}
	}

}

/*window.Noticias = {

	HabilitaSelectCategorias : function(){
		Class_categorias.Seleciona(1,0,0,this.HabilitaSelectCategorias_CallBack)	
	},
	
	HabilitaSelectCategorias_CallBack : function(response){
		if(response.error == null){
			var retorno = response.value;
			var ds = retorno;
			if(ds!=null && typeof(ds) == "object" && ds.Tables!=null){
				document.frmCategoria.DropCategoria.length =ds.Tables[0].Rows.length+2;
				document.frmCategoria.DropCategoria.options[0].text= 'Escolha a categoria';
				document.frmCategoria.DropCategoria.options[0].value= 0;
				document.frmCategoria.DropCategoria.options[1].text= 'Todas';
				document.frmCategoria.DropCategoria.options[1].value= 0;
				
				for(var i=0; i<ds.Tables[0].Rows.length; i++){
					var row = ds.Tables[0].Rows[i];
					document.frmCategoria.DropCategoria.options[i+2].text= row.nome_categoria;
					document.frmCategoria.DropCategoria.options[i+2].value= row.id_categoria;
				}
			} 
		}		
	},
	
	HabilitaNoticiasLista : function(grupo){
	if (navigator.appName == 'Microsoft Internet Explorer')
		window.location.hash = '';
		document.getElementById('noticia_lista').innerHTML = '<br><br><br><center>Carregando...</center>';
		hotnews.lista_noticias(grupo,this.HabilitaNoticiasLista_CallBack);
		//document.getElementById("baixo").src='images/bg_move_034.jpg';
	},
	
	HabilitaNoticiasLista_CallBack: function(response){
		document.getElementById('noticia_lista').innerHTML = response.value;
		Paginacao.Limpar();
		Paginacao.MontaNumeracao();
		document.getElementById("img_news").style.display='';
		document.getElementById("baixo").src='images/bg_move_034.jpg';
	},
	
	HabilitaNoticiasInterna : function(id_noticia){
	if (navigator.appName == 'Microsoft Internet Explorer')
			window.location.hash = '?id_noticia=' + id_noticia;
			hotnews.interna_noticia(id_noticia,this.HabilitaNoticiasInterna_CallBack);
	},
	
	HabilitaNoticiasInterna_CallBack : function(response){
		document.getElementById('noticia_lista').innerHTML = response.value;
		document.getElementById("img_news").style.display='none';
		document.getElementById("baixo").src='images/bg_move_033.jpg';
	},
	
	Voltar : function(){
		valor = document.frmCategoria.DropCategoria.value;
		this.HabilitaNoticiasLista(valor);
	},
	
	Inicia : function(){
		parametros  = new String();
		parametros = window.location.search;
		this.HabilitaSelectCategorias();		
		if (parametros==''){
			this.HabilitaNoticiasLista(0);
		}else{
			id_noticia = FuncoesGerais.BuscaParametro('id_noticia');
			this.HabilitaNoticiasInterna(id_noticia);
		}
	}

}*/



window.Noticias = {

	totalregistros : 0,
	numpaginas : '',
	nomedivnums : '',
	paginaatual : 1,
	quadrante : 1,
	grupo : '',

	HabilitaSelectCategorias : function(){
		Class_categorias.Seleciona(1,0,2,this.HabilitaSelectCategorias_CallBack)	
	},
	
	HabilitaSelectCategorias_CallBack : function(response){
		if(response.error == null){
			var retorno = response.value;
			var ds = retorno;
			if(ds!=null && typeof(ds) == "object" && ds.Tables!=null){
				document.frmCategoria.DropCategoria.length =ds.Tables[0].Rows.length+2;
				document.frmCategoria.DropCategoria.options[0].text= 'Escolha a categoria';
				document.frmCategoria.DropCategoria.options[0].value= 0;
				document.frmCategoria.DropCategoria.options[1].text= 'Todas';
				document.frmCategoria.DropCategoria.options[1].value= 0;
				
				for(var i=0; i<ds.Tables[0].Rows.length; i++){
					var row = ds.Tables[0].Rows[i];
					document.frmCategoria.DropCategoria.options[i+2].text= row.nome_categoria;
					document.frmCategoria.DropCategoria.options[i+2].value= row.id_categoria;
				}
			} 
		}		
	},
	
	HabilitaNoticiasLista : function(grupo,pagina){
	if (navigator.appName == 'Microsoft Internet Explorer')
		window.location.hash = '';
		this.grupo = grupo;
		//document.getElementById('noticia_lista').innerHTML = '<br><br><br><center>Carregando...</center>';
		this.itenspagina = parseInt(document.getElementById('ItensPagina').value);
		//conteudo = document.getElementById('noticia_lista').innerHTML;
		document.getElementById('noticia_lista').innerHTML = hotnews.lista_noticias_paginado(grupo,pagina,this.itenspagina).value;
		document.getElementById("img_news").style.display='';
		document.getElementById("baixo").src='images/bg_move_033.jpg';
		this.paginaatual = pagina;
		this.IniciaPaginacao(); 
		//document.getElementById("baixo").src='images/bg_move_034.jpg';
	},
	
	IniciaPaginacao : function(){
		this.totalregistros = parseInt(document.getElementById('TotalRegistros').value);
		this.numpaginas =this.totalregistros/this.itenspagina;
		this.MostraDiv();
		this.MontaNumeracao();
	},
	
	MostraDiv : function(){
		//alert(this.linhas);
		nomediv = document.getElementById('NomeDivNums').value;
		if (Math.ceil(this.numpaginas)<=1)
			document.getElementById(nomediv).style.display = 'none';
		else
			document.getElementById(nomediv).style.display = '';
	},
	
	MontaNumeracao : function(){
		//this.CalculaNumeroPaginas();
		this.nomedivnums = document.getElementById('NomeDivNums').value;
		conteudo = '';
		
		if (this.paginaatual!=1)
			conteudo = '<a href="javascript:Noticias.HabilitaNoticiasLista('+this.grupo+','+(parseInt(this.paginaatual)-1)+')" class="bnco" id="ant">&lt; </a>';
		
		this.quadrante = this.RetornaQuadrante();
		aux = 0;
		for (cont=0;cont<this.numpaginas;cont++){
			nummostra = cont+1;
			
			if(nummostra>=this.quadrante && nummostra<=this.quadrante+3){
				if (nummostra==this.paginaatual)
					classe = 'pretoa';
				else
					classe = 'bnco';
				if (aux==0)
					conteudo += '<a href="javascript:Noticias.HabilitaNoticiasLista('+this.grupo+','+nummostra+')" class="'+classe+'" id="num_'+nummostra+'">'+nummostra+'</a>';
				else
					conteudo += ' - <a href="javascript:Noticias.HabilitaNoticiasLista('+this.grupo+','+nummostra+')" class="'+classe+'" id="num_'+nummostra+'">'+nummostra+'</a>';
				aux = 1;
			}
			
		}
		if (this.paginaatual!=Math.ceil(this.numpaginas))
			conteudo += ' <a href="javascript:Noticias.HabilitaNoticiasLista('+this.grupo+','+(parseInt(this.paginaatual)+1)+')" class="bnco" id="prox">&gt;</a>';
			
		document.getElementById('numerosdepaginas').innerHTML = conteudo;
	},
	
	RetornaQuadrante : function(){
		for(x=1;x<Math.ceil(parseInt(this.numpaginas))+1;x=x+4){
			if(this.paginaatual>=x && this.paginaatual<x+4){
				return x;
				x=tot_paginas;
			}
		}
	},
	
	HabilitaNoticiasInterna : function(id_noticia){
	if (navigator.appName == 'Microsoft Internet Explorer')
			window.location.hash = '?id_noticia=' + id_noticia;
			hotnews.interna_noticia(id_noticia,this.HabilitaNoticiasInterna_CallBack);
	},
	
	HabilitaNoticiasInterna_CallBack : function(response){
		document.getElementById('noticia_lista').innerHTML = response.value;
		document.getElementById("img_news").style.display='none';
		document.getElementById("baixo").src='images/bg_move_033.jpg';
	},
	
	Voltar : function(){
		valor = document.frmCategoria.DropCategoria.value;
		this.HabilitaNoticiasLista(valor,1);
	},
	
	Inicia : function(){
		parametros  = new String();
		parametros = window.location.search;
		this.HabilitaSelectCategorias();		
		if (parametros==''){
			this.HabilitaNoticiasLista(0,1);
		}else{
			id_noticia = FuncoesGerais.BuscaParametro('id_noticia');
			this.HabilitaNoticiasInterna(id_noticia);
		}
	}

}



window.Paginacao = {
	
	numpaginas : '',
	nomedivnums : '',
	paginaatual : 1,
	itenspagina : 0,
	itensbloco : 0,
	linhas : 0,
	quadrante : 1,

	CalculaNumeroPaginas : function(){
		nometabela = document.getElementById('NomeTabela').value;
		linhasfora = parseInt(document.getElementById('LinhasFora').value);
		this.itenspagina = parseInt(document.getElementById('ItensPagina').value);
		this.itensbloco = parseInt(document.getElementById('ItensBloco').value);
		this.linhas = document.getElementById(nometabela).getElementsByTagName('TR').length;
		this.numpaginas = ((this.linhas- linhasfora)/this.itensbloco)/this.itenspagina;
		this.MostraDiv();
	},
	
	Limpar : function(){
		this.numpaginas = 0;
		this.paginaatual = 1;
		this.quadrante = 1;
		document.getElementById('numerosdepaginas').innerHTML ='';	
	},
	
	MostraDiv : function(){
		//alert(this.linhas);
		nomediv = document.getElementById('NomeDivNums').value;
		if (Math.ceil(this.numpaginas)<=1)
			document.getElementById(nomediv).style.display = 'none';
		else
			document.getElementById(nomediv).style.display = '';
	},
	
	MontaNumeracao : function(){
		this.CalculaNumeroPaginas();
		this.nomedivnums = document.getElementById('NomeDivNums').value;
		conteudo = '';
		
		if (this.paginaatual!=1)
			conteudo = '<a href="javascript:Paginacao.TrocaPagina('+(parseInt(this.paginaatual)-1)+')" class="bnco" id="ant">&lt; </a>';
		
		this.quadrante = this.RetornaQuadrante();
		aux = 0;
		for (cont=0;cont<this.numpaginas;cont++){
			nummostra = cont+1;
			
			if(nummostra>=this.quadrante && nummostra<=this.quadrante+3){
				if (nummostra==this.paginaatual)
					classe = 'pretoa';
				else
					classe = 'bnco';
				if (aux==0)
					conteudo += '<a href="javascript:Paginacao.TrocaPagina('+nummostra+')" class="'+classe+'" id="num_'+nummostra+'">'+nummostra+'</a>';
				else
					conteudo += ' - <a href="javascript:Paginacao.TrocaPagina('+nummostra+')" class="'+classe+'" id="num_'+nummostra+'">'+nummostra+'</a>';
				aux = 1;
			}
			
		}
		if (this.paginaatual!=Math.ceil(this.numpaginas))
			conteudo += ' <a href="javascript:Paginacao.TrocaPagina('+(parseInt(this.paginaatual)+1)+')" class="bnco" id="prox">&gt;</a>';
			
		document.getElementById('numerosdepaginas').innerHTML = conteudo;
	},
	
	TrocaPagina : function(pagina){
		this.paginaatual = pagina;
		aux = (pagina - 1) * this.itenspagina;
		this.itensbloco = parseInt(document.getElementById('ItensBloco').value);
		for (cont=0; cont <= (this.linhas); cont++) {
			for (cont2=1; cont2 <= this.itensbloco; cont2++) {
				nome_linha = 'linha'+cont2+'_'+cont;
				if (document.getElementById(nome_linha)){
					a = document.getElementById(nome_linha);
					if (cont>=aux && cont<aux+this.itenspagina){
						a.style.display = '';
					}else{
						a.style.display = 'none';
					}
				}
			}		
		}
		this.MontaNumeracao();
		//alert(this.RetornaQuadrante());
	},
	
	RetornaQuadrante : function(){
		for(x=1;x<Math.ceil(parseInt(this.numpaginas))+1;x=x+4){
			if(this.paginaatual>=x && this.paginaatual<x+4){
				return x;
				x=tot_paginas;
			}
		}
	}

}



window.FaleConosco = {

	nome : '',
	email : '',
	data_nascimento : '',
	pais : '',
	estado : '',
	cidade : '',
	assunto : '',
	mensagem : '',

	HabilitaEstadoCidade : function(pais){
	
		if(pais=='1'){
			document.getElementById('campo_estado').innerHTML = '<select  class="input" name="UF" onchange="javascript:FuncoesGerais.CarregaCidade(this.value)"></select>';
			document.getElementById('campo_cidade').innerHTML = '<select  class="input" name="Cidade"></select>';
			FuncoesGerais.CarregaEstado();
		}else{
			document.getElementById('campo_estado').innerHTML = '<input name="UF" type="text" class="input">';
			document.getElementById('campo_cidade').innerHTML = '<input name="Cidade" type="text" class="input">';
		}
	
	},
	
	Valida : function(){
		NomeForm = FrmFaleConosco;
	
		this.nome = NomeForm.Nome.value;
		this.email = NomeForm.Email.value;
		
		dia = NomeForm.DiaNasc.value;
		mes = NomeForm.MesNasc.value;
		ano = NomeForm.AnoNasc.value;
		this.data_nascimento = FuncoesGerais.FormataData(dia,mes,ano);
				
		this.pais = NomeForm.Pais.value;
		this.estado = NomeForm.UF.value;
		
		this.cidade = NomeForm.Cidade.value;
		this.assunto = NomeForm.Assunto.value;
		this.mensagem = NomeForm.Mensagem.value;
		
		if(this.nome=='')
			return "Preencha o nome";
		else if(FuncoesGerais.ValidaEmail(this.email)==0)
			return "Preencha o e-mail corretamente";
		else if(FuncoesGerais.ValidaDataSeparada(dia,mes,ano)==0)
			return "Preencha a data corretamente";
		else if(this.estado=='')
			return "Preencha/Selecione o estado";
		else if(this.cidade=='')
			return "Preencha/Selecione a cidade";
		else if(this.assunto=='')
			return "Selecione o assunto";
		else if(this.mensagem=='')
			return "Digite sua mensagem";
		else
			return "OK";
				
	},
//(ByVal nome As String, ByVal email As String, ByVal data_nascimento As Date, ByVal pais As String, ByVal estado As String, ByVal cidade As String, ByVal assunto As String, ByVal mensagem As String)
	Postar : function(){
	resposta = this.Valida();
		if (resposta=="OK"){
				Class_fale_conosco.inserir(this.nome, this.email, this.data_nascimento,  this.pais, this.estado, this.cidade, this.assunto, this.mensagem,this.Postar_CallBack);
				this.LimparFormulario();
		}else
			alert(resposta);	
	},
	
	Postar_CallBack : function(response){
		alert(response.value);
	},
	
	LimparFormulario : function (){
		FrmFaleConosco.reset();
	}


}

window.TrabalheConosco = {
	
	nome : '',
	data_nasc : '',
	estado_civil : '',
	nacionalidade : '',
	sexo : '',
	endereco : '',
	ddd_residencial : '',
	tel_residencial : '',
	email : '',
	ddd_celular : '',
	telefone_celular : '',
	estado : '',
	cidade : '',
	bairro : '',
	cep : '',
	formacao : '',
	curso : '',
	cursos_complementares : '',
	nivel_ingles : '',
	nivel_espanhol : '',
	outro_idioma : '',
	nivel_outro : '',
	empresa : '',
	cargo : '',
	data_adimissao : '1911-11-11',
	data_desligamento : '1911-11-11',
	principais_real : '',
	motivo_desligamento : '',
	empresa2 : '',
	cargo2 : '',
	data_adimissao2 : '1911-11-11',
	data_desligamento2 : '1911-11-11',
	principais_real2 : '',
	motivo_desligamento2 : '',
	empregado_atualmente : '',
	area_interesse : '',
	cargo_interesse : '',
	pretencao_salarial : '',
	Administrativa_Finenceira : '',
	TI : '',
	RH : '',
	Atendimento_ao_Cliente : '',
	Game_Expert : '',
	Game_Master : '',
	Marketing : '',
	Comercial : '',
	Web_Design : '',
	porque_trabalhar : '',
	fale_voce : '',
	objetivos_metas : '',
	
	Valida : function(){
		NomeForm = FrmTrabalheConosco;
		
		this.nome = NomeForm.Nome.value ;
		dia = NomeForm.DiaNasc.value;
		mes = NomeForm.MesNasc.value;
		ano = NomeForm.AnoNasc.value;
		this.data_nasc = FuncoesGerais.FormataData(dia,mes,ano);
		this.estado_civil = NomeForm.EstadoCivil.value ;
		this.nacionalidade = NomeForm.Nacionalidade.value ;
		this.sexo = FuncoesGerais.RetornaValorRadio(NomeForm.Sexo) ;
		this.endereco = NomeForm.Endereco.value ;
		this.ddd_residencial = FuncoesGerais.TrocaVazio(NomeForm.DDD.value) ;
		this.tel_residencial = FuncoesGerais.TrocaVazio(NomeForm.Telefone.value) ;
		this.email = NomeForm.Email.value ;
		this.ddd_celular = FuncoesGerais.TrocaVazio(NomeForm.DDDCel.value) ;
		this.telefone_celular = FuncoesGerais.TrocaVazio(NomeForm.Celular.value) ;
		this.estado = NomeForm.UF.value ;
		this.cidade = NomeForm.Cidade.value ;
		this.bairro = NomeForm.Bairro.value ;
		this.cep = NomeForm.CEP.value ;
		this.formacao = FuncoesGerais.RetornaValorRadio(NomeForm.Formacao) ;
		this.curso = NomeForm.NomeCurso.value ;
		this.cursos_complementares = NomeForm.CursosComplementares.value ;		
		this.nivel_ingles = FuncoesGerais.RetornaValorRadio(NomeForm.IngNivel) ;
		this.nivel_espanhol = FuncoesGerais.RetornaValorRadio(NomeForm.EspNivel) ;
		this.outro_idioma = NomeForm.OutroIdioma.value ;
		this.nivel_outro = FuncoesGerais.RetornaValorRadio(NomeForm.OutNivel) ;
		this.empresa = NomeForm.Empresa.value ;
		this.cargo = NomeForm.Cargo.value ;
		dia_adm = NomeForm.DiaAdm.value;
		mes_adm = NomeForm.MesAdm.value;
		ano_adm = NomeForm.AnoAdm.value;
		this.data_adimissao = FuncoesGerais.FormataData(dia_adm,mes_adm,ano_adm) ;
		dia_des = NomeForm.DiaDes.value;
		mes_des = NomeForm.MesDes.value;
		ano_des = NomeForm.AnoDes.value;
		this.data_desligamento =FuncoesGerais.FormataData(dia_des,mes_des,ano_des) ;
		this.principais_real = NomeForm.Realizacoes.value ;
		this.motivo_desligamento = NomeForm.Motivo.value ;
				
		this.empresa2 = NomeForm.Empresa2.value ;
		this.cargo2 = NomeForm.Cargo2.value ;
		dia_adm2 = NomeForm.DiaAdm2.value;
		mes_adm2 = NomeForm.MesAdm2.value;
		ano_adm2 = NomeForm.AnoAdm2.value;
		this.data_adimissao2 = FuncoesGerais.FormataData(dia_adm2,mes_adm2,ano_adm2) ;
		dia_des2 = NomeForm.DiaDes2.value;
		mes_des2 = NomeForm.MesDes2.value;
		ano_des2 = NomeForm.AnoDes2.value;
		this.data_desligamento2 =FuncoesGerais.FormataData(dia_des2,mes_des2,ano_des2) ;
		this.principais_real2 = NomeForm.Realizacoes2.value ;
		this.motivo_desligamento2 = NomeForm.Motivo2.value ;
		
		this.empregado_atualmente = FuncoesGerais.RetornaValorRadio(NomeForm.EmpregadoAtualmente);
		this.area_interesse = NomeForm.AreaInteresse.value;
		this.cargo_interesse = NomeForm.CargoInteresse.value;
		this.pretencao_salarial = NomeForm.PretencaoSalarial.value;
		
		this.Administrativa_Finenceira = FuncoesGerais.RetornaValorCheckUnico(NomeForm.AdministrativaFinenceira) ;
		this.TI = FuncoesGerais.RetornaValorCheckUnico(NomeForm.TI) ;
		this.RH = FuncoesGerais.RetornaValorCheckUnico(NomeForm.RH) ;
		this.Atendimento_ao_Cliente = FuncoesGerais.RetornaValorCheckUnico(NomeForm.AtendimentoCliente) ;
		this.Game_Expert = FuncoesGerais.RetornaValorCheckUnico(NomeForm.GameExpert) ;
		this.Game_Master = FuncoesGerais.RetornaValorCheckUnico(NomeForm.GameMaster) ;
		this.Marketing = FuncoesGerais.RetornaValorCheckUnico(NomeForm.Marketing) ;
		this.Comercial = FuncoesGerais.RetornaValorCheckUnico(NomeForm.Comercial) ;
		this.Web_Design = FuncoesGerais.RetornaValorCheckUnico(NomeForm.WebDesign) ;
		
		this.porque_trabalhar = NomeForm.PorqueTrabalhar.value;
		this.fale_voce = NomeForm.FaleVoce.value;
		this.objetivos_metas = NomeForm.ObjetivosMetas.value;
	
	
		
		if(this.nome=='')
			return "Preencha o nome";
		else if(FuncoesGerais.ValidaDataSeparada(dia,mes,ano)==0)
			return "Preencha a data corretamente";
		else if(this.estado_civil=='')
			return "Preencha o Estado Civil";
		else if(this.nacionalidade=='')
			return "Preencha a Nacionalidade";
		else if(this.sexo=='')
			return "Escolha o sexo";
		else if(FuncoesGerais.ValidaEmail(this.email)==0)
			return "Preencha o e-mail corretamente";
		else if(this.ddd_residencial=='' && this.tel_residencial=='')
			return "Digite o telefone residencial";
		else if(this.formacao=='')
			return "Escolha a formação";
		else if(FuncoesGerais.ValidaDataSeparada(dia_adm,mes_adm,ano_adm)==0 && (dia_adm!='' || mes_adm!='' || ano_adm!=''))
			return "Preencha a primeira data de adimissão corretamente";
		else if(FuncoesGerais.ValidaDataSeparada(dia_des,mes_des,ano_des)==0 && (dia_des!='' || mes_des!='' || ano_des!=''))
			return "Preencha a primeira data de desligamento corretamente";
		else if(FuncoesGerais.ValidaDataSeparada(dia_adm2,mes_adm2,ano_adm2)==0 && (dia_adm2!='' || mes_adm2!='' || ano_adm2!=''))
			return "Preencha a segunda data de adimissão corretamente";
		else if(FuncoesGerais.ValidaDataSeparada(dia_des2,mes_des2,ano_des2)==0 && (dia_des2!='' || mes_des2!='' || ano_des2!=''))
			return "Preencha a segunda data de desligamento corretamente";		
		else if(this.Administrativa_Finenceira==0 && this.TI==0 && this.RH==0 && this.Atendimento_ao_Cliente==0 && this.Game_Expert==0 && this.Game_Master==0 && this.Marketing==0 && this.Comercial==0 && this.Web_Design==0)
			return "Selecione alguma Área de Interesse";	
		else
			return "OK";
				
	},
	
	Postar : function(){
	resposta = this.Valida();
		if (resposta=="OK"){
		
			Class_trabalhe_conosco.inserir(this.nome, this.data_nasc, this.estado_civil, this.nacionalidade, this.sexo, this.endereco, this.ddd_residencial, this.tel_residencial, this.email, this.ddd_celular, this.telefone_celular, this.estado,this.cidade, this.bairro, this.cep, this.formacao, this.curso,this.cursos_complementares, this.nivel_ingles, this.nivel_espanhol, this.outro_idioma, this.nivel_outro, this.empresa, this.cargo, this.data_adimissao, this.data_desligamento, this.principais_real, this.motivo_desligamento, this.empresa2, this.cargo2, this.data_adimissao2, this.data_desligamento2, this.principais_real2, this.motivo_desligamento2, this.empregado_atualmente, this.area_interesse, this.cargo_interesse, this.pretencao_salarial, this.Administrativa_Finenceira, this.TI, this.RH, this.Atendimento_ao_Cliente, this.Game_Expert, this.Game_Master, this.Marketing, this.Comercial, this.Web_Design, this.porque_trabalhar, this.fale_voce, this.objetivos_metas, this.Postar_CallBack);
			this.LimparFormulario();
		}else
			alert(resposta);	
	},
	
	Postar_CallBack : function(response){
		alert("Obrigado! Seu cadastro foi efetuado com sucesso!");
	},
	
	LimparFormulario : function (){
		FrmTrabalheConosco.reset();
	}

}

window.Pais = {

	MudaPagina : function(pagina){
		window.location.href = pagina;
		//alert(pagina);
	}
	
}

window.Newsletter = {
	nome : '',
	email : '',
	
	enviarForm : function(){
		resposta = this.Valida();
		if (resposta=="OK"){
			Class_cad_newsletter.insere(this.nome,this.email,this.enviarForm_CallBack);
		}else{
			alert(resposta);
		}
	},
	
	enviarForm_CallBack: function(response){
		if (response.value == 'ok'){
			alert('Cadastro efetuado com sucesso');
			NomeForm.Nome.value = '';
			NomeForm.Email.value = '';
		}
	},
	
	Valida : function(){
		NomeForm = FrmNewsletter;
	
		this.nome = NomeForm.Nome.value;
		this.email = NomeForm.Email.value;
		
		if(this.nome=='')
			return "Preencha o nome";
		else if(FuncoesGerais.ValidaEmail(this.email)==0)
			return "Preencha o e-mail corretamente";
		else
			return "OK";
	}
	
}