$(document).ready( function(){
							
	// função texto como máquina escrever
	i = 1;
	str= $(".telefone p").text();
	tID = 0;
		
	typeLayer = function() {
		if(i > str.length){
			tID = setTimeout(function(){i=1;typeLayer();},5000);
		} else {
			msg = str.substring(0,i).replace("&","<strong>").replace("%","</strong>");
			$(".telefone p").empty().append(msg);
			i++;
			tID = setTimeout(function(){typeLayer();},70);
		}
	}
	
	typeLayer();
							
							
	// Pega elemento pelo id
	function g(x){ return document.getElementById(x); }
	
	function URLencode(sStr){
		return escape(sStr).
				 replace(/\+/g, '%2B').
					replace(/\"/g,'%22').
					   replace(/\'/g, '%27').
						 replace(/\//g,'%2F');
	 }

	/************************************************
	/												/
	/	Funções Padrões -> Com a biblioteca JQuery	/
	/	Por Diego Marques							/
	/	Agencia DMK - 2007							/
	/												/
	************************************************/
	
	/*
		"abrirRel"
		Acressenta a classe "abrirRel" no link e no
		campo rel o elemento alvo.
		
		Seletores: '#' -> por id
				   '.' -> por classe
		
		Ex.: <a href="javascript:void(0);" title="Saiba Mais" class="abrirRel" rel="#solucoes">Saiba mais</a>
	*/
	$(".abrirRel").click( function(){
		$($(this).attr("rel")).slideToggle("fast");
	});
	

	///////////////////* Funções Específicas *////////////////////
	
	/* Tree Menu */
	$(".treemenu").toggle( function(){
		$(this).next(".hide").slideDown("fast");
	}, function(){
		$(this).next("div").slideUp("fast");
	});
	
	/* Menu */
	$(".btmenu").click( function(){
		classe = $(this).attr("class").search("ativo");
		if(classe == -1){
			$(this).next("div").slideDown("fast");
			$(this).addClass("ativo");
		}else{
			$(this).next("div").slideUp("fast");
			$(this).removeClass("ativo");
		}
	});
	
	/* Newsletter 
	$("#newsletter_link").click( function(){
		classe = $("#newsletter_janela").attr("class");
		if(classe == "hide"){
			$("#newsletter_janela").show("fast", function(){ $(this).removeClass("hide"); });
		}else{
			$("#newsletter_janela").hide("fast", function(){ $(this).addClass("hide"); });
		}
	});
	$("#newsletter_fechar").click( function(){
		$("#newsletter_janela").hide("fast", function(){ $(this).addClass("hide"); });
	});*/
	
	/* Caixa de Download */
	$("#bloqueio").css({opacity: 0.8});
	var arquivo = "";
	$(".download_rel").click( function(){
		scroll(0,0);
		arquivo = $(this).attr("rel");
		$("html").css("overflow","hidden");
		$("#bloqueio").fadeIn("fast", function(){
			$("#box_download").fadeIn("fast");
		});
	});
	$.fechar = function(){
		$("html").css("overflow","auto");
		$("#box_download").fadeOut("fast", function(){
			$("#bloqueio").fadeOut("fast");
		});
	}
	$(".fechar").click( function(){
		$.fechar();
	});
	$("#form_download").submit( function(){
		if(validaForm(document.form_download)){
			checado = g("download_aguardo_contato").checked ? "sim" : "não";
			gets = "nome="+$("#download_nome").val()+"&email="+$("#download_email").val()+"&telefone="+$("#download_telefone").val()+"&empresa="+$("#download_empresa").val()+"&cargo="+$("#download_cargo").val()+"&comentarios="+$("#download_comentarios").val()+"&aguardo_contato="+checado+"&folder="+arquivo
			$.ajax({
				type:"POST",
				url:"biblioteca/ajax.asp",
				data:gets,
				success: function(retorno){
					alert("Dados enviados com sucesso!\nClique aqui para iniciar o download.");
					$.fechar();
					window.location = "download.asp?filename="+arquivo.replace("download/","").replace(".pdf","")+"&path="+arquivo;
					//$("#box_download").html(retorno);
				}
			});
		}
	});
});