/**
 * jQuery.induce - jQuery Plugin
 *
 * Under The MIT License
 * Copyright (c) 2011 Tetsuya MORI. (http://monry.jp/)
 * 
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Version: 1.0.0
 * Revision: $Rev$
 * Date: $Date$
 */
(
  function($) {
    $.B = {};
    $.B.check = function() {
      // {{{ 初期化
      // 新しいブラウザかどうか
      $.B.modern = false;
      // 古いブラウザかどうか
      $.B.legacy = false;
      // Internet Explorer かどうか
      $.B.IE = false;
      // Internet Explorer 5.5 以下かどうか
      $.B.IE55l = false;
      // Internet Explorer 6 かどうか
      $.B.IE6 = false;
      // Internet Explorer 7 かどうか
      $.B.IE7 = false;
      // Internet Explorer 8 かどうか
      $.B.IE8 = false;
      // Internet Explorer 9 かどうか
      $.B.IE9 = false;
      // Internet Explorer (Quirks モード) かどうか
      $.B.IEQuirks = false;
      // Internet Explorer 7 (互換モード) かどうか
      $.B.IE7Emulated = false;
      // Internet Explorer 8 (互換モード) かどうか
      $.B.IE8Emulated = false;
      // Mozilla Firefox かどうか
      $.B.FF = false;
      // エンジンが WebKit かどうか
      $.B.WK = false;
      // Google Chrome かどうか
      $.B.GC = false;
      // Safari かどうか
      $.B.SF = false;
      // Opera かどうか
      $.B.OP = false;
      // それ以外のブラウザかどうか
      $.B.other = false;
      // }}}

      // {{{ 判定処理
      if (!$.support.checkOn && !$.support.focusinBubbles) {
        /* WebKit */
        $.B.WK = true;
      } else if ($.support.checkOn && $.support.noCloneEvent && window.globalStorage) {
        /* Firefox */
        $.B.FF = true;
      } else if ($.support.checkOn && $.support.noCloneEvente && !window.globalStorage) {
        /* Opera */
        $.B.OP = true;
      } else if (typeof window.ActiveXObject != 'undefined' || typeof window.document.all != 'undefined') {
        /* Internet Explorer */
        if (typeof document.documentMode != 'undefined') {
          if (document.documentMode == '8') {
            $.B.IE8Emulated = true;
          } else if (document.documentMode == '7') {
            $.B.IE7Emulated = true;
          } else if (document.documentMode == '5') {
            $.B.IEQuirks = true;
          }
        }
        if ($.support.opacity) {
          /* Internet Explorer 9 */
          $.B.IE9 = true;
        } else if (typeof document.documentElement.style.maxHeight == 'undefined') {
          /* Internet Explorer 6 */
          $.B.IE6 = true;
        } else if (typeof document.querySelectorAll == 'undefined') {
          /* Internet Explorer 7 */
          $.B.IE7 = true;
        } else if (typeof document.getElementsByClassName == 'undefined') {
          /* Internet Explorer 8 */
          $.B.IE8 = true;
        } else {
          /* Internet Explorer 5.5 以下 */
          $.B.IE55L = true;
        }
      } else {
        /* 判別不能 */
        $.B.other = true;
      }
      // }}}

      // {{{ 条件が重複するモノを一括で判定
      $.B.IE = $.B.IE55l || $.B.IE6 || $.B.IE7 || $.B.IE8 || $.B.IE9;
      $.B.modern = !$.B.IE55l && !$.B.IE6 && !$.B.IE7 && !$.B.IE8 && !$.B.other;
      $.B.legacy = !$.B.modern;
      $.B.GC = $.B.WK;
      $.B.SF = $.B.WK;
      // }}}

      // {{{ 冗長な名前でも値を持っておく
      $.B.InternetExplorer = $.B.IE;
      $.B.InternetExplorer55Lower = $.B.IE55L;
      $.B.InternetExplorer6 = $.B.IE6;
      $.B.InternetExplorer7 = $.B.IE7;
      $.B.InternetExplorer8 = $.B.IE8;
      $.B.InternetExplorer9 = $.B.IE9;
      $.B.Firefox = $.B.FF;
      $.B.WebKit = $.B.WK;
      $.B.Safari = $.B.WK;
      $.B.GoogleChrome = $.B.WK;
      $.B.Opera = $.B.OP;
      // }}}
    };
    $.B.check();
  }
)(jQuery);


