<!--

num_selected = 0;

function show(url, wtitle)
{
    var w = 600;
    var h = 750;
    var xMax = screen.width, yMax = screen.height;
    var xOffset = (xMax - w) / 2;
    var yOffset = (yMax - h) / 2;

    var child = window.open(url, '', 'location=no, scrollbars=yes, menubar=no, width=' + w + ', height=' + h + ', screenX=' + xOffset + ', screenY=' + yOffset + ', top=' + yOffset + ', left=' + xOffset );
    //var child = window.open(url, 'title', 'location=no, scrollbars=yes, menubar=n');
    child.focus();
}

function checkProducts()
{
    var show_products = document.searchform.show_products[0].checked;
    if (show_products)
    {
        document.searchform.product_type_id.disabled = false;
    }
    else
    {
        document.searchform.product_type_id.disabled = true;
    }
}

function popCalendar(fieldname)
{
    val = eval("document.searchform." + fieldname);
    initdate="";
    if (val)
    {
        initdate = val.value;
    }

    newwindow = window.open(
        "/calendar.jsp?field=" + fieldname + "&initdate=" + initdate,
        "ptcalendar",
        "width=310, height=240, scrolling=0, resize=0");

    if (!newwindow.opener)
    {
        newwindow.opener = window;
    }

    newwindow.focus();
}

function toggleBook(id)
{
    div = document.getElementById(id);
    field = eval("document.searchform.input" + id);
    value = field.value;
    if (value == "0")
    {
        field.value = "1";
        div.className = 'highlighted';
        num_selected += 1;
    }
    else
    {
        field.value = "0";
        div.className = 'nothighlighted';
        num_selected -= 1;
    }
}

function checkNumSelected()
{
    if (num_selected == 0)
    {
        alert("Please select a book");
        return false;
    }
    else
    {
        return true;
    }
}

function checkValue(field_name, form_name)
{
    var chapters = new Array 
    (
        50,
        40,
        27,
        36,
        34,
        24,
        21,
        4,
        31,
        24,
        22,
        25,
        29,
        36,
        10,
        13,
        10,
        42,
        150,
        31,
        12,
        8,
        66,
        52,
        5,
        48,
        12,
        14,
        3,
        9,
        1,
        4,
        7,
        3,
        3,
        3,
        2,
        14,
        4,
        28,
        16,
        24,
        21,
        28,
        16,
        16,
        13,
        6,
        6,
        4,
        4,
        5,
        3,
        6,
        4,
        3,
        1,
        13,
        5,
        5,
        3,
        5,
        1,
        1,
        1,
        22
        );

    var chapter_id = new Array(
        "1-1",
        "1-2",
        "1-3",
        "1-4",
        "1-5",
        "1-6",
        "1-7",
        "1-8",
        "1-9",
        "1-10",
        "1-11",
        "1-12",
        "1-13",
        "1-14",
        "1-15",
        "1-16",
        "1-17",
        "1-18",
        "1-19",
        "1-20",
        "1-21",
        "1-22",
        "1-23",
        "1-24",
        "1-25",
        "1-26",
        "1-27",
        "1-28",
        "1-29",
        "1-30",
        "1-31",
        "1-32",
        "1-33",
        "1-34",
        "1-35",
        "1-36",
        "1-37",
        "1-38",
        "1-39",
        "1-40",
        "1-41",
        "1-42",
        "1-43",
        "1-44",
        "1-45",
        "1-46",
        "1-47",
        "1-48",
        "1-49",
        "1-50",
        "2-1",
        "2-2",
        "2-3",
        "2-4",
        "2-5",
        "2-6",
        "2-7",
        "2-8",
        "2-9",
        "2-10",
        "2-11",
        "2-12",
        "2-13",
        "2-14",
        "2-15",
        "2-16",
        "2-17",
        "2-18",
        "2-19",
        "2-20",
        "2-21",
        "2-22",
        "2-23",
        "2-24",
        "2-25",
        "2-26",
        "2-27",
        "2-28",
        "2-29",
        "2-30",
        "2-31",
        "2-32",
        "2-33",
        "2-34",
        "2-35",
        "2-36",
        "2-37",
        "2-38",
        "2-39",
        "2-40",
        "3-1",
        "3-2",
        "3-3",
        "3-4",
        "3-5",
        "3-6",
        "3-7",
        "3-8",
        "3-9",
        "3-10",
        "3-11",
        "3-12",
        "3-13",
        "3-14",
        "3-15",
        "3-16",
        "3-17",
        "3-18",
        "3-19",
        "3-20",
        "3-21",
        "3-22",
        "3-23",
        "3-24",
        "3-25",
        "3-26",
        "3-27",
        "4-1",
        "4-2",
        "4-3",
        "4-4",
        "4-5",
        "4-6",
        "4-7",
        "4-8",
        "4-9",
        "4-10",
        "4-11",
        "4-12",
        "4-13",
        "4-14",
        "4-15",
        "4-16",
        "4-17",
        "4-18",
        "4-19",
        "4-20",
        "4-21",
        "4-22",
        "4-23",
        "4-24",
        "4-25",
        "4-26",
        "4-27",
        "4-28",
        "4-29",
        "4-30",
        "4-31",
        "4-32",
        "4-33",
        "4-34",
        "4-35",
        "4-36",
        "5-1",
        "5-2",
        "5-3",
        "5-4",
        "5-5",
        "5-6",
        "5-7",
        "5-8",
        "5-9",
        "5-10",
        "5-11",
        "5-12",
        "5-13",
        "5-14",
        "5-15",
        "5-16",
        "5-17",
        "5-18",
        "5-19",
        "5-20",
        "5-21",
        "5-22",
        "5-23",
        "5-24",
        "5-25",
        "5-26",
        "5-27",
        "5-28",
        "5-29",
        "5-30",
        "5-31",
        "5-32",
        "5-33",
        "5-34",
        "6-1",
        "6-2",
        "6-3",
        "6-4",
        "6-5",
        "6-6",
        "6-7",
        "6-8",
        "6-9",
        "6-10",
        "6-11",
        "6-12",
        "6-13",
        "6-14",
        "6-15",
        "6-16",
        "6-17",
        "6-18",
        "6-19",
        "6-20",
        "6-21",
        "6-22",
        "6-23",
        "6-24",
        "7-1",
        "7-2",
        "7-3",
        "7-4",
        "7-5",
        "7-6",
        "7-7",
        "7-8",
        "7-9",
        "7-10",
        "7-11",
        "7-12",
        "7-13",
        "7-14",
        "7-15",
        "7-16",
        "7-17",
        "7-18",
        "7-19",
        "7-20",
        "7-21",
        "8-1",
        "8-2",
        "8-3",
        "8-4",
        "9-1",
        "9-2",
        "9-3",
        "9-4",
        "9-5",
        "9-6",
        "9-7",
        "9-8",
        "9-9",
        "9-10",
        "9-11",
        "9-12",
        "9-13",
        "9-14",
        "9-15",
        "9-16",
        "9-17",
        "9-18",
        "9-19",
        "9-20",
        "9-21",
        "9-22",
        "9-23",
        "9-24",
        "9-25",
        "9-26",
        "9-27",
        "9-28",
        "9-29",
        "9-30",
        "9-31",
        "10-1",
        "10-2",
        "10-3",
        "10-4",
        "10-5",
        "10-6",
        "10-7",
        "10-8",
        "10-9",
        "10-10",
        "10-11",
        "10-12",
        "10-13",
        "10-14",
        "10-15",
        "10-16",
        "10-17",
        "10-18",
        "10-19",
        "10-20",
        "10-21",
        "10-22",
        "10-23",
        "10-24",
        "11-1",
        "11-2",
        "11-3",
        "11-4",
        "11-5",
        "11-6",
        "11-7",
        "11-8",
        "11-9",
        "11-10",
        "11-11",
        "11-12",
        "11-13",
        "11-14",
        "11-15",
        "11-16",
        "11-17",
        "11-18",
        "11-19",
        "11-20",
        "11-21",
        "11-22",
        "12-1",
        "12-2",
        "12-3",
        "12-4",
        "12-5",
        "12-6",
        "12-7",
        "12-8",
        "12-9",
        "12-10",
        "12-11",
        "12-12",
        "12-13",
        "12-14",
        "12-15",
        "12-16",
        "12-17",
        "12-18",
        "12-19",
        "12-20",
        "12-21",
        "12-22",
        "12-23",
        "12-24",
        "12-25",
        "13-1",
        "13-2",
        "13-3",
        "13-4",
        "13-5",
        "13-6",
        "13-7",
        "13-8",
        "13-9",
        "13-10",
        "13-11",
        "13-12",
        "13-13",
        "13-14",
        "13-15",
        "13-16",
        "13-17",
        "13-18",
        "13-19",
        "13-20",
        "13-21",
        "13-22",
        "13-23",
        "13-24",
        "13-25",
        "13-26",
        "13-27",
        "13-28",
        "13-29",
        "14-1",
        "14-2",
        "14-3",
        "14-4",
        "14-5",
        "14-6",
        "14-7",
        "14-8",
        "14-9",
        "14-10",
        "14-11",
        "14-12",
        "14-13",
        "14-14",
        "14-15",
        "14-16",
        "14-17",
        "14-18",
        "14-19",
        "14-20",
        "14-21",
        "14-22",
        "14-23",
        "14-24",
        "14-25",
        "14-26",
        "14-27",
        "14-28",
        "14-29",
        "14-30",
        "14-31",
        "14-32",
        "14-33",
        "14-34",
        "14-35",
        "14-36",
        "15-1",
        "15-2",
        "15-3",
        "15-4",
        "15-5",
        "15-6",
        "15-7",
        "15-8",
        "15-9",
        "15-10",
        "16-1",
        "16-2",
        "16-3",
        "16-4",
        "16-5",
        "16-6",
        "16-7",
        "16-8",
        "16-9",
        "16-10",
        "16-11",
        "16-12",
        "16-13",
        "17-1",
        "17-2",
        "17-3",
        "17-4",
        "17-5",
        "17-6",
        "17-7",
        "17-8",
        "17-9",
        "17-10",
        "18-1",
        "18-2",
        "18-3",
        "18-4",
        "18-5",
        "18-6",
        "18-7",
        "18-8",
        "18-9",
        "18-10",
        "18-11",
        "18-12",
        "18-13",
        "18-14",
        "18-15",
        "18-16",
        "18-17",
        "18-18",
        "18-19",
        "18-20",
        "18-21",
        "18-22",
        "18-23",
        "18-24",
        "18-25",
        "18-26",
        "18-27",
        "18-28",
        "18-29",
        "18-30",
        "18-31",
        "18-32",
        "18-33",
        "18-34",
        "18-35",
        "18-36",
        "18-37",
        "18-38",
        "18-39",
        "18-40",
        "18-41",
        "18-42",
        "19-1",
        "19-2",
        "19-3",
        "19-4",
        "19-5",
        "19-6",
        "19-7",
        "19-8",
        "19-9",
        "19-10",
        "19-11",
        "19-12",
        "19-13",
        "19-14",
        "19-15",
        "19-16",
        "19-17",
        "19-18",
        "19-19",
        "19-20",
        "19-21",
        "19-22",
        "19-23",
        "19-24",
        "19-25",
        "19-26",
        "19-27",
        "19-28",
        "19-29",
        "19-30",
        "19-31",
        "19-32",
        "19-33",
        "19-34",
        "19-35",
        "19-36",
        "19-37",
        "19-38",
        "19-39",
        "19-40",
        "19-41",
        "19-42",
        "19-43",
        "19-44",
        "19-45",
        "19-46",
        "19-47",
        "19-48",
        "19-49",
        "19-50",
        "19-51",
        "19-52",
        "19-53",
        "19-54",
        "19-55",
        "19-56",
        "19-57",
        "19-58",
        "19-59",
        "19-60",
        "19-61",
        "19-62",
        "19-63",
        "19-64",
        "19-65",
        "19-66",
        "19-67",
        "19-68",
        "19-69",
        "19-70",
        "19-71",
        "19-72",
        "19-73",
        "19-74",
        "19-75",
        "19-76",
        "19-77",
        "19-78",
        "19-79",
        "19-80",
        "19-81",
        "19-82",
        "19-83",
        "19-84",
        "19-85",
        "19-86",
        "19-87",
        "19-88",
        "19-89",
        "19-90",
        "19-91",
        "19-92",
        "19-93",
        "19-94",
        "19-95",
        "19-96",
        "19-97",
        "19-98",
        "19-99",
        "19-100",
        "19-101",
        "19-102",
        "19-103",
        "19-104",
        "19-105",
        "19-106",
        "19-107",
        "19-108",
        "19-109",
        "19-110",
        "19-111",
        "19-112",
        "19-113",
        "19-114",
        "19-115",
        "19-116",
        "19-117",
        "19-118",
        "19-119",
        "19-120",
        "19-121",
        "19-122",
        "19-123",
        "19-124",
        "19-125",
        "19-126",
        "19-127",
        "19-128",
        "19-129",
        "19-130",
        "19-131",
        "19-132",
        "19-133",
        "19-134",
        "19-135",
        "19-136",
        "19-137",
        "19-138",
        "19-139",
        "19-140",
        "19-141",
        "19-142",
        "19-143",
        "19-144",
        "19-145",
        "19-146",
        "19-147",
        "19-148",
        "19-149",
        "19-150",
        "20-1",
        "20-2",
        "20-3",
        "20-4",
        "20-5",
        "20-6",
        "20-7",
        "20-8",
        "20-9",
        "20-10",
        "20-11",
        "20-12",
        "20-13",
        "20-14",
        "20-15",
        "20-16",
        "20-17",
        "20-18",
        "20-19",
        "20-20",
        "20-21",
        "20-22",
        "20-23",
        "20-24",
        "20-25",
        "20-26",
        "20-27",
        "20-28",
        "20-29",
        "20-30",
        "20-31",
        "21-1",
        "21-2",
        "21-3",
        "21-4",
        "21-5",
        "21-6",
        "21-7",
        "21-8",
        "21-9",
        "21-10",
        "21-11",
        "21-12",
        "22-1",
        "22-2",
        "22-3",
        "22-4",
        "22-5",
        "22-6",
        "22-7",
        "22-8",
        "23-1",
        "23-2",
        "23-3",
        "23-4",
        "23-5",
        "23-6",
        "23-7",
        "23-8",
        "23-9",
        "23-10",
        "23-11",
        "23-12",
        "23-13",
        "23-14",
        "23-15",
        "23-16",
        "23-17",
        "23-18",
        "23-19",
        "23-20",
        "23-21",
        "23-22",
        "23-23",
        "23-24",
        "23-25",
        "23-26",
        "23-27",
        "23-28",
        "23-29",
        "23-30",
        "23-31",
        "23-32",
        "23-33",
        "23-34",
        "23-35",
        "23-36",
        "23-37",
        "23-38",
        "23-39",
        "23-40",
        "23-41",
        "23-42",
        "23-43",
        "23-44",
        "23-45",
        "23-46",
        "23-47",
        "23-48",
        "23-49",
        "23-50",
        "23-51",
        "23-52",
        "23-53",
        "23-54",
        "23-55",
        "23-56",
        "23-57",
        "23-58",
        "23-59",
        "23-60",
        "23-61",
        "23-62",
        "23-63",
        "23-64",
        "23-65",
        "23-66",
        "24-1",
        "24-2",
        "24-3",
        "24-4",
        "24-5",
        "24-6",
        "24-7",
        "24-8",
        "24-9",
        "24-10",
        "24-11",
        "24-12",
        "24-13",
        "24-14",
        "24-15",
        "24-16",
        "24-17",
        "24-18",
        "24-19",
        "24-20",
        "24-21",
        "24-22",
        "24-23",
        "24-24",
        "24-25",
        "24-26",
        "24-27",
        "24-28",
        "24-29",
        "24-30",
        "24-31",
        "24-32",
        "24-33",
        "24-34",
        "24-35",
        "24-36",
        "24-37",
        "24-38",
        "24-39",
        "24-40",
        "24-41",
        "24-42",
        "24-43",
        "24-44",
        "24-45",
        "24-46",
        "24-47",
        "24-48",
        "24-49",
        "24-50",
        "24-51",
        "24-52",
        "25-1",
        "25-2",
        "25-3",
        "25-4",
        "25-5",
        "26-1",
        "26-2",
        "26-3",
        "26-4",
        "26-5",
        "26-6",
        "26-7",
        "26-8",
        "26-9",
        "26-10",
        "26-11",
        "26-12",
        "26-13",
        "26-14",
        "26-15",
        "26-16",
        "26-17",
        "26-18",
        "26-19",
        "26-20",
        "26-21",
        "26-22",
        "26-23",
        "26-24",
        "26-25",
        "26-26",
        "26-27",
        "26-28",
        "26-29",
        "26-30",
        "26-31",
        "26-32",
        "26-33",
        "26-34",
        "26-35",
        "26-36",
        "26-37",
        "26-38",
        "26-39",
        "26-40",
        "26-41",
        "26-42",
        "26-43",
        "26-44",
        "26-45",
        "26-46",
        "26-47",
        "26-48",
        "27-1",
        "27-2",
        "27-3",
        "27-4",
        "27-5",
        "27-6",
        "27-7",
        "27-8",
        "27-9",
        "27-10",
        "27-11",
        "27-12",
        "28-1",
        "28-2",
        "28-3",
        "28-4",
        "28-5",
        "28-6",
        "28-7",
        "28-8",
        "28-9",
        "28-10",
        "28-11",
        "28-12",
        "28-13",
        "28-14",
        "29-1",
        "29-2",
        "29-3",
        "30-1",
        "30-2",
        "30-3",
        "30-4",
        "30-5",
        "30-6",
        "30-7",
        "30-8",
        "30-9",
        "31-1",
        "32-1",
        "32-2",
        "32-3",
        "32-4",
        "33-1",
        "33-2",
        "33-3",
        "33-4",
        "33-5",
        "33-6",
        "33-7",
        "34-1",
        "34-2",
        "34-3",
        "35-1",
        "35-2",
        "35-3",
        "36-1",
        "36-2",
        "36-3",
        "37-1",
        "37-2",
        "38-1",
        "38-2",
        "38-3",
        "38-4",
        "38-5",
        "38-6",
        "38-7",
        "38-8",
        "38-9",
        "38-10",
        "38-11",
        "38-12",
        "38-13",
        "38-14",
        "39-1",
        "39-2",
        "39-3",
        "39-4",
        "40-1",
        "40-2",
        "40-3",
        "40-4",
        "40-5",
        "40-6",
        "40-7",
        "40-8",
        "40-9",
        "40-10",
        "40-11",
        "40-12",
        "40-13",
        "40-14",
        "40-15",
        "40-16",
        "40-17",
        "40-18",
        "40-19",
        "40-20",
        "40-21",
        "40-22",
        "40-23",
        "40-24",
        "40-25",
        "40-26",
        "40-27",
        "40-28",
        "41-1",
        "41-2",
        "41-3",
        "41-4",
        "41-5",
        "41-6",
        "41-7",
        "41-8",
        "41-9",
        "41-10",
        "41-11",
        "41-12",
        "41-13",
        "41-14",
        "41-15",
        "41-16",
        "42-1",
        "42-2",
        "42-3",
        "42-4",
        "42-5",
        "42-6",
        "42-7",
        "42-8",
        "42-9",
        "42-10",
        "42-11",
        "42-12",
        "42-13",
        "42-14",
        "42-15",
        "42-16",
        "42-17",
        "42-18",
        "42-19",
        "42-20",
        "42-21",
        "42-22",
        "42-23",
        "42-24",
        "43-1",
        "43-2",
        "43-3",
        "43-4",
        "43-5",
        "43-6",
        "43-7",
        "43-8",
        "43-9",
        "43-10",
        "43-11",
        "43-12",
        "43-13",
        "43-14",
        "43-15",
        "43-16",
        "43-17",
        "43-18",
        "43-19",
        "43-20",
        "43-21",
        "44-1",
        "44-2",
        "44-3",
        "44-4",
        "44-5",
        "44-6",
        "44-7",
        "44-8",
        "44-9",
        "44-10",
        "44-11",
        "44-12",
        "44-13",
        "44-14",
        "44-15",
        "44-16",
        "44-17",
        "44-18",
        "44-19",
        "44-20",
        "44-21",
        "44-22",
        "44-23",
        "44-24",
        "44-25",
        "44-26",
        "44-27",
        "44-28",
        "45-1",
        "45-2",
        "45-3",
        "45-4",
        "45-5",
        "45-6",
        "45-7",
        "45-8",
        "45-9",
        "45-10",
        "45-11",
        "45-12",
        "45-13",
        "45-14",
        "45-15",
        "45-16",
        "46-1",
        "46-2",
        "46-3",
        "46-4",
        "46-5",
        "46-6",
        "46-7",
        "46-8",
        "46-9",
        "46-10",
        "46-11",
        "46-12",
        "46-13",
        "46-14",
        "46-15",
        "46-16",
        "47-1",
        "47-2",
        "47-3",
        "47-4",
        "47-5",
        "47-6",
        "47-7",
        "47-8",
        "47-9",
        "47-10",
        "47-11",
        "47-12",
        "47-13",
        "48-1",
        "48-2",
        "48-3",
        "48-4",
        "48-5",
        "48-6",
        "49-1",
        "49-2",
        "49-3",
        "49-4",
        "49-5",
        "49-6",
        "50-1",
        "50-2",
        "50-3",
        "50-4",
        "51-1",
        "51-2",
        "51-3",
        "51-4",
        "52-1",
        "52-2",
        "52-3",
        "52-4",
        "52-5",
        "53-1",
        "53-2",
        "53-3",
        "54-1",
        "54-2",
        "54-3",
        "54-4",
        "54-5",
        "54-6",
        "55-1",
        "55-2",
        "55-3",
        "55-4",
        "56-1",
        "56-2",
        "56-3",
        "57-1",
        "58-1",
        "58-2",
        "58-3",
        "58-4",
        "58-5",
        "58-6",
        "58-7",
        "58-8",
        "58-9",
        "58-10",
        "58-11",
        "58-12",
        "58-13",
        "59-1",
        "59-2",
        "59-3",
        "59-4",
        "59-5",
        "60-1",
        "60-2",
        "60-3",
        "60-4",
        "60-5",
        "61-1",
        "61-2",
        "61-3",
        "62-1",
        "62-2",
        "62-3",
        "62-4",
        "62-5",
        "63-1",
        "64-1",
        "65-1",
        "66-1",
        "66-2",
        "66-3",
        "66-4",
        "66-5",
        "66-6",
        "66-7",
        "66-8",
        "66-9",
        "66-10",
        "66-11",
        "66-12",
        "66-13",
        "66-14",
        "66-15",
        "66-16",
        "66-17",
        "66-18",
        "66-19",
        "66-20",
        "66-21",
        "66-22"
        );

    var num_verses = new Array(
        31,
        25,
        24,
        26,
        32,
        22,
        24,
        22,
        29,
        32,
        32,
        20,
        18,
        24,
        21,
        16,
        27,
        33,
        38,
        18,
        34,
        24,
        20,
        67,
        34,
        35,
        46,
        22,
        35,
        43,
        55,
        32,
        20,
        31,
        29,
        43,
        36,
        30,
        23,
        23,
        57,
        38,
        34,
        34,
        28,
        34,
        31,
        22,
        33,
        26,
        22,
        25,
        22,
        31,
        23,
        30,
        25,
        32,
        35,
        29,
        10,
        51,
        22,
        31,
        27,
        36,
        16,
        27,
        25,
        26,
        36,
        31,
        33,
        18,
        40,
        37,
        21,
        43,
        46,
        38,
        18,
        35,
        23,
        35,
        35,
        38,
        29,
        31,
        43,
        38,
        17,
        16,
        17,
        35,
        19,
        30,
        38,
        36,
        24,
        20,
        47,
        8,
        59,
        57,
        33,
        34,
        16,
        30,
        37,
        27,
        24,
        33,
        44,
        23,
        55,
        46,
        34,
        54,
        34,
        51,
        49,
        31,
        27,
        89,
        26,
        23,
        36,
        35,
        16,
        33,
        45,
        41,
        50,
        13,
        32,
        22,
        29,
        35,
        41,
        30,
        25,
        18,
        65,
        23,
        31,
        40,
        16,
        54,
        42,
        56,
        29,
        34,
        13,
        46,
        37,
        29,
        49,
        33,
        25,
        26,
        20,
        29,
        22,
        32,
        32,
        18,
        29,
        23,
        22,
        20,
        22,
        21,
        20,
        23,
        30,
        25,
        22,
        19,
        19,
        26,
        68,
        29,
        20,
        30,
        52,
        29,
        12,
        18,
        24,
        17,
        24,
        15,
        27,
        26,
        35,
        27,
        43,
        23,
        24,
        33,
        15,
        63,
        10,
        18,
        28,
        51,
        9,
        45,
        34,
        16,
        33,
        36,
        23,
        31,
        24,
        31,
        40,
        25,
        35,
        57,
        18,
        40,
        15,
        25,
        20,
        20,
        31,
        13,
        31,
        30,
        48,
        25,
        22,
        23,
        18,
        22,
        28,
        36,
        21,
        22,
        12,
        21,
        17,
        22,
        27,
        27,
        15,
        25,
        23,
        52,
        35,
        23,
        58,
        30,
        24,
        42,
        15,
        23,
        29,
        22,
        44,
        25,
        12,
        25,
        11,
        31,
        13,
        27,
        32,
        39,
        12,
        25,
        23,
        29,
        18,
        13,
        19,
        27,
        31,
        39,
        33,
        37,
        23,
        29,
        33,
        43,
        26,
        22,
        51,
        39,
        25,
        53,
        46,
        28,
        34,
        18,
        38,
        51,
        66,
        28,
        29,
        43,
        33,
        34,
        31,
        34,
        34,
        24,
        46,
        21,
        43,
        29,
        53,
        18,
        25,
        27,
        44,
        27,
        33,
        20,
        29,
        37,
        36,
        21,
        21,
        25,
        29,
        38,
        20,
        41,
        37,
        37,
        21,
        26,
        20,
        37,
        20,
        30,
        54,
        55,
        24,
        43,
        26,
        81,
        40,
        40,
        44,
        14,
        47,
        40,
        14,
        17,
        29,
        43,
        27,
        17,
        19,
        8,
        30,
        19,
        32,
        31,
        31,
        32,
        34,
        21,
        30,
        17,
        18,
        17,
        22,
        14,
        42,
        22,
        18,
        31,
        19,
        23,
        16,
        22,
        15,
        19,
        14,
        19,
        34,
        11,
        37,
        20,
        12,
        21,
        27,
        28,
        23,
        9,
        27,
        36,
        27,
        21,
        33,
        25,
        33,
        27,
        23,
        11,
        70,
        13,
        24,
        17,
        22,
        28,
        36,
        15,
        44,
        11,
        20,
        32,
        23,
        19,
        19,
        73,
        18,
        38,
        39,
        36,
        47,
        31,
        22,
        23,
        15,
        17,
        14,
        14,
        10,
        17,
        32,
        3,
        22,
        13,
        26,
        21,
        27,
        30,
        21,
        22,
        35,
        22,
        20,
        25,
        28,
        22,
        35,
        22,
        16,
        21,
        29,
        29,
        34,
        30,
        17,
        25,
        6,
        14,
        23,
        28,
        25,
        31,
        40,
        22,
        33,
        37,
        16,
        33,
        24,
        41,
        30,
        24,
        34,
        17,
        6,
        12,
        8,
        8,
        12,
        10,
        17,
        9,
        20,
        18,
        7,
        8,
        6,
        7,
        5,
        11,
        15,
        50,
        14,
        9,
        13,
        31,
        6,
        10,
        22,
        12,
        14,
        9,
        11,
        12,
        24,
        11,
        22,
        22,
        28,
        12,
        40,
        22,
        13,
        17,
        13,
        11,
        5,
        26,
        17,
        11,
        9,
        14,
        20,
        23,
        19,
        9,
        6,
        7,
        23,
        13,
        11,
        11,
        17,
        12,
        8,
        12,
        11,
        10,
        13,
        20,
        7,
        35,
        36,
        5,
        24,
        20,
        28,
        23,
        10,
        12,
        20,
        72,
        13,
        19,
        16,
        8,
        18,
        12,
        13,
        17,
        7,
        18,
        52,
        17,
        16,
        15,
        5,
        23,
        11,
        13,
        12,
        9,
        9,
        5,
        8,
        28,
        22,
        35,
        45,
        48,
        43,
        13,
        31,
        7,
        10,
        10,
        9,
        8,
        18,
        19,
        2,
        29,
        176,
        7,
        8,
        9,
        4,
        8,
        5,
        6,
        5,
        6,
        8,
        8,
        3,
        18,
        3,
        3,
        21,
        26,
        9,
        8,
        24,
        13,
        10,
        7,
        12,
        15,
        21,
        10,
        20,
        14,
        9,
        6,
        33,
        22,
        35,
        27,
        23,
        35,
        27,
        36,
        18,
        32,
        31,
        28,
        25,
        35,
        33,
        33,
        28,
        24,
        29,
        30,
        31,
        29,
        35,
        34,
        28,
        28,
        27,
        28,
        27,
        33,
        31,
        18,
        26,
        22,
        16,
        20,
        12,
        29,
        17,
        18,
        20,
        10,
        14,
        17,
        17,
        11,
        16,
        16,
        13,
        13,
        14,
        31,
        22,
        26,
        6,
        30,
        13,
        25,
        22,
        21,
        34,
        16,
        6,
        22,
        32,
        9,
        14,
        14,
        7,
        25,
        6,
        17,
        25,
        18,
        23,
        12,
        21,
        13,
        29,
        24,
        33,
        9,
        20,
        24,
        17,
        10,
        22,
        38,
        22,
        8,
        31,
        29,
        25,
        28,
        28,
        25,
        13,
        15,
        22,
        26,
        11,
        23,
        15,
        12,
        17,
        13,
        12,
        21,
        14,
        21,
        22,
        11,
        12,
        19,
        12,
        25,
        24,
        19,
        37,
        25,
        31,
        31,
        30,
        34,
        22,
        26,
        25,
        23,
        17,
        27,
        22,
        21,
        21,
        27,
        23,
        15,
        18,
        14,
        30,
        40,
        10,
        38,
        24,
        22,
        17,
        32,
        24,
        40,
        44,
        26,
        22,
        19,
        32,
        21,
        28,
        18,
        16,
        18,
        22,
        13,
        30,
        5,
        28,
        7,
        47,
        39,
        46,
        64,
        34,
        22,
        22,
        66,
        22,
        22,
        28,
        10,
        27,
        17,
        17,
        14,
        27,
        18,
        11,
        22,
        25,
        28,
        23,
        23,
        8,
        63,
        24,
        32,
        14,
        49,
        32,
        31,
        49,
        27,
        17,
        21,
        36,
        26,
        21,
        26,
        18,
        32,
        33,
        31,
        15,
        38,
        28,
        23,
        29,
        49,
        26,
        20,
        27,
        31,
        25,
        24,
        23,
        35,
        21,
        49,
        30,
        37,
        31,
        28,
        28,
        27,
        27,
        21,
        45,
        13,
        11,
        23,
        5,
        19,
        15,
        11,
        16,
        14,
        17,
        15,
        12,
        14,
        16,
        9,
        20,
        32,
        21,
        15,
        16,
        15,
        13,
        27,
        14,
        17,
        14,
        15,
        21,
        17,
        10,
        10,
        11,
        16,
        13,
        12,
        13,
        15,
        16,
        20,
        15,
        13,
        19,
        17,
        20,
        19,
        18,
        15,
        20,
        15,
        23,
        21,
        13,
        10,
        14,
        11,
        15,
        14,
        23,
        17,
        12,
        17,
        14,
        9,
        21,
        14,
        17,
        18,
        6,
        25,
        23,
        17,
        25,
        48,
        34,
        29,
        34,
        38,
        42,
        30,
        50,
        58,
        36,
        39,
        28,
        27,
        35,
        30,
        34,
        46,
        46,
        39,
        51,
        46,
        75,
        66,
        20,
        45,
        28,
        35,
        41,
        43,
        56,
        37,
        38,
        50,
        52,
        33,
        44,
        37,
        72,
        47,
        20,
        80,
        52,
        38,
        44,
        39,
        49,
        50,
        56,
        62,
        42,
        54,
        59,
        35,
        35,
        32,
        31,
        37,
        43,
        48,
        47,
        38,
        71,
        56,
        53,
        51,
        25,
        36,
        54,
        47,
        71,
        53,
        59,
        41,
        42,
        57,
        50,
        38,
        31,
        27,
        33,
        26,
        40,
        42,
        31,
        25,
        26,
        47,
        26,
        37,
        42,
        15,
        60,
        40,
        43,
        48,
        30,
        25,
        52,
        28,
        41,
        40,
        34,
        28,
        41,
        38,
        40,
        30,
        35,
        27,
        27,
        32,
        44,
        31,
        32,
        29,
        31,
        25,
        21,
        23,
        25,
        39,
        33,
        21,
        36,
        21,
        14,
        23,
        33,
        27,
        31,
        16,
        23,
        21,
        13,
        20,
        40,
        13,
        27,
        33,
        34,
        31,
        13,
        40,
        58,
        24,
        24,
        17,
        18,
        18,
        21,
        18,
        16,
        24,
        15,
        18,
        33,
        21,
        14,
        24,
        21,
        29,
        31,
        26,
        18,
        23,
        22,
        21,
        32,
        33,
        24,
        30,
        30,
        21,
        23,
        29,
        23,
        25,
        18,
        10,
        20,
        13,
        18,
        28,
        12,
        17,
        18,
        20,
        15,
        16,
        16,
        25,
        21,
        18,
        26,
        17,
        22,
        16,
        15,
        15,
        25,
        14,
        18,
        19,
        16,
        14,
        20,
        28,
        13,
        28,
        39,
        40,
        29,
        25,
        27,
        26,
        18,
        17,
        20,
        25,
        25,
        22,
        19,
        14,
        21,
        22,
        18,
        10,
        29,
        24,
        21,
        21,
        13,
        15,
        25,
        20,
        29,
        22,
        11,
        14,
        17,
        17,
        13,
        21,
        11,
        19,
        18,
        18,
        20,
        8,
        21,
        18,
        24,
        21,
        15,
        27,
        21
        );


    if (field_name == "scr_book_id_1" || field_name == "scr_book_id_2")
    {
        value = eval("document.searchform." + field_name + ".value");
        chaps = chapters[value - 1];
        
        if (field_name == "scr_book_id_1")
        {
            book_2 = document.searchform.scr_book_id_2;
            book_2.value = value;
            select = document.searchform.scr_chapter_1;
            select_2 = document.searchform.scr_chapter_2;
            set_selection(select, 1, chaps, 150);
            set_selection(select_2, 1, chaps, 150);
            clear_all(document.searchform.scr_verse_1);
            clear_all(document.searchform.scr_verse_2);
        }
        else
        {
            select = document.searchform.scr_chapter_2;
            select.value = null;
            first_chap = 1;
            if (document.searchform.scr_book_id_2.value == document.searchform.scr_book_id_1.value)
            {
                first_chap = document.searchform.scr_chapter_1.value;
                select.value = first_chap;
            }    
            set_selection(select, first_chap, chaps, 150)
            document.searchform.scr_verse_2.value = null;
        }
    }
    else if (field_name == "scr_chapter_1" || field_name == "scr_chapter_2")
    {
        // work out number of verses in this chapter of this book!

        selected_chapter = eval("document.searchform." + field_name + ".value");
        
        if (field_name == "scr_chapter_1")
        {
            selected_book = document.searchform.scr_book_id_1.value;
            select = document.searchform.scr_verse_1;
        }
        else
        {
            selected_book = document.searchform.scr_book_id_2.value;
            select = document.searchform.scr_verse_2;
        }

        selected_string = selected_book + "-" + selected_chapter;
        the_num_verses = 0;
        for (i = 0; i < chapter_id.length && the_num_verses == 0; i++)
        {
            if (chapter_id[i] == selected_string)
            {
                the_num_verses = num_verses[i];
            }
        }
        
        set_selection(select, 1, the_num_verses, 176);

        if (field_name == "scr_chapter_1")
        {
            if (document.searchform.scr_book_id_2.value == document.searchform.scr_book_id_1.value)
            {
                chap_2 = document.searchform.scr_chapter_2;
                set_selection(chap_2, selected_chapter, chapters[selected_book - 1], 150);
                chap_2.value = selected_chapter;
                select_2 = document.searchform.scr_verse_2;
                set_selection(select_2, select.value, the_num_verses, 176);
                clear_all(document.searchform.scr_verse_2.value);
            }
            clear_all(document.searchform.scr_verse_1.value);
        }
        else if (field_name == "scr_chapter_2")
        {
            clear_all(document.searchform.scr_verse_2.value);
        }
    }
    else if (field_name == "scr_verse_1")
    {
        if ((document.searchform.scr_book_id_2.value == document.searchform.scr_book_id_1.value) && (document.searchform.scr_chapter_2.value == document.searchform.scr_chapter_1.value))
        {
            select = document.searchform.scr_verse_2;
            verse_value = document.searchform.scr_verse_1.value;

            selected_string = document.searchform.scr_book_id_1.value + "-" + document.searchform.scr_chapter_1.value;
            the_num_verses = 0;
            for (i = 0; i < chapter_id.length && the_num_verses == 0; i++)
            {
                if (chapter_id[i] == selected_string)
                {
                    the_num_verses = num_verses[i];
                }
            }
            set_selection(select, verse_value, the_num_verses, 176);
            select.value = verse_value;
        }
    }
    else if (field_name == "scr_book_id_series")
    {
        book_value = eval("document." + form_name + ".scr_book_id_series.value");
        chaps = chapters[book_value - 1];
        
        select = eval("document." + form_name + ".scr_chapter_1_series");
        select_2 = eval("document." + form_name + ".scr_chapter_2_series");
        set_selection(select, 1, chaps, 150);
        set_selection(select_2, 1, chaps, 150);
    }
    else if (field_name == "scr_chapter_1_series")
    {
        selected_chapter = eval("document." + form_name + "." + field_name + ".value");
        chap_2 = eval("document." + form_name + ".scr_chapter_2_series");
        chaps = chapters[eval("document." + form_name + ".scr_book_id_series.value") - 1];
        set_selection(chap_2, selected_chapter, chaps, 150);
        chap_2.value = selected_chapter;
    }
}
function set_selection(select, start_num, end_num, poss_num)
{
    clear_options(select, poss_num)

    for (i = 1; i <= end_num; i++)
    {
        select.options[i] = new Option(i, i);
    }

    clear_options(select, start_num - 1);
}
function clear_options(select, to_option)
{
    for (i = to_option; i > 0; i--)
    {
        select.options[i] = null;
    }
}
function clear_all(select)
{
    for (i = select.options.length; i > 0; i--)
    {
        select.options[i] = null;
    }
}
function checkScripRange()
{
    book_1 = document.searchform.scr_book_id_1.value;
    book_2 = document.searchform.scr_book_id_2.value;
    speaker = document.searchform.speaker_id.value;
    if ((book_1 == -1 || book_2 == -1) && speaker == -1)
        alert("Please select a book or speaker.");
    else if ((book_2 - book_1) > 4)
    {
        var conf = confirm("Are you sure you want to search such a wide range?");
        if (conf == true) document.searchform.submit();
    }
    else
        document.searchform.submit();
}

function checkSeriesBook()
{
    book = document.searchform_series.scr_book_id_series.value;
    if (book == -1)
        alert("Please select a book.");
    else
        document.searchform_series.submit();
}

function checkTopic()
{
    topic = document.searchform_topic.topic_id.value;
    if (topic > 0)
        document.searchform_topic.submit();
    else
        alert("Please select a topic.");
}
function submitTopicForm()
{
    document.searchform_topic.submit();
}
function jumpToAnchor(anchor)
{
    window.location.hash="topictitle";
}
function redirect_me(file_name)
{    
    var w = 650;
    var h = 300;
    var xMax = screen.width, yMax = screen.height;
    var xOffset = (xMax - w) / 2;
    var yOffset = (yMax - h) / 2;
    child = window.open(file_name, 'st3dcard_popup', 'location=no, scrollbars=no, menubar=no, width=' + w + ', height=' + h + ', screenX=' + xOffset + ', screenY=' + yOffset + ', top=' + yOffset + ', left=' + xOffset);
    child.focus();
}

function checkPrivacyPolicyTermsConditions()
{
    if (document.registerform.privacy_policy[0].checked == false)
    {
        alert("Please confirm that you've read and understood the privacy policy.");
        return false;
    }
    else if (document.registerform.terms_conditions[0].checked == false)
    {
        alert("Please confirm that you agree to our terms and conditions");
        return false;
    }
    else
    {
        return true;
    }
}
//-->

