﻿/*****************************************************************************************
*****************************************************************************************/
function select_filter_option(optn) {
    var el;

    switch (optn)
    {
        case "AIR":
            el = document.getElementById("rdoAir");
            break;
        case "INST":
            el = document.getElementById("rdoInstrument");
            break;
        case "PNEU":
            el = document.getElementById("rdoPneumatic");
            break;
        case "MAG":
            el = document.getElementById("rdoMagneto");
            break;
    }
    el.checked = true;
}

/*****************************************************************************************
*****************************************************************************************/
function askForFilterTypeSelection(ftTop, ftLeft, result_handler_name_string) {
    var xst = document.getElementById("FilterTypeSelection");
    if (xst != null)
    {
        alert("askForFilterTypeSelection:Error:Please Response to the Last:");
        return;
    }
    var newDiv = document.createElement("div");
    newDiv.id = "FilterTypeSelection";

    var ypos, xpos;
    if (ftLeft == undefined)
    {
        xpos = (document.body.clientWidth - 405) / 2;
        if (xpos <= 0) xpos = 20;
    }
    else
        xpos = ftLeft;

    if (ftTop == undefined)
    {
        ypos = (document.body.clientHeight - 233) / 3;
        if (ypos <= 0) ypos = 50;
    }
    else
        ypos = ftTop;

    newDiv.setAttribute("style", "height: 233px; width: 405px; border: 4px solid #0000FF; padding: 5px; margin: 5px; background-color: #FFFFFF; font-family: Arial, Helvetica, sans-serif, veranda; font-size: 16px; font-weight:bold; color: #000000; text-align: center;" + " position: absolute; top: " + parseInt(ypos, 10) + "px; left: " + parseInt(xpos, 10) + "px;");
    var sContent = ""
    sContent = sContent + "<table id=\"tblOutLine\" width=400  border=\"0\" cellspacing=\"0\" bordercolor=\"black\">";
    sContent = sContent + "<tr>";
    sContent = sContent + "<td colspan=\"2\" align=\"center\" valign=\"top\" style=\"font-family: Arial, Helvetica, sans-serif; font-size: 20px; color:blue;font-weight: normal;height:45px;\">";
    sContent = sContent + "Please select the desired filter type";
    sContent = sContent + "</td>";
    sContent = sContent + "</tr>";
    sContent = sContent + "<tr>";
    sContent = sContent + "<td style=\"width:97px;height:33px;\"></td>";
    sContent = sContent + "<td align=\"left\" style=\"font-family: Arial, Helvetica, sans-serif, veranda; font-size: 18px;height:33px;\" valign=\"top\">";
    sContent = sContent + "<input type=radio id=\"rdoAir\" name=\"rdoFilterType\" checked><span onclick=\"select_filter_option('AIR')\" style=\"cursor:pointer\">INDUCTION AIR FILTERS</span>";
    sContent = sContent + "</td>";
    sContent = sContent + "</tr>";
    sContent = sContent + "<tr>";
    sContent = sContent + "<td style=\"width:97px;height:33px;\"></td>";
    sContent = sContent + "<td align=\"left\" style=\"font-family: Arial, Helvetica, sans-serif, veranda; font-size: 18px;height:30px;\" valign=\"top\">";
    sContent = sContent + "<input type=radio id=\"rdoInstrument\" name=\"rdoFilterType\"><span onclick=\"select_filter_option('INST')\" style=\"cursor:pointer\">INSTRUMENT FILTERS</span>";
    sContent = sContent + "</td>";
    sContent = sContent + "</tr>";
    sContent = sContent + "<tr>";
    sContent = sContent + "<td style=\"width:97px;height:33px;\"></td>";
    sContent = sContent + "<td align=\"left\" style=\"font-family: Arial, Helvetica, sans-serif, veranda; font-size: 18px;height:30px;\" valign=\"top\" >";
    sContent = sContent + "<input type=radio id=\"rdoPneumatic\" name=\"rdoFilterType\"><span onclick=\"select_filter_option('PNEU')\" style=\"cursor:pointer\">PNEUMATIC FILTERS</span>";
    sContent = sContent + "</td>";
    sContent = sContent + "</tr>";
    sContent = sContent + "<tr>";
    sContent = sContent + "<td style=\"width:97px;height:33px;\"></td>";
    sContent = sContent + "<td align=\"left\" style=\"font-family: Arial, Helvetica, sans-serif, veranda; font-size: 18px;height:30px;\" valign=\"top\">";
    sContent = sContent + "<input type=radio id=\"rdoMagneto\" name=\"rdoFilterType\"><span onclick=\"select_filter_option('MAG')\" style=\"cursor:pointer\">MAGNETO FILTERS</span>";
    sContent = sContent + "</td>";
    sContent = sContent + "</tr>";
    sContent = sContent + "<tr height=\"40px\"><td colspan=\"2\" align=\"right\" valign=\"bottom\">";
    sContent = sContent + "<input type=\"button\" id=\"cmdYes\" name=\"cmdYes\" value=\"OK\" style=\"WIDTH: 65px;  HEIGHT: 24px\" onClick=\"closeFilterTypeSelection(true, " + result_handler_name_string + ");\">";
    //sContent = sContent + "<input type=\"button\" id=\"cmdCancel\" name=\"cmdCancel\" value=\"Cancel\" style=\"WIDTH: 65px;  HEIGHT: 24px;\" onClick=\"closeFilterTypeSelection(false, " + result_handler_name_string + ");\">";
    sContent = sContent + "</td></tr>";
    sContent = sContent + "</table>";
    newDiv.innerHTML = sContent;
    document.body.insertBefore(newDiv, null);
    document.getElementById("rdoAir").focus();
}

function closeFilterTypeSelection(branch_to_page, filter_result_handler) {
    var el = document.getElementById("FilterTypeSelection");
    var SelectedFilterType = "";
    if (document.getElementById("rdoAir").checked)
        SelectedFilterType = "AIR";
    else if (document.getElementById("rdoInstrument").checked)
        SelectedFilterType = "INST";
    else if (document.getElementById("rdoPneumatic").checked)
        SelectedFilterType = "PNEU";
    else if (document.getElementById("rdoMagneto").checked)
        SelectedFilterType = "MAG";
    document.body.removeChild(el);
    if (branch_to_page == true)
    {
        filter_result_handler(SelectedFilterType);
    }
}

