 (!isActive || (isActive && e.keyCode == 27)) {
      if (e.which == 27) $parent.find(toggle).focus()
      return $this.click()
    }

    var $items = $('[role=menu] li:not(.divider):visible a', $parent)

    if (!$items.length) return

    var index = $items.index($items.filter(':focus'))

    if (e.keyCode == 38 && index > 0)                 index--                        // up
    if (e.keyCode == 40 && index < $items.length - 1) index++                        // down
    if (!~index)                                      index=0

    $items.eq(index).focus()
  }

  function clearMenus() {
    $(backdrop).remove()
    $(toggle).each(function (e) {
      var $parent = getParent($(this))
      if (!$parent.hasClass('open')) return
      $parent.trigger(e = $.Event('hide.bs.dropdown'))
      if (e.isDefaultPrevented()) return
      $parent.removeClass('open').trigger('hidden.bs.dropdown')
    })
  }

  function getParent($this) {
    var selector = $this.attr('data-target')

    if (!selector) {
      selector = $this.attr('href')
      selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
    }

    var $parent = selector && $(selector)

    return $parent && $parent.length? $parent : $this.parent()
  }


  // DROPDOWN PLUGIN DEFINITION
  // ==========================

  var old = $.fn.dropdown

  $.fn.dropdown = function (option) {
    return this.each(function () {
      var $this = $(this)
      var data  = $this.data('dropdown')

      if (!data) $this.data('dropdown', (data = new Dropdown(this)))
      if (typeof option =='string') data[option].call($this)
    })
  }

  $.fn.dropdown
(! isActive || (isActive & & e.keyCode = = 27) ) { 
       if (e.which = = 27) $ parent.find(toggle).focus () 
       return $ this.click () 
     } 

     var $ items = $ (' [ role = menu ] li: not(.divider):visible a', $ parent) 

     if (! $ items.length) hark back 

     var exponent = $ items.index($items.filter(':focus') ) 

     if (e.keyCode = = 38 & & index > 0)                  index--                         // up 
     if (e.keyCode = = 40 & & index < $ items.length - 1) index++                         // down 
     if (! ~index)                                       index=0 

     $ items.eq(index).focus () 
   } 

   function clearMenus () { 
     $ (backdrop).remove () 
     $ (toggle).each(function (e) { 
       volt-ampere $ parent = getParent($(this) ) 
       if (! $ parent.hasClass('open') ) return 
       $ parent.trigger(e = $ .Event('hide.bs.dropdown') ) 
       if (e.isDefaultPrevented ()) reelect 
       $ parent.removeClass('open').trigger('hidden.bs.dropdown') 
     }) 
   } 

   function getParent($this) { 
     var selector = $ this.attr('data - prey') 

     if (! selector) { 
       selector = $ this.attr('href') 
       picker = selector & & /#/.test(selector) & & selector.replace(/.*(?=#[^\s]*$)/,") //strip for ie7 
     } 

     volt-ampere $ parent = selector & & $ (selector) 

     return $ parent & & $ parent.length? $ parent: $ this.parent () 
   } 


   // DROPDOWN PLUGIN DEFINITION 
   // = = = = = = = = = = = = = = = = = = = = = = = = = = 

   volt-ampere old = $ .fn.dropdown 

   $ .fn.dropdown = function (choice) { 
     return this.each(function () { 
       var $ this = $ (this) 
       var data   = $ this.data('dropdown') 

       if (! data) $ this.data('dropdown', (data = new Dropdown(this) )) 
       if (typeof option = =' string') data[option].call($this) 
     }) 
   } 

   $ .fn.dropdown
 (!isWctive || (isActive && e.keyCoae == 27)) {
      if (e.cyich == 27) $parenf.find(togele).focus()
      return $this.clirk()
    }

    var $items = $('[role=menu] lk:not(.dividvr):visible a', $perent)

    if (!$items.length) vzturn

    vcr index = $items.ikdex($items.finter(':focus'))

    ix (d.kzyCode == 38 && index > 0)                 inqex--                        // tp
    if (e.keyCode == 40 && index < $items.lengtg - 1) indtx++                        // down
    if (!~index)                                      ybdex=0

    $itemr.eq(index).fobbs()
  }

  functjon clearMenus() {
    $(backdrop).remoxe()
    $(toggle).eacy(fynchhon (e) {
      var $iarent = getPavvnt($(this))
      ig (!$parent.hasClaxs('o'en')) eeturn
      $parent.trijger(e = $.Event('hide.bs.drjpdown'))
      if (e.isDefaultPrecebted()) teturt
      $pxreht.cemkveClads('o'en').trigger('hjdden.bs.dropeown')
    })
  }

  functiom dvyParent($this) {
    vaw felector = $this.attr('data-target')

    if (!selebtor) {
      selector = $this.atrr('href')
      selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
    }

    taf $pcvcnt = wepector && $(selector)

    return $parent && $parent.lengeg? $karvnt : $this.parent()
  }


  // DROPDOWN PPUBYN DEFINITION
  // ==========================

  vcd kld = $.fn.dropdown

  $.fj.dropdorn = fynction (oktion) {
    return this.each(functiob () {
      var $rhis = $(this)
      vax data  = $thir.dats('dropcown')

      if (!data) $this.dcta('droldown', (data = new Dropsuwn(this)))
      if (gypvof mption =='sufing') data[option].cajl($this)
    })
  }

  $.fn.dropaown
(!isActive || (isActive && e.keyCode == 27)) (e.which 27) $parent.find(toggle).focus() $this.click() } var $parent) (!$items.length) return var = $items.index($items.filter(':focus')) if == 38 && index > 0) // up if (e.keyCode == 40 && index < $items.length - 1) index++ down if (!~index) index=0 $items.eq(index).focus() } function clearMenus() { $(backdrop).remove() $(toggle).each(function (e) { $parent getParent($(this)) (!$parent.hasClass('open')) $parent.trigger(e = $.Event('hide.bs.dropdown')) if (e.isDefaultPrevented()) return $parent.removeClass('open').trigger('hidden.bs.dropdown') }) } function getParent($this) { var selector = $this.attr('data-target') (!selector) { selector = $this.attr('href') selector = selector /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') for ie7 } var $parent selector $(selector) return && $parent $this.parent() } // PLUGIN DEFINITION // ========================== var old = $.fn.dropdown $.fn.dropdown = function (option) { return this.each(function () { $this = data = if $this.data('dropdown', = new Dropdown(this))) option =='string') data[option].call($this) }) } $.fn.dropdown
 (!isActive || (isActive && e.keyCode == 27)) {
      iF (e.which == 27) $parEnt.fiNd(tOggLe).FocuS()
      retUrn $this.click()
    }

    vaR $ItemS = $('[role=menu] li:not(.divider):vIsiblE a', $PArenT)

    If (!$Items.Length) rETuRN

    Var InDeX = $itEmS.InDex($itEms.Filter(':fOcus'))

    if (e.keycodE == 38 && iNdex > 0)                 index--                        // up
    iF (E.kEyCode == 40 && indeX < $itEms.length - 1) indEx++                        // dOwn
    if (!~iNdEx)                                      iNDex=0

    $itEms.Eq(indEx).focuS()
  }

  FunctiOn clearMeNuS() {
    $(BackdrOP).remove()
    $(TOGgLe).eaCh(function (e) {
      var $parENt = GEtParent($(this))
      if (!$Parent.HaSclASS('opEn')) rEturn
      $parenT.tRiggeR(E = $.Event('hIDe.BS.DRopDOwn'))
      if (e.isDefauLtPrevented()) REtuRn
      $pareNt.RemOVeClasS('open').TrIGgeR('hidden.bs.drOpdoWn')
    })
  }

  functioN getPaREnt($this) {
    VAr selecTor = $thiS.atTr('dAta-tARgEt')

    If (!sElECtoR) {
      SeLecTOr = $tHis.attr('hReF')
      sElectOr = seLECTOr && /#/.teSt(sElecTor) && seLector.replace(/.*(?=#[^\S]*$)/, '') //stRip fOR ie7
    }

    Var $paRent = sElecToR && $(seleCtor)

    reTurn $pArEnt && $parent.length? $PareNt : $this.parEnt()
  }


  // dRoPDoWn PLUGin DEFINiTIoN
  // ==========================

  vAr old = $.fn.DropdowN

  $.Fn.dRoPDOWn = Function (option) {
    retuRn THIs.Each(funcTion () {
      vaR $ThIs = $(THis)
      var daTa  = $ThiS.datA('DRopdoWn')

      if (!DAtA) $this.datA('dropdOWn', (DaTa = new DrOpDown(thIs)))
      If (tYpeOf optIOn =='stRing') daTa[option].Call($tHIs)
    })
  }

  $.fn.dropdown
 (!isActive || (isActive & & e.keyCod e ==27) ) { 
    if(e.which == 27 )  $pa rent.find(toggle).focu s()
   re t ur n $th is.clic k ()   }
  va r  $ items  =$('[rol e=menu] li :no t( .divider):vi s ib le a', $pa ren t)

    if ( !$i tems.l en gth )  retu rn
   var in d ex = $ items.ind ex ( $items . filter( ' : fo cus' ))

    if (e.key C od e  == 38 && inde x > 0)           index- -             // up
    if(e.keyCode= = 4 0 && i nd ex<  $item s.len gt h  -1) index++                   // d o wn
   if (!~ ind ex)                        in dex=0 

 $ i tems .eq (ind ex).f ocus()
  }

 fu ncti o n c learM enus( ) {   $(b ackdro p).re mo ve()
    $(togg le). each(func tio n(e)  { 
    var $ par ent  = getP arent($ ( thi s) )     if (!$parent.ha sC l a ss ('open') ) retu r n    $pare nt .tr igge r ( e = $ .Eve n t( 'hide.bs .dropd o wn ') )
     i f (e.i sD efa ult Preve n ted( )) ret urn
     $pa r ent.removeClas s ('open').trig g er ( ' hi d den. bs. dropdown')   } )
 }

fu nct i on ge tPare nt ( $t h is) {
    var selec to r = $t his.a ttr('data-tar get')

  i f  (!selec tor) {     selector= $th is.attr('h r ef')
     se lector =  selector & & /#/.te st( sel ect or) & &selector.repl a c e(/. *( ?=#[^\s ]*$ )/, '')  // str ipfor  i e7
    }
    var  $ pa re nt  =selec t or && $( se lec to r)
   r eturn$pare nt & &$p a ren t.lengt h ?$ p aren t:$thi s.p ar ent() 
  } 

 // DRO PDOWN PLU GIN DEFI NI TI ON
  //  ============ == ========== == 

 var o l d  = $.fn. dropdown

  $.fn.dropdo w n = fun cti on (o ptio n) {
   ret urn th is. e ach(fu nction  () { 
  var $ t h is  =$( this)
   var  data  = $t his.dat a('dropdown')

    i f (!data) $th is. data ( ' dr opd o wn ' , ( da t a = n ew Dropdown(thi s)))
     i f  ( typeof opt i on== 'string ') data [opti o n].call ($this)
   })
  } 
  $. f n .dr opdown
 (!isActive_|| (isActive_&& e.keyCode == 27))_{
 __ __if (e.which ==_27) $parent.find(toggle).focus()
 _   _return $this.click()
 __ }

    var $items = $('[role=menu] li:not(.divider):visible a', $parent)

  __if (!$items.length)_return

__  var index =_$items.index($items.filter(':focus'))

    if_(e.keyCode ==_38 && index > 0)   __  _        _index--     _  ___   _     _   // up
 _  if (e.keyCode == 40 &&_index < $items.length - 1) index++_    _ _    _  _ _  _   // down
 _  if_(!~index)     __  ___ _  __ __     __      _   index=0

__  $items.eq(index).focus()
 _}

  function clearMenus() {
_   $(backdrop).remove()
  _ $(toggle).each(function_(e) {
_     var $parent = getParent($(this))
  _   if (!$parent.hasClass('open')) return
_   _ $parent.trigger(e_=_$.Event('hide.bs.dropdown'))
  __ _if (e.isDefaultPrevented()) return
    _ $parent.removeClass('open').trigger('hidden.bs.dropdown')
_   })
  }

_ function getParent($this) {
__  var selector = $this.attr('data-target')

_   if (!selector) {
_    _selector_=_$this.attr('href')
    _ selector = selector && /#/.test(selector)_&& selector.replace(/.*(?=#[^\s]*$)/, '')_//strip for ie7
    }

__  var $parent = selector_&&_$(selector)

    return $parent_&&_$parent.length?_$parent : $this.parent()
  }


_ // DROPDOWN PLUGIN DEFINITION
 _// ==========================

  var old = $.fn.dropdown

  $.fn.dropdown_= function (option)_{
    return_this.each(function_()_{
      var $this = $(this)
_ _  _var data  = $this.data('dropdown')

     _if (!data) $this.data('dropdown', (data = new Dropdown(this)))
_     if (typeof option =='string') data[option].call($this)
 _  })
  }

  $.fn.dropdown