function fetchObject()
{
    var objlist = document.getElementsByTagName('object');
    var h;
    for(h=0;h<objlist.length;h++)
    {
       if(!objlist[h].id || objlist[h].id.indexOf("flowplayer") < 0)
       {
          return objlist[h];
       }
    }   
    /* if there are no objects, this might be IE6, so try a different way */
    
    objlist = document.getElementsByTagName('embed');
    return (objlist && objlist.length !=0)?objlist[0]:null;
}

function FixMissingYouTube()
{
  if(typeof addVideosToQuicklist != 'function')
  {
    var obj;
    for(var counter=0;obj = fetchObject();counter++)
    {
      width = obj.width;
      height = obj.height;
      var par = obj.parentNode;
      var j;
      var url=null;
      
      for (j=0;obj.childNodes && j<obj.childNodes.length;j++)
      {
        if(obj.childNodes[j].tagName && obj.childNodes[j].tagName == "PARAM" && obj.childNodes[j].name && obj.childNodes[j].name == "movie" && obj.childNodes[j].value)
        {
          url = obj.childNodes[j].value;
          break;
        } 
      }
      
      url = (!url && obj.tagName == 'EMBED')?obj.src:url; /* catching IE6 case where OBJECT may be missing from DOM */
      if(url)
      {
        var pos1 = url.indexOf("&") - 1;
        pos1 = (pos1<0)?(url.length):pos1;
        var url = url.substring(0,pos1);
        pos1 = url.lastIndexOf("=");
        pos2 = url.lastIndexOf("/");
        pos1 = (pos2>pos1)?pos2:pos1;
        url = url.substring(pos1+1,url.length);
        var ptemp = document.createElement('P');
        ptemp.innerHTML = '<object width="' + width + '" height="' + height + '" id="flowplayer' + counter + '" name="_player" data="/flowplayer/flowplayer-3.2.2.swf" type="application/x-shockwave-flash"><param name="movie" value="/flowplayer/flowplayer-3.2.2.swf" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="flashvars" value=\'config={"clip":{"url":"http://www.plumis.co.uk/videos/'+url+'.flv","autoPlay":false,"autoBuffering":true}}\' /></object>';
        var newobj = ptemp.firstChild;
        par.replaceChild(newobj,obj);
      }
    }
  }
}

FixMissingYouTube();
