﻿/*
=============================================================================
DESCRIPTION
Class to initialise the master GAM Holding page when it is first displayed,
and when it is resized.

HISTORY
Version     Date        By                    Modification
2010.1.4.0  2010-09-09  John Blair            Created
=============================================================================
*/

$(document).ready(function()  {
  /*
  //	=============================================================================
  //	DESCRIPTION
  //	Initialise the page.
  //  Set the white content container to be the height of the browser.
  //
  //	PARAMETERS
  //
  //	RETURN VALUE
  //
  //	HISTORY
  //	Version     Date        By       		     Modification
  //  2010.1.4.0  2010-09-09  John Blair       Created
  //	=============================================================================
  */
  try {

    // Initialise the page when it is fully loaded or resized.
    // This ready function happens when the dom is loaded.
    // The load function happens after the page has fully loaded i.e. after when all images have been loaded.
    // The resize function happens when the browser is resized.

    $(window)
       .resize(initialisePage)
       .load(initialisePage);

    // Size the white container to the window browser as soon as possible.
    initialisePage();  
    
  } catch (e) {
    //Ignore.
  }
})



function initialisePage() {
  /*
  //	=============================================================================
  //	DESCRIPTION
  //	Ensures the #content div is sized to fit the browser window height 
  //  Use JQuery for maximum browser reach.
  //
  //	PARAMETERS
  //
  //	RETURN VALUE
  //
  //	HISTORY
  //	Version     Date        By       		     Modification
  //  2010.1.4.0  2010-09-09  John Blair       Created
  //	=============================================================================
  */
  try {
    //Get the browser window height.
    var browserWindowHeight = $(window).height();

    //Get the content div to be extended to the browser window height.
    var divContent = $("#content")[0];
    
    //Use -1 below as a bottom border of 1px has been added to the "page" CSS class.
    divContent.style.minHeight = browserWindowHeight - 1 + "px";

    // Older browsers including IE6 don't support minHeight
    // Handle future versions 10+
    if ($.browser.msie && $.browser.version.substr(0, 1) < "7" && $.browser.version.substr(1, 1) == ".") {
      // IE 6
      if (browserWindowHeight > $("#content").height()) {
        divContent.style.height = browserWindowHeight - 1 + "px";
      }
      else {
        // No set height required (clear out any carry over from previous setting).
        divContent.style.height = "";
      }
      
    }

    //alert('$.browser.version =' + $.browser.version);
    //alert('divContent.style.minHeight =' + divContent.style.minHeight);
    //alert('divContent.style.height =' + $("#content").height());
  } catch (e) {
    //Ignore.
  }
};
