// 1999 (C)opyright by Andrew Golovin
// All rights reserved
// You can use this script free of charge in case of remain
// this comments unchanged or if you set link to Andrew Golovin's
// home page in your document.
// Link: <A HREF="http://home.ural.ru/~tbi/exper/all.html">Andrew Golovin</A>
//

// Description:
// =========================
// BROWSER DETECTION VERSION
// br - detailed browser description object
// br.name - browser title: Internet Explorer, Netscape Navigator or Opera
// br.shortName - short name for browser:
//    EXP - Internet Explorer
//    NAV - Netscape Navigator
//    OPR - Opera  
// br.version - browser version
// br.minorVer - minor version (ex: IE4.01 minor is 1)
// br.language - browser lnguage
// br.plainAgentStr - same as navigator.userAgent 
// br.plainNameStr - same as navigator.appName 
// br.plainVersionStr - same as navigator.appVersion 
// IE - true if any version of Internet Explorer
// NN - true if any version of Netscape Navigtor
// OP - true if any version of Opera
//
// =========================
// CROSS BROWSER WINDOW PARMETERS
// Remember to call initDetect() after page loading (in onLoad event) in order
// to use this methods and objects
// client - detailed browser window parameters object
// client.width - width of visible area
// client.height - height of visible area
// client.XOffset() - current offset of left window border
// client.YOffset() - current offset of top window border

// =========================
// CROSS BROWSER POSITIONING & STYLE SECTION
// getX - gets X coordinate in pixels;
// getY - gets Y coordinate in pixels;
// getWidth - gets width in pixels;
// getHeight - gets height in pixels;
// setX - set X coordinate in pixels;
// setY - set Y coordinate in pixels;
// moveTo - moves object to specified x and y coordinates;
// moveBy - moves object by dX and dY distance;
// show - show hidden element;
// hide - hide visible element;

function detectAgent() {
  with (navigator) {
       var tempAgent = userAgent;
	   var tempName = appName;
	   this.plainAgentStr = userAgent;
	   this.plainNameStr = appName;
	   this.plainVersionStr = appVersion;
	   if (tempAgent.indexOf('Opera')>=0) {
	      this.name = "Opera";
		  this.shortName = "OPR";
		  var tempVer = tempAgent.substring(tempAgent.indexOf("Opera") + 6, tempAgent.length);
		  this.version = tempVer.substring(0, tempVer.indexOf(" "));
          this.minorVer = this.version.substring(tempVer.indexOf(".") + 1, tempVer.length);
          this.language = tempAgent.substring(tempAgent.indexOf("[") + 1, tempAgent.indexOf("]"));
		  
	   }
       else {
	      if (tempAgent.indexOf('MSIE')>=0) {
		     this.name = "Internet Explorer";
			 this.shortName = "EXP";
             var tempVer = tempAgent.substring(tempAgent.indexOf("MSIE") + 5, tempAgent.length);
             this.version = tempVer.substring(0, tempVer.indexOf(";"));
             this.minorVer = this.version.substring(tempVer.indexOf(".") + 1, tempVer.length);
             this.language = browserLanguage;
		  }
		  else {
		    if (tempName.indexOf('Netscape')>=0) {
			   this.name = "Netscape Navigator";
			   this.shortName = "NAV"
			   this.minorVer = appVersion.substring(appVersion.indexOf(".") + 1, appVersion.indexOf(" "));
               this.language = tempAgent.substring(tempAgent.indexOf("[") +1, tempAgent.indexOf("]"));
               this.version = appVersion.substring(0, appVersion.indexOf(" "));			   
			}
			else {
			   this.name = "Unknown";
			   this.shortName = "UNK"
			}
		  }
	   }
  }
}

// Element position and size methods
// 
//

function getWidth(el) {
  if (NN) {
     return(document.layers[el].clip.width);
  }
  else {
     return(document.all[el].style.pixelWidth);
  }
}

function getHeight(el) {
  if (NN) {
     return(document.layers[el].clip.height);
  }
  else {
     return(document.all[el].style.pixelHeight);
  }
}

function setX(el, x) {
   if (NN) {
      document.layers[el].left = x;
   }
   else {
      document.all[el].style.pixelLeft = x;   
   }
}

function setY(el, y) {
   if (NN) {
      document.layers[el].top = y;
   }
   else {
      document.all[el].style.pixelTop = y;
   }
}

function getX(el) {
  if (NN) {
     return(document.layers[el].left);
  }
  else {
     return(document.all[el].style.pixelLeft);
  }
}
  
function getY(el) {
  if (NN) {
     return(document.layers[el].top);
  }
  else {
     return(document.all[el].style.pixelTop);
  }
}
  
function moveTo(el, toX, toY) {
  setX(el,toX);
  setY(el,toY);
}

function moveBy(el, dX, dY) {
  setX(el, getX(el) + dX );
  setY(el, getY(el) + dY );
}

function show(el) {
  if (NN) {
     document.layers[el].visibility = "show";
  }
  else {
     document.all[el].style.visibility = "visible";
  }
}

function hide(el) {
  if (NN) {
     document.layers[el].visibility = "hide";
  }
  else {
     document.all[el].style.visibility = "hidden";
  }
}

// Implementtion of "clientParams" object
// 
//

function getParams() {
	if (NN) {
	   this.width = window.innerWidth;
	   this.height = window.innerHeight;
	}
	else {
	   this.width = document.body.clientWidth;
	   this.height = document.body.clientHeight;
	}
}

function YOffset() {
    return( NN? window.pageYOffset: document.body.scrollTop );
}

function XOffset() {
    return( NN? window.pageXOffset: document.body.scrollLeft );
}

function updateParams() {
   getParams();
}

function clientParams() {
  this.getParams = getParams;
  this.YOffset = YOffset;
  this.XOffset = XOffset;  
  this.updateParams = updateParams;
}

function updateClient() {
  client.getParams();
}

var br = new detectAgent();
var NN = (br.shortName == "NAV");
var IE = (br.shortName == "EXP");
var OP = (br.shortName == "OPR");

function initDetect() {
  client = new clientParams();
  client.getParams();
  window.onresize = updateClient;
}


