function userAgent()
{
    var agent   = navigator.userAgent.toLowerCase();

    this.major  = parseInt(navigator.appVersion);
    this.minor  = parseFloat(navigator.appVersion);

    this.ns     = (
                    ( agent.indexOf('mozilla')!=-1) &&
                    ( ( agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1) ) &&
                    ( agent.indexOf('netscape6')==-1) // otherwise is.ns will be true and is.dom too
                  );
    this.ns2    = (this.ns && (this.major == 3));
    this.ns3    = (this.ns && (this.major == 3));
    this.ns4    = (this.ns && (this.major == 4));

    this.ie     = (agent.indexOf("msie") != -1);
    if (this.ie) {
        var regExpr = /msie.?([^;]+)/i;
        regExpr.exec(agent);
        this.version = RegExp.$1;
        this.ie3    = parseInt(this.version) == 2;
        this.ie4    = parseInt(this.version) == 4;
        this.ie5    = parseInt(this.version) == 5;
        this.ie6    = parseInt(this.version) == 6;
    }

    this.kon    = (agent.indexOf("konqueror") != -1);

    // returns something like that for agent if it simulates a NS: mozilla/4.73 (windows 98; u) opera 4.02 [en]
    // if it should be simply itself: opera/4.02 (windows 98; u) [en]
    // or Opera/5.0 (Linux ...) [en]
    // and the navigator version is the one which is set in the opera setting, since the opera
    // can do kinda camouflage to say "i am a NS", so the navVersion cant be used
    this.op     = (agent.indexOf("opera") != -1);
    if( this.op )
    {
        operaVersion = agent.split("opera");
        operaVersion = operaVersion[1];
        operaVersion = operaVersion.replace(/\//,'');
        
        this.version = operaVersion;
        this.op3    = (parseInt(operaVersion) == 3);
        this.op4    = (parseInt(operaVersion) == 4);
        this.op5    = (parseInt(operaVersion) == 5);
        this.op7    = (parseInt(operaVersion) == 7);

        // set all others to false, since it is no other browser, but an opera :-)
        this.ie = this.ie4 = this.ie3 = false;
        this.ns = this.ns4 = this.ns3 = this.ns2 = false;
        this.kon = false;
        //this.ie4 = true;

        //alert(operaVersion+" parseint "+parseInt(operaVersion)+"\nop4="+this.op4+"    op3="+this.op3+"    op5="+this.op5);
    }
    if (this.op7) {
        this.dom = true;
    }

    if (agent.indexOf("gecko")!=-1) {
        this.moz = true;
        var regExpr = /.*(\d.\d)\) gecko.*/i;
        regExpr.exec(agent);
        this.version = RegExp.$1;
    }
    
    // netscape 6 PR3 returns something like this for agent: mozilla/5.0 (windows; u; win98; en-us; m18) gecko/20000929 netscape6/6.03b
    // the version: 5.0 (Windows; en-us)
    this.dom =  (agent.indexOf("netscape6") != -1) ||
                            (agent.indexOf("gecko") != -1) ||
                            (agent.indexOf("konqueror/2.") != -1) ||
                            this.op || 
                            (this.ie && this.version>4);  //opera doesnt really get it
    
    this.windows = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;                            

}

/////////////////////////////////////////////////
//
//      determine the available height/width
//
function Env()
{
  this.screenWidth=screen.width;
  this.screenHeight=screen.height;

  if(document)  // BUG - this doesnt work, if u include the js-files before the body taag it doesnt bring the alert-warning
  {
    if(is.ns4)
    {
      this.availableWidth=innerWidth;
      this.availableHeight=innerHeight;
    }
    if(is.ie4 || is.ie5){
      this.availableWidth=document.body.clientWidth;
      this.availableHeight=document.body.clientHeight;
    }else if(is.dom)
    {      
      this.availableWidth =  (!(userAgent.ie6))?window.innerWidth :document.documentElement.offsetWidth;
      this.availableHeight = (!(userAgent.ie6))?window.innerHeight:document.documentElement.offsetHeight;
    }
  }
  else
  {
    alert('please include the env.js after the "body" tag so the document`s properties can be read');
  }
  this.getEnv = env_get;

}

function env_get()
{
    Env(); // re-get the environment
}

var userAgent = new userAgent();    // instanciate an object of class userAgent
var is = userAgent;         // this is deprecated, but still very much in use

var env = new Env;    // get enviroment
