title: Obtaining YouTube video ID in a URL and inputting selected video ID into a URL
body: <p>I've been having trouble in trying to figure this out. What I am trying to do is, obtain the ID of a video from YouTube, and input the 11 character ID into the css of a <code>div</code> of a specific id by using jQuery. I know the URL for the thumbnail of any video, but I just need to be able to change the ID to display different video thumbnails.</p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function() {
          function(data) {
              videoID = data.split('www.youtube.com/v/')[1].split('&amp;amp')[0];
              $("#304817679").append(videoID);
          });
  
          $("#304817679").replaceWith("&lt;div id=\"304817679\" " +
              "style=\"background: url(http://img.youtube.com/vi/" + 
              $.function(data) + 
              "/0.jpg) no-repeat middle; width: 15px; height: 150px;\"&gt;&lt;/div&gt;");
      });
  &lt;/script&gt;
  
  &lt;div id="304817679"&gt;
      &lt;div style="display: none;"&gt;
          &lt;object width="248" height="222"&gt;
              &lt;param name="movie" value="http://www.youtube.com/v/vy90n2nNRKQ&amp;amp;rel=0&amp;amp;egm=0&amp;amp;showinfo=0&amp;amp;fs=1"&gt;&lt;/param&gt;
              &lt;param name="wmode" value="transparent"&gt;&lt;/param&gt;
              &lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;
              &lt;embed src="http://www.youtube.com/v/vy90n2nNRKQ&amp;amp;rel=0&amp;amp;egm=0&amp;amp;showinfo=0&amp;amp;fs=1" type="application/x-shockwave-flash" width="248" height="222" allowFullScreen="true" wmode="transparent"&gt;&lt;/embed&gt;
          &lt;/object&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Trying to explain this better, I want the 11 Character YouTube Video ID from the embedded code, and put it into the URL of the thumbnail (<code>http://img.youtube.com/vi/" + 
  function(data) + "/0.jpg"</code>). Which, would then also replace the original <code>div</code> (<code>&lt;div id="304817679"&gt;</code>).</p>
  
  <p>Am I on the right track with my script?</p>