$(document).ready(function() {

		$(function() {

  			var msie6 = $.browser == 'msie' && $.browser.version < 7;
  			var lastScrollTop = 0;

  				if (!msie6) {

							var top = $('#crc-es-menu').offset().top - parseFloat($('#crc-es-menu').css('margin-top').replace(/auto/, 0));

							$(window).scroll(function (event) {

									var y = $(this).scrollTop();

									if (y >= top) {

										   if (y > lastScrollTop){
											 $('#crc-es-menu').addClass('fixed').stop().animate({"top":""+y-120+"px"}, 300, 'easeOutQuad');
										   } else {
										   $('#crc-es-menu').addClass('fixed').stop().css({"top":""+y-120+"px"});
										   }

									} else {


											$('#crc-es-menu').removeClass('fixed').css({"top":"0px"});

									}
									
									lastScrollTop = y;

							});

    				}

		});

		$(function() {

				$("ul#menu li").css({"margin-top":"-30px"}).show().animate({"margin-top":"0px"}, 1000, 'easeOutBounce');

		});

		$(function() {

				$("a.link-hfx").hover(function() {
				var objImg = $(this).find("img");
				objImg.attr("src", objImg.attr("hover"));
				}, function() {
				var objImg = $(this).find("img");
				objImg.attr("src", objImg.attr("alt"));
				});
				
				$("a.link-ani-01").hover(function() {
				$(this).stop().animate({"top":"-15px"}, 600, 'easeOutQuad');
				}, function() {
				$(this).stop().animate({"top":"0px"}, 800, 'easeOutBounce');
				});

		});

		$(function() {

				$("ul#menu li").hover(function() {
				$(this).not(".selected").not(".static").find("a.menu-item").animate({"margin-top":"0px","padding-top":"15px"}, 300, 'easeOutBounce');
				}, function() {
				$(this).not(".selected").not(".static").find("a.menu-item").animate({"margin-top":"0px","padding-top":"9px"}, 300, 'easeOutBounce');
				});

		});

		$(function() {

				$("button#btnSearch").live("click", function(event) {

				    event.preventDefault();
				    alert('O sistema de busca está temporariamente desativado.');
				    $("input#form_search").val("Procurar ...");

				});

				$("button#btnNLreg").live("click", function(event) {

				    event.preventDefault();

						var nome 	= jQuery.trim($("#nl_nome").val());
						var email	= jQuery.trim($("#nl_email").val());

						    if(nome.length == 0 || nome == "Nome:") {
						    alert("Preencha o campo \"Nome\".");
						    $("#nl_nome").focus().select();
						    return;
						    }

						    if(email.length == 0 || email == "E-Mail:") {
						    alert("Preencha o campo \"E-Mail\".");
						    $("#nl_email").focus().select();
						    return;
						    }

						    $("#crc-es-actvix").html("").empty().load("./gateway.php", { cmd: "newsletter", user_nome: nome, user_email: email, ts:new Date().getTime() }, function(response, status, xhr) { return false; });
						    
						    return false;

				});

		});

		$(function() {

				Cufon.replace(".calibri-bold-italic", { fontFamily: "Calibri Bold Italic", hover: true });
				Cufon.replace(".calibri-italic", { fontFamily: "Calibri Italic", hover: true });
				Cufon.replace(".calibri-bold", { fontFamily: "Calibri Bold", hover: true });
				Cufon.replace(".calibri", { fontFamily: "Calibri", hover: true });

		});

});
