/*
**	crossbrowser.js
**
**	======================================================
**	Copyright (c) 2007, Bill Parrott - All Rights Reserved
**	======================================================
*/

var itFirstTime = true;
var strBrowser = "??";

document.write( "<" + "span id=\"browsertest\">." + "<" + "/span>" );

WhichBrowser();
SetInnerText( "browsertest", "" );

function GetInnerText( strObj )
{
   var obj;

   try {
      if ( (typeof strObj) == "string" )
         obj = document.getElementById( strObj );
      else if ( (typeof strObj) == "object" )
         obj = strObj;
      else
         obj = null;

      if ( WhichBrowser() == "IE" )
         return ( obj.innerText );
      else
         if ( WhichBrowser() == "FF" )
            return ( obj.textContent );
      }
   catch ( e ) {
      /* just do nothing */
      }

   return ( "GetInnerText() failure" );
}

function SetInnerText( strObj, strText )
{
   var obj;

   try {
      if ( (typeof strObj) == "string" )
         obj = document.getElementById( strObj );
      else if ( (typeof strObj) == "object" )
         obj = strObj;
      else
         obj = null;

      if ( WhichBrowser() == "IE" )
         return ( obj.innerText = strText );
      else
         if ( WhichBrowser() == "FF" )
            return ( obj.textContent = strText );
      }
   catch ( e ) {
            /* fail silently */
      }

   return ( "SetInnerText() failure" );
}

function WhichBrowser()
{
   var s;

   if ( itFirstTime )
      {
      try {
         s = document.getElementById("browsertest");

         if ( typeof(s.innerText) != "undefined" )
            strBrowser = "IE";
         else
            if ( typeof(s.textContent) != "undefined" )
               strBrowser = "FF";

         itFirstTime = false;
         }
      catch ( e ) {
					alert( "Browser detection failed in WhichBrowser()" );
         }
      }

   return ( strBrowser );
}

