// This file contains common javascript functions needed throughout bnelson.com

if (document.images) {
Iindex_04_01 = new Image(187, 23);Iindex_04_01.src = '/images/menu/buglistNormal.jpg';
Iindex_04_01o = new Image(187, 23);Iindex_04_01o.src = '/images/menu/bugListOver.jpg';
Iindex_05_01 = new Image(187, 23);Iindex_05_01.src = '/images/menu/coursestaughtNormal.jpg';
Iindex_05_01o = new Image(187, 23);Iindex_05_01o.src = '/images/menu/coursestaughtOver.jpg';
Iindex_06_01 = new Image(187, 23);Iindex_06_01.src = '/images/menu/directoryNormal.jpg';
Iindex_06_01o = new Image(187, 23);Iindex_06_01o.src = '/images/menu/directoryOver.jpg';
Iindex_07_01 = new Image(187, 23);Iindex_07_01.src = '/images/menu/eInfraNormal.jpg';
Iindex_07_01o = new Image(187, 23);Iindex_07_01o.src = '/images/menu/eInfraOver.jpg';
Iindex_08_01 = new Image(187, 23);Iindex_08_01.src = '/images/menu/funstuffNormal.jpg';
Iindex_08_01o = new Image(187, 23);Iindex_08_01o.src = '/images/menu/funstuffOver.jpg';
Iindex_09_01 = new Image(187, 23);Iindex_09_01.src = '/images/menu/javascriptNormal.jpg';
Iindex_09_01o = new Image(187, 23);Iindex_09_01o.src = '/images/menu/javascriptOver.jpg';
Iindex_0a_01 = new Image(187, 23);Iindex_0a_01.src = '/images/menu/perlNormal.jpg';
Iindex_0a_01o = new Image(187, 23);Iindex_0a_01o.src = '/images/menu/perlOver.jpg';
Iindex_0b_01 = new Image(187, 23);Iindex_0b_01.src = '/images/menu/resumeNormal.jpg';
Iindex_0b_01o = new Image(187, 23);Iindex_0b_01o.src = '/images/menu/resumeOver.jpg';
Iindex_0c_01 = new Image(187, 23);Iindex_0c_01.src = '/images/menu/sizingNormal.jpg';
Iindex_0c_01o = new Image(187, 23);Iindex_0c_01o.src = '/images/menu/sizingOver.jpg';
}

function showImage(imgName,imgSrc) {
  if (document.images) {
      document.images[imgName].src=imgSrc;
  }
}

// This function opens a popup window with a particular HTML page in it.
function openWindow(page) {
    var msie=false;
    var appName=navigator.appName;
    if(appName.indexOf("Microsoft")==0) {
        msie=true;
    }
    helpWindow=window.open(page, "helpWindow", "width=505,height=360,resizable=yes,menubar=no,scrollbars=yes,toolbar=no,location=no");
    if(!msie) {
        helpWindow.focus();
    }
}

function getRadioButtonValue (radio) {

    for (var i = 0; i < radio.length; i++)
    {
        if (radio[i].checked) { break }
    }
    return radio[i].value
}

function getPullDownValue (pullDown)
{
    for (var i = 0; i < pullDown.length; i++)
    {
        if (pullDown[i].selected) { break }
    }
    return pullDown[i].value
}

// This function pops open a new window that displays the help page for the page that the user is on.
function displayHelpWindow(u)
{

    alert(u);

    page = u.pathname.split(".");
    page = page[0].split("/");

    switch(page[1]) {
        case "userMain":
                openWindow('/help/userMainHelp.html','505','360','yes')
                break;
        case "addressBook":
                openWindow('help/userAddressBookHelp.html','505','360','yes')
                break;
        default:
                openWindow('help/noHelp.html','505','360','yes')
                break;
    }
}

function checkEmail(email,checkbox)
{
    if (checkbox.checked)
    {
        if ( email == "" )
        {
            alert("Nothing Entered!")
            checkbox.checked = 0;
        }
        else
        {
            alert("An email message will open in your email client window.\n\nPlease send this email to the address that you entered and verify that the recipient receives it as intended.\n\nIf they do not, then please modify the text in the Email field and verify the information again.\n\nPlease note:  email is not instantaneous and it may take a few minutes (or even hours, sometimes) for your recipient to receive this email.")
            parent.location.href='mailto:'+email+'?subject=BibleNet Email Verification';
            checkbox.checked = 0;
        }
    }
}

function checkURL(url,checkbox)
{
    if (checkbox.checked)
    {
        if ( url == "http://" )
        {
            alert("Nothing Entered!")
            checkbox.checked = 0;
        }
        else
        {
            alert("Another browser window will now open pointing to the page that you indicated.\n\nPlease verify that the page that opens is what you intended.\n\nIf it is not, then please modify the text in the URL field and verify the information again.")
            openWindow(url)
            checkbox.checked = 0;
        }
    }
}
