var Login = new function() {
  var notice;
  return {
    setNotice: function(n) {
      notice = n;
    },

    showNotice: function() {
      if (notice != null) {
        alert(notice);
      }
    }
  };
}();

var Slideshow = new function() {
  var delayTime = 2000;
  var fadeTime = 1500;
  var slideshow;

  return {
    initialize: function() {
      slideshow = $('#home_photos');
      this.loadImages();
      this.bindEvents();
      slideshow.find('.img-panel').trigger('swapImage');
    },

    bindEvents: function() {
      $('.img-panel', '#home_photos').bind('swapImage', function() {
        var element = this;
        var activeImage = $(this).find('img:visible');
        var nextImage;
        if (activeImage.next().length == 0) {
          nextImage = activeImage.parent().children(':first');
        } else {
          nextImage = activeImage.next();
        }
        activeImage.fadeOut(fadeTime);
        nextImage.fadeIn(fadeTime, function() {
          window.setTimeout(function() {
            $(element).trigger('swapImage');
          }, delayTime);
        });
      });
    },

    loadImages: function() {
      slideshow.find('img:not(:last-child)').hide();
    }
  };
}();

$(function() {
  window.setTimeout(function() {
    Slideshow.initialize();
  }, 1500);
  Login.showNotice();
  $('#access_code_code1').focus();
});


