﻿function select_drain_valve_option(optn) {
    var el;
    switch (optn)
    {
        case "FUEL":
            el = document.getElementById("rdoFuel");
            break;
        case "OIL":
            el = document.getElementById("rdoOil");
            break;
    }
    el.checked = true;

}

/*****************************************************************************************
*****************************************************************************************/
function askForDrainValveTypeSelection(ftTop, ftLeft, result_handler_name_string) {
    var xst = document.getElementById("DrainValveTypeSelection");
    if (xst != null)
    {
        alert("askForDrainValveTypeSelection:Error:Please Response to the Last:");
        return;
    }
    var newDiv = document.createElement("div");
    newDiv.id = "DrainValveTypeSelection";

    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: 205px; 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\" height=\"203\" border=0 bordercolor=\"black\">";
    sContent = sContent + "<tr>";
    sContent = sContent + "<td colspan=\"2\" align=\"center\" style=\"font-family: Arial, Helvetica, sans-serif; font-size: 22px; font-weight: bold; color: #0000FF;\" class=\"style2\" >";
    sContent = sContent + "Please select the desired valve type";
    sContent = sContent + "</td>";
    sContent = sContent + "</tr>";
    sContent = sContent + "<tr>";
    sContent = sContent + "<td style=\"width:99px;height:37px;\"></td>";
    sContent = sContent + "<td align=\"left\" style=\"font-family: Arial, Helvetica, sans-serif, veranda; font-size: 18px\" valign=\"top\" >";
    sContent = sContent + "<input type=radio id=\"rdoFuel\" name=\"rdoCat\" value=\"V1\"  checked><span onclick=\"select_drain_valve_option('FUEL')\" style=\"cursor:pointer\">FUEL DRAINS VALVES&nbsp;&nbsp;</span>";
    sContent = sContent + "</td>";
    sContent = sContent + "</tr>";
    sContent = sContent + "<tr>";
    sContent = sContent + "<td style=\"width:99px;height:37px;\"></td>";
    sContent = sContent + "<td align=\"left\" style=\"font-family: Arial, Helvetica, sans-serif, veranda; font-size: 18px\" valign=\"top\">";
    sContent = sContent + "<input type=radio id=\"rdoOil\" name=\"rdoCat\" value=\"V1\"><span onclick=\"select_drain_valve_option('OIL')\" style=\"cursor:pointer\">OIL DRAIN VALVES</span>";
    sContent = sContent + "</td>";
    sContent = sContent + "</tr>";
    sContent = sContent + "<tr><td colspan=\"2\" align=\"right\" style=\"height:52px;\">";
    sContent = sContent + "<input type=\"button\" id=\"cmdYes\" name=\"cmdYes\" value=\"OK\" style=\"WIDTH: 65px;  HEIGHT: 24px\" onClick=\"closeDrainValveTypeSelection(true, " + result_handler_name_string + ");\">&nbsp;";
    sContent = sContent + "<input type=\"button\" id=\"cmdCancel\" name=\"cmdCancel\" value=\"Cancel\" style=\"WIDTH: 65px;  HEIGHT: 24px;\" onClick=\"closeDrainValveTypeSelection(false, " + result_handler_name_string + ");\">";
    sContent = sContent + "</td></tr>";
    sContent = sContent + "</table>";
    newDiv.innerHTML = sContent;
    document.body.insertBefore(newDiv, null);
    document.getElementById("rdoFuel").focus();
}

function closeDrainValveTypeSelection(branch_to_page, filter_result_handler) {
    var el = document.getElementById("DrainValveTypeSelection");
    var SelectedFilterType = "";
    if (document.getElementById("rdoFuel").checked)
        SelectedFilterType = "FUEL";
    else if (document.getElementById("rdoOil").checked)
        SelectedFilterType = "OIL";
    document.body.removeChild(el);
    if (branch_to_page == true)
    {
        filter_result_handler(SelectedFilterType);
    }
}

