title: join Javascript embed code
body: <p>This is about a Blogger template called Bloggertube
  Its originally coded to embed youtube videos and grab url image and post the image thumbnail</p>
  
  <p>I also modified to work with Dailymotion</p>
  
  <p>But I'm pretty newbie at Javascript, and I'm trying to figure out how to make a condition to make them work at same time, and also add more sites in the future</p>
  
  <p>function <em>createVideoThumb</em> refers to thumbnail creation</p>
  
  <p>function <em>createVideoThumb2</em> refers to player's embed code</p>
  
  <p><strong>The blogger post sintax is:</strong></p>
  
  <p>(youtube link)endofvid</p>
  
  <p>[starttext]
  (post text)
  [endtext]</p>
  
  <p>Youtube code:</p>
  
  <pre><code>function createVideoThumb(pID){
      var div = document.getElementById(pID);
      var summ = summary_noimg;
      if (div.innerHTML.indexOf("http://www.youtube.com/watch?v=")!=-1){
        var vidid = div.innerHTML.substring(div.innerHTML.indexOf("http://www.youtube.com/watch?v=")+31,div.innerHTML.indexOf("endofvid"));
      }else {var vidid =""};  
      var postlink = div.innerHTML.substring(div.innerHTML.indexOf("[postlink]")+10,div.innerHTML.indexOf("[/postlink]"));    
      if (vidid ==""){var imgvid ='&lt;a href="'+ postlink + '"&gt;&lt;img  class="thumbnail" src="http://i195.photobucket.com/albums/z105/dantearaujo/novideo.png" width="'+img_thumb_width+'px" height="'+img_thumb_height+'px"/&gt;&lt;/a&gt;';
                     }else{
                       var imgvid ='&lt;a href="'+ postlink + '"&gt;&lt;img  class=thumbnail src="http://img.youtube.com/vi/'+vidid+'/mqdefault.jpg" width="'+img_thumb_width+'px" height="'+img_thumb_height+'px"/&gt;&lt;/a&gt;';
                     };
      var summary = imgvid ;
      div.innerHTML = summary;
    }
    function createVideoThumb2(pID){
      var div = document.getElementById(pID);
      var imgtag = "";
      var summ = summary_noimg;
      if (div.innerHTML.indexOf("http://www.youtube.com/watch?v=")!=-1){
        var vidid = div.innerHTML.substring(div.innerHTML.indexOf("http://www.youtube.com/watch?v=")+31,div.innerHTML.indexOf("endofvid"));
      }else {var vidid =""};
      var textinside = div.innerHTML.substring(div.innerHTML.indexOf("[starttext]")+11,div.innerHTML.indexOf("[endtext]"));
      var postlink = div.innerHTML.substring(div.innerHTML.indexOf("[postlink]")+10,div.innerHTML.indexOf("[/postlink]"));
      var embedvid = "";
      if (vidid!="") {
        embedvid = '&lt;object width="654" height="393"&gt;&lt;param name="movie" value="http://www.youtube.com/v/'+ vidid + '&amp;hl=en&amp;fs=1&amp;rel=0&amp;autoplay=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/'+ vidid + '&amp;hl=en&amp;fs=1&amp;rel=0&amp;autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="654" height="393"&gt;&lt;/embed&gt;&lt;/object&gt;'
      }
      var summary =  embedvid + '&lt;div class="content"&gt;' + textinside  + '&lt;/div&gt;';
      div.innerHTML = summary;
    }
  </code></pre>
  
  <p>Dailymotion code</p>
  
  <pre><code>function createVideoThumb(pID){
      var div = document.getElementById(pID);
      var summ = summary_noimg;
      if (div.innerHTML.indexOf("http://www.dailymotion.com/video/")!=-1){
        var vidid = div.innerHTML.substring(div.innerHTML.indexOf("http://www.dailymotion.com/video/")+33,div.innerHTML.indexOf("endofvid"));
      }else {var vidid =""};  
      var postlink = div.innerHTML.substring(div.innerHTML.indexOf("[postlink]")+10,div.innerHTML.indexOf("[/postlink]"));    
      if (vidid ==""){var imgvid ='&lt;a href="'+ postlink + '"&gt;&lt;img  class="thumbnail" src="http://i195.photobucket.com/albums/z105/dantearaujo/novideo.png" width="'+img_thumb_width+'px" height="'+img_thumb_height+'px"/&gt;&lt;/a&gt;';
                     }else{
                       var imgvid ='&lt;a href="'+ postlink + '"&gt;&lt;img  class=thumbnail src=" http://www.dailymotion.com/thumbnail/video/'+vidid+'" width="'+img_thumb_width+'px" height="'+img_thumb_height+'px"/&gt;&lt;/a&gt;';
                     };
      var summary = imgvid ;
      div.innerHTML = summary;
    }
    function createVideoThumb2(pID){
      var div = document.getElementById(pID);
      var imgtag = "";
      var summ = summary_noimg;
      if (div.innerHTML.indexOf("http://www.dailymotion.com/video/")!=-1){
        var vidid = div.innerHTML.substring(div.innerHTML.indexOf("http://www.dailymotion.com/video/")+33,div.innerHTML.indexOf("endofvid"));
      }else {var vidid =""};
      var textinside = div.innerHTML.substring(div.innerHTML.indexOf("[starttext]")+11,div.innerHTML.indexOf("[endtext]"));
      var postlink = div.innerHTML.substring(div.innerHTML.indexOf("[postlink]")+10,div.innerHTML.indexOf("[/postlink]"));
      var embedvid = "";
      if (vidid!="") {
        embedvid = '&lt;iframe frameborder="0" width="654" height="393" src="//www.dailymotion.com/embed/video/'+ vidid +'" allowfullscreen&gt;&lt;/iframe&gt;'
      }
      var summary =  embedvid + '&lt;div class="content"&gt;' + textinside  + '&lt;/div&gt;';
      div.innerHTML = summary;
    }
  </code></pre>