(function($) {
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(!$.support.opacity)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
})(jQuery);

window.onerror = function(){return true}
var bxtt972k = {curi:0, itens:undefined, ttin: undefined, ttout:undefined}
function dosetas()
{
  $("#boxft_back").show();
  $("#boxft_forw").show();
  if (bxtt972k["itens"].length == 1)
  {
      $("#boxft_back").hide();
      $("#boxft_forw").hide();
  }
}
function doboxrotate(i)
{
  clearTimeout(bxtt972k["ttout"]);
  bxtt972k["curi"] += i;
  if (bxtt972k["curi"] >= bxtt972k["itens"].length)
    bxtt972k["curi"] = 0;

  if (bxtt972k["curi"] < 0)
    bxtt972k["curi"] = bxtt972k["itens"].length -1;
   
  bxtt972k["itens"].each(function(){ $(this).hide() });
  bxtt972k["itens"].eq(bxtt972k["curi"]).customFadeIn('slow', function()
  {
    bxtt972k["ttout"] = setTimeout("doboxrotate(1)", 10000);
  });
}
function inittte()
{
  clearTimeout(bxtt972k["ttin"]);
  if (document.getElementById("gallery") && window.DIT == 0)
  {
    bxtt972k["itens"] = $("#gallery > span[ft]");
    dosetas();
     //Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
    $('#gallery .box_letras').animate({opacity: 0.7},1 );
    if (bxtt972k["itens"].length == 1) return;
    $("#boxft_back").click(function(){ doboxrotate(-1) });
    $("#boxft_forw").click(function(){ doboxrotate(1) });
    bxtt972k["ttout"] = setTimeout("doboxrotate(1)", 10000);
  } else {
    bxtt972k["ttin"] = setTimeout("inittte()", 1000);
  }
   
}
inittte();
