if(typeof(console) == 'undefined') {
  console = {log: function(){}};
}

var Panda = {
  apps: $([
    { name: "Cool Curlings",
      thumbUrl: "/images/curlings-thumb.png",
      imageUrl: "/images/curlings.png",
      description: "The best iPhone game about the Jamaican Curling team ever made!",
      targetUrl: "/curling/"
    },
    { name: "Pocket Soccer",
      thumbUrl: "/images/soccer-thumb.png",
      imageUrl: "/images/soccer.png",
      description: "Soccer? Football? &iquest;F&uacute;tbol? We call it fun!",
      targetUrl: "/soccer/"
    }
  ]),

  domReady: function() {
    Panda.apps.each(function(i, app) {
      var click = function() {
        if (app.targetUrl) location.href = app.targetUrl;
      }
      var appDiv = $('<div class="app"></div>');
      appDiv.appendTo($('div#apps'));
      $('<img/>').attr({
        src: app.thumbUrl, title: app.name, alt: app.name
      }).appendTo(appDiv).click(click);
      appDiv.append("<div class=\"name\">" + app.name + "</div>");
      var image = new Image();
      image.src = app.imageUrl;

      var over = function () {
        $('#description').html(app.description)
        $('#logo > img').attr({
          src: app.imageUrl, title: app.name, alt: app.name,
          width: 300, height: 200
        })
      };
      var out = function () {
      }
      appDiv.hover(over, out);
    });
  },
  _: null
}

$(document).ready(Panda.domReady);
