var vidIndex = -1;  
                var vidIndices = [];  
                var vidURLs = [];
                
                //parses blog entries for video tags and replaces them with video holder div elements
                function insertVideos(){
                                allEntries = $('.ms-PostBody');
                                //for each blog entry, parse entry and create video holders
                                for (var i=0; i<allEntries.length;i++){
                                                entryContent=allEntries[i].firstChild.innerHTML;
                                                entryContent=entryContent.replace(/&lt;BLOGVIDEO:\s*(.*)&gt;/gi,function(m){return getHolderCode(m)});     
                                                allEntries[i].innerHTML=entryContent;  
                                }
                                
                                //for each video on the page, inject the media player into the appropriate holder
                                for(k=0;k<vidURLs.length;k++){
                                                insertVideo(document.getElementById('videoHolder'+vidIndices[k]),vidURLs[k]);                                                       
                                }                              
                }
                
                                
                //provides an incremented ID for a videoHolder div element and associates this videoHolder ID with the video URL
                function getHolderCode(matched){
                                if (matched.match(/&lt;BLOGVIDEO:\s*(.*)&gt;/i)) vidURL=RegExp.lastParen;
                                if (matched.match(/<A href="(.*)"/i)) vidURL=RegExp.lastParen;
                                vidIndex++;
                                vidURLs.push(vidURL);  
                                vidIndices.push(vidIndex);          
                                return "<div id='videoHolder" + vidIndex + "'></div>";   
                }

                
                //inserts a media web part with given video into a given video holder div
                function insertVideo(videoHolder,videoURL){
                                mediaPlayer.createMediaPlayer(
                                videoHolder,
                                                                videoHolder.id,
                '400px', 
                '266px',
                {
                                displayMode:'Inline',
                                mediaTitle:'Video Entry',
                                mediaSource:videoURL,
                                previewImageSource:'',
                                autoPlay:false,
                                loop:true,
                                mediaFileExtensions:'wmv;wma;avi;mpg;mp3;',
                                silverlightMediaExtensions:'wmv;wma;mp3;'
                }
            );

                }
                
                
              
