(function(b) {
  noise = window.noise || {};
  noise.gallery = function(l, h, e) {
    function m() {
      //e && b(".arrow-left,.arrow-right").fadeTo(500,0);
	//e && b(".arrow-left,.arrow-right").animate({opacity:0});
      var a;
      c.each(function(f, g) {
        g = b(g);
        a = b("div.caption", g);
        a.css("bottom", a.height() * -1);
        g.hide()
      })
    }
    var i = b(l), c = b("div.item", i), k = c.length;
    h = h || 5E3;
    var d = -1, j;
    e || (e = true);
    e && i.append('<a class="arrow-left"/></a><a class="arrow-right"/></a>');
    return{start:function() {
      i.removeClass('loading'); // added by raliste@reactor.cl on 20100221
      if(i.length) {
        var a = this;
        m();
        this.show(0);
        j = window.setInterval(function() {
          a.go(1)
        }, h);
        if(e) {
          b(".arrow-left").click(function() {
            a.go(0, 1)
          });
          b(".arrow-right").click(function() {
            a.go(1, 1)
          });
          /*b(".arrow-left,.arrow-right").hover(function() {
            //b(this).fadeTo(250, 1);
            b(this).animate({opacity:1});
          }, function() {
            b(this).animate({opacity:0});
  		//b(this).fadeTo(250, 0);
          })*/
        }return this
      }
    }, go:function(a, f) {
      if(f) {
        window.clearTimeout(j);
        j = null
      }if(a) {
        a = d + 1;
        if(a >= k)a = 0
      }else {
        a = d - 1;
        if(a < 0)a = k - 1
      }this.show(a)
    }, show:function(a) {
      if(d >= 0) {
        var f = b("div.caption", b(c[d]));
        f.animate({bottom:f.height() * -1});
        b(c[d]).fadeOut()
      }b(c[a]).fadeIn();
      b("div.caption", b(c[a])).animate({bottom:0});
      d = a
    }}
  };
  b(document).ready(function() {
    // we do not like the .each method in jquery 1.3!
    (new noise.gallery("#slideshow")).start()
  })
})(jQuery);

