/*

This was copied from Driving--most of it probably won't be needed, so just uncomment
code when it's useful to do so.

*/







//================================= Constants ===============================================

// var undefined;
// var isNetscape4 = (document.layers && navigator.appName == 'Netscape');
// var isNetscape6 = (document.getElementById && !document.all && 
//                    (navigator.appName == 'Netscape6' || navigator.appName == 'Netscape') &&
//                    navigator.vendor != 'Firefox');
// var isIE4 = (document.all && !document.getElementById);
// var isIE5 = (document.all && document.getElementById());
// var isIE6 = (navigator.appName == 'Microsoft Internet Explorer' && navigator.appVersion.indexOf('MSIE 6') > -1);
// var isFirefox = (navigator.vendor == 'Firefox');
// if (lsWebServerPath == undefined) {
//   if (location.pathname.toLowerCase().indexOf('/chapter') > -1 ) {
//     var lsWebServerPath = '../';
//   } else {
     var lsWebServerPath = '';
//   }
// }
// 
// // Store a reference to all open windows and use stored values to close them when page changes
// var laWindows = new Array();
// self.onunload = function () {
//                          for (var i=0; i<laWindows.length; i++) {
//                            if (laWindows[i] && !laWindows[i].closed) {
//                             laWindows[i].close(); 
//                            }
//                          }
//                         }
// 
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// // Trim leading and trailing spaces
// function allTrim(s) {
//   return lTrim(rTrim(s));
// }
// 
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// // Verify text in a text area does not exceed database column size
// function checkLength(fld, ln) {
//   if (fld.value.length > ln) {
//     alert("This response is limited to " + ln + " characters");
//     fld.value = fld.value.substr(0, ln);
//     fld.focus();
//   }
// }
// 
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// // Return the selected value from a radio group
// function checkRadio(radioCollection) {
//   var lsSelectedValue = null;
//   for (i=0; i<radioCollection.length; i++) {
//     if (radioCollection[i].checked) {
//       lsSelectedValue = radioCollection[i].value;
//       break;
//     }
//   }
//   return lsSelectedValue;
// }
// 
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// // Return the selected value from a select box 
// function getSelBoxValue(selBox) {
//   var lsSelectedValue = selBox.options[selBox.selectedIndex].value;
//   return lsSelectedValue;
// }
// 
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// function getValue(poEl) {
//   switch (poEl.type) {
//     case 'radio' :
//       return checkRadio(poEl);
//       break;
//     case 'select-one' :
//       return getSelBoxValue(poEl);
//       break;
//     default :
//       return poEl.value;
//   } 
// }
// 
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// function inList(){
// 	if (arguments.length > 1){
// 		var theTestValue = arguments[0];
// 		for (var i=1; i < arguments.length; i++){
// 			if (arguments[i].valueOf() == theTestValue.valueOf()) {
//         return true;
//       }
// 		}
// 	}
// 	return false;
// }
// 
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// function isValidEmail (psEmail) {
//   var re = /^[\w']+([\.-]?[\w']+)*@[\w']+([\.-]?[\w']+)*(\.\w{2,3})+$/;
//   if (!(re.test(psEmail))){
//     return false;
//   } else {
//     return true;
//   }
// }
// 
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// // (Left) trim leading spaces
// function lTrim(s) {
//   return s.replace(/^\s*([\S])/, '$1');
// }
// 
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// //function nextPage(page) {
// function nextPage(page) {
//   if (lbOKtoProceed) {
//     //document.location = page;
//     document.location = lsNextPage;
//   } else {
//     var msg = 'The dialog on this page is an important part of the course material.  ' +
//               '\n\nPlease play the audio or view the transcript of the scenario before proceeding.';
//     alert(msg);
//   }
// }
// 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Function to standardize handling of links and pop-ups.  Pop-ups are opened in named windows
// so that windows for each type can be re-used if user leaves a previous window open.  Although
// default sizes are suggested for each type, the default width and height can be overridden by 
// passing the preferred values.  (In general, if not using the defaults, use the "C" (Custom) 
// window type, since this will ensure that a new window is opened and the previous size isn't 
// re-used.)
function popUpExt(poLink, psType, pnWidth, pnHeight) {
  if (poLink == null || poLink == '')     {
    return void(0);   
  } else {
    var lsURL = poLink;
  }
  var lsType = 'E';
  var lnWidth = 800;
  var lnHeight = 550;
  var lnOffset = 10;
  var lsWinName = 'Handout';

  // Override default size if custom values provided
  if (arguments.length >= 2) {
    lsType = psType;
  }
  if (arguments.length >= 3) {
    lnWidth = pnWidth;
  }
  if (arguments.length >= 4) {
    lnHeight = pnHeight;
  }

 var winFeat = 'toolbar,location,menubar,resizable,scrollbars,left=' + lnOffset + ',top=' + lnOffset + ',screenX=' + lnOffset + ',screenY=' + lnOffset + ',width=' + lnWidth + ',height=' + lnHeight;
 if (lsType == 'E') {

    // Pass current page location to function since Request.ServerVariables("HTTP_Referer") doesn't work in IE
    // when opening a new window.
    lsURL = lsWebServerPath + "loadExternalPage.asp?referer=" + location.href + "&URL=" + lsURL;
  } else {
    lsURL = poLink;
  }

//   // Create a window reference so that, if an existing window of same name/type is already open,  
//   // it can be closed and new features will take effect
   loWin = window.open(lsURL, lsWinName, winFeat);
//   laWindows[laWindows.length] = loWin;
   loWin.focus(); 
}

// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// // (Right) Trim trailing spaces
// function rTrim(s) {
//   return s.replace(/([\S])\s*$/, '$1');
// }
// 
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// // Set the focus to the named field if the current element selected.
// // In order to work, HTML form must be named "mainForm."  
// function setFocus(fldName) {
//   // Workaround for problem setting focus correctly in Firefox
//   //document.mainForm[fldName].focus(); 
//   setTimeout('document.mainForm.elements["' + fldName + '"].focus()', 1);
// }
// 
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// // Use for forms being transferred to ADEPT; hidden field matches ADEPT field name, 
// // user input element has same name with an underscore in front of it
// function setHidden(fld) {
//   var hiddenFld = fld.name.substr(1);
//   var thisForm = fld.form;
//   if (fld.type == 'checkbox') {
//     if (fld.checked) {
//       thisForm[hiddenFld].value = 1;
//     } else {
//       thisForm[hiddenFld].value = 2;
//     }
//   } else if (fld.type == 'text' || fld.type == 'textarea') {
//     if (fld.value == '') {
//       thisForm[hiddenFld].value = '-9';
//     } else {
//       thisForm[hiddenFld].value = fld.value;
//     }
//   }
// }
// 
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// // Sort a string of numbers and return sorted string; use for prompts for missing test 
// // answers.  
// function sortString(s) {
// 
//   // Remove spaces, then split string
//   var laItems = s.replace(/,\s/g, ',').split(',');
//   var sortItems = function (a, b) {
//                     // Kludge to deal with numbers with subletters (GEFGW)
//                     var x = a.match(/\d+/);
//                     var y = b.match(/\d+/);
//                     if ((x - y) == 0) {
//                       return (a > b ? 1 : -1);
//                     } else {
//                       return x - y;
//                     }
//                   }
//   laItems.sort(sortItems);  
//   var lsSortedString = laItems.join(', ');
//   return lsSortedString;
// }
// 
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// //         toChar(datetime,mask) 
// //
// // Convert a datetime to a string based on a mask similar to Oracles
// // Supports the following mask components:
// //    DD         Date 01-31
// //    dd         Date 1-31 (no leading zero)
// //    MM         Month 01-12
// //    mm         Month 1-12 (no leading zero)
// //    MON        Abbreviated Month Name in caps
// //    Month      Full Month Name
// //    YYYY       4 digit year
// //    HH24       Hour 00-23
// //    HH         hour 01-12
// //    hh         hour 1-12 (no leading zero)
// //    MI         Minutes 01-59
// //    SS         seconds 01-59
// //    AM or PM   meridian part of day as AM or PM
// //    D          day number of the week (0=Sunday, 6=Saturday)
// //    Day        Name of day of week
// //    DAY        Abbreviated day of week in caps
// //
// // If datetime item is null function returns empty string.
// //
// // Requires:
// //    dDateTime:  Date object.
// //    sMask:  String containing mask format.
// // Returns:  
// //    String.
// //------------------------------------------------------------------------
// function toChar(dDateTime,sMask) {
//   var cReturn;
//   if (dDateTime == null) {
//     cReturn='';
//   } else {
//     var cReturn=sMask;
//     var re;
//     var nTemp;
//     var maskCollection = new Array();
//     var laMonths = 
//         new Array('January', 'February', 'March', 'April', 'May', 'June',
//                   'July', 'August', 'September', 'October', 'November', 'December');
//     var laDays = 
//         new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
//     function zeroPad(sNumber) {
//       var sReturn = sNumber;
//       if (sNumber.length<2) {
//         sReturn='0'+sReturn;
//       }
//       return sReturn;
//     }  
//   
//     maskCollection['YYYY'] = String(dDateTime.getFullYear());
//     maskCollection['MM'] = zeroPad(String(dDateTime.getMonth()+1));
//     maskCollection['mm'] = String(dDateTime.getMonth()+1);
//     maskCollection['Month'] = laMonths[dDateTime.getMonth()];
//     maskCollection['Mon'] = laMonths[dDateTime.getMonth()].substr(0, 3);
//     maskCollection['MON'] = laMonths[dDateTime.getMonth()].toUpperCase();
//     maskCollection['DD'] = zeroPad(String(dDateTime.getDate()));
//     maskCollection['dd'] = String(dDateTime.getDate());
//     maskCollection['HH24'] = zeroPad(String(dDateTime.getHours()));
//     nTemp=dDateTime.getHours();
//     if (nTemp==0) { nTemp=12; }
//     if (nTemp>12) {nTemp=nTemp-12;}
//     maskCollection['HH'] = zeroPad(String(nTemp));
//     maskCollection['hh'] = String(nTemp);
//     maskCollection['MI'] = zeroPad(String(dDateTime.getMinutes()));
//     maskCollection['SS'] = zeroPad(String(dDateTime.getSeconds()));
//     maskCollection['AM'] = (Number(maskCollection['HH24'])>12?'PM':'AM');
//     maskCollection['PM'] = maskCollection['AM'];
//     maskCollection['Day'] = laDays[dDateTime.getDay()];
//     maskCollection['DAY'] = laDays[dDateTime.getDay()].substr(0,3).toUpperCase();
//     maskCollection['DW'] = String(dDateTime.getDay());
// 
//     for (var i in maskCollection) {
//       re = new RegExp(i,"g");
//       cReturn=cReturn.replace(re,maskCollection[i]);
//     }
//   }
//   return cReturn;
// }
// 
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// function validate() {
//   return true;
// }
// 
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// 
