var cdfollow_timeout;

soundManager.url = './swf/';

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preloadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery);

function windowResized() {
  var w, h;
  
  w = $(this).width();
  h = $(this).height();
  
  if(h < 480) {
    $('#footer').css({
      top: '413px',
      bottom: 'auto'
    });
  }
  else {
    $('#footer').css({
      top: 'auto',
      bottom: '30px'
    });
  }
}

$(document).ready(function() {

  if(js_page == 'music' && $(window).height() >= 710) {
    $('#icon_cd .menupop').show();
  }

  $('.icon').hover(function() {
    var $menupop = $(this).parent().find('.menupop');
    
    if($menupop.is(':hidden')) {
      $('.menupop').fadeOut();
      $menupop.fadeIn();
    }
  }, function() {
    var self = this;
    cdfollow_timeout = setTimeout(function() {
      $(self).parent().find('.menupop').fadeOut();
    }, 200);
  });

  $('.menupop').hover(function() {
    clearTimeout(cdfollow_timeout);
  }, function() {
    $(this).fadeOut();
  });
  
  $.preloadImages(
    'img/menupop_bg_social.png',
    "img/menupop_bg_music.png"
  );
  
  windowResized();
  
  $(window).resize(function() {
    windowResized();
  });

});
