var DocumentDimension = {
  getViewportHeight: function() {
    var rv = 0;
    if ( window.innerHeight )
      rv = window.innerHeight;
    else {
      var body = ( document.documentElement )
        ? document.documentElement : document.body;
      if ( body.clientHeight )
        rv = body.clientHeight;
    }
    return parseInt( rv, 10 );
  },
  getScrollHeight: function() {
    var rv = 0;
    if ( window.pageYOffset )
      rv = window.pageYOffset;
    else {
      var body = ( document.documentElement )
        ? document.documentElement : document.body;
      if ( body.scrollTop )
        rv = body.scrollTop;
    }
    return parseInt( rv, 10 );
  },
  getDocumentHeight: function() {
    var rv = 0;
    if ( window.innerHeight ) {
      rv = ( document.documentElement.scrollHeight > window.innerHeight )
        ? document.documentElement.scrollHeight : window.innerHeight;
    } else {
      rv = document.body.offsetHeight;
    }
    return parseInt( rv, 10 );
  },
  getWindowHeight: function() {
    var rv = 0;
    if ( window.innerHeight ) {
      rv = ( document.documentElement.scrollHeight > window.innerHeight )
        ? document.documentElement.scrollHeight : window.innerHeight;
    } else {
      var body = ( document.documentElement )
        ? document.documentElement : document.body;

      if ( body.scrollHeight ) {
        rv = body.scrollHeight;
      } else if ( body.clientHeight ) {
        rv = body.clientHeight;
      } else {
        rv = body.offsetHeight;
      }
    }

    return parseInt( rv, 10 );
  },
  getViewportWidth: function() {
    var rv = 0;
    if ( window.innerWidth )
      rv = window.innerWidth;
    else {
      var body = ( document.documentElement )
        ? document.documentElement : document.body;
      if ( body.clientWidth )
        rv = body.clientWidth;
    }
    return parseInt( rv, 10 );
  },
  getScrollWidth: function() {
    var rv = 0;
    if ( window.pageXOffset )
      rv = window.pageXOffset;
    else {
      var body = ( document.documentElement )
        ? document.documentElement : document.body;
      if ( body.scrollLeft )
        rv = body.scrollLeft;
    }
    return parseInt( rv, 10 );
  },
  getDocumentWidth: function() {
    var rv = 0;
    if ( window.innerWidth ) {
      rv = ( document.documentElement.scrollWidth > window.innerWidth )
        ? document.documentElement.scrollWidth : window.innerWidth;
    } else {
      rv = document.body.offsetWidth;
    }
    return parseInt( rv, 10 );
  },
  getWindowWidth: function() {
    var rv = 0;
    if ( window.innerWidth ) {
      rv = ( document.documentElement.scrollWidth > window.innerWidth )
        ? document.documentElement.scrollWidth : window.innerWidth;
    } else {
      var body = ( document.documentElement )
        ? document.documentElement : document.body;

      if ( body.scrollWidth ) {
        rv = body.scrollWidth;
      } else if ( body.clientWidth ) {
        rv = body.clientWidth;
      } else {
        rv = body.offsetWidth;
      }
    }

    return parseInt( rv, 10 );
  }
}
