	$(function(){
		
		$("input[rel*='cpf']").mask("999.999.999-99");
		$("input[rel*='cnpj']").mask("99.999.999/9999-99");
		$("input[rel*='moeda']").maskMoney();
		$("input[rel*='data']").mask("99/99/9999");
		$("input[rel*='hora']").mask("99:99");
		$("input[rel*='cep']").mask("99999-999");
		$("input[rel*='telefone']").mask("(99) 9999-9999");
		$("input[rel*='numero']").numeric();

		$("input:eq(0)").focus();
		
		$("#botao-cancelar").click(function(){
			window.history.back();
			return false;
		});
		
		$("#botao-voltar").click(function(){
			window.history.back();
			return false;
		});		
		
		moveRelogio();
		
		$("#listagem table.lista tbody tr:odd").css("background-color", "#ffffff");
		
		$("#menu ul li ul li").hover(
			function(){	
				$(this).css("background-color", "#7E7E7E");				   
			},
			function(){			
				$(this).css("background-color", "#636363");										   
			}
		);
		
		$("#btn-filtro").click(function(){
			$("#barra-filtro").slideToggle();
		});
		
		$("#box-status-oportunidades-revendas #form-filtro-2 button").click(function(){
																					 
			var id_Revenda = $("#box-status-oportunidades-revendas #form-filtro-2 #Revenda").val();
			
			sec = new Date().getSeconds();

			if(id_Revenda==''){
				$("#box-status-oportunidades-revendas .grafico").fadeOut('slow');
			}else{
				$("#box-status-oportunidades-revendas .grafico").hide().fadeIn('slow').attr("src", "grafico/status_oportunidades_revenda.asp?id=" + id_Revenda + "&t=" + sec);
			}
																					 
			return false;
			
		});
		
		$("#box-status-oportunidades-revendas .grafico").click(function(){
			$(this).fadeOut('slow');
			return false;
		});
		
		$("#box-oportunidades-revendas #form-filtro button").click(function(){
			
			carregarRevendas($("#box-oportunidades-revendas #form-filtro #Periodo").val())
																					 
			return false;
			
		});
		
		carregarRevendas('0,0');
		
	});

	function carregarRevendas(Periodo){
		
		$.ajax({
			type: "POST",
			url: "ajax/listar-revendas-oportunidades.asp",
			data: { periodo: Periodo },
			async: true,
			cache: false,					
			success: function(resposta){
				$("#lista-revendas").hide().fadeIn('slow').html(resposta);		
			}
		});
			
	}
	
	function incflash(arquivo, largura, altura){
	
		document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + largura + '" height="' + altura + '">');
		document.writeln('  <param name="movie" value="' + arquivo + '">');
		document.writeln('  <param name="quality" value="high">');
		document.writeln('  <param name="allowScriptAccess" value="sameDomain" />');
		document.writeln('  <param name="wmode" value="transparent" />');
		document.writeln('  <param name="menu" value="false" />');
		document.writeln('  <param name="bgcolor" value="#ffffff" />');
		document.writeln('  <embed src="' + arquivo + '" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + largura + '" height="' + altura + '"></embed>');
		document.writeln('</object>');

	}

	function makenum(nro) {
		var valid    = "0123456789";
		var numerook = "";
		var temp;
		for(var i = 0; i < nro.length; i++)
		{
			temp = nro.substr(i, 1);
			if (valid.indexOf(temp) != -1)
				numerook = numerook + temp;
		}
		return(numerook);
	}
	
	function moveRelogio(){
		
		momentoAtual = new Date()
		
		hora 	= momentoAtual.getHours();
		minuto 	= momentoAtual.getMinutes();
		segundo = momentoAtual.getSeconds();
	
		str_segundo = new String (segundo)
		if (str_segundo.length == 1)
		   segundo = "0" + segundo
	
		str_minuto = new String (minuto)
		if (str_minuto.length == 1)
		   minuto = "0" + minuto
	
		str_hora = new String (hora)
		if (str_hora.length == 1)
		   hora = "0" + hora
	
		horaView = hora + ":" + minuto + ":" + segundo
	
		$("#divRelogio").text(horaView);
	
		setTimeout("moveRelogio()",1000);
		
	} 
	
	
	function pagTitulo(texto){
		$("#titulo .tit").fadeIn('slow').html(texto);
	}

	function pagDescricao(texto){
		
		if(texto==''){
			$("#titulo").css("paddingTop", "18px");
		}else{
			$("#titulo .sub").fadeIn('slow').html(texto);
		}
		
	}

	function AbreJanela(linkjanela, x, y, s){
	
		var t = (screen.height - y) / 2;
		var e = (screen.width - x) / 2;

		window.open(linkjanela,'','width=' + x + ',height=' + y + ',scrollbars=' + s + ',toolbar=0,location=0,status=0,menubar=0,resizable=0,left=' + e + ',top=' + t + '');

	}
		
	function atualizar_noticia(id_not){
									   
		$.ajax({
			type: "GET",
			url: "ajax/noticias.asp",
			data: { id: id_not },
			async: true,
			cache: false,					
			success: function(resposta){
				eval(resposta);
			
				$("#box-noticias a").hide().fadeIn('normal').text(unescape(resNoticia['titulo']));
				$("#box-noticias a").hide().fadeIn('normal').attr("href", "noticia.asp?id=" + unescape(resNoticia['id']));
				
				setTimeout('atualizar_noticia(' + unescape(resNoticia['id']) + ');', 1000*5);
	
			}
		});
		
	}
