<!-- Begin
/*Naming method
**I name variables by follow following rules
**1.Variables are form of type and description: type_description eg. int_pageNumber.
**2.Type is consisted of 3 characters only, if the length is not enough, use the first 3 characters.
**3.The first one character of type can't be removed.
**4.The sound charcters would be removed.
**5.If there is consecutive same characters, we would get one only.
**6.Boolean variables are the exception, their prefixes are "is" eg. isinteger.
*/

//Object constructor
function clsEssential(){
  this.getBrowser = getBrowser;
  this.getScreenWidth = getScreenWidth;
  this.getScreenHeight = getScreenHeight;
  this.getColorDepth = getColorDepth;
  this.getOffset = getOffset;
  this.removeStyleClassName = removeStyleClassName;
  this.isStyleClassNameExisted = isStyleClassNameExisted;
  this.getElement = getElement;
}

//----------------------------------------------------------------------------
// General utility functions.
//----------------------------------------------------------------------------
function getBrowser(){
  var isIE = document.all?1:0;
  var isNS = document.layers?1:0;
  var isNSUp = document.getElementById&&!document.all?1:0;

  if(isNS)
    return "NS";
  else if(isNSUp)
    return "NSUp";
  else if(isIE)
    return "IE";
}

//----------------------------------------------------------------------------
// General utility functions.
//----------------------------------------------------------------------------
function getOS(){

}

//----------------------------------------------------------------------------
// General utility functions.
//----------------------------------------------------------------------------
function getScreenWidth(){
  return screen.width;
}

//----------------------------------------------------------------------------
// General utility functions.
//----------------------------------------------------------------------------
function getScreenHeight(){
  return screen.height;
}

//----------------------------------------------------------------------------
// General utility functions.
//----------------------------------------------------------------------------
function getColorDepth(){
  return window.screen.colorDepth;
}

//----------------------------------------------------------------------------
// General utility functions.
//----------------------------------------------------------------------------
function getOffset(objElement, strPosition, intAdjustment) {
  var coordinate, strAction;
  // Return the coordinate of an element relative to the page.
  strAction = "coordinate = objElement." + strPosition;
  eval(strAction);
  if (objElement.offsetParent != null)
    coordinate += getOffset(objElement.offsetParent, strPosition, intAdjustment);
  
  coordinate = coordinate + intAdjustment
  return coordinate;
}

//----------------------------------------------------------------------------
// General utility functions.
//----------------------------------------------------------------------------
function removeStyleClassName(objElement, strName) {
  var intPosition, strClassName;

  if (objElement.className != null){
    strClassName = new String();
	strClassName = objElement.className;
	intPosition = strClassName.indexOf(strName,0);
    objElement.className = strClassName.substring(0, intPosition) + strClassName.substring(intPosition+strName.length, strClassName.length);
  }
}

//----------------------------------------------------------------------------
// General utility functions.
//----------------------------------------------------------------------------
function isStyleClassNameExisted(objElement, strName) {
  var strClassName;

  strClassName = new String();
  strClassName = objElement.className;
  if(strClassName.indexOf(strName,0)==-1)
	return false;
  else 
	return true;
}

//----------------------------------------------------------------------------
// General utility functions.
//----------------------------------------------------------------------------
function getElement(objNode, strTagName, strClassName) {

  // Starting with the given node, find the nearest containing element
  // with the specified tag name and style class.

  while (objNode != null) {
    if (objNode.tagName != null && objNode.tagName == strTagName &&
        essential.isStyleClassNameExisted(objNode, strClassName))
      return objNode;
    objNode = objNode.parentNode;
  }

  return objNode;
}
// End -->
