function navJump(frmSel) {
//Respond to a selection list event and jump to a new page
//Parameters: the selection list that called this function

  var selIndex = frmSel.selectedIndex;
	var selVal = frmSel.options[selIndex].value;
		
	if(selVal != "")
	  window.location = selVal;
	else
	  alert("Please select a page to go to.");
}

function colored_hr(colorStr, height, width) {
//simulates a colored <hr>, because the "color" attribute of <hr> isn't supported on all browsers
//params:
//  colorStr: the color code (defaults to #5a99ff)
//  height: thickness of the horizontal line in pixels (defaults to 2)
//  width: width ("width" setting of "style" attribute) of the horizontal line (defaults to '100%')

  if(colorStr == "") colorStr = "#5a99ff";
  if(height == "") height = 2;
  if(width == "") width = "100%";

  var html = "<center><div style='width:" + width + "; height:" + height + "px; background-color:" + colorStr + "; text-align:center; margin: 0.1in 0in 0.1in 0in;'><img src='img/trans.gif' width=1 height=" + height + "></div></center>";
  document.write(html);
}

function img_hr(img, height, width) {
//simulates an <hr> with an image instead of a solid color
//params:
//  img: path and name of the image to use (defaults to #5a99ff)
//  height: thickness of the horizontal line in pixels (defaults to 2)
//  width: width ("width" attribute of <img>) of the horizontal line (defaults to '100%')

  if(height == "") height = 2;
  if(width == "") width = "100%";

  var html = "<div style='width:100%; height:" + height + "px; text-align:center; margin: 0.1in 0in 0.1in 0in;'><img src='" + img + "' width='" + width + "' height='100%'></div>";
  document.write(html);
}

function title(txt) {
//writes out a title header
//param: the text to put in the title

  var html = "<center><table border=0 cellspacing=0 cellpadding=0>"
             + "<tr><td style='height:4px'><img src='img/line_grad_lightorange.jpg' width='100%' height=4></td></tr>"
             + "<tr><td class='Title'>" + txt + "</td></tr>"
             + "<tr><td style='height:4px'><img src='img/line_grad_lightorange.jpg' width='100%' height=4></td></tr>"
             + "</table></center>";
  document.write(html);
}

function header(txt) {
//writes out a header
//param: the text to put in the header

  var html = "<table border=0 cellspacing=0 cellpadding=0>"
             + "<tr><td style='height:3px'><img src='img/line_grad_lightblue.jpg' width='100%' height=3></td></tr>"
             + "<tr><td class='Header'>" + txt + "</td></tr>"
             + "<tr><td style='height:3px'><img src='img/line_grad_lightblue.jpg' width='100%' height=3></td></tr>"
             + "</table>";
  document.write(html);
}

function blueBox(outerFormatting, innerFormatting, txt) {
//writes out a blue highlight box
//params:
//  outerFormatting: formatting attributes for the overall table to control width, etc.
//  innerFormatting: formatting attributes for the inner cell, to control text appearance and alignment, etc.
//  txt: the text to put the box

  startBlueBox(outerFormatting, innerFormatting);
  document.write(txt);
  endBlueBox();
}

function startBlueBox(outerFormatting, innerFormatting) {
//writes all the code for a blue highlight box up to the start of the box contents

  var cornerStyle = "style='width:9px; height:9px'";
  var hEdgeStyle = "style='height:9px'";
  var vEdgeStyle = "style='width:9px'";
  var transImg = "<img src='img/trans.gif' width=9 height=1>";

  var html = "<div " + outerFormatting + ">"
             + "<table width='100%' border=0 cellspacing=0 cellpadding=0><tr>"
             + "<td background='img/edge_blue_tl.gif' " + cornerStyle + ">" + transImg + "</td>"
             + "<td background='img/edge_blue_t.gif' " + hEdgeStyle + ">" + transImg + "</td>"
             + "<td background='img/edge_blue_tr.gif' " + cornerStyle + ">" + transImg + "</td>"
             + "</tr><tr>"
             + "<td background='img/edge_blue_l.gif' " + vEdgeStyle + ">" + transImg + "</td>"
             + "<td bgcolor='blue' " + innerFormatting + ">";
  document.write(html);
}

function endBlueBox() {
//writes all the code for a blue highlight box that comes after the box contents

  var cornerStyle = "style='width:9px; height:9px'";
  var hEdgeStyle = "style='height:9px'";
  var vEdgeStyle = "style='width:9px'";
  var transImg = "<img src='img/trans.gif' width=9 height=1>";

  var html = "</td>"
             + "<td background='img/edge_blue_r.gif' " + vEdgeStyle + ">" + transImg + "</td>"
             + "</tr><tr>"
             + "<td background='img/edge_blue_bl.gif' " + cornerStyle + ">" + transImg + "</td>"
             + "<td background='img/edge_blue_b.gif' " + hEdgeStyle + ">" + transImg + "</td>"
             + "<td background='img/edge_blue_br.gif' " + cornerStyle+ ">" + transImg + "</td>"
             + "</tr></table>"
             + "</div>";
  document.write(html);
}

function orangeBox(outerFormatting, innerFormatting, txt) {
//writes out an orange highlight box
//params:
//  outerFormatting: formatting attributes for the overall table to control width, etc.
//  innerFormatting: formatting attributes for the inner cell, to control text appearance and alignment, etc.
//  txt: the text to put the box

  startOrangeBox(outerFormatting, innerFormatting);
  document.write(txt);
  endOrangeBox();
}

function startOrangeBox(outerFormatting, innerFormatting) {
//writes all the code for an orange highlight box up to the start of the box contents

  var cornerStyle = "style='width:9px; height:9px'";
  var hEdgeStyle = "style='height:9px'";
  var vEdgeStyle = "style='width:9px'";
  var transImg = "<img src='img/trans.gif' width=9 height=1>";

  var html = "<div " + outerFormatting + ">"
             + "<table width='100%' border=0 cellspacing=0 cellpadding=0><tr>"
             + "<td background='img/edge_orange_tl.gif' " + cornerStyle + ">" + transImg + "</td>"
             + "<td background='img/edge_orange_t.gif' " + hEdgeStyle + ">" + transImg + "</td>"
             + "<td background='img/edge_orange_tr.gif' " + cornerStyle + ">" + transImg + "</td>"
             + "</tr><tr>"
             + "<td background='img/edge_orange_l.gif' " + vEdgeStyle + ">" + transImg + "</td>"
             + "<td bgcolor='#ffdba8' " + innerFormatting + ">";
  document.write(html);
}

function endOrangeBox() {
//writes all the code for an orange highlight box that comes after the box contents

  var cornerStyle = "style='width:9px; height:9px'";
  var hEdgeStyle = "style='height:9px'";
  var vEdgeStyle = "style='width:9px'";
  var transImg = "<img src='img/trans.gif' width=9 height=1>";

  var html = "</td>"
             + "<td background='img/edge_orange_r.gif' " + vEdgeStyle + ">" + transImg + "</td>"
             + "</tr><tr>"
             + "<td background='img/edge_orange_bl.gif' " + cornerStyle + ">" + transImg + "</td>"
             + "<td background='img/edge_orange_b.gif' " + hEdgeStyle + ">" + transImg + "</td>"
             + "<td background='img/edge_orange_br.gif' " + cornerStyle+ ">" + transImg + "</td>"
             + "</tr></table>"
             + "</div>";
  document.write(html);
}

function menuBox(outerFormatting, innerFormatting, header, content) {
//writes out a menu box
//params:
//  outerFormatting: formatting attributes for the overall table to control width, etc.
//  innerFormatting: formatting attributes for the inner cell, to control text appearance and alignment, etc.
//  header: content of the header
//  content: content of the box body


  startMenuBox(outerFormatting, innerFormatting, header);
  document.write(content);
  endMenuBox();
}

function startMenuBox(outerFormatting, innerFormatting, header) {
//writes all the code for a menu box that comes before the box contents

  var cornerStyle = "style='width:9px; height:9px'";
  var hEdgeStyle = "style='height:9px'";
  var vEdgeStyle = "style='width:9px'";
  var transImg = "<img src='img/trans.gif' width=9 height=1>";

  var html = "<div " + outerFormatting + ">"
             + "<table width='100%' border=0 cellspacing=0 cellpadding=0><tr>"
             + "<td background='img/edge_menu_tl.gif' " + cornerStyle + ">" + transImg + "</td>"
             + "<td background='img/edge_menu-head_t.gif' " + hEdgeStyle + ">" + transImg + "</td>"
             + "<td background='img/edge_menu_tr.gif' " + cornerStyle + ">" + transImg + "</td>"
             + "</tr><tr>"
             + "<td background='img/edge_menu-head_l.gif' " + vEdgeStyle + ">" + transImg + "</td>"
             + "<td align='center' bgcolor='blue'><span class='MenuBoxHeader'>" + header + "</span></td>"
             + "<td background='img/edge_menu-head_r.gif' " + vEdgeStyle + ">" + transImg + "</td>"
             + "</tr>"
             + "<tr><td colspan=3 bgcolor='#ffbe00' style='height:2px'>" + transImg + "</td></tr>"
             + "<tr>"
             + "<td background='img/edge_menu_l.gif' " + vEdgeStyle + ">" + transImg + "</td>"
             + "<td " + innerFormatting + ">";
  document.write(html);
}

function endMenuBox() {
//writes all the code for a menu box that comes after the box contents

  var cornerStyle = "style='width:9px; height:9px'";
  var hEdgeStyle = "style='height:9px'";
  var vEdgeStyle = "style='width:9px'";
  var transImg = "<img src='img/trans.gif' width=9 height=1>";

  var html = "</td>"
             + "<td background='img/edge_menu_r.gif' " + vEdgeStyle + ">" + transImg + "</td>"
             + "</tr>"
             + "<td background='img/edge_menu_bl.gif' " + cornerStyle + ">" + transImg + "</td>"
             + "<td background='img/edge_menu_b.gif' " + hEdgeStyle + ">" + transImg + "</td>"
             + "<td background='img/edge_menu_br.gif' " + cornerStyle + ">" + transImg + "</td>"
             + "</tr></table>"
             + "</div>";
  document.write(html);
}

function CSXfilter(frmTxt) {
//Helps guard from Cross-Site Scripting (CSX) vulnerability.  Will not allow form submission if any characters are input that might be part of some malicious code entered by a hacker.
//Parameters: a text box form element
//Returns: true or false
	var badChars = new Array("<", ">", "(", ")", "[", "]", "{", "}", "%", ";"); //An array of characters not allowed
	
	if(isInStringMulti(frmTxt.value, badChars)) {
	  alert("For computer security reasons, the following characters are not allowed:\n\n" +
		      "\< \> \( \) \[ \] \{ \} \% \;\n\n" +
					"Please remove any of these characters that you may have typed in and try again.");
	  return false;
	} else return true;
}

/*function writeEmailLink(user,domain,text,inAnchorCode,openFormatTags,closeFormatTags) {
//Write e-mail link to web page in such a way as to hide it from spammers' web spiders searching for e-mail addresses
//Parameters: the e-mail user name; the e-mail domain (including suffix); link text; link style declarations; opening link text format tags; closing link text format tags

  var linkString = "";               //The string to hold the completed link code
  var address = user + "@" + domain; //The e-mail address

  //If no link text was specified, use the address as the link text
  if (text == "")
    text = address;

  //Build the link
  linkString += "<a href='mailto:" + address + "'";
  if (inAnchorCode != "")            //Include any code to be placed inside the <a href> tag if it was specified (such as style or class declarations)
    linkString += inAnchorCode;
  linkString += ">";
  if (openFormatTags != "")          //Include any text format tags if they were specified
    linkString += openFormatTags + text + closeFormatTags + "</a>";
  else
    linkString += text + "</a>";

  document.write(linkString);        //Write the completed link
  document.close();
}*/

function explainMunge() {
  var txt = "This email address is disguised to hide it from spammers"
          + " who collect email addresses from web pages.  To use this address,"
          + " remove the extra 'at' sign and the extra period.";
  alert(txt);
}

function isEmailAddr(addr) {
//See if a string is an email address
//Parameter: the address to validate
//Returns: T or F

  //The regular expression to match.
  //Looks for beginning of string; then at least 1 letter, number, hyphen, or underscore;
  // then @; then at least 1 letter, number, hyphen, or underscore; then a period;
  // then 2 to 4 alphanumeric chars; then end of string.
  var regex = /^[\w-_]+@[\w-_]+\.\w{2,4}$/;

  if(regex.test(addr))
    return true;
  else
    return false;
}

function isInString(string, substring) {
//Tell if a substring is found within a string
//Parameters: a string, and a substring to search for within the string
//Returns: T/F


  if(string.indexOf(substring,0) >= 0)
	  return true;
	else
	  return false;
}

function isInStringMulti(string, array) {
//Tell if any of several substrings are found within a string
//Parameters: a string, and an array of substrings to search for within the string
//Returns: T/F

  var found = false; //Has any substring been found in the string yet?
	
	//Search for the substrings
  for(var i = 0; i < array.length; i++)
	  if(isInString(string, array[i])) {
		  found = true;
			break;
		}
	
  return found;
}

function startsWith(string, substring) {
//sees if a string starts with the given substring
//Parameters: a string, and a substring to search for at the beginning the string
//Returns: T/F

  return (string.indexOf(substring) == 0);
}

function TEVcopyright() {
  document.write("(TEV) Scripture taken from the Good News Bible in Today's English Version - Second Edition, Copyright &copy; 1992 by American Bible Society. Used by Permission.");
}

function NIVcopyright() {
  document.write("(NIV) Scripture taken from the New International Version (North American Edition), copyright &copy; 1973, 1978, 1984 by the International Bible Society. Used by permission of Zondervan Publishing House.");
}
