function homepageBannerStep(box, pagingItem, data, step) {
  var image = '<a href="'+ data[step].url +'"><img src="'+ data[step].image_url +'" alt="" class="hidden" /></a>';
  $(image).find("img").load(function() {
    $(box).find(".in a:first img").fadeOut("normal", function() { $(this).parents("a").remove(); });
    $(box).find(".in .img").append(image).find("img").fadeIn("normal").removeClass("hidden");
    $(box).find(".paging li").removeClass("active").parents("ul");
    $(pagingItem).addClass("active");
  });
}

function homepageBannerTimeoutTrigger(box, homepageBannerSystem, activeBanner, bannersCount) {
  var imageId = (activeBanner >= (bannersCount - 1)) ? 0 : Number(activeBanner+1);
  var pagingItem = $(box).find(".paging li a[rel='"+ imageId +"']").parents("li");
  homepageBannerStep(box, pagingItem, homepageBannerSystem, imageId);
  return imageId;
}
