
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
                         
                
            

                myGlossaryTerms = new Array("allowable\ amount","annual\ deductible","annual\ out\-of\-pocket\ maximum","claim","claim\ form","COBRA","coinsurance","contracting\ hospital\ ","copayment","covered\ person","covered\ service","deductible","dependent\ ","exclusions","family\ coverage","drug\ formulary","group\ ","Health\ Maintenance\ Organization\ \(HMO\)","individual\ health\ insurance","individual\ lifetime\ maximum","in\-network\ ","inpatient\ services","maximum\ annual\ benefit\ ","Medicare","non\-contracting\ hospital\ ","out\-of\-network\ ","prescription\ drugs","provider\ ","specialist");
myGlossaryBlurbs = new Array("The\ maximum\ amount\ a\ health\ care\ benefits\ plan\ will\ reimburse\ a\ doctor\ or\ hospital\ for\ a\ covered\ service\.","The\ amount\ you\ are\ required\ to\ pay\ annually\ before\ reimbursement\ by\ your\ health\ care\ benefits\ plan\ begins\.","The\ maximum\ amount\,\ per\ year\,\ you\ are\ required\ to\ pay\ out\ of\ your\ own\ pocket\ for\ covered\ health\ care\ services\ after\ the\ deductible\ is\ met\.","An\ itemized\ bill\ for\ services\ that\ have\ been\ provided\ to\ a\ subscriber\,\ a\ subscriber\'s\ spouse\ or\ dependents\.","A\ form\ you\ or\ your\ doctor\ fill\ out\ and\ submit\ to\ your\ health\ care\ benefits\ plan\ for\ payment\.","The\ federal\ Consolidated\ Omnibus\ Budget\ Reconciliation\ Act\ of\ 1985\.\ ","A\ percentage\ of\ a\ covered\ service\ that\ you\ are\ responsible\ for\ paying\ or\ the\ percentage\ paid\ by\ your\ plan\.","A\ hospital\ that\ has\ contracted\ with\ a\ particular\ health\ care\ plan\ to\ provide\ hospital\ services\ to\ members\ of\ that\ plan\.","A\ fixed\ dollar\ amount\ you\ are\ required\ to\ pay\ for\ covered\ services\ at\ the\ time\ you\ receive\ care\.","The\ eligible\ person\ enrolled\ in\ the\ group\ health\ care\ benefits\ plan\ and\ any\ enrolled\ eligible\ family\ members\.","A\ service\ which\ is\ covered\ according\ to\ the\ terms\ in\ your\ health\ care\ benefits\ plan\.","A\ fixed\ amount\ you\ are\ required\ to\ pay\ before\ health\ care\ benefits\ begin\.","An\ eligible\ person\,\ other\ than\ the\ member\ \(generally\ a\ spouse\ or\ child\)\,\ who\ has\ health\ care\ benefits\ under\ the\ member\'s\ policy\.","Specific\ medical\ conditions\ or\ services\ that\ are\ not\ covered\ under\ a\ health\ care\ plan\.","Health\ care\ coverage\ for\ a\ member\ and\ his\ or\ her\ eligible\ dependents\.","A\ list\ of\ preferred\ drugs\ chosen\ by\ a\ panel\ of\ doctors\ and\ pharmacists\.\ Both\ brand\ and\ generic\ medications\ are\ included\ on\ the\ formulary\.","A\ group\ of\ people\ covered\ under\ the\ same\ health\ care\ plan\ and\ identified\ by\ their\ relation\ to\ the\ same\ employer\ or\ organization\.","An\ organization\ that\ provides\ health\ care\ coverage\ to\ its\ members\ through\ a\ network\ of\ doctors\,\ hospitals\ and\ other\ health\ care\ providers\.","Health\ care\ coverage\ for\ an\ individual\ with\ no\ covered\ dependents\.","The\ maximum\ amount\ of\ benefits\ your\ policy\ will\ pay\ over\ the\ course\ of\ your\ lifetime\.","Services\ provided\ or\ coordinated\ by\ your\ primary\ care\ physician\ \(PCP\)\ and\ paid\ at\ a\ higher\ benefit\ level\.","Services\ provided\ when\ a\ member\ is\ registered\ as\ a\ bed\ patient\ and\ is\ treated\ as\ such\ in\ a\ health\ care\ facility\ such\ as\ a\ hospital\.","The\ maximum\ dollar\ amount\ your\ health\ care\ plan\ will\ pay\ for\ health\ care\ services\ provided\ to\ you\ during\ one\ year\.","The\ federal\ program\ established\ to\ provide\ health\ care\ coverage\ for\ eligible\ beneficiaries\.\ ","A\ hospital\ that\ has\ not\ contracted\ with\ a\ particular\ health\ care\ plan\ to\ provide\ hospital\ services\ to\ members\ in\ that\ plan\.","Services\ provided\ by\ doctors\ and\ hospitals\ who\ have\ not\ contracted\ with\ your\ health\ plan\.","Drugs\ and\ medications\ that\,\ by\ law\,\ must\ be\ dispensed\ by\ a\ written\ prescription\ from\ a\ licensed\ doctor\.","A\ licensed\ health\ care\ facility\,\ program\,\ agency\,\ doctor\ or\ health\ professional\ that\ delivers\ health\ care\ services\.","A\ health\ care\ professional\ whose\ practice\ is\ limited\ to\ a\ certain\ branch\ of\ medicine");




function markText(inputHtml)
{
    var matchedFlag = 0;
    var re;                      /*regex object*/
    var varMatches;                  /*matches array*/
    var outHtml;                     /*output html*/
    var replaceText;
    var replaceDiv="";
    var beenReplaced;
    var usedTerms = [];
    
    re=new RegExp('(\<[^>][^<]*\>)([^<]*)','g'); /*create non-greedy regex match*/
    outHtml=new String('');              /*init html string*/
       
    while ((varMatches = re.exec(inputHtml)) != null)        /*exec sequentially to apply span tags*/
    {
        outHtml+=varMatches[1];    /*html tag part*/
        matchHold = varMatches[1].toUpperCase();
        matchHold2 = varMatches[2];
        
        var matchA = matchHold.indexOf("<A");
        var matchH1 = matchHold.indexOf("<H1>");
        var matchH2 = matchHold.indexOf("<H2>");
        var matchH3 = matchHold.indexOf("<H3>");
        var matchH4 = matchHold.indexOf("<H4>");
        if (matchedFlag == 1){
            outHtml+=matchHold2;
        }else{
            if (matchA == 0 ||matchH1 == 0 || matchH2 == 0|| matchH3 == 0|| matchH4 == 0){
                outHtml+=matchHold2;
            }else{
                var termCount=0;
                for (termCount=0;termCount<myGlossaryTerms.length;termCount++){
                    txtKeyword = myGlossaryTerms[termCount];
                    var usedTermsStr = usedTerms.toString();
                    var matchPattern = usedTermsStr.indexOf(txtKeyword);
                    if(usedTermsStr.indexOf(txtKeyword) == -1){
                        beenReplaced = replaceMe(matchHold2, txtKeyword, termCount);
                        if (beenReplaced != matchHold2){
                            matchedFlag = 1;
                            matchHold2 = beenReplaced;
                            blurb = myGlossaryBlurbs[termCount];
                            replaceDiv += '<div  id="def'+termCount+'" class="definition"><br/>';
                            replaceDiv += '<div class="definition_content"><span><a href="javascript:ReverseContentDisplay(\''+termCount+'\')"></a></span>';
                            replaceDiv += '<p><b>'+txtKeyword+'</b><br />'+blurb+'</p></div><div class="definition_bottom">&nbsp;</div></div>';
                            usedTerms[usedTerms.length]= txtKeyword;   
                        }
                    }
                }
                outHtml+=matchHold2;
                matchedFlag = 0;
            }
        }
    }
    outHtml+=replaceDiv;
    return outHtml;
}

function getLayerHtml()
{
    var inHtml = new String('');
    if (document.getElementById)
    {
        x = document.getElementsByTagName('div');
        for(i=0;i<x.length;i++)
        {
            xclass = x[i].className;
            if(xclass == "content" || xclass == "contentbox"){
                inHtml = x[i].innerHTML;
            }
        }
    }
    else
     if (document.all)
    {
        x = document.all[id];
        xclass = x.className;
        inHtml = x.innerHTML;
    }
    return inHtml;
}

function setLayerHtml(text)
{
    if (document.getElementById)
    {
        elemObj = document.getElementsByTagName('div');
        for(i=0;i<elemObj.length;i++)
        {
            xclass = elemObj[i].className;
            if(xclass == "content" || xclass == "contentbox"){
                elemObj[i].innerHTML = text ;
            }
        }
        }else if (document.all)
        {
        elemObj = document.all[id];
        elemObj.innerHTML = text;
        }
  }


function replaceMe(str, txtKeyword, termCount) {
    var pattern = new RegExp('\\b'+txtKeyword+'(?=[ \\W])' ,'i');
    var matches = str.match(pattern);
    if (matches){
        var indexmatch = str.indexOf(txtKeyword);
        var strmatch = "-"+txtKeyword;
        if(str.match(strmatch)){
            return str;
        }else{
            matches = matches[0];
            replaceText = '<a href="../../getting_started/health_insurance/glossary.html#'+matches+'" class="glossary" onMouseOver="toggleDiv(\'def'+termCount+'\',1);UpdateCursorPositionDocAll(this);" onMouseOut="toggleDiv(\'def'+termCount+'\',0)">'+matches+' <img src="/images/question.gif" border="0" alt="'+matches+'" /></a>';      
            return str.replace( pattern, replaceText);
        }
    }else{
        return str;
    }
}

function startGlossary(){
    var inHtml = getLayerHtml();       
    var outHtml = markText(inHtml);
//    alert(outHtml);
    setLayerHtml(outHtml);
}

var glossaryOn=true;

