$().ready(function(){
  //to begin, take the first three images and move them to the end of the collection (i.e. they appear on top)
  $('#right-image-container img:nth-child(1)').appendTo($('#right-image-container'));  
  $('#right-image-container img:nth-child(1)').appendTo($('#right-image-container'));  
  $('#right-image-container img:nth-child(1)').appendTo($('#right-image-container'));  
  window.setInterval(dealPicture, 1500);
});

var _pi_slot = 1;
function dealPicture() {
  var image = $('#right-image-container img:nth-child(1)');
  
  image.appendTo($('#right-image-container'));
  
  if ($.browser.msie) {
    switch (_pi_slot++) {
      case 1:
        image.css({position: "absolute", left: 58+10*Math.random(), top: 0+10*Math.random()}).show();
        break;
      case 2:
        image.css({position: "absolute", left: 58+10*Math.random(), top: 170+10*Math.random()}).show();
        break;
      case 3:
        image.css({position: "absolute", left: 58+10*Math.random(), top: 340+10*Math.random()}).show();
        break;
    }
  } else {
    switch (_pi_slot++) {
      case 1:
        image.css({position: "absolute", left: 53+10*Math.random(), top: -5+10*Math.random()}).hide().fadeIn();
        break;
      case 2:
        image.css({position: "absolute", left: 53+10*Math.random(), top: 165+10*Math.random()}).hide().fadeIn();
        break;
      case 3:
        image.css({position: "absolute", left: 53+10*Math.random(), top: 335+10*Math.random()}).hide().fadeIn();
        break;
    }
  }
  
  if (_pi_slot > 3) { _pi_slot = 1 };
}
