Background = {
  
  init: function() {
    var form = $('form[@id=bg-images-getter]');
    $.post(form.attr('action'), $(form).serialize(), function(photos){
      Background.photos = $(photos).find('photo');
      $($('#background img').get(0)).attr('src',
        $(Background.photos.get(Background.currentIndex = Math.floor(
          Math.random() * Background.photos.length
        ))).attr('url')
      );
      if (Background.photos.length > 1) {
        Background.update();
      }
    }, 'xml');
  },
  
  update: function() {
    do {
      nextIndex = Math.floor(Math.random() * Background.photos.length);
    } while (nextIndex ==　Background.currentIndex);
    $('#background img').attr('src', $(Background.photos.get(nextIndex)).attr('url'));
    Background.currentIndex = nextIndex;
    setTimeout(Background.update, 17000);
  },
  
  layout: function() {
  　　minmax_layout();
    setTimeout(Background.layout, 100);
  }
  
};

$(document).ready(function() {
  /*@cc_on
  @if (@_win32 && @_jscript_version>4)
  　　minmax_stop();
  @end @*/
  Background.init();
  /*@cc_on
  @if (@_win32 && @_jscript_version>4)
  Background.layout();
  @end @*/
});
