
EVERYZING.transcriptMod_openFullTranscript = function(){
    var pWidth = 520; // width of popup
    var pHeight = 520; // height of popup
    var leftPos = screen.width - pWidth - 100; // 100px from right of screen
    var topPos = (screen.height - pHeight)/2; // vertically centered
    
    window.open(location.href.replace("/m/", "/transcript/"), "Transcript", "left=" + leftPos + ",top=" + topPos + ",width=" + pWidth + ",height=" + pHeight + ",resizable,scrollbars");
};


EVERYZING.transcriptMod_ares_keywordClick = function(keywordEl, lckeyword){
    var transcriptComponent = jQuery(".ez-transcriptMod-ares-snippets");
    var transcriptTabPanes = jQuery(".transcript-content", transcriptComponent);
    var keywordContainer = jQuery(".ez-transcriptMod-ares-keywords");
    
    var keywordFound = false;
    var keywordElement = jQuery(keywordEl);
    var keywordText = keywordElement.text();
    var keyword = new RegExp(keywordText, 'gi');
    var snippetShowingCounter = 0;
    
    /* Highlight the keyword */
    keywordContainer.find(".kwHeaderHighlight").removeClass("kwHeaderHighlight");
    keywordElement.addClass("kwHeaderHighlight");
    
    /* Show matching snippetItems */
    transcriptTabPanes.children("#snippetsTranscriptPane").find(".ez-transcriptMod-ares-snippetItem").each(function(){
        var snippetItem = jQuery(this);
        var snippetText = snippetItem.text();
        var snippet = snippetText.replace(/\s+/g, ' ');
        
        if (snippet.match(keyword)) {
            snippetItem.show();
            snippetShowingCounter++;
            keywordFound = true;
            
            /* highlight keywords in the snippetItem */
            snippetItem.find("span").each(function(){
                var wordElement = jQuery(this);
                var wordText = wordElement.text();
                
                if (keywordText.toLowerCase().indexOf(wordText.toLowerCase()) != -1){
                    wordElement.addClass("kwHighlight")
                }else{
                    wordElement.removeClass("kwHighlight");
                    wordElement.removeClass("stHighlight"); /* TODO: remove st types */
                }
            });
        }else {
            snippetItem.hide();
        }
    });
    
    if (!keywordFound) {
        transcriptTabPanes.children("#notFoundTranscript").show().siblings().hide();
    } else {
        // Here, we'll update the count span to show the number of results being displayed...
        transcriptComponent.find(".number-results").html("("+snippetShowingCounter+")");
        snippetShowingCounter = 0;
    };
    
    /* Show snippet in flash player */
    if (typeof playerInst0 != 'undefined') {
        playerInst0.showHideSnippetArrow(true, lckeyword);
    }
    
};
