﻿function IsPopupBlocker(lst1, lst2, lst3, lst4, clientname, progcode, BenefitPlan) {
    var oWin = window.open("", "testpopupblocker", "width=100,height=50,top=5000,left=5000");
    if (oWin == null || typeof (oWin) == "undefined") {
        alert("Pop-ups are currently blocked. To get the expected results from this site, you must disable your pop-up blocker or allow pop-ups for this site.");
        return false;
    } else {
        oWin.close();

        var list1 = document.getElementById(lst1);
        var list2 = document.getElementById(lst2);
        var list3 = document.getElementById(lst3);
        var list4 = document.getElementById(lst4);
        var strDesc = '';
        var strDValue = '';        
        //alert(list3.options[list3.selectedIndex].value.toString());

        if (list4.value != '') {
            if (list4.options[list4.selectedIndex].value != "" && list3.options[list3.selectedIndex].value != "" && list2.options[list2.selectedIndex].value != "" && list1.options[list1.selectedIndex].value != "") {
                strDesc = list1.options[list1.selectedIndex].text + "/" + list2.options[list2.selectedIndex].text + "/" + list3.options[list3.selectedIndex].text + "/" + list4.options[list4.selectedIndex].text;
                strDValue = list4.options[list4.selectedIndex].value;
            }
        }
        else if (list3.value != '') {            
            if (list3.options[list3.selectedIndex].value != "" && list2.options[list2.selectedIndex].value != "" && list1.options[list1.selectedIndex].value != "") {
                strDesc = list1.options[list1.selectedIndex].text + "/" + list2.options[list2.selectedIndex].text + "/" + list3.options[list3.selectedIndex].text;
                strDValue = list3.options[list3.selectedIndex].value;
            }
        }
        else if (list2.value != '') {            
            if (list2.options[list2.selectedIndex].value != "" && list1.options[list1.selectedIndex].value != "") {
                strDesc = list1.options[list1.selectedIndex].text + "/" + list2.options[list2.selectedIndex].text;
                strDValue = list2.options[list2.selectedIndex].value;
            }
        }
        else if (list1.value != '') {
        if (list1.options[list1.selectedIndex].value != "") {
            strDesc = list1.options[list1.selectedIndex].text;
            strDValue = list1.options[list1.selectedIndex].value;
            }
        }
        strDesc = "Smart Formulary Search - Top 100 by Specialty " + strDesc;
        //window.open("Report/SpecialtyReport.aspx?description=" + strDesc + "&spec=" + document.getElementById(ddlSpecialityCode).value, "SpecialtyReport", "width=1100, height=750, menubar=Yes, resizable=Yes, scrollbars=1");
        window.open("Report/TherapyClassReport.aspx?hierarchy=" + strDesc + "&ahfs=" + strDValue + "&ClientName=" + clientname + "&progcode=" + progcode + "&BenefitPlan=" + BenefitPlan, "SpecialtyReport", "width=1100, height=750, menubar=Yes, resizable=Yes, scrollbars=1");
        return false;
    }
}

function PrintDrugName(txtName, srchtxt, clientname, progcode, BenefitPlan) {
    var valToPass = "";    
    if (document.getElementById(txtName).value.length > 0)
        valToPass = document.getElementById(txtName).value;
    else
        valToPass = srchtxt;

    window.open("Report/DrugNReport.aspx?search=" + valToPass + "&ClientName=" + clientname + "&progcode=" + progcode + "&BenefitPlan=" + BenefitPlan, "DrugNameRpt", "width=1000, height=750, menubar=Yes, resizable=Yes, scrollbars=1");

    return false;
}

function PrintSpeciality(ddlSpecialityCode, clientname, progcode, BenefitPlan) {
    
    var oWin = window.open("", "testpopupblocker", "width=100,height=50,top=5000,left=5000");
    if (oWin == null || typeof (oWin) == "undefined") {
        alert("Pop-ups are currently blocked. To get the expected results from this site, you must disable your pop-up blocker or allow pop-ups for this site.");
        return false;
    } else {
        oWin.close();
        var mylist = document.getElementById(ddlSpecialityCode);
        var strDesc = "Smart Formulary Search - Top 100 by Specialty " + mylist.options[mylist.selectedIndex].text;
        window.open("Report/SpecialtyReport.aspx?description=" + strDesc + "&spec=" + document.getElementById(ddlSpecialityCode).value + "&ClientName=" + clientname + "&progcode=" + progcode + "&BenefitPlan=" + BenefitPlan, "SpecialtyReport", "width=1100, height=750, menubar=Yes, resizable=Yes, scrollbars=1");

        return false;
    }
}




function EnableSrchBtn(ddlSel, btnSrch) {

    if (document.getElementById(ddlSel).value == 'Please select Provider Speciality') {
        document.getElementById(btnSrch).disabled = true;
        document.getElementById(ddlSel).focus();
    }
    else {
        document.getElementById(btnSrch).disabled = false;
    }

}

function CheckSelValue(ddlSel, btnSrch) {

    if (document.getElementById(ddlSel).value == 'Please select Provider Speciality') {
        document.getElementById(ddlSel).focus();
        return false;
    }
    else {
        return true;
    }

}
