$(document).ready(function(){
  var elms = $('.rotation');
  var i = Math.floor(Math.random() * elms.length);
  $.each(elms, function(idx, elm){
    if (idx == i) {
      
      var close_btn = $('<div class="close_btn ui-icon ui-icon-circle-close"></div>');
      $(elm).append(close_btn);

      var timer_id = window.setInterval(function(){
        $(elm).effect('bounce');
      }, 5000);

      close_btn.click(function(){
        window.clearInterval(timer_id);
        close_btn.parent().hide();
      });

    } else {
      $(elm).hide();
    }

    var tag_panel = $('.tags_panel');
    if (tag_panel != null) {
      tag_panel.hide();
    }

    $('a.more_tags').click(function(){
      var tags_panel = $('.tags_panel');
      if (tags_panel != null) {
        tags_panel.show('slow');
      }
    });
  });

  var elms = $('.rotation2');
  var i = Math.floor(Math.random() * elms.length);
  $.each(elms, function(idx, elm){
    if (idx != i) {
      $(elm).hide();
    }
  });
});
