
// Checks the browser and adds classes to the body to reflect it.

(
function ($)
{

$.browserDetect  =
  { userAgent:	navigator.userAgent.toLowerCase()
  , type:	'unknown'
  , n_version:	''
  , getParts:	function (type, name, no_version)
    {
      var ind = $.browserDetect.userAgent.indexOf(name)
	, len = name.length
	;
      $.browserDetect.type	= type;

      if (!no_version)
      {
	$.browserDetect.n_version  = 
		      $.browserDetect.userAgent.substring(ind + len);

	$.browserDetect.n_version =
			      $.browserDetect.n_version.substring(0,1);
      }
    }
  , detector: function ()
    {
      if ($.browserDetect.type)
      {
	$('body').addClass($.browserDetect.type);

	if ($.browserDetect.n_version)
	{
	  $('body').addClass('' + $.browserDetect.type +
				  $.browserDetect.n_version);
	}
      }
    }
  };

// jQuery browser tests currently exclude chrome
//
$.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase()); 

if ($.browser.msie) // Is this a version of IE?
{
  $.browserDetect.getParts('browserIE', 'msie ');
}
else if ($.browser.chrome) // Is this a version of Chrome?
{
  $.browserDetect.getParts('browserChrome', 'chrome/');

  // If it is chrome then jQuery might think it's safari so we have to
  // tell jQuery that it isn't
  //
  $.browser.safari = false;
}
else if ($.browser.safari) // Is this a version of Safari?
{
  $.browserDetect.getParts('browserSafari', 'version/');
}
else if ($.browser.mozilla) // Is this a version of Mozilla?
{
  // Is it Firefox?
  //
  if (navigator.userAgent.toLowerCase().indexOf('firefox') != -1)
  {
    $.browserDetect.getParts('browserFirefox', 'firefox/');
  }
  else // If not then it must be another Mozilla
  {
    $.browserDetect.getParts('browserMozilla', '', true);
  }
}
if ($.browser.opera) // Is this a version of Opera?
{
  $.browserDetect.getParts('browserOpera', '', true);
}

$(document).ready($.browserDetect.detector);

}
)(jQuery);

