/*
 *  @filename     browser_functions.js
 *  @title        Browser Functions
 *  @author       Kevin Barsotti <kevin.barsotti@tribaldawn.com>
 *
 *  @created      07.30.2006
 *  @modified     01.09.2008
 *  @modified     02.10.2008
 *
 *  @description  This file contains functions for detecting browser
 *                information.
 */

/*
 *  @function getBrowser
 *
 *  @comment  Retrieves the name of the browser currently in use.
 *
 *            Possible return values include:
 *
 *              IE6
 *              IE7
 *              Opera
 *              Konqueror
 *              Safari
 *
 *  @author   Kevin Barsotti <kevin.barsotti@tribaldawn.com>
 *
 *  @return   browser     Name of browser in string format.
 */
function getBrowser(){
  var userAgent = navigator.userAgent;
  userAgent = userAgent.toLowerCase();
  var browser;

  if(userAgent.match("msie 6")) browser = 'IE6';
  else if(userAgent.match("msie 7")) browser = 'IE7';
  else if(userAgent.match("opera")) browser = 'Opera';
  else if(userAgent.match("konqueror")) browser = 'Konqueror';
  else if(userAgent.match("safari")) browser = 'Safari';
  else browser = 'Unknown';

  return browser;
}// end function getBrowser()

/*
 *  @function getOSName
 *
 *  @comment  Retrieves the name of the operating system the browser is
 *            currently running on.
 *
 *            Possible return values include:
 *
 *              Windows
 *              Macintosh
 *              X11
 *
 *  @author  Kevin Barsotti <kevin.barsotti@tribaldawn.com>
 *  @author  Nicholas Swierczek <nicholas.swierczek@tribaldawn.com>
 *
 *  @return  OSName          Name of the OS in string format.
 */
function getOSName(){
  var userAgent = navigator.userAgent;
  userAgent = userAgent.toLowerCase();
  var OSName;

  if(userAgent.match("windows")) OSName =  'Windows';
  else if(userAgent.match("mac")) OSName =  'Macintosh';
  else if(userAgent.match("x11")) OSName =  'X11';
  else OSName =  'Unknown';

  return OSName;
}// end function getOSName()

/*
 *  @function getOSVersion
 *
 *  @comment  Retrieves the version of the operating system the browser is
 *            currently running on.
 *
 *  @author   Kevin Barsotti <kevin.barsotti@tribaldawn.com>
 *
 *  @return   osVersion          Version of the OS in string format.
 */
function getOSVersion(){
  var userAgent = navigator.userAgent;
  var OSName = getOSName();
  var OSVersion = "Unknown";

  if(OSName=='Windows'){

  }// end (OSName=='Windows')
  else if(OSName=='Macintosh'){

  }// end if(OSName=='Macintosh')
  else if(OSName=='X11'){

  }// end if(OSName=='X11')

  return OSVersion;
}// end function getOSVersion

/*
 *  @function fixIEPlugins
 *
 *  @comment  Re-renders all OBJECT and EMBED tags within a given webpage
 *            to accommodate Internet Explorer's new court-ruled handling
 *            of active content.
 *
 *            THIS FUNCTION MUST BE CALLED ONLY AFTER THE LAST EMBED OR
 *            OBJECT TAG IN A GIVEN PAGE.  IT IS RECOMMENDED THAT IT BE
 *            RUN IN THE PAGE FOOTER.
 *
 *  @author   Kevin Barsotti <kevin.barsotti@tribaldawn.com>
 *
 *  @return   true            Boolean true.
 */
function fixIEPlugins(){
  objects = document.getElementsByTagName("object");
  for(var i=0;i<objects.length;i++){
    objects[i].outerHTML = objects[i].outerHTML;
  }// end for(var i=0;i<objects.length;i++)

  embeds = document.getElementsByTagName("embed");
  for(var i=0;i<embeds.length;i++){
    embeds[i].outerHTML = embeds[i].outerHTML;
  }// end for(var i=0;i<objects.length;i++)

  return true;
}// end function fixIEPlugins()
