﻿function advancedActivity()
{
    try { document.getElementById('AdvancedProgress').style.display = 'block'; } catch(e) {}
}

function basicActivity()
{
    try { document.getElementById('BasicProgress').style.display = 'block'; } catch(e) {}
}

function enroll(mpn, nm, mcp)
{
    try 
    {
        url = document.URL;
        rt = getQueryVariable('returnTo');
        ag = rt.substring(2, 3);
        if (getQueryVariable('hospital') == 'yes') {
            window.opener.document.getElementById('txt' + rt + 'HospitalName').value = nm;
            window.opener.document.getElementById('txt' + rt + 'HospitalNumber').value = mpn;
        }
        else {
            window.opener.document.getElementById('txt' + rt + 'PCPName').value = nm;
            window.opener.document.getElementById('txt' + rt + 'PCPNumber').value = mpn;
        }
        if (getQueryVariable('mcp') == '') 
        {
            ddMCP = window.opener.document.getElementById('ddlNewMCP'+ag);
            for (m = 0; m < ddMCP.options.length; m++)
                if (ddMCP.options[m].text == mcp)
                    ddMCP.options[m].selected = true;
        }
        window.close();
    } 
    catch (e) 
    {
        alert(e.description);
    }
}

function fieldFocus(ctrl) {
    return;
    t = document.getElementById('Tip');
    ti = document.getElementById('TipTitle');
    tx = document.getElementById('TipText');
    nm = ctrl.id.substring(ctrl.id.lastIndexOf('_') + 1);

    switch(nm)
    {
        case 'Name':
            ti.innerHTML = 'Name';
            tx.innerHTML = 'The name of a doctor, clinic, hospital, etc.  Use the \"Fuzzy\" option if you are unsure of the exact spelling of a doctors name.';
            break;
        case 'Fuzzy':
            ti.innerHTML = 'Fuzzy';
            tx.innerHTML = 'Searches based on what the name \"sounds like\" rather than the exact spelling.';
            break;
        case 'ProviderTypeID':
            ti.innerHTML = 'Provider Type';
            tx.innerHTML = 'The type of provider or facility you are searching for.';
            break;
        case 'Counties':
            ti.innerHTML = 'County';
            tx.innerHTML = 'Limit results to those that are present in one of the selected counties.<br /><br />' +
                'Hold down the [Ctrl] key on your keyboard to select multiple items.';
            break;
        case 'Zip':
            ti.innerHTML = 'Zip Code';
            tx.innerHTML = 'Limit results to those that are present in the selected zip code.';
            break;
       case 'Radius':
            ti.innerHTML = 'Radius';
            tx.innerHTML = 'Limit results to those that are within a certain distance from the given Zip Code.';
            break;
        case 'MCPID':
            ti.innerHTML = 'Health Plan';
            tx.innerHTML = 'Limit results to those that are available in the selected Managed Care Plan.';
            break;
        case 'ProgramID':
            ti.innerHTML = 'Program';
            tx.innerHTML = 'Limit results to those that are available in the selected Ohio Medicaid Program.';
            break;
        case 'IsPCP':
            ti.innerHTML = 'PCP\'s Only';
            tx.innerHTML = 'Limit results to providers that can be selected as a Primary Care Provider.';
            break;
        case 'StateID':
            ti.innerHTML = 'State';
            tx.innerHTML = 'Limit results to providers that are present in the selected state.';
            break;
        case 'ProviderGenderID':
            ti.innerHTML = 'Provider Gender';
            tx.innerHTML = 'Limit results to providers of the selected gender.';
            break;
        case 'PatientGenderID':
            ti.innerHTML = 'Patient Gender';
            tx.innerHTML = 'Limit results to providers who accept patients of the selected gender.';
            break;
        case 'AgeLimitLow':
            ti.innerHTML = 'Minimum Patient Age';
            tx.innerHTML = 'Limit results to providers who will see patients this young (in years).';
            break;
        case 'AgeLimitHigh':
            ti.innerHTML = 'Maximum Patient Age';
            tx.innerHTML = 'Limit results to providers who will see patients this old. (in years).';
            break;
        case 'AcceptNewPatients':
            ti.innerHTML = 'Accepts New Patients';
            tx.innerHTML = 'Limit results to providers who are accepting new patients.';
            break;
        case 'AcceptNewborns':
            ti.innerHTML = 'Accepts Newborns';
            tx.innerHTML = 'Limit results to providers who will see newborn babies.';
            break;
        case 'AcceptPregnantWomen':
            ti.innerHTML = 'Accepts Pregnant Women';
            tx.innerHTML = 'Limit results to providers who will see pregnant women.';
            break;
       case 'Affiliations':
            ti.innerHTML = 'Hospital Affiliation';
            tx.innerHTML = 'Limit results to providers who have hospital privileges in at least one of the selected hospitals.<br /><br />' +
                           'Hold down the [Ctrl] key on your keyboard to select multiple items.';
            break;
       case 'Languages':
            ti.innerHTML = 'Language';
            tx.innerHTML = 'Limit results to providers who work at a location where at least one of the selected languages is spoken.<br /><br />' +
                           'Hold down the [Ctrl] key on your keyboard to select multiple items.';
            break;
       case 'Specialties':
            ti.innerHTML = 'Specialty';
            tx.innerHTML = 'Limit results to providers who specialize in at least one of the selected specialties.<br /><br />' +
                           'Hold down the [Ctrl] key on your keyboard to select multiple items.';
            break;
    }
    
    t.style.display = 'block';
}

function findSelected() {
    oACnty = document.getElementById('ctl00_cph_adv_Counties');
    oAff = document.getElementById('ctl00_cph_adv_Affiliations');
    oLan = document.getElementById('ctl00_cph_adv_Languages');
    oSpe = document.getElementById('ctl00_cph_adv_Specialties');
    listChange(oACnty, 'ACntyNote');
    listChange(oAff, 'AffNote');
    listChange(oLan, 'LanNote');
    listChange(oSpe, 'SpeNote');
    try { oCnty.options[oCnty.selectedIndex].selected = true; } catch (e) { }
    try { oACnty.options[oACnty.selectedIndex].selected = true; } catch (e) { }
    try { oAff.options[oAff.selectedIndex].selected = true; } catch (e) { }
    try { oLan.options[oLan.selectedIndex].selected = true; } catch (e) { }
    try { oSpe.options[oSpe.selectedIndex].selected = true; } catch (e) { }
}

function getQueryVariable(variable) {
    try {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
            var pair = vars[i].split("=");
            if (pair[0] == variable) {
                return pair[1];
            }
        } 
        return '';
    } catch (e) {
        return '';
    }
}

function isNumberKey(evt)
{
    if (window.event)
        kc = evt.keyCode;
    else
        kc = evt.which;
    return (kc >= '0'.charCodeAt() && kc <= '9'.charCodeAt()) || (kc == 0) || (kc == 13) || (kc == 8);
}

function listChange(s, note) {
    try {
        n = document.getElementById(note);
        c = 0;
        for (i = 0; i < s.options.length; i++) {
            if (s.options[i].selected)
                c++;
        }
        n.innerHTML = c.toString() + " selected";
    }
    catch (e) { }
}

function showDetails(recordTypeID, rowID)
{
    window.open("details.aspx?rowID=" + rowID + "&recordTypeID=" + recordTypeID, 'details', 'width=760,height=630,toolbar=no,location=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes');
}