function expand_wt($mvd_id)
 {
     global $wgOut, $mvgIP;
     global $mvDefaultSearchVideoPlaybackRes;
     require_once $mvgIP . '/includes/MV_Index.php';
     require_once $mvgIP . '/includes/MV_Title.php';
     require_once $mvgIP . '/includes/MV_MetavidInterface/MV_Overlay.php';
     $mvd = MvIndex::getMVDbyId($mvd_id);
     if (count($mvd) != 0) {
         $mvTitle = new MvTitle($mvd->wiki_title);
         //validate title and load stream ref:
         if ($mvTitle->validRequestTitle()) {
             list($vWidth, $vHeight) = explode('x', $mvDefaultSearchVideoPlaybackRes);
             $embedHTML = '<span style="float:left;width:' . ($vWidth + 20) . 'px">' . $mvTitle->getEmbedVideoHtml($mvd_id, $mvDefaultSearchVideoPlaybackRes) . '</span>';
             $wgOut->clearHTML();
             $title = Title::MakeTitle(MV_NS_MVD, $mvd->wiki_title);
             $article = new Article($title);
             $MvOverlay = new MV_Overlay();
             $MvOverlay->parse_format_text($article->getContent(), $mvTitle);
             $bgcolor = $MvOverlay->getMvdBgColor($mvd);
             $pageHTML = $wgOut->getHTML();
             //encasulate page html:
             $pageHTML = '<span style="padding-top:10px;float:left;width:450px">' . $pageHTML . '</span>';
             return $embedHTML . $pageHTML . '<div style="clear: both;"/>';
         } else {
             return wfMsg('mvBadMVDtitle');
         }
     } else {
         return wfMsg('mv_error_mvd_not_found');
     }
     //$title = Title::MakeTitle(MV_NS_MVD, $wiki_title);
     //$article = new Article($title);
     //output table with embed left, and content right
     //return $wgOut->parse($article->getContent());
 }
    function getResultsHTML()
    {
        global $mvgIP, $wgOut, $mvgScriptPath, $mvgContLang, $wgUser, $wgParser;
        $sk =& $wgUser->getSkin();
        $o = '';
        if ($this->outputContainer) {
            $o .= '<div id="mv_search_results_container">';
        }
        //for each stream range:
        if (count($this->results) == 0) {
            $o .= '<h2><span class="mw-headline">' . wfMsg('mv_search_no_results') . '</span></h2>';
            if ($this->outputContainer) {
                $o .= '</div>';
            }
            return $o;
        } else {
            if ($this->outputInlineHeader) {
                $o .= '<h2>
						<span class="mw-headline">' . wfMsg('mv_media_matches') . '</span>
					</h2>';
                $title = Title::MakeTitle(NS_SPECIAL, 'MediaSearch');
                $o .= $sk->makeKnownLinkObj($title, wfMsg('mv_advaced_search'), $this->get_httpd_filters_query());
            }
        }
        //media pagging:
        $prevnext = mvViewPrevNext($this->offset, $this->limit, SpecialPage::getTitleFor('MediaSearch'), $this->get_httpd_filters_query(), $this->num < $this->limit);
        $o .= "<br /><span id=\"mv_search_pagging\">{$prevnext}</span>\n";
        //add the rss link:
        $sTitle = Title::MakeTitle(NS_SPECIAL, 'MvExportSearch');
        $o .= '<span style="float:right;">';
        $o .= $sk->makeKnownLinkObj($sTitle, '<img border="0" src="' . $mvgScriptPath . '/skins/images/feed-icon-28x28.png">', $this->get_httpd_filters_query());
        $o .= '</span>';
        //add the results bar:
        $o .= $this->getResultsBar();
        //print_r($this->results);
        foreach ($this->results as $stream_id => &$stream_set) {
            $matches = 0;
            $stream_out = $mvTitle = '';
            foreach ($stream_set as &$srange) {
                $cat_html = $mvd_out = '';
                $range_match = 0;
                foreach ($srange['rows'] as $inx => &$mvd) {
                    $matches++;
                    $mvTitle = new MV_Title($mvd->wiki_title);
                    //retrieve only the first article:
                    //$title = Title::MakeTitle(MV_NS_MVD, $mvd->wiki_title);
                    //$article = new Article($title);
                    $bgcolor = MV_Overlay::getMvdBgColor($mvd);
                    //output indent if not the first and count more than one
                    if (count($srange['rows']) != 1 && $inx != 0) {
                        $mvd_out .= '&nbsp; &nbsp; &nbsp; &nbsp;';
                    }
                    //'<img src="'. $mvgScriptPath . '/skins/images/film.png">'
                    //$mvd_out .= '<div class="mv_rtdesc" title="' . wfMsg('mv_expand_play') . '"  '.
                    //				'> ';
                    $mvd_out .= '<img style="float:left;width:84px;cursor:pointer;border:solid #' . $bgcolor . '" ' . ' onclick="mv_ex(\'' . $mvd->id . '\')" width="80" height="60" src="' . $mvTitle->getStreamImageURL('icon') . '">';
                    $mvd_out .= '</div>';
                    $mvd_out .= '<b>' . $mvTitle->getTimeDesc() . '</b>&nbsp;';
                    $mvd_cnt_links = '';
                    if (isset($mvd->spoken_by)) {
                        $ptitle = Title::MakeTitle(NS_MAIN, $mvd->spoken_by);
                        $mvd_cnt_links .= wfMsg('mv_search_spoken_by') . ': ' . $sk->makeKnownLinkObj($ptitle);
                        $mvd_cnt_links .= '<br>';
                    }
                    if ($this->outputSeqLinks == true) {
                        $mvd_cnt_links .= '&nbsp;<a href="javascript:mv_add_to_seq({mvclip:\'' . $mvTitle->getStreamName() . '/' . $mvTitle->getTimeRequest() . '\',' . 'src:\'' . $mvTitle->getWebStreamURL() . '\',' . 'img_url:\'' . $mvTitle->getStreamImageURL() . '\'})">' . '<img style="cursor:pointer;" ' . 'title="' . wfMsg('mv_seq_add_end') . '" ' . 'src="' . $mvgScriptPath . '/skins/mv_embed/images/application_side_expand.png">' . wfMsg('mv_seq_add_end') . '</a>';
                    }
                    $mvd_cnt_links .= '<a title="' . wfMsg('mv_expand_play') . '" href="javascript:mv_ex(\'' . $mvd->id . '\')">' . '<img id="mv_img_ex_' . $mvd->id . '"  src="' . $mvgScriptPath . '/skins/images/closed.png">' . '<span id="mv_watch_clip_' . $mvd->id . '">' . wfMsg('mv_watch_clip') . '</span>' . '<span style="display:none;" id="mv_close_clip_' . $mvd->id . '">' . wfMsg('mv_close_clip') . '</span>' . '</a>' . '&nbsp;&nbsp;';
                    //output control links:
                    //make stream title link:
                    $mvStreamTitle = Title::MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName());
                    //$mvTitle->getStreamName() .'/'.$mvTitle->getStartTime() .'/'. $mvTitle->getEndTime() );
                    $mvd_cnt_links .= $sk->makeKnownLinkObj($mvStreamTitle, '<img border="1" src="' . $mvgScriptPath . '/skins/images/run_mv_stream.png"> ' . wfMsg('mv_improve_transcript'), '', '', '', '', ' title="' . wfMsg('mv_view_in_stream_interface') . '" ');
                    $mvd_cnt_links .= '<br>';
                    //$title = MakeTitle::()
                    //don't inclue link to wiki page (too confusing)
                    //$mvd_out .='&nbsp;';
                    $mvdTitle = Title::MakeTitle(MV_NS_MVD, $mvd->wiki_title);
                    //$mvd_out .= $sk->makeKnownLinkObj($mvdTitle, '<img border="0" src="' . $mvgScriptPath . '/skins/images/run_mediawiki.png">', '', '', '', '', ' title="' . wfMsg('mv_view_wiki_page') . '" ');
                    $mvd_out .= '<span id="mvr_desc_' . $mvd->id . '">';
                    if (!isset($mvd->toplq)) {
                        $mvd->toplq = false;
                    }
                    //output short desc send partial regEx:
                    if (!$mvd->toplq) {
                        $mvd_out .= $this->termHighlight($mvd->text, implode('|', $this->getTerms()));
                    } else {
                        if ($mvdTitle->exists() && !isset($mvd->text)) {
                            //grab the article text:
                            $curRevision = Revision::newFromTitle($mvdTitle);
                            $wikiText = $curRevision->getText();
                        } else {
                            $wikiText =& $mvd->text;
                        }
                        //@@todo parse category info if present
                        $cat_html = '';
                        //run via parser to add in Category info:
                        $parserOptions = ParserOptions::newFromUser($wgUser);
                        $parserOptions->setEditSection(false);
                        $parserOptions->setTidy(true);
                        $title = Title::MakeTitle(MV_NS_MVD, $mvd->wiki_title);
                        $parserOutput = $wgParser->parse($wikiText, $title, $parserOptions);
                        $cats = $parserOutput->getCategories();
                        foreach ($cats as $catkey => $title_str) {
                            $catTitle = Title::MakeTitle(NS_CATEGORY, $catkey);
                            $cat_html .= ' ' . $sk->makeKnownLinkObj($catTitle);
                        }
                        //add category pre-text:
                        //if ($cat_html != '')
                        //$mvd_out.= wfMsg('Categories') . ':' . $cat_html;
                        $mvd_out .= $cat_html;
                        $mvd_out .= count($srange['rows']) - 1 == 1 ? wfMsg('mv_match_text_one') : wfMsg('mv_match_text', count($srange['rows']) - 1);
                        //$wgOut->addCategoryLinks( $parserOutput->getCategories() );
                        //$cat_html = $sk->getCategories();
                        //empty out the categories
                        //$wgOut->mCategoryLinks = array();
                    }
                    $mvd_out .= '</span>';
                    $mvd_out .= '<br>' . $mvd_cnt_links;
                    $mvd_out .= '<div style="display:block;clear:both;padding-top:4px;padding-bottom:4px;"/>';
                    $mvd_out .= '<div id="mvr_' . $mvd->id . '" style="display:none;background:#' . $bgcolor . ';" ></div>';
                }
                $stream_out .= $mvd_out;
                /*if(count($srange['rows'])!=1){					
                			$stream_out .= '&nbsp;' . $cat_html . ' In range:' . 
                			seconds2ntp($srange['s']) . ' to ' . seconds2ntp($srange['e']) .
                			wfMsg('mv_match_text', count($srange['rows'])).'<br />' . "\n";
                			$stream_out .= $mvd_out;
                		}else{								
                			$stream_out .= $mvd_out;
                		}*/
            }
            $nsary = $mvgContLang->getNamespaces();
            //output stream name and mach count
            /*$o.='<br /><img class="mv_stream_play_button" name="'.$nsary[MV_NS_STREAM].':' .
            			$mvTitle->getStreamName() .
            				'" align="left" src="'.$mvgScriptPath.'/skins/mv_embed/images/vid_play_sm.png">';
            		*/
            $o .= '<h3>' . $mvTitle->getStreamNameText();
            $o .= $matches == 1 ? wfMsg('mv_match_text_one') : wfMsg('mv_match_text', $matches);
            $o .= '</h3>';
            $o .= '<div id="mv_stream_' . $stream_id . '">' . $stream_out . '</div>';
        }
        if ($this->outputContainer) {
            $o .= '</div>';
        }
        return $o;
    }