/*'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Name       :  AlignPage
' Purpose    :  Align the page elements on the screen so that the
'               background grids all line up properly.
' Parameters :  none.
' Return val :  none.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''*/
function AlignPage()
{
// if (gvIE4)
// {
//    layerRef = "document.all";
//    styleRef = ".style";
// }
// else
// {
//    layerRef = "document.layers";
//    styleRef = "";
// }

// alert("document.body.offsetHeight = " + document.body.offsetHeight);
// alert("document.body.offsetWidth = " + document.body.offsetWidth);

   bkgndImgWidth = 30;
   bkgndImgHeight = 30;
   mainTableWidth = 800;
   borderOffset = 3;
   horzNavbarWidth = 19;

   // extract the numeric pixel value from the pixel indicator ("px"), if it exists
   unusedSpace = document.body.offsetWidth - mainTableWidth - horzNavbarWidth;
// alert("unusedSpace = " + unusedSpace);

   // determine the amount of space allowed for the page margins
   marginWidth = unusedSpace / 2;
// alert("marginWidth = " + marginWidth);

   // calculate the max number of background grids that can fit into the left margin
   gridsPerMargin = Math.round(marginWidth / bkgndImgWidth);
// alert("gridsPerMargin = " + gridsPerMargin);

   // calculate left margin
   leftMarginWidth = (gridsPerMargin * bkgndImgWidth) - borderOffset;
// alert("leftMarginWidth = " + leftMarginWidth);

   // set temp y-offset to line up the background grids
   yOffset = 30;

   if (gvIE4)
   {
      // position the navigation division on screen
//    document.all.divPageNavigation.style.display = "";
      document.all.divPageNavigation.style.position = "absolute";
      document.all.divPageNavigation.style.left = leftMarginWidth;
      document.all.divPageNavigation.style.top = yOffset;
      heightDivPageNavigation = document.all ? divPageNavigation.clientHeight : (isDOM ? divPageNavigation.offsetHeight : divPageNavigation.document.height);
//    heightDivPageNavigation = 164;
//    document.all.divPageNavigation.style.display = "none";
//    alert("heightDivPageNavigation = " + heightDivPageNavigation);

      // position the upper content banner division on screen
//    document.all.divPageUpperContentBanner.style.display = "";
      document.all.divPageUpperContentBanner.style.position = "absolute";
      document.all.divPageUpperContentBanner.style.left = leftMarginWidth;
      document.all.divPageUpperContentBanner.style.top = heightDivPageNavigation + yOffset;
      heightDivPageUpperContentBanner = document.all ? divPageUpperContentBanner.clientHeight : (isDOM ? divPageUpperContentBanner.offsetHeight : divPageUpperContentBanner.document.height);
//    heightDivPageUpperContentBanner = 83;
//    document.all.divPageUpperContentBanner.style.display = "none";
//    alert("heightDivPageUpperContentBanner = " + heightDivPageUpperContentBanner);

      // position the content division on screen
//    document.all.divPageContent.style.display = "";
      document.all.divPageContent.style.position = "absolute";
      document.all.divPageContent.style.left = leftMarginWidth;
      document.all.divPageContent.style.top = heightDivPageNavigation + heightDivPageUpperContentBanner + yOffset;
      heightDivPageContent = document.all ? divPageContent.clientHeight : (isDOM ? divPageContent.offsetHeight : divPageContent.document.height);
//    document.all.divPageContent.style.display = "none";
//    alert("heightDivPageContent = " + heightDivPageContent);

      // position the lower content banner division on screen
//    document.all.divPageLowerContentBanner.style.display = "";
      document.all.divPageLowerContentBanner.style.position = "absolute";
      document.all.divPageLowerContentBanner.style.left = leftMarginWidth;
      document.all.divPageLowerContentBanner.style.top = heightDivPageNavigation + heightDivPageUpperContentBanner + heightDivPageContent + yOffset;
      heightDivPageLowerContentBanner = document.all ? divPageLowerContentBanner.clientHeight : (isDOM ? divPageLowerContentBanner.offsetHeight : divPageLowerContentBanner.document.height);
//    heightDivPageLowerContentBanner = 62;
//    document.all.divPageLowerContentBanner.style.display = "none";
//    alert("heightDivPageLowerContentBanner = " + heightDivPageLowerContentBanner);

      // position the page footer division on screen
//    document.all.divPageFooter.style.display = "";
      document.all.divPageFooter.style.position = "absolute";
      document.all.divPageFooter.style.left = leftMarginWidth;
      document.all.divPageFooter.style.top = heightDivPageNavigation + heightDivPageUpperContentBanner + heightDivPageContent + heightDivPageLowerContentBanner + yOffset;
//    document.all.divPageFooter.style.display = "none";
   }
   else
   {
      // position main division on screen
      document.layers["divPageNavigation"].visibility = "hide";
      document.layers["divPageNavigation"].left = leftMarginWidth;
//    document.layers["divPageNavigation"].top = ((window.innerHeight / 2) - (400 / 2) + yOffset);
      document.layers["divPageNavigation"].visibility = "show";
   }
}
