//
// When inspecting this code, view it as a draft example designed for this specific site.
// It is source code with functionality as much as required, but as low as possible.
//
// Contact our professional services for extended and generic functionality/libraries 
// in final quality structured design.
//
// objNav, (C) 2003 Ingenieurbuero Arno-Can Uestuensoez <info@i4p.de>
// objNav, (C) 2003 Engineering Office Arno-Can Uestuensoez <info@i4p.de>
//
// You can copy/modify and distribute this code under the conditions
// of the GNU GENERAL PUBLIC LICENSE Version 2.
//


//BrowserCheck - currently singleton so no prototype required
function BrowserManager(){
   
   //Version
   this.version=parseInt(navigator.appVersion);

   //OS
   if((this.isosLin=(navigator.platform.indexOf('Linux')>=0))) this.osName="lin";
   if((this.isosWin=(navigator.platform.indexOf('Win')>=0)))this.osName="win";
   if((this.isosSol=(navigator.platform.indexOf('Solaris')>=0))) this.osName="sol";
   if((this.isosOBSD=(navigator.platform.indexOf('OpenBSD')>=0))) this.osName="obsd";
   if(!this.osName) this.osName="unknown";

   //CPU-Checks
   if(navigator.cpuClass)   this.cpu=navigator.cpuClass;
   else if(navigator.oscpu) this.cpu=navigator.oscpu;

   //Browser
   if((this.isbrNs=((navigator.appName.indexOf("Netscape") != -1)?true:false))){
      this.browserName="Netscape";
      this.Xcorrect=[14/20,12/15,10/12,9/10,9/10,9/10,9/10,9/10,9/10,9/10,9/10,9/10];
      this.Ycorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
   }
   if((this.isbrNs4=(this.isbrNs&&((document.layers)?true:false)))){
      this.browserName="Netscape4";
      this.Xcorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
      this.Ycorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
   }
   if((this.isbrNs6=((navigator.userAgent.indexOf("Netscape6") != -1)?true:false))){
      this.browserName="Netscape6";
      this.Xcorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
      this.Ycorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
   }
   
   if(((this.isbrIE=((navigator.userAgent.indexOf('MSIE')))>=0)?true:false)){
      this.browserName="IExplorer";
//                   0      1      2      3      4      5      6      7      8      9      10     11  
      this.Xcorrect=[1.11,  1.11,  1.10,  1.12,  1.12,  1.11,  1.09,  1.06,  1.05,  1.00,  1.00,  1.00 ];
      this.Ycorrect=[1.11,  1.11,  1.10,  1.12,  1.12,  1.11,  1.09,  1.06,  1.05,  1.00,  1.00,  1.00 ];


                      /*0      1      2      3      4      5      6      7      8      9      10     11   */
      this.WinWcorrect=[0.90,  0.90,  0.90,  0.90,  0.90,  0.90,  0.90,  0.90,  0.90,  0.90,  0.90,  0.90 ];
      this.WinHcorrect=[0.90,  0.90,  0.90,  0.90,  0.90,  0.90,  0.90,  0.90,  0.90,  0.90,  0.90,  0.90 ];

                               /*0     1     2     3     4     5     6    7    8    9    10   11   */

//      this.Xcorrect=[14/20,12/15,10/12,9/10,9/10,9/10,9/10,9/10,9/10,9/10,9/10,9/10];
//      this.Ycorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];

   }
   if(((this.isbrIE4=((navigator.userAgent.indexOf('MSIE 4')))>=0)?true:false)){
      this.browserName="IExplorer4";
      this.Xcorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
      this.Ycorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
   }
   if(((this.isbrIE5=((navigator.userAgent.indexOf('MSIE 5')))>=0)?true:false)){
      this.browserName="IExplorer5";
      this.Xcorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
      this.Ycorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
   }
   if(((this.isbrIE6=((navigator.userAgent.indexOf('MSIE 6')))>=0)?true:false)){
      this.browserName="IExplorer6";
//                   0      1      2      3      4      5      6      7      8      9      10     11  
      this.Xcorrect=[1.11,  1.11,  1.10,  1.12,  1.12,  1.11,  1.09,  1.16,  1.06,  1.00,  1.00,  1.00 ];
      this.Ycorrect=[1.11,  1.11,  1.10,  1.12,  1.12,  1.11,  1.09,  1.11,  1.04,  1.00,  1.00,  1.00 ];
//      this.Xcorrect=[14/20,12/15,10/12,9/10,9/10,9/10,9/10,9/10,9/10,9/10,9/10,9/10];
//      this.Ycorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
//      this.Xcorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
//      this.Ycorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
   }
   if((this.isbrGaleon=((navigator.userAgent.indexOf('Galeon')>=0)?true:false))){
      this.browserName="Galeon";
      this.Xcorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
      this.Ycorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
   }
   if((this.isbrNautilus=((navigator.userAgent.indexOf('Nautilus')>=0)?true:false))){
      this.browserName="Nautilus";
      this.Xcorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
      this.Ycorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
   }
   if((this.isbrOpera=((navigator.userAgent.indexOf('Opera')>=0)?true:false))){
      this.browserName="Opera";
      this.Xcorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
      this.Ycorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
   }
   if((this.isbrKonqueror=((navigator.userAgent.indexOf('Konqueror')>=0)?true:false))){
      this.browserName="Konqueror";
//                   0      1      2      3      4      5      6      7      8      9      10     11  
      this.Xcorrect=[1.13,  1.11,  1.10,  1.13,  1.12,  1.11,  1.09,  1.06,  1.00,  1.00,  1.00,  1.00 ];
      this.Ycorrect=[1.13,  1.11,  1.10,  1.13,  1.12,  1.11,  1.09,  1.06,  1.00,  1.00,  1.00,  1.00 ];
   }
   if((this.isbrEpiphany=((navigator.userAgent.indexOf('Epiphany')>=0)?true:false))){
      this.browserName="Epiphany";
//                   0      1      2      3      4      5      6      7      8      9      10     11  
      this.Xcorrect=[1.13,  1.11,  1.10,  1.13,  1.12,  1.11,  1.09,  1.06,  1.05,  1.00,  1.00,  1.00 ];
      this.Ycorrect=[1.13,  1.11,  1.10,  1.13,  1.12,  1.11,  1.09,  1.06,  1.05,  1.00,  1.00,  1.00 ];
   }
   if((this.isbrFirefox=((navigator.userAgent.indexOf('Firefox')>=0)?true:false))){
      this.browserName="Firefox";
//                   0      1      2      3      4      5      6      7      8      9      10     11  
      this.Xcorrect=[1.13,  1.11,  1.10,  1.13,  1.12,  1.11,  1.09,  1.06,  1.05,  1.00,  1.00,  1.00 ];
      this.Ycorrect=[1.13,  1.11,  1.10,  1.13,  1.12,  1.11,  1.09,  1.06,  1.05,  1.00,  1.00,  1.00 ];
   }
   if(
      (this.isbrMozilla=(
           ((navigator.userAgent.indexOf('Mozilla')>=0)?true:false)
         &&!this.isbrNs
         &&!this.isbrIE
         &&!this.isbrGaleon
         &&!this.isbrNautilus
         &&!this.isbrKonqueror
         &&!this.isbrEpiphany
         &&!this.isbrFirefox
         )
      )
     )
   {
      this.browserName="Mozilla";
      this.Xcorrect=['12/20','10/15','10/12','8/10','8/10','8/10','8/10','8/10','8/10','8/10','8/10','8/10'];
      this.Ycorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
   }
   if(!this.browserName){
      this.browserName="unknown";
      this.Xcorrect=['12/20','10/15','10/12','8/10','8/10','8/10','8/10','8/10','8/10','8/10','8/10','8/10'];
//      this.Xcorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
      this.Ycorrect=['1', '1','1','1','1','1','1','1','1','1','1','1'];
   }

   //JavaScript
//   this.javascriptVersion=( );

   //Path
   this.rootPath="";

   //Window
   this._winW=800;
   this._winH=600;

   //Screen
   this._scrW=800;
   this._scrH=600;

   //Layout
   this._layoutMap=1; //for outline
   this._WinWdivScrW=1; //for outline
   this._WinHdivScrH=1; //for outline

   //CSS-Info
   this.cssFile=""; //for outline
   this.cssDefault="default.css";
   this.cssPath=""; //for outline
   this.cssLinkDefault=""; //for outline
   this.cssLink=""; //for outline
   this.cssAdaptor=""; //for outline
   this.baseFontShort='medium';
//   this.baseFontSize='1';
//   this.baseFontSizeUnit='em';
   this.baseFontSize='100';
   this.baseFontSizeUnit='%';
   




this.getBaseFontSize=BS_getBaseFontSize;
this.getBaseFontUnit=BS_getBaseFontUnit;
this.setRootPath=_BS_setRootPath;
this.getWinW=BS_getWinW;
this.getWinH=BS_getWinH;
this.setCurWinW=BS_setCurWinW;
this.setCurWinH=BS_setCurWinH;
this.getScrW=BS_getScrW;
this.getScrH=BS_getScrH;
this.getWinWdivScrW=BS_getWinWdivScrW;
this.getWinHdivScrH=BS_getWinHdivScrH;
this.getLayoutMap=BS_getLayoutMap;
this.getLayoutXcorrect=BS_getLayoutXcorrect;
this.getLayoutYcorrect=BS_getLayoutYcorrect;
this.setCSSconf=_BS_setCSSconf;
this.setCSSconf();

 this.isNs=this.isbrNs;
 this.isNs4=this.isbrNs4;
 this.isNs6=this.isbrNs6;
 this.isIE=this.isbrIE;
 this.isIE4=this.isbrIE4;
 this.isIE5=this.isbrIE5;
 this.isIE6=this.isbrIE6;
 this.isGaleon=this.isbrGaleon;
 this.isNautilus=this.isbrNautilus;
 this.isOpera=this.isbrOpera;
 this.isKonqueror=this.isbrKonqueror;
 this.isEpiphany=this.isbrEpiphany;
 this.isFirefox=this.isbrFirefox;
 this.isMozilla=this.isbrMozilla;

   
   /**** Diagnostics ***/
   //Lists all specs.
   

}

//new BrowserManager();
//BrowserManager.prototype.setCSSconf=_BS_setCSSconf;
//BrowserManager.prototype.setRootPath=_BS_setRootPath;
//BrowserManager.prototype.getBaseFontSize=BS_getBaseFontSize;
//BrowserManager.prototype.getBaseFontUnit=BS_getBaseFontUnit;
//BrowserManager.prototype.getWinW=BS_getWinW;
//BrowserManager.prototype.getWinH=BS_getWinH;
//BrowserManager.prototype.setCurWinW=BS_setCurWinW;
//BrowserManager.prototype.setCurWinH=BS_setCurWinH;
//BrowserManager.prototype.getScrW=BS_getScrW;
//BrowserManager.prototype.getScrH=BS_getScrH;
//BrowserManager.prototype.getWinWdivScrW=BS_getWinWdivScrW;
//BrowserManager.prototype.getWinHdivScrH=BS_getWinHdivScrH;
//BrowserManager.prototype.getLayoutMap=BS_getLayoutMap;
//BrowserManager.prototype.getLayoutXcorrect=BS_getLayoutXcorrect;
//BrowserManager.prototype.getLayoutYcorrect=BS_getLayoutYcorrect;





function _BS_setRootPath(){
   var url=/(.*\/)([^\/]*)$/;
   var l=top.location.toString();
   var result=l.match(url);
   this.rootPath=result[1];
}



function _BS_setCSSconf(){
   this.cssFile=this.browserName+'.css';
   this.setRootPath();
   this.cssPath=this.rootPath;
   this.cssPath=this.cssPath+'../../css/';
   this.cssLinkDefaultDisp='&lt;link rel="stylesheet" type="text/css" href="'+this.cssPath+this.cssDefault+'"&gt;';
   this.cssLinkDisp='&lt;link rel="stylesheet" type="text/css" href="'+this.cssPath+this.cssFile+'"&gt;';
   this.cssLinkDefault='<link rel="stylesheet" type="text/css" href="'+this.cssPath+this.cssDefault+'">';
   this.cssLink='<link rel="stylesheet" type="text/css" href="'+this.cssPath+this.cssFile+'">';


   //set the inheritance-base size (relative itself), 
  //all other definitions on the whole site MUST BE relative to this!!!

   this.cssAdaptor="<STYLE TYPE=\"text/css\">";
   this.cssAdaptor=this.cssAdaptor
       +"<!--"
       +"BODY, TD {"
       +"font-size:"+(this.baseFontSize*this.getWinWdivScrW())+this.baseFontSizeUnit+";"
       +"}"
       +"-->";
   this.cssAdaptor=this.cssAdaptor+"</STYLE>";

}

function _BS_checkSupport(){

   if(!(this.isNetscape||this.isMicrosoft||this.isIE||this.isOpera||this.isGecko)) return 1;
   else if(!(this.browser=='_mac'||this.browser=='_win')) return 2;
   else if(this.layoutSize) return 4;
   else return 0;
/*
   else if(!(this.version=parseInt(navigator.appVersion)) return 3;
*/
}


function BS_getBaseFontSize(){
   return this.baseFontSize;
}

function BS_getBaseFontUnit(){
   return this.baseFontSizeUnit;
}

function BS_getWinWdivScrW(){
   var w=this.getWinW();//Not for IE before document but else
   if(!w)w=this.getScrW();//So dear IE
   if(!w)return this._WinWdivScrW;//oops???

   var s=this.getScrW();
   if(!s)return this._WinWdivScrW;//oops???
   return w/s;
}


function BS_getWinHdivScrH(){
   var h=this.getWinH();//Not for IE before document but else
   if(!h)h=this.getScrH();//So dear IE
   if(!h)return this._WinHdivScrH;//oops???

   var s=this.getScrH();
   if(!s)return this._WinHdivScrH;//oops???
   return h/s;
}


function BS_getLayoutMap(){
//   var h=this.getWinH();
   var w=this.getWinW();//Not for IE before document but else
   if(!w)w=this.getScrW();//So dear IE
   if(!w)return this._layoutMap;//oops???
   if      (w<400)    this._layoutMap=0;
   else if(w<500)    this._layoutMap=1;
   else if(w<600)    this._layoutMap=2;
   else if(w<700)    this._layoutMap=3;
   else if(w<800)    this._layoutMap=4;
   else if(w<900)    this._layoutMap=5;
   else if(w<1000)   this._layoutMap=6;
   else if(w<1100)   this._layoutMap=7;
   else if(w<1200)   this._layoutMap=8;
   else if(w<1300)   this._layoutMap=9;
   else if(w<1400)   this._layoutMap=10;
   else               this._layoutMap=11;
  
   return this._layoutMap;
}

function BS_getLayoutYcorrect(){
   return this.Ycorrect[this._layoutMap];
}

function BS_getLayoutXcorrect(){
   return this.Xcorrect[this._layoutMap];
}


function BS_setCurWinW(w){
  this.curWinW=w;
}


function BS_setCurWinH(h){
  this.curWinH=h;
}

function BS_getWinW(){
   if(this.version>3){
      if(this.isbrNs){
         this._winW=window.innerWidth;
      } else{
         if(this.isbrIE){
            if(document&&document.body){
               this._winW=document.body.offsetWidth;
            } else if(document&&document.width){
               this._winW=document.width;
            }else if(this.curWinW){
               this._winW=this.curWinW;
            }
         }else{
            this._winW=window.innerWidth;
         }
      }
   }
   return this._winW;
}

function BS_getWinH(){
   if(this.version>3){
      if(this.isbrNs){
         this._winH=window.innerHeight;
      } else{	
         if(this.isbrIE){
            if(document&&document.body){
               this._winH=document.body.offsetHeight;
            } else if(document&&document.height){
                this._winW=document.height;
            }else if(this.curWinH){
                this._winH=this.curWinH;
            }
         }else{
            this._winH=window.innerHeight;
         }         
      }
    }
   return this._winH;
}

function BS_getScrW(){
   if(this.version>3){
      this._scrW=screen.width;
   }
   return this._scrW;
}

function BS_getScrH(){
   if(this.version>3){
      this._scrH=screen.height;
   }
   return this._scrH;
}

function BS_showSpec(){
   var browserInfo="BROWSER INFORMATION:\n\n";
   for(var propname in navigator){
      browserInfo += propname + ": " + navigator[propname] + "\n";
   }
   alert(browserInfo);

   var topInfo="TOP INFORMATION:\n\n";
   var cnt=0;
   for(var propname in top){
      topInfo += propname + ": " + top[propname] + "\n";
      if(cnt++==5){
      	cnt=0;
        alert(topInfo);
        topInfo="";
      }
   }
   alert(topInfo);
}

