function SetPageDisplay(){
  //alert ("Entering SetPageDisplay Function")
//-------------------------------------------------------------------------------------------------
// This function dynamically sets the display characteristics of the separate "screens" on the 
// HTML page.  e.g., the HTML Page contains multiple "Screens" in the form of images and buttons
// that allow the user to "toggle through" the screens.  But ONLY ONE SCREEN IS VISIBLE AT A TIME. 
// Three hidden fields in a form on the page define which screen is the default, what the highest
// or last screen is on the page, and keeps track of the current screen (while the page is active). 
// 
// When this function runs (as the page is initialized) the following takes place. 
//   (1) Check the hidden Field values for validity to avoid design and development errors that
//       surprise us after implementation.  If errors the whole page is revealed, otherwise 
//   (2) the display value for all "screens" is set to "none" - do NOT display.
//   (3) the display value for defafult "screens" is set to "block" - so it WILL DISPLAY.
//   (4) the initial value of the current screen is set to the default screen value.  
//-------------------------------------------------------------------------------------------------
  if (CheckHiddenFields() == false)
    {
	showAll()
	}
  else 
    {
	hideAll()
	//alert ("Hidden Default Before Changing Visibility to Default in SetPageDisplay Function: " + document.hiddenVariables.hiddenDefault.value )
	changeObjectVisibility(document.hiddenVariables.hiddenDefault.value,'block')
	document.hiddenVariables.hiddenCurrent.value = document.hiddenVariables.hiddenDefault.value
	}
  //alert ("Leaving SetPageDisplay Function")
} // End of Setting Page Display



/* 
function switchDiv(div_id)
{
  var style_sheet = getStyleObject(div_id);
  if (style_sheet)
  {
    hideAll();
    changeObjectVisibility(div_id,"block");
  }
  else 
  {
    alert("sorry, this only works in browsers that do Dynamic HTML");
  }
}
*/ 

/*
function getParm()
{
		a=document.hiddenVariables.hiddenCurrent.value
		b=document.hiddenVariables.hiddenDefault.value
		c=document.hiddenVariables.hiddenLast.value
		alert("a=" +a +"\nb=" +b  +"\nc=" +c)
}
*/

function printMyWindow(){
  showAll()
  window.print()
  hideAll()
  changeObjectVisibility(document.hiddenVariables.hiddenCurrent.value,'block')
}


// function hideAll()
//  hides a bunch of divs
//
function hideAll(){
  //alert ("Entering hideAll Function")
  LastScreenString = document.hiddenVariables.hiddenLast.value
  LastScreenNum = document.hiddenVariables.hiddenLast.value.substr(1)
  LastScreenNum = LastScreenNum - 0 
  MaxLoopNumber = LastScreenNum + 1
  for (i=1; i < MaxLoopNumber; i++) 
    {
    ScreenID = "s" + i  
	changeObjectVisibility(ScreenID,"none");
	}  // end of for I Loop
  //alert ("Leaving hideAll Function")
}


function showAll(){
  LastScreenID = document.hiddenVariables.hiddenLast.value
  LastScreenNum = LastScreenNum - 0 
  MaxLoopNumber = LastScreenNum + 1
  for (i=1; i < MaxLoopNumber; i++) 
    {
	ScreenID = "s" + i  
	changeObjectVisibility(ScreenID,"block");
    }  // end of for I Loop
} // end of showALL function.

function ChangeScreens(MeCommand,MeTargetID){
  Errors_Found = false // assume no errors until we find one. 
  
  if ((MeTargetID != "") && (MeCommand.toUpperCase() != "GOTOID"))
    {
	alert("DESIGN / DEVELOPMENT ERROR: invalid parameter combination in your call to the \"ChangeScreens\" function.  \n\nThe \"TargetID\" passed to the \"ChangeScreens\" function must be blanked out because the specified command requieres a blank Target ID. \n\nA non blank \"TargetID\" is only allowed if you call this function using the \"GoToID\" command.")
    Errors_Found = true
	}
  else 
    {
    DefaultScreenID = document.hiddenVariables.hiddenDefault.value
  
    CurrentScreenID = document.hiddenVariables.hiddenCurrent.value
    CurrentScreenNum = document.hiddenVariables.hiddenCurrent.value.substr(1)
    CurrentScreenNum = CurrentScreenNum - 0 

    LastScreenID = document.hiddenVariables.hiddenLast.value
    LastScreenNum = document.hiddenVariables.hiddenLast.value.substr(1)
    LastScreenNum = LastScreenNum - 0 
  
  
//----------------------------------------------------------------------------------------------------  
// the switch statement checks for valid input and sets the NewScreenID accordingly.
// After the switch statement, the code will actually display the appropriate page. 
//----------------------------------------------------------------------------------------------------  
    switch (MeCommand.toUpperCase()){ // select 
      case "NEXT":
	    PrintCurrent = CurrentScreenNum
	    PrintLast = LastScreenNum
	    //alert("Current Screen: " + document.hiddenVariables.hiddenCurrent.value + "\n     Num=" + PrintCurrent + "\n\n)Last Screen: "  + document.hiddenVariables.hiddenLast.value + "\n     Num=" + PrintLast + "\n\n)Default Screen: "  + document.hiddenVariables.hiddenDefault.value)
	    if (CurrentScreenNum == LastScreenNum) 
          {
          NewScreenID = DefaultScreenID
		  }
	    else 
	      {
	      NewScreenNum = CurrentScreenNum + 1
          NewScreenID = "s"  + NewScreenNum
		  }
      break;  
      case "PREVIOUS": 
  	    if (CurrentScreenNum == 1) 
          {
          NewScreenID = DefaultScreenID
		  }
	    else 
	      {
	      NewScreenNum = CurrentScreenNum - 1
          NewScreenID = "s"  + NewScreenNum
		  }
      break;  
      case "DEFAULT":  
        NewScreenID = DefaultScreenID
      break;  
      case "FIRST":  
	    NewScreenID = "s1";
      break;  
      case "LAST":  
        NewScreenID = LastScreenID
      break;  
      case "GOTOID":
//--------------------------------------------------------------------------------------------------
// Check the MeCommand passed in, to see if it is a valid Screen ID based on the rules required by
// these functions. 
//   (1) is the value blank ?
//   (2) does it begin with an "S" ?
//   (3) is the remainder of the string numeric? 
//-------------------------------------------------------------------------------------------------   
        //alert ("Target ID= \"" + MeTargetID + "\"")
	    if ((MeTargetID == "")) // can't be blank
          {
          alert ("DESIGN OR DEVELOPMENT ERROR: Invalid Target ID Passed to the \"ChangeScreens\" function.\n\nLOOK AT THE BUTTON, GRAPHIC, OR LINK THAT YOU JUST CLICKED ON.  THE PROBLEM IS THERE.\n\nYOUR CODE THAT CALLED THIS FUNCTION MAY LOOK SOMETHING LIKE THIS: \"ChangeScreens(\"GoToID\",\"\")\".\n\nIF YOU INTEND TO USE THE \"GoToID\" command, YOU MUST ENTER A VALID \"TargetID\". \n\nThe \"ChangeScreens\" function (called from your click) allows the following parameters:\n\n  (1) \"Default\" - displays the default screen of this page\n  (2) \"First\" - displays the \"s1\" screen of this page\n  (3) \"Next\" - displays the next screen of this page based on the screen ID number\n  (4)  \"Previous\" - displays the previous screen of this page based on the screen ID number  (5) \"Last\" - displays the last screen on this page\n  (6) \"GoToID\"  displays a predetermined screen based on the \"TargetID\" parameter\n\n The \"TartetID\" parameter must meet the following requirements to function properly:\n\n* It must have a value.\n* The value must begin with a LOWER CASE \"s\" (not capitalized)\n* Position 2 through the end of the string must contain a numeric value.\n* Examples of allowable values: \"s1\" \"s2\" \"s3\"...\n\nPlease check and correct the syntax of your \"TargetID\" parameter to the \"ChangeScreens\" function - on the button you just clicked.")
          Errors_Found = true
	      }
    
        if (MeTargetID.substr(0,1) != "s") // first position must be an "S"
          {
          alert ("DESIGN OR DEVELOPMENT ERROR: Invalid Target ID Passed to the \"ChangeScreens\" function.\n\nLOOK AT THE BUTTON, GRAPHIC, OR LINK THAT YOU JUST CLICKED ON.  THE PROBLEM IS THERE.\n\nYOUR \"TARGEID\" PARAMETER DOES NOT CONTAIN A LOWER CASE \"s\" IN POSITION ONE (YES A CAPITAL \"s\" WILL CAUSE PROBLEMS).\n\nThe \"ChangeScreens\" function (called from your click) allows the following parameters:\n\n  (1) \"Default\" - displays the default screen of this page\n  (2) \"First\" - displays the \"s1\" screen of this page\n  (3) \"Next\" - displays the next screen of this page based on the screen ID number\n  (4)  \"Previous\" - displays the previous screen of this page based on the screen ID number  (5) \"Last\" - displays the last screen on this page\n  (6) \"GoToID\"  displays a predetermined screen based on the \"TargetID\" parameter\n\n The \"TartetID\" parameter must meet the following requirements to function properly:\n\n* It must have a value.\n* The value must begin with a LOWER CASE \"s\" (not capitalized)\n* Position 2 through the end of the string must contain a numeric value.\n* Examples of allowable values: \"s1\" \"s2\" \"s3\"...\n\nPlease check and correct the syntax of your \"TargetID\" parameter to the \"ChangeScreens\" function - on the button you just clicked.")
          Errors_Found = true
	      }
	
        NumberPortion = MeTargetID.substr(1)  
        if (IsNum(NumberPortion) == false)
          {
          alert ("DESIGN OR DEVELOPMENT ERROR: Invalid Target ID Passed to the \"ChangeScreens\" function.\n\nLOOK AT THE BUTTON, GRAPHIC, OR LINK THAT YOU JUST CLICKED ON.  THE PROBLEM IS THERE.\n\nYOUR TARGET ID DOES NOT CONATAIN A NUMERIC VALUE IN POSITION 2 TO THE END OF THE STRING.\n\nThe \"ChangeScreens\" function (called from your click) allows the following parameters:\n\n  (1) \"Default\" - displays the default screen of this page\n  (2) \"First\" - displays the \"s1\" screen of this page\n  (3) \"Next\" - displays the next screen of this page based on the screen ID number\n  (4)  \"Previous\" - displays the previous screen of this page based on the screen ID number  (5) \"Last\" - displays the last screen on this page\n  (6) \"GoToID\"  displays a predetermined screen based on the \"TargetID\" parameter\n\n The \"TartetID\" parameter must meet the following requirements to function properly:\n\n* It must have a value.\n* The value must begin with a LOWER CASE \"s\" (not capitalized)\n* Position 2 through the end of the string must contain a numeric value.\n* Examples of allowable values: \"s1\" \"s2\" \"s3\"...\n\nPlease check and correct the syntax of your \"TargetID\" parameter to the \"ChangeScreens\" function - on the button you just clicked.")
          Errors_Found = true
		  }
//------------------------------------------------------------------------------------------------------
// Below, if no errors were found No Errors were found in the command it is apparently a valid 
// screen ID (at least it follows the rules).  
//------------------------------------------------------------------------------------------------------
        if (Errors_Found == false)  
          {
          NewScreenID = MeTargetID
	      }  	
      break;  
      default:   
        alert ("DESIGN OR DEVELOPMENT ERROR: Invalid Command Passed to the \"ChangeScreens\" function.\n\nLOOK AT THE BUTTON, GRAPHIC, OR LINK THAT YOU JUST CLICKED ON.  THE PROBLEM IS THERE.\n\nYOU HAVE ENTERED AN INVALID COMMAND PARAMETER.\n\nThe \"ChangeScreens\" function (called from your click) allows the following parameters:\n\n  (1) \"Default\" - displays the default screen of this page\n  (2) \"First\" - displays the \"s1\" screen of this page\n  (3) \"Next\" - displays the next screen of this page based on the screen ID number\n  (4)  \"Previous\" - displays the previous screen of this page based on the screen ID number  (5) \"Last\" - displays the last screen on this page\n  (6) \"GoToID\"  displays a predetermined screen based on the \"TargetID\" parameter\n\n The \"TartetID\" parameter must meet the following requirements to function properly:\n\n* It must have a value.\n* The value must begin with a LOWER CASE \"s\" (not capitalized)\n* Position 2 through the end of the string must contain a numeric value.\n* Examples of allowable values: \"s1\" \"s2\" \"s3\"...\n\nPlease check and correct the syntax of your \"Command\" parameter (first parameter) to the \"ChangeScreens\" function - on the button you just clicked.")
        Errors_Found = true
      break; 
    } // end of switch statement on MeCommand
  } // end of bad combination of paramers. 
  
  if (Errors_Found == true)  
    {
	alert ("The Screen will not change due to the error described earlier. ")	
    return false
	}  	
  else 
    {
    hideAll() // first hide all of the sections, then show the one you want below.
    //alert("NewScreenID: " + NewScreenID)
    changeObjectVisibility(NewScreenID,"block");
    document.hiddenVariables.hiddenCurrent.value = NewScreenID
	}  	

} // end of function ChangeScreens 
  
function changeObjectVisibility(objectId, newVisibility) {
    // first get a reference to the cross-browser style object 
    // and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.display = newVisibility;
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;
    }
}  // end of changeObjectVisibility function

// function getStyleObject(string) -> returns style object
//  given a string containing the id of an object
//  the function returns the stylesheet of that object
//  or false if it can't find a stylesheet.  Handles
//  cross-browser compatibility issues.
//
function getStyleObject(objectId) {
  // checkW3C DOM, then MSIE 4, then NN 4.
  //
  //alert ("OBJECT ID: " + objectId)
  if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId).style;
   }
   else if (document.all && document.all(objectId)) {  
	return document.all(objectId).style;
   } 
   else if (document.layers && document.layers[objectId]) { 
	return document.layers[objectId];
   } else {
	return false;
   }
}  // end of getStyleObject function

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
} // end of function MM_findObj

function CheckHiddenFields() {
  Errors_Found = false
  MeTypeC = typeof document.hiddenVariables.hiddenCurrent  // returns a type of field "undefined"
  MeTypeB = typeof document.hiddenVariables.hiddenDefault  // returns a type of field "undefined"
  MeTypeL = typeof document.hiddenVariables.hiddenLast  // returns a type of field or "undefined"
  if (MeTypeC == "undefined" || MeTypeL == "undefined"|| MeTypeL == "undefined")
    {
    alert ("DESIGN OR DEVELOPMENT ERROR: Required Hidden Field is not defined on the page.\n\nThis page requires three hidden fields defined in a form named \"hiddenVariables\" \n\n(1) \"hiddenDefault.\" \n(2) \"hiddenCurrent.\" \n(3) \"hiddenLast.\" \n\nThe form or One or more of these required hidden input fields are not defined or improperly named. \n\nPLEASE CHECK YOUR PAGE AND TRY AGAIN")
    Errors_Found = true
    return false
    }
//--------------------------------------------------------------------------------------------------
// Check the hiddenDefault and the hiddenLast valid initial values 
//   (1) is the value blank ?
//   (2) does it begin with an "S" ?
//   (3) is the remainder of the string numeric? 
//   (4) is the number between 1 and 20 since this function will handle only 20 screens per html page.   
//-------------------------------------------------------------------------------------------------   
  if ((document.hiddenVariables.hiddenDefault.value == "") || (document.hiddenVariables.hiddenLast.value == "")) //the fields cannot be blank
    {
    alert ("DESIGN OR DEVELOPMENT ERROR: Invalid Hidden Field Value Detected. \n\nTHE VALUE(S) SPECIFIED IN FIELD 1 AND / OR FIELD 2 ARE EMPTY OR BLANK.\n\nThis page requires three hidden fields defined in a form tag like this: <FORM Name=\"hiddenVariables\"> \nThe fields should be named and defined as described below.\n\n     (1) \"hiddenDefault\" - This is the ID of the screen that will initially be displayed for the page.\n     (2) \"hiddenLast\" - This is the highest numbered screen ID on the page.\n     (3) \"hiddenCurrent\" - The JavaScript will keep track of the current page using this input field.\n\n* Fields 1 and 2 must be given initial values.\n* Field 3 does not require a value and if entered will be irrelevant.\n* The values of field 1 and 2 must begin with a LOWER CASE \"s\" (not capitalized)\n* Position 2 through the end of the string must contain a numeric value.\n* Examples of allowable values: \"s1\" \"s2\" \"s3\"...\n\nPlease check your page and try again.")
    Errors_Found = true
	return false
	}
  
  
  if ((document.hiddenVariables.hiddenDefault.value.substr(0,1) != "s") || ((document.hiddenVariables.hiddenLast.value.substr(0,1) != "s"))) // first position must be an "s"
    {
    alert ("DESIGN OR DEVELOPMENT ERROR: Invalid Hidden Field Value Detected. \n\nTHE VALUE(S) SPECIFIED IN FIELD 1 AND / OR FIELD 2 DO NOT CONTAIN A LOWER CASE \"s\" (NOT CAPITALIZED) IN THE FIRST POSITION.\n\nThis page requires three hidden fields defined in a form tag like this: <FORM Name=\"hiddenVariables\"> \nThe fields should be named and defined as described below.\n\n     (1) \"hiddenDefault\" - This is the ID of the screen that will initially be displayed for the page.\n     (2) \"hiddenLast\" - This is the highest numbered screen ID on the page.\n     (3) \"hiddenCurrent\" - The JavaScript will keep track of the current page using this input field.\n\n* Fields 1 and 2 must be given initial values.\n* Field 3 does not require a value and if entered will be irrelevant.\n* The values of field 1 and 2 must begin with a LOWER CASE \"s\" (not capitalized)\n* Position 2 through the end of the string must contain a numeric value.\n* Examples of allowable values: \"s1\" \"s2\" \"s3\"...\n\nPlease check your page and try again.")
    Errors_Found = true
	return false
	}
	
DefaultScreenNum = document.hiddenVariables.hiddenDefault.value.substr(1)  
LastScreenNum = document.hiddenVariables.hiddenLast.value.substr(1)

  if ((IsNum(DefaultScreenNum) == false) || (IsNum(LastScreenNum) == false))
    {
    alert ("DESIGN OR DEVELOPMENT ERROR: Invalid Hidden Field Value Detected. \n\nTHE VALUE(S) SPECIFIED IN FIELD 1 AND / OR FIELD 2 DO NOT CONTIAN A NUMERIC VALUE BEGINNING IN POSITION 2 THROUGH THE END OF THE STRING.\n\nThis page requires three hidden fields defined in a form tag like this: <FORM Name=\"hiddenVariables\"> \nThe fields should be named and defined as described below.\n\n     (1) \"hiddenDefault\" - This is the ID of the screen that will initially be displayed for the page.\n     (2) \"hiddenLast\" - This is the highest numbered screen ID on the page.\n     (3) \"hiddenCurrent\" - The JavaScript will keep track of the current page using this input field.\n\n* Fields 1 and 2 must be given initial values.\n* Field 3 does not require a value and if entered will be irrelevant.\n* The values of field 1 and 2 must begin with a LOWER CASE \"s\" (not capitalized)\n* Position 2 through the end of the string must contain a numeric value.\n* Examples of allowable values: \"s1\" \"s2\" \"s3\"...\n\nPlease check your page and try again.")
    Errors_Found = true
	return false
	}
	
  if (Errors_Found = false)  // No Errors were found in the Hidden Fields
    {
	return true
	}
} // End of Function  Checking the hidden field parameters. 

function IsNum(varInput){
//--------------------------------------------------------------------------------------------------
//  This JavaScript function determines if a value passed in is a number or not.
//  
//  It checks for blank string, then checks each character in the string to see if it is 
//  less than a character "0" or greater than a character "9".  
//
//  INPUTS:
//   - varInput - a character string which will be interrogated to see if it is numeric.  
//                 
//  RETURN VALUE:
//   - true, if the string is a number, false if the string is blank or not a numer 
//
//
//  OTHER FUNCTIONS CALLED:  
//   - NONE.  Only builtin functions, methods, and properties are used in this function.
//
//   NOTES: 
//    - blank passed in is considered a non-number. 
//--------------------------------------------------------------------------------------------------

if (varInput == "") {
  return false
}
else {
  for (i=0; i<varInput.length; i++) {  // start of for loop
    if ((varInput.charAt(i) < "0") || (varInput.charAt(i) > "9")) {
      return false
	}  
  }  // End of for loop
  return true
} // End of Else (not blank) processing
}  // End of "IsNum" function 
  

/*function showAll()
{
   changeObjectVisibility("s1","block");
   changeObjectVisibility("s2","block");
   changeObjectVisibility("s3","block");
   changeObjectVisibility("s4","block");
   changeObjectVisibility("s5","block");
   changeObjectVisibility("s6","block");
   changeObjectVisibility("s7","block");
   changeObjectVisibility("s8","block");
} */


