function addVideo(id) {
  var swf = $("#videoInfo_" + id).attr("swf"),
      title = $("#videoInfo_" + id).html();
  swfobject.embedSWF(swf, "videoObj", "340", "300", "8.0.0");
  $("#videoTitle").html(title);
}

$(function() {
  
  // Load the first SWF Object
  addVideo(1);
  
  $(".videoListItem").click(function() {
                              var id = $(this).attr("id").split("_")[1],
                                  offset = $(this).offset(),
                                  ww = $(this).width(),
                                  hh = $(this).height(),
                                  img = $(this).attr("src"),
                                  newLeft = $("#video").offset().left + 10,
                                  newTop = $("#video").offset().top + 10,
                                  newWidth = 320,
                                  newHeight = 240;
                                  
                              $("#tmpImg").remove();
                              $("#videoObj").html("");
                              $("#videoObj").hide();
                              
                              // Animation
                              // Create a copy of the image we clicked on
                              var h = "<img id=\"tmpImg\"/>";
                              $(h).appendTo("body")
                                  .css({position: "absolute",
                                        left: offset.left,
                                        top: offset.top,
                                        width: ww,
                                        height: hh,
                                        zIndex: 9999})
                                  .attr({src: img});
                                  
                              $("#tmpImg").animate({left: newLeft,
                                                    top: newTop,
                                                    width: newWidth,
                                                    height: newHeight}, function() {
                                                      
                                                                          // Display the right video
                                                                          addVideo(id);
                                                                          $("#videoObj").show();
                                                                          
                                                                          $(this).remove();
                                                                        });
                              
                            });
});