/*
 * Copyright (c) 2003 - 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
 * 
 * Project: OpenSubsystems
 * 
 * $Id: browser.js,v 1.2 2007/01/07 06:14:08 bastafidli Exp $
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License. 
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 */

/*
 * Global JS files used to detect what browser is client using. By including
 * this js file the page can just reference global variable browser and ask
 * questions such as browser.isIE or browser.isNS and browser.version.
 *
 * @version $Id: browser.js,v 1.2 2007/01/07 06:14:08 bastafidli Exp $
 * @author Miro Halas
 * @code.reviewer Miro Halas
 * @code.reviewed Initial revision
 */

var DOMViewerObj = null;
var DOMViewerName = null;

/**
 * Display debugging page containing structure of the document.
 *
 * @param strElementName - root element where to start tracing the tree
 * @param strContextPath - context path where the application is installed
 */
function domViewer(
   strElementName,
   strContextPath
)
{
   if (strElementName == '')
   {
      DOMViewerObj = null;
   }
   else
   {
      DOMViewerObj = document.getElementById(strElementName);
   }

   window.open(strContextPath + "/core/jsp/page/domviewer.jsp");
}

/**
 * Determine browser and version.
 */
function Browser(
) 
{
   var ua, s, i;

   this.isIE    = false;  // Internet Explorer
   this.isNS    = false;  // Netscape
   this.version = null;

   ua = navigator.userAgent;

   s = "MSIE";
   if ((i = ua.indexOf(s)) >= 0) 
   {
      this.isIE = true;
      this.version = parseFloat(ua.substr(i + s.length));
      return;
   }

   s = "Netscape6/";
   if ((i = ua.indexOf(s)) >= 0) 
   {
      this.isNS = true;
      this.version = parseFloat(ua.substr(i + s.length));
      return;
   }

   // Treat any other "Gecko" browser as NS 6.1.
   s = "Gecko";
   if ((i = ua.indexOf(s)) >= 0) 
   {
      this.isNS = true;
      this.version = 6.1;
      return;
   }
}

/**
 * Global variable which can be used by other pages
 */
var browser = new Browser();

