/*
   (c) 2005, 2007, M-SYS Document Technologies
   No public usage allowed.

   Include into project header:
     var browser = new TBrowser();

   Definition:
   
   class TCookies {
     constructor TBrowser();
     var ver: string;     //versionstring
     var agent: string;   //useragent
     var dom: boolean;    //has DOM
     var opera: boolean;  //is Opera
     var opera5: boolean; //is Opera V5
     var ie: boolean;     //is IE
     var ie4: boolean;    //is IE4
     var ie5: boolean;    //is IE5
     var ie6: boolean;    //is IE6
     var mac: boolean;    //is MAC
     var ns4: boolean;    //is Netscape V4
     var ns6: boolean;    //is Netscape V6
     var px: string;      //Name of pixel until
   }
*/

function TBrowser() 
{
  this.ver = navigator.appVersion;
  this.agent = navigator.userAgent;
  this.dom = document.getElementById ? 1 : 0;
  this.opera = (window.opera) ? 1 : 0;
  this.opera5 = this.agent.indexOf("Opera 5") > -1;
  this.ie5 = (this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5) ? 1 : 0;
  this.ie6 = (this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5) ? 1 : 0;
  this.ie4 = (document.all && !this.dom && !this.opera5) ? 1 : 0;
  this.ie  = this.ie4 || this.ie5 || this.ie6;
  this.mac = this.agent.indexOf("Mac") > -1;
  this.ns6 = (this.dom && parseInt(this.ver) >= 5) ? 1 : 0;
  this.ns4 = (document.layers && !this.dom) ? 1 : 0;
  this.bw  = (this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5);

  // A unit of measure that will be added when setting the position of a layer.
  this.px = (this.ns4 || this.opera) ? "" : "px";
  return this;
}


function getElement(id, idx)
{
  if (browser.ie5 || browser.ie6) {
    var list = document.getElementsByName(id);
    return (list.length >= idx) ? list[idx] : false;
  };
  return (idx == 0) ? document.getElementById(id) : false;
}

function GetInnerWidth()
{
  if (typeof(window.innerWidth)=='number') return window.innerWidth;  // Non IE
  if (document.documentElement && 
      document.documentElement.clientWidth) return document.documentElement.clientWidth; // IE6
  if (document.body && document.body.clientWidth) return document.body.clientWidth; // IE4
  return window.width;
}

function GetInnerHeight()
{
  if (typeof(window.innerHeight)=='number') return window.innerHeight;  // Non IE
  if (document.documentElement && 
      document.documentElement.clientHeight) return document.documentElement.clientHeight;  // IE6
  if (document.body && document.body.clientHeight) return document.body.clientHeight; // IE4
  return window.height;
}

function scrollXOffset()
{
   if (window.pageXOffset) return self.pageXOffset;
   if (document.documentElement &&
       document.documentElement.scrollLeft) return document.documentElement.scrollLeft;
   if (document.body) return document.body.scrollLeft;
   return 0;
}

function scrollYOffset()
{
   if (window.pageYOffset) return self.pageYOffset;
   if (document.documentElement && 
       document.documentElement.scrollTop) return document.documentElement.scrollTop;
   if (document.body) return document.body.scrollTop;
   return 0;
}
