Cufon.replace(".fontReplace", { fontFamily : "Code Bold",	hover: true});
Cufon.replace(".fontReplace2", { fontFamily : "Asenine",	hover: true});
Cufon.replace(".fontReplaceCodeLight", { fontFamily : "Code Light",	hover: true});
Cufon.replace("h2", { fontFamily : "Asenine",	hover: true});
Cufon.replace("h3", { fontFamily : "Code Bold",	hover: true});

/****************** Scroll Personalizado */
function initScrollPane()
{
	$('.scrollPane, .clip-scroll').jScrollPane(
		{
			showArrows: true,
			verticalDragMaxHeight: 30,
			hideFocus: true
		}
	);
}
$(document).ready(function()
{
	initScrollPane();
});


/*************************  Galeria Fotos */
$(document).ready(function()
{
	$('#slideshow').cycle({
		fx: 'fade',
		speed: 'slow',
		timeout: 4000,
		pager: '#slider_nav',
		loop: true,
		activePagerClass: "activeSlide",
		pagerAnchorBuilder: function(idx, slide)
		{
			return '#slider_nav li:eq(' + (idx) + ') a';
		}
	});

	$("#slider").easySlider({
		prevId: 'slide-prev',
		nextId: 'slide-next',
		controlsShow: false,
		speed: 800,
		auto: true,
		pause: 2000,
		continuous: true
	});
});

$(document).ready(function()
{
	$('#slideshow2').cycle({
		fx: 'fade',
		speed: 'slow',
		timeout: 4000,
		pager: '#slider_nav2',
		loop: true,
		activePagerClass: "activeSlide",
		pagerAnchorBuilder: function(idx, slide)
		{
			return '#slider_nav2 li:eq(' + (idx) + ') a';
		}
	});

	$("#slider2").easySlider({
		prevId: 'slide-prev',
		nextId: 'slide-next',
		controlsShow: false,
		speed: 800,
		auto: true,
		pause: 2000,
		continuous: true
	});
});
/* **********************	Script Movimentos Boxes*/
	var i = 0;
	
	/*function boxOver(el)
	{
		if (!el.animating && !el.mouseover)
		{
			el.mouseover = true;
			el.animating = true;
			
			$(el).find(".stefany").animate(
			{
				left : "-285px"
			},
			"slow",
			function ()
			{
				this.parentNode.animating = false;
			});
		}
	}
	
	function boxOut(el)
	{
		var fnc = function ()
		{
			if (!el.animating && el.mouseover && !el.over)
			{
				el.mouseover = false;
				el.animating = true;
				
				$(el).find(".stefany").animate(
				{
					left : "0"
				},
				"slow",
				function ()
				{
					this.parentNode.animating = false;
				});
			}
		}
		
		setTimeout(fnc, 200);
	}*/
	
	$(document).ready(function ()
	{
		$(".bloquinho")
			.mouseover(function () {
				/*this.over = true;
				boxOver(this);*/
				$(this).find('.stefany').animate({
					left: '-285px'
				},{
					duration: 'slow',
					queue: false
				});
			})
			.mouseout(function () {
				/*this.over = false;
				boxOut(this);*/
				$(this).find('.stefany').animate({
					left: 0
				},{
					duration: 'slow',
					queue: false
				});
			});
	});
/*********************************** aparecer/esconder news */
$(document).ready(function() {
    $("a#news").toggle(function() {
        $("#envolve-newsletter").show('slow');
		$("#escuresse-site").addClass("estilo"); 
        }, function() {
        $("#envolve-newsletter").show('slow');
		$("#escuresse-site").addClass("estilo");
    });
	$("a#fechar").toggle(function() {
        $("#envolve-newsletter").hide('slow');
		$("#escuresse-site").removeClass("estilo"); 
        }, function() {
        $("#envolve-newsletter").hide('slow');
		$("#escuresse-site").removeClass("estilo"); 
    });
});
/******************************** enviar news */
function lightBoxNewsletter(acao, msg, erro)
{
	acao = acao.toUpperCase();
	
	if (acao == "SHOW")
	{
		$lb = $('<div id="lightBoxNewsletter">');
		$shadow = $('<div class="shadow"></div>');
		$box = $('<div class="lightBox"></div>');
		$boxContent = $('<span></span>');
		$boxButtom = $('<div class="buttom"></div');
		$boxImgButtom = $('<a href="javascript:void(0);" id="buttomOK" alt="Fechar" title="Fechar">x</a>')
			.click(function ()
			{
				lightBoxNewsletter("HIDE");
			});
		
		if (erro)
		{
			$box.addClass("erro");
		}
		
		$boxButtom.append($boxImgButtom);
		$boxContent.append(msg);
		$box.append($boxButtom).append($boxContent);
		$lb.append($shadow).append($box);
		
		$("#newsletter").prepend($lb);
	}
	else if (acao == "HIDE")
	{
		$("#lightBoxNewsletter").remove();
	}
}

function formNewsSubmit(url)
{
	$("#newsForm").append('<div class="lightbox loading"></div>');
	
	var $dc_email = $("#dc_email");
	var dc_email = $dc_email.val();
	
	$dc_email.val("Enviando...");
	
	$.ajax(
	{
		type: "POST",
		url: url + "/themes/larocca/newsletter.php",
		data: "dc_email=" + dc_email,
		success: function(msg)
		{
			$("#newsForm").children(".loading").remove();
			
			var erro = false;
			
			if (msg.indexOf("#") != -1)
			{
				erro = true;
				msg = msg.split("#");
				msg = msg[1];
			}
			
			lightBoxNewsletter("SHOW", msg, erro);
			
			$("#dc_email").val("");
		}
	});
}
/****************************** AGENDA EVENTOS */
/*$(function () {
    $('.date_has_event').each(function () {
      // options
      var distance = 10;
      var time = 250;
      var hideDelay = 500;

      var hideDelayTimer = null;

      // tracker
      var beingShown = false;
      var shown = false;

      var trigger = $(this);
      var popup = $('.events ul', this).css('opacity', 0);

      // set the mouseover and mouseout on both element
      $([trigger.get(0), popup.get(0)]).mouseover(function () {
        // stops the hide event if we move from the trigger to the popup element
        if (hideDelayTimer) clearTimeout(hideDelayTimer);

        // don't trigger the animation again if we're being shown, or already visible
        if (beingShown || shown) {
          return;
        } else {
          beingShown = true;

          // reset position of popup box
          popup.css({
            bottom: 20,
            left: -76,
            display: 'block' // brings the popup back in to view
          })

          // (we're using chaining on the popup) now animate it's opacity and position
          .animate({
            bottom: '+=' + distance + 'px',
            opacity: 1
          }, time, 'swing', function() {
            // once the animation is complete, set the tracker variables
            beingShown = false;
            shown = true;
          });
        }
      }).mouseout(function () {
        // reset the timer if we get fired again - avoids double animations
        if (hideDelayTimer) clearTimeout(hideDelayTimer);

        // store the timer so that it can be cleared in the mouseover if required
        hideDelayTimer = setTimeout(function () {
          hideDelayTimer = null;
          popup.animate({
            bottom: '-=' + distance + 'px',
            opacity: 0
          }, time, 'swing', function () {
            // once the animate is complete, set the tracker variables
            shown = false;
            // hide the popup entirely after the effect (opacity alone doesn't do the job)
            popup.css('display', 'none');
          });
        }, hideDelay);
      });
    });
  });*/
