
/*  _gdr_banner.js
      Javascript functions to support the functionality of the
      ESS GDR geochem metadata website                               
    Designed for cross-browser compatibility with DPI scaling other
    than the 96dpi CSS default
    Works in conjunction with _subsite.css, in which
    div.esst_banner_gdr p { top } is set to different values for 
    different browsers:
    W3C-compliant: -30px
    IE7:            7px
    IE6:            
 */

/* ------------------------------------------------------------------ */

/* ------------------------------------------------------------------ */

  function esst_banner()
  {
    var divGDR = get_Elements_By_Class('esst_banner_gdr', document.body, 'div');

    if ( divGDR.length != 1 )
    {
      /* There should be exactly one <div class="esst_banner_gdr"> element
         on the page                                                  */
      alert('Unexpected page layout!\n' +
             'The page may not be displayed properly.');
      return;
    } 

    var divTop = getElementStyle(divGDR[0], "top", "top");

    var pTag = divGDR[0].getElementsByTagName("p"); 
    var pTop = getElementStyle(pTag[0], "top", "top");

/*    
    alert('Reached here:!\n' +
             ' style.height = ' + divTop +'\n' +
             ' p.top = ' + pTop );
*/

  }

/* ------------------------------------------------------------------ */

/*  getElementsByClass()
      function to get elements by class.
      The node and tag parameters are optional                        */

/* ------------------------------------------------------------------ */

  function get_Elements_By_Class(searchClass,node,tag)
  {
    var classElements = new Array();
    if ( node == null )	node = document;
    if ( tag == null ) tag = '*';
    var els = node.getElementsByTagName(tag);
    var elsLen = els.length;
    var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
    for (i = 0, j = 0; i < elsLen; i++)
    {
      if ( pattern.test(els[i].className) )
      {
        classElements[j] = els[i];
        j++;
      }
    }
    return classElements;
  }

/* ------------------------------------------------------------------ */

  function getElementStyle(elem, IEStyleProp, CSSStyleProp)
  {
    if (elem.currentStyle)
    {
      return elem.currentStyle[IEStyleProp];
    } 
    else if (window.getComputedStyle)
    {
      var compStyle = window.getComputedStyle(elem, "");
      return compStyle.getPropertyValue(CSSStyleProp);
    }
    return "";
  }

