text: /* ============================================================
   * bootstrap-dropdown.js v2.3.2
   * http://twitter.github.com/bootstrap/javascript.html#dropdowns
   * ============================================================
   * Copyright 2012 Twitter, Inc.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   * http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   * ============================================================ */
  
  
  !function ($) {
  
    "use strict"; // jshint ;_;
  
  
   /* DROPDOWN CLASS DEFINITION
    * ========================= */
  
    var toggle = '[data-toggle=dropdown]'
      , Dropdown = function (element) {
          var $el = $(element).on('click.dropdown.data-api', this.toggle)
          $('html').on('click.dropdown.data-api', function () {
            $el.parent().removeClass('open')
          })
        }
  
    Dropdown.prototype = {
  
      constructor: Dropdown
  
    , toggle: function (e) {
        var $this = $(this)
          , $parent
          , isActive
  
        if ($this.is('.disabled, :disabled')) return
  
        $parent = getParent($this)
  
        isActive = $parent.hasClass('open')
  
        clearMenus()
  
        if (!isActive) {
          if ('ontouchstart' in document.documentElement) {
            // if mobile we we use a backdrop because click events don't delegate
            $('<div class="dropdown-backdrop"/>').insertBefore($(this)).on('click', clearMenus)
          }
          $parent.toggleClass('open')
        }
  
        $this.focus()
  
        return false
      }
  
    , keydown: function (e) {
        var $this
          , $items
          , $active
          , $parent
          , isActive
          , index
  
        if (!/(38|40|27)/.test(e.keyCode)) return
  
        $this = $(this)
  
        e.preventDefault()
        e.stopPropagation()
  
        if ($this.is('.disabled, :disabled')) return
  
        $parent = getParent($this)
  
        isActive = $parent.hasClass('open')
  
        if (!isActive || (isActive && e.keyCode == 27)) {
          if (e.which == 27) $parent.find(toggle).focus()
          return $this.click()
        }
  
        $items = $('[role=menu] li:not(.divider):visible a', $parent)
  
        if (!$items.length) return
  
        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() {
      $('.dropdown-backdrop').remove()
      $(toggle).each(function () {
        getParent($(this)).removeClass('open')
      })
    }
  
    function getParent($this) {
      var selector = $this.attr('data-target')
        , $parent
  
      if (!selector) {
        selector = $this.attr('href')
        selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
      }
  
      $parent = selector && $(selector)
  
      if (!$parent || !$parent.length) $parent = $this.parent()
  
      return $parent
    }
  
  
    /* DROPDOWN PLUGIN DEFINITION
     * ========================== */
  
    var old = $.fn.dropdown
  
    $.fn.dropdown = function (option) {
      return this.each(function () {
        var $this = $(this)
          , data = $this.data('dropdown')
        if (!data) $this.data('dropdown', (data = new Dropdown(this)))
        if (typeof option == 'string') data[option].call($this)
      })
    }
  
    $.fn.dropdown.Constructor = Dropdown
  
  
   /* DROPDOWN NO CONFLICT
    * ==================== */
  
    $.fn.dropdown.noConflict = function () {
      $.fn.dropdown = old
      return this
    }
  
  
    /* APPLY TO STANDARD DROPDOWN ELEMENTS
     * =================================== */
  
    $(document)
      .on('click.dropdown.data-api', clearMenus)
      .on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
      .on('click.dropdown.data-api'  , toggle, Dropdown.prototype.toggle)
      .on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
  
  }(window.jQuery);
  /**
    *
    * jPanelMenu 1.3.0 (http://jpanelmenu.com)
    * By Anthony Colangelo (http://acolangelo.com)
    *
  * */
  
  (function($){
  	$.jPanelMenu = function(options) {
  		if ( typeof(options) == "undefined" || options == null ) { options = {}; };
  
  		var jP = {
  			options: $.extend({
  				menu: '#menu',
  				trigger: '.menu-trigger',
  				excludedPanelContent: 'style, script',
  
  				direction: 'left',
  				openPosition: '250px',
  				animated: true,
  				closeOnContentClick: true,
  
  				keyboardShortcuts: [
  					{
  						code: 27,
  						open: false,
  						close: true 
  					},
  					{
  						code: 37,
  						open: false,
  						close: true 
  					},
  					{
  						code: 39,
  						open: true,
  						close: true 
  					},
  					{
  						code: 77,
  						open: true,
  						close: true 
  					}
  				],
  
  				duration: 150,
  				openDuration: options.duration || 150,
  				closeDuration: options.duration || 150,
  
  				easing: 'ease-in-out',
  				openEasing: options.easing || 'ease-in-out',
  				closeEasing: options.easing || 'ease-in-out',
  
  				before: function(){ },
  				beforeOpen: function(){ },
  				beforeClose: function(){ },
  
  				after: function(){ },
  				afterOpen: function(){ },
  				afterClose: function(){ },
  
  				beforeOn: function(){ },
  				afterOn: function(){ },
  
  				beforeOff: function(){ },
  				afterOff: function(){ }
  			},options),
  
  			settings: {
  				transitionsSupported:	'WebkitTransition' in document.body.style ||
  										'MozTransition' in document.body.style ||
  										'msTransition' in document.body.style ||
  										'OTransition' in document.body.style ||
  										'Transition' in document.body.style
  				,
  				shiftFixedChildren: false,
  				panelPosition: 'relative',
  				positionUnits: 'px'
  			},
  
  			menu: '#jPanelMenu-menu',
  
  			panel: '.jPanelMenu-panel',
  
  			fixedChildren: [],
  
  			timeouts: {},
  
  			clearTimeouts: function() {
  				clearTimeout(jP.timeouts.open);
  				clearTimeout(jP.timeouts.afterOpen);
  				clearTimeout(jP.timeouts.afterClose);
  			},
  
  			setPositionUnits: function() {
  				var foundUnit = false,
  					allowedUnits = ['%','px','em']
  				;
  
  				for ( unitID in allowedUnits ) {
  					var unit = allowedUnits[unitID];
  					if ( jP.options.openPosition.toString().substr(-unit.length) == unit )
  					{
  						foundUnit = true;
  						jP.settings.positionUnits = unit;
  					}
  				}
  
  				if ( !foundUnit ) { jP.options.openPosition = parseInt(jP.options.openPosition) + jP.settings.positionUnits }
  			},
  
  			checkFixedChildren: function() {
  				jP.disableTransitions();
  
  				var defaultPanelStyle = { position: $(jP.panel).css('position') };
  
  				defaultPanelStyle[jP.options.direction] = ($(jP.panel).css(jP.options.direction) == 'auto')?0:$(jP.panel).css(jP.options.direction);
  
  				$(jP.panel).find('> *').each(function(){
  					if ( $(this).css('position') == 'fixed' && $(this).css(jP.options.direction) == 'auto' ) { jP.fixedChildren.push(this); }
  				});
  				
  				if ( jP.fixedChildren.length > 0 )
  				{
  					var newPanelStyle = { position: 'relative' };
  					newPanelStyle[jP.options.direction] = '1px';
  					jP.setPanelStyle(newPanelStyle);
  
  					if ( parseInt($(jP.fixedChildren[0]).offset().left) == 0 ) { jP.settings.shiftFixedChildren = true; }
  				}
  
  				jP.setPanelStyle(defaultPanelStyle);
  			},
  
  			setjPanelMenuStyles: function() {
  				var bgColor = '#fff';
  				var htmlBG = $('html').css('background-color');
  				var bodyBG = $('body').css('background-color');
  
  				if ( bodyBG != 'transparent' && bodyBG != "rgba(0, 0, 0, 0)") { bgColor = bodyBG; }
  				else if ( htmlBG != 'transparent' && htmlBG != "rgba(0, 0, 0, 0)") { bgColor = htmlBG; }
  				else { bgColor = '#fff'; }
  
  				if ( $('#jPanelMenu-style-master').length == 0 )
  				{
  					$('body').append('<style id="jPanelMenu-style-master">body{width:100%}.jPanelMenu{overflow-x:hidden}#jPanelMenu-menu{display:block;position:fixed;top:0;'+jP.options.direction+':0;height:100%;z-index:-1;overflow-x:hidden;overflow-y:scroll;-webkit-overflow-scrolling:touch}.jPanelMenu-panel{position:static;'+jP.options.direction+':0;top:0;z-index:2;width:100%;min-height:100%;background:' + bgColor + '}</style>');
  				}
  			},
  
  			setMenuState: function(open) {
  				var position = (open)?'open':'closed';
  				$('body').attr('data-menu-position', position);
  			},
  
  			getMenuState: function() {
  				return $('body').attr('data-menu-position');
  			},
  
  			menuIsOpen: function() {
  				if ( jP.getMenuState() == 'open' ) return true;
  				else return false;
  			},
  
  			setMenuStyle: function(styles) {
  				$(jP.menu).css(styles);
  			},
  
  			setPanelStyle: function(styles) {
  				$(jP.panel).css(styles);
  			},
  
  			showMenu: function() {
  				jP.setMenuStyle({
  					display: 'block'
  				});
  				jP.setMenuStyle({
  					'z-index': '1'
  				});
  			},
  
  			hideMenu: function() {
  				jP.setMenuStyle({
  					'z-index': '-1'
  				});
  				jP.setMenuStyle({
  					display: 'none'
  				});
  			},
  
  			enableTransitions: function(duration, easing) {
  				var formattedDuration = duration/1000;
  				var formattedEasing = jP.getCSSEasingFunction(easing);
  				jP.disableTransitions();
  				$('body').append('<style id="jPanelMenu-style-transitions">.jPanelMenu-panel{-webkit-transition: all ' + formattedDuration + 's ' + formattedEasing + '; -moz-transition: all ' + formattedDuration + 's ' + formattedEasing + '; -o-transition: all ' + formattedDuration + 's ' + formattedEasing + '; transition: all ' + formattedDuration + 's ' + formattedEasing + ';}</style>');
  			},
  
  			disableTransitions: function() {
  				$('#jPanelMenu-style-transitions').remove();
  			},
  
  			enableFixedTransitions: function(selector, id, duration, easing) {
  				var formattedDuration = duration/1000;
  				var formattedEasing = jP.getCSSEasingFunction(easing);
  				jP.disableFixedTransitions(id);
  				$('body').append('<style id="jPanelMenu-style-fixed-' + id + '">' + selector + '{-webkit-transition: all ' + formattedDuration + 's ' + formattedEasing + '; -moz-transition: all ' + formattedDuration + 's ' + formattedEasing + '; -o-transition: all ' + formattedDuration + 's ' + formattedEasing + '; transition: all ' + formattedDuration + 's ' + formattedEasing + ';}</style>');
  			},
  
  			disableFixedTransitions: function(id) {
  				$('#jPanelMenu-style-fixed-' + id).remove();
  			},
  
  			getCSSEasingFunction: function(name) {
  				switch ( name )
  				{
  					case 'linear':
  						return name;
  						break;
  
  					case 'ease':
  						return name;
  						break;
  
  					case 'ease-in':
  						return name;
  						break;
  
  					case 'ease-out':
  						return name;
  						break;
  
  					case 'ease-in-out':
  						return name;
  						break;
  
  					default:
  						return 'ease-in-out';
  						break;
  				}
  			},
  
  			getJSEasingFunction: function(name) {
  				switch ( name )
  				{
  					case 'linear':
  						return name;
  						break;
  
  					default:
  						return 'swing';
  						break;
  				}
  			},
  
  			openMenu: function(animated) {
  				if ( typeof(animated) == "undefined" || animated == null ) { animated = jP.options.animated };
  				
  				jP.clearTimeouts();
  
  				jP.options.before();
  				jP.options.beforeOpen();
  
  				jP.setMenuState(true);
  
  				jP.setPanelStyle({ position: 'relative' });
  				
  				jP.showMenu();
  
  				var animationChecks = {
  					none: (!animated)?true:false,
  					transitions: (animated && jP.settings.transitionsSupported)?true:false
  				};
  
  				if ( animationChecks.transitions || animationChecks.none ) {
  					if ( animationChecks.none ) jP.disableTransitions();
  					if ( animationChecks.transitions ) jP.enableTransitions(jP.options.openDuration, jP.options.openEasing);
  
  					var newPanelStyle = {};
  					newPanelStyle[jP.options.direction] = jP.options.openPosition;
  					jP.setPanelStyle(newPanelStyle);
  
  					if ( jP.settings.shiftFixedChildren )
  					{
  						$(jP.fixedChildren).each(function(){
  							var id = $(this).prop("tagName").toLowerCase() + ' ' + $(this).attr('class'),
  								selector = id.replace(' ','.'),
  								id = id.replace(' ','-')
  							;
  
  							if ( animationChecks.none ) jP.disableFixedTransitions(id);
  							if ( animationChecks.transitions ) jP.enableFixedTransitions(selector, id, jP.options.openDuration, jP.options.openEasing);
  
  							var newChildrenStyle = {};
  							newChildrenStyle[jP.options.direction] = jP.options.openPosition;
  							$(this).css(newChildrenStyle);
  						});
  					}
  
  					jP.timeouts.afterOpen = setTimeout(function(){
  						jP.disableTransitions();
  						if ( jP.settings.shiftFixedChildren )
  						{
  							$(jP.fixedChildren).each(function(){
  								var id = $(this).prop("tagName").toLowerCase() + ' ' + $(this).attr('class'),
  									id = id.replace(' ','-')
  								;
  
  								jP.disableFixedTransitions(id);
  							});
  						}
  
  						jP.options.after();
  						jP.options.afterOpen();
  						jP.initiateContentClickListeners();
  					}, jP.options.openDuration);
  				}
  				else {
  					var formattedEasing = jP.getJSEasingFunction(jP.options.openEasing);
  
  					var animationOptions = {};
  					animationOptions[jP.options.direction] = jP.options.openPosition;
  					$(jP.panel).stop().animate(animationOptions, jP.options.openDuration, formattedEasing, function(){
  						jP.options.after();
  						jP.options.afterOpen();
  						jP.initiateContentClickListeners();
  					});
  
  					if ( jP.settings.shiftFixedChildren )
  					{
  						$(jP.fixedChildren).each(function(){
  							var childrenAnimationOptions = {};
  							childrenAnimationOptions[jP.options.direction] = jP.options.openPosition;
  							$(this).stop().animate(childrenAnimationOptions, jP.options.openDuration, formattedEasing);
  						});
  					}
  				}
  			},
  
  			closeMenu: function(animated) {
  				if ( typeof(animated) == "undefined" || animated == null ) { animated = jP.options.animated };
  
  				jP.clearTimeouts();
  
  				jP.options.before();
  				jP.options.beforeClose();
  
  				jP.setMenuState(false);
  
  				var animationChecks = {
  					none: (!animated)?true:false,
  					transitions: (animated && jP.settings.transitionsSupported)?true:false
  				};
  
  				if ( animationChecks.transitions || animationChecks.none ) {
  					if ( animationChecks.none ) jP.disableTransitions();
  					if ( animationChecks.transitions ) jP.enableTransitions(jP.options.closeDuration, jP.options.closeEasing);
  
  					var newPanelStyle = {};
  					newPanelStyle[jP.options.direction] = 0 + jP.settings.positionUnits;
  					jP.setPanelStyle(newPanelStyle);
  
  					if ( jP.settings.shiftFixedChildren )
  					{
  						$(jP.fixedChildren).each(function(){
  							var id = $(this).prop("tagName").toLowerCase() + ' ' + $(this).attr('class'),
  								selector = id.replace(' ','.'),
  								id = id.replace(' ','-')
  							;
  
  							if ( animationChecks.none ) jP.disableFixedTransitions(id);
  							if ( animationChecks.transitions ) jP.enableFixedTransitions(selector, id, jP.options.closeDuration, jP.options.closeEasing);
  
  							var newChildrenStyle = {};
  							newChildrenStyle[jP.options.direction] = 0 + jP.settings.positionUnits;
  							$(this).css(newChildrenStyle);
  						});
  					}
  
  					jP.timeouts.afterClose = setTimeout(function(){
  						jP.setPanelStyle({ position: jP.settings.panelPosition });
  
  						jP.disableTransitions();
  						if ( jP.settings.shiftFixedChildren )
  						{
  							$(jP.fixedChildren).each(function(){
  								var id = $(this).prop("tagName").toLowerCase() + ' ' + $(this).attr('class'),
  									id = id.replace(' ','-')
  								;
  
  								jP.disableFixedTransitions(id);
  							});
  						}
  
  						jP.hideMenu();
  						jP.options.after();
  						jP.options.afterClose();
  						jP.destroyContentClickListeners();
  					}, jP.options.closeDuration);
  				}
  				else {
  					var formattedEasing = jP.getJSEasingFunction(jP.options.closeEasing);
  
  					var animationOptions = {};
  					animationOptions[jP.options.direction] = 0 + jP.settings.positionUnits;
  					$(jP.panel).stop().animate(animationOptions, jP.options.closeDuration, formattedEasing, function(){
  						jP.setPanelStyle({ position: jP.settings.panelPosition });
  
  						jP.hideMenu();
  						jP.options.after();
  						jP.options.afterClose();
  						jP.destroyContentClickListeners();
  					});
  
  					if ( jP.settings.shiftFixedChildren )
  					{
  						$(jP.fixedChildren).each(function(){
  							var childrenAnimationOptions = {};
  							childrenAnimationOptions[jP.options.direction] = 0 + jP.settings.positionUnits;
  							$(this).stop().animate(childrenAnimationOptions, jP.options.closeDuration, formattedEasing);
  						});
  					}
  				}
  			},
  
  			triggerMenu: function(animated) {
  				if ( jP.menuIsOpen() ) jP.closeMenu(animated);
  				else jP.openMenu(animated);
  			},
  
  			initiateClickListeners: function() {
  				$(document).on('click',jP.options.trigger,function(){ jP.triggerMenu(jP.options.animated); return false; });
  			},
  
  			destroyClickListeners: function() {
  				$(document).off('click',jP.options.trigger,null);
  			},
  
  			initiateContentClickListeners: function() {
  				if ( !jP.options.closeOnContentClick ) return false;
  
  				$(document).on('click',jP.panel,function(e){
  					if ( jP.menuIsOpen() ) jP.closeMenu(jP.options.animated);
  				});
  				
  				$(document).on('touchend',jP.panel,function(e){
  					if ( jP.menuIsOpen() ) jP.closeMenu(jP.options.animated);
  				});
  			},
  
  			destroyContentClickListeners: function() {
  				if ( !jP.options.closeOnContentClick ) return false;
  
  				$(document).off('click',jP.panel,null);
  				$(document).off('touchend',jP.panel,null);
  			},
  
  			initiateKeyboardListeners: function() {
  				var preventKeyListeners = ['input', 'textarea'];
  				$(document).on('keydown',function(e){
  					var target = $(e.target),
  					prevent = false;
  					$.each(preventKeyListeners, function(){
  						if (target.is(this.toString())) { prevent = true; }
  					});
  					if ( prevent ) { return true; }
  
  					for ( mapping in jP.options.keyboardShortcuts ) {
  						if ( e.which == jP.options.keyboardShortcuts[mapping].code )
  						{
  							var key = jP.options.keyboardShortcuts[mapping];
  
  							if ( key.open && key.close ) { jP.triggerMenu(jP.options.animated); }
  							else if ( (key.open && !key.close) && !jP.menuIsOpen() ) { jP.openMenu(jP.options.animated); }
  							else if ( (!key.open && key.close) && jP.menuIsOpen() ) { jP.closeMenu(jP.options.animated); }
  
  							return false;
  						}
  					}
  				});
  			},
  
  			destroyKeyboardListeners: function() {
  				$(document).off('keydown',null);
  			},
  
  			setupMarkup: function() {
  				$('html').addClass('jPanelMenu');
  				$('body > *').not(jP.menu + ', ' + jP.options.excludedPanelContent).wrapAll('<div class="' + jP.panel.replace('.','') + '"/>');
  				$(jP.options.menu).clone().attr('id', jP.menu.replace('#','')).insertAfter('body > ' + jP.panel);
  			},
  
  			resetMarkup: function() {
  				$('html').removeClass('jPanelMenu');
  				$('body > ' + jP.panel + ' > *').unwrap();
  				$(jP.menu).remove();
  			},
  
  			init: function() {
  				jP.options.beforeOn();
  
  				jP.initiateClickListeners();
  				if ( Object.prototype.toString.call(jP.options.keyboardShortcuts) === '[object Array]' ) { jP.initiateKeyboardListeners(); }
  
  				jP.setjPanelMenuStyles();
  				jP.setMenuState(false);
  				jP.setupMarkup();
  
  				jP.setMenuStyle({ width: jP.options.openPosition });
  
  				jP.checkFixedChildren();
  				jP.setPositionUnits();
  
  				jP.closeMenu(false);
  
  				jP.options.afterOn();
  			},
  
  			destroy: function() {
  				jP.options.beforeOff();
  
  				jP.closeMenu();
  				jP.destroyClickListeners();
  				if ( Object.prototype.toString.call(jP.options.keyboardShortcuts) === '[object Array]' ) { jP.destroyKeyboardListeners(); }
  
  				jP.resetMarkup();
  				var childrenStyles = {};
  				childrenStyles[jP.options.direction] = 'auto';
  				$(jP.fixedChildren).each(function(){ $(this).css(childrenStyles); });
  				jP.fixedChildren = [];
  
  				jP.options.afterOff();
  			}
  		};
  
  		return {
  			on: jP.init,
  			off: jP.destroy,
  			trigger: jP.triggerMenu,
  			open: jP.openMenu,
  			close: jP.closeMenu,
  			isOpen: jP.menuIsOpen,
  			menu: jP.menu,
  			getMenu: function() { return $(jP.menu); },
  			panel: jP.panel,
  			getPanel: function() { return $(jP.panel); }
  		};
  	};
  })(jQuery);
  /**
   *  jQuery Avgrund Popin Plugin
   *  http://github.com/voronianski/jquery.avgrund.js/
   *
   *  (c) 2012-2013 http://pixelhunter.me/
   *  MIT licensed
   */
  
  (function ($) {
  	$.fn.avgrund = function (options) {
  		var defaults = {
  			width: 380, // max = 640
  			height: 280, // max = 350
  			showClose: false,
  			showCloseText: '',
  			closeByEscape: true,
  			closeByDocument: true,
  			holderClass: '',
  			overlayClass: '',
  			enableStackAnimation: false,
  			onBlurContainer: '',
  			openOnEvent: true,
  			setEvent: 'click',
  			onLoad: false,
  			onUnload: false,
  			template: '<p>This is test popin content!</p>'
  		};
  
  		options = $.extend(defaults, options);
  
  		return this.each(function() {
  			var self = $(this),
  				body = $('body'),
  				maxWidth = options.width > 640 ? 640 : options.width,
  				maxHeight = options.height > 350 ? 350 : options.height,
  				template = typeof options.template === 'function' ? options.template(self) : options.template;
  
  			body.addClass('avgrund-ready');
  			body.append('<div class="avgrund-overlay ' + options.overlayClass + '"></div>');
  
  			if (options.onBlurContainer !== '') {
  				$(options.onBlurContainer).addClass('avgrund-blur');
  			}
  
  			function onDocumentKeyup (e) {
  				if (options.closeByEscape) {
  					if (e.keyCode === 27) {
  						deactivate();
  					}
  				}
  			}
  
  			function onDocumentClick (e) {
  				if (options.closeByDocument) {
  					if ($(e.target).is('.avgrund-overlay, .avgrund-close')) {
  						e.preventDefault();
  						deactivate();
  					}
  				} else {
  					if ($(e.target).is('.avgrund-close')) {
  						e.preventDefault();
  						deactivate();
  					}
  				}
  			}
  
  			function activate () {
  				if (typeof options.onLoad === 'function') {
  					options.onLoad(self);
  				}
  
  				setTimeout(function() {
  					body.addClass('avgrund-active');
  				}, 100);
  
  				body.append('<div class="avgrund-popin ' + options.holderClass + '">' + template + '</div>');
  
  				$('.avgrund-popin').css({
  					'width': maxWidth + 'px',
  					'height': maxHeight + 'px',
  					'margin-left': '-' + (maxWidth / 2 + 10) + 'px',
  					'margin-top': '-' + (maxHeight / 2 + 10) + 'px'
  				});
  
  				if (options.showClose) {
  					$('.avgrund-popin').append('<a href="#" class="avgrund-close">' + options.showCloseText + '</a>');
  				}
  
  				if (options.enableStackAnimation) {
  					$('.avgrund-popin').addClass('stack');
  				}
  
  				body.bind('keyup', onDocumentKeyup);
  				body.bind('click', onDocumentClick);
  			}
  
  			function deactivate () {
  				body.unbind('keyup', onDocumentKeyup);
  				body.unbind('click', onDocumentClick);
  
  				body.removeClass('avgrund-active');
  
  				setTimeout(function() {
  					$('.avgrund-popin').remove();
  				}, 500);
  
  				if (typeof options.onUnload === 'function') {
  					options.onUnload(self);
  				}
  			}
  
  			if (options.openOnEvent) {
  				self.bind(options.setEvent, function (e) {
  					e.stopPropagation();
  
  					if ($(e.target).is('a')) {
  						e.preventDefault();
  					}
  
  					activate();
  				});
  			} else {
  				activate();
  			}
  		});
  	};
  })(jQuery);
  /**
   * DropKick
   *
   * Highly customizable <select> lists
   * https://github.com/JamieLottering/DropKick
   *
   * &copy; 2011 Jamie Lottering <http://github.com/JamieLottering>
   *                        <http://twitter.com/JamieLottering>
   * 
   */
  (function ($, window, document) {
  
    document.documentElement.className = document.documentElement.className + ' dk_fouc';
    
    var
      // Public methods exposed to $.fn.dropkick()
      methods = {},
  
      // Cache every <select> element that gets dropkicked
      lists   = [],
  
      // Convenience keys for keyboard navigation
      keyMap = {
        'left'  : 37,
        'up'    : 38,
        'right' : 39,
        'down'  : 40,
        'enter' : 13
      },
  
      // HTML template for the dropdowns
      dropdownTemplate = [
        '<div class="dk_container {{ classname }}" id="dk_container_{{ id }}" tabindex="{{ tabindex }}">',
          '<a class="dk_toggle">',
            '<span class="dk_label">{{ label }}</span>',
            '<span class="select-icon"></span>',
          '</a>',
          '<div class="dk_options">',
            '<ul class="dk_options_inner">',
            '</ul>',
          '</div>',
        '</div>'
      ].join(''),
  
      // HTML template for dropdown options
      optionTemplate = '<li class="{{ current }}"><a data-dk-dropdown-value="{{ value }}">{{ text }}</a></li>',
  
      // Some nice default values
      defaults = {
        startSpeed : 100,  // I recommend a high value here, I feel it makes the changes less noticeable to the user
        theme  : false,
        change : false
      },
  
      // Make sure we only bind keydown on the document once
      keysBound = false
    ;
  
    // Called by using $('foo').dropkick();
    methods.init = function (settings) {
      settings = $.extend({}, defaults, settings);
  
      return this.each(function () {
        var
          // The current <select> element
          $select = $(this),
  
          // Store a reference to the originally selected <option> element
          $original = $select.find(':selected').first(),
  
          // Save all of the <option> elements
          $options = $select.find('option'),
  
          // We store lots of great stuff using jQuery data
          data = $select.data('dropkick') || {},
  
          // This gets applied to the 'dk_container' element
          id = $select.attr('id') || $select.attr('name'),
  
          // This gets updated to be equal to the longest <option> element
          width  = settings.width || $select.outerWidth(),
  
          // Check if we have a tabindex set or not
          tabindex  = $select.attr('tabindex') ? $select.attr('tabindex') : '',
  
          // Check if we have a class name set or not
          classname  = $select.attr('class') ? $select.attr('class') : '',
  
          // The completed dk_container element
          $dk = false,
  
          theme
        ;
  
        // Dont do anything if we've already setup dropkick on this element
        if (data.id) {
          return $select;
        } else {
          data.settings  = settings;
          data.tabindex  = tabindex;
          data.classname = classname;
          data.id        = id;
          data.$original = $original;
          data.$select   = $select;
          data.value     = _notBlank($select.val()) || _notBlank($original.attr('value'));
          data.label     = $original.text();
          data.options   = $options;
        }
  
        // Build the dropdown HTML
        $dk = _build(dropdownTemplate, data);
  
        // Make the dropdown fixed width if desired
        $dk.find('.dk_toggle').css({
          // Disable inline width since it should fill all available parrent space
          // 'width' : width + 'px'
        });
  
        // Hide the <select> list and place our new one in front of it
        $select.before($dk);
  
        // Update the reference to $dk
        $dk = $('#dk_container_' + id).addClass('dk_shown');
  
        // Save the current theme
        theme = settings.theme ? settings.theme : 'default';
        $dk.addClass('dk_theme_' + theme);
        data.theme = theme;
  
        // Save the updated $dk reference into our data object
        data.$dk = $dk;
  
        // Save the dropkick data onto the <select> element
        $select.data('dropkick', data);
  
        // Do the same for the dropdown, but add a few helpers
        $dk.data('dropkick', data);
  
        lists[lists.length] = $select;
  
        // Focus events
        $dk.bind('focus.dropkick', function (e) {
          $dk.addClass('dk_focus');
        }).bind('blur.dropkick', function (e) {
          $dk.removeClass('dk_open dk_focus');
        });
  
        setTimeout(function () {
          $select.hide();
        }, 0);
      });
    };
  
    // Allows dynamic theme changes
    methods.theme = function (newTheme) {
      var
        $select   = $(this),
        list      = $select.data('dropkick'),
        $dk       = list.$dk,
        oldtheme  = 'dk_theme_' + list.theme
      ;
  
      $dk.removeClass(oldtheme).addClass('dk_theme_' + newTheme);
  
      list.theme = newTheme;
    };
  
    // Reset all <selects and dropdowns in our lists array
    methods.reset = function () {
      for (var i = 0, l = lists.length; i < l; i++) {
        var
          listData  = lists[i].data('dropkick'),
          $dk       = listData.$dk,
          $current  = $dk.find('li').first()
        ;
  
        $dk.find('.dk_label').text(listData.label);
        $dk.find('.dk_options_inner').animate({ scrollTop: 0 }, 0);
  
        _setCurrent($current, $dk);
        _updateFields($current, $dk, true);
      }
    };
  
    // Expose the plugin
    $.fn.dropkick = function (method) {
      if (methods[method]) {
        return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
      } else if (typeof method === 'object' || ! method) {
        return methods.init.apply(this, arguments);
      }
    };
  
    // private
    function _handleKeyBoardNav(e, $dk) {
      var
        code     = e.keyCode,
        data     = $dk.data('dropkick'),
        options  = $dk.find('.dk_options'),
        open     = $dk.hasClass('dk_open'),
        current  = $dk.find('.dk_option_current'),
        first    = options.find('li').first(),
        last     = options.find('li').last(),
        next,
        prev
      ;
  
      switch (code) {
        case keyMap.enter:
          if (open) {
            _updateFields(current.find('a'), $dk);
            _closeDropdown($dk);
          } else {
            _openDropdown($dk);
          }
          e.preventDefault();
        break;
  
        case keyMap.up:
          prev = current.prev('li');
          if (open) {
            if (prev.length) {
              _setCurrent(prev, $dk);
            } else {
              _setCurrent(last, $dk);
            }
          } else {
            _openDropdown($dk);
          }
          e.preventDefault();
        break;
  
        case keyMap.down:
          if (open) {
            next = current.next('li').first();
            if (next.length) {
              _setCurrent(next, $dk);
            } else {
              _setCurrent(first, $dk);
            }
          } else {
            _openDropdown($dk);
          }
          e.preventDefault();
        break;
  
        default:
        break;
      }
    }
  
    // Update the <select> value, and the dropdown label
    function _updateFields(option, $dk, reset) {
      var value, label, data;
  
      value = option.attr('data-dk-dropdown-value');
      label = option.text();
      data  = $dk.data('dropkick');
  
      $select = data.$select;
      $select.val(value);
  
      $dk.find('.dk_label').text(label);
  
      reset = reset || false;
  
      if (data.settings.change && !reset) {
        data.settings.change.call($select, value, label);
      }
    }
  
    // Set the currently selected option
    function _setCurrent($current, $dk) {
      $dk.find('.dk_option_current').removeClass('dk_option_current');
      $current.addClass('dk_option_current');
  
      _setScrollPos($dk, $current);
    }
  
    function _setScrollPos($dk, anchor) {
      var height = anchor.prevAll('li').outerHeight() * anchor.prevAll('li').length;
      $dk.find('.dk_options_inner').animate({ scrollTop: height + 'px' }, 0);
    }
  
    // Close a dropdown
    function _closeDropdown($dk) {
      $dk.removeClass('dk_open');
    }
  
    // Open a dropdown
    function _openDropdown($dk) {
      var data = $dk.data('dropkick');
      $dk.find('.dk_options').css({ top : $dk.find('.dk_toggle').outerHeight() - 1 });
      $dk.toggleClass('dk_open');
  
    }
  
    /**
     * Turn the dropdownTemplate into a jQuery object and fill in the variables.
     */
    function _build (tpl, view) {
      var
        // Template for the dropdown
        template  = tpl,
        // Holder of the dropdowns options
        options   = [],
        $dk
      ;
  
      template = template.replace('{{ id }}', view.id);
      template = template.replace('{{ label }}', view.label);
      template = template.replace('{{ tabindex }}', view.tabindex);
      template = template.replace('{{ classname }}', view.classname);
  
      if (view.options && view.options.length) {
        for (var i = 0, l = view.options.length; i < l; i++) {
          var
            $option   = $(view.options[i]),
            current   = 'dk_option_current',
            oTemplate = optionTemplate
          ;
  
          oTemplate = oTemplate.replace('{{ value }}', $option.val());
          oTemplate = oTemplate.replace('{{ current }}', (_notBlank($option.val()) === view.value) ? current : '');
          oTemplate = oTemplate.replace('{{ text }}', $option.text());
  
          options[options.length] = oTemplate;
        }
      }
  
      $dk = $(template);
      $dk.find('.dk_options_inner').html(options.join(''));
  
      return $dk;
    }
  
    function _notBlank(text) {
      return ($.trim(text).length > 0) ? text : false;
    }
  
    $(function () {
  
      // Handle click events on the dropdown toggler
      $(document).on('click', '.dk_toggle', function (e) {
        var $dk  = $(this).parents('.dk_container').first();
  
        _openDropdown($dk);
  
        if ("ontouchstart" in window) {
          $dk.addClass('dk_touch');
          $dk.find('.dk_options_inner').addClass('scrollable vertical');
        }
  
        e.preventDefault();
        return false;
      });
  
      // Handle click events on individual dropdown options
      $(document).on('click', '.dk_options a', function (e) {
        var
          $option = $(this),
          $dk     = $option.parents('.dk_container').first(),
          data    = $dk.data('dropkick')
        ;
      
        _closeDropdown($dk);
        _updateFields($option, $dk);
        _setCurrent($option.parent(), $dk);
      
        e.preventDefault();
        return false;
      });
  
      // Setup keyboard nav
      $(document).bind('keydown.dk_nav', function (e) {
        var
          // Look for an open dropdown...
          $open    = $('.dk_container.dk_open'),
  
          // Look for a focused dropdown
          $focused = $('.dk_container.dk_focus'),
  
          // Will be either $open, $focused, or null
          $dk = null
        ;
  
        // If we have an open dropdown, key events should get sent to that one
        if ($open.length) {
          $dk = $open;
        } else if ($focused.length && !$open.length) {
          // But if we have no open dropdowns, use the focused dropdown instead
          $dk = $focused;
        }
  
        if ($dk) {
          _handleKeyBoardNav(e, $dk);
        }
      });
    });
  })(jQuery, window, document);
  /*!
   * iCheck v0.9.1, http://git.io/uhUPMA
   * =================================
   * Powerful jQuery plugin for checkboxes and radio buttons customization
   *
   * (c) 2013 Damir Foy, http://damirfoy.com
   * MIT Licensed
   */
  
  (function($) {
  
    // Cached vars
    var _iCheck = 'iCheck',
      _iCheckHelper = _iCheck + '-helper',
      _checkbox = 'checkbox',
      _radio = 'radio',
      _checked = 'checked',
      _unchecked = 'un' + _checked,
      _disabled = 'disabled',
      _determinate = 'determinate',
      _indeterminate = 'in' + _determinate,
      _update = 'update',
      _type = 'type',
      _click = 'click',
      _touch = 'touchbegin.i touchend.i',
      _add = 'addClass',
      _remove = 'removeClass',
      _callback = 'trigger',
      _label = 'label',
      _cursor = 'cursor',
      _mobile = /ipad|iphone|ipod|android|blackberry|windows phone|opera mini/i.test(navigator.userAgent);
  
    // Plugin init
    $.fn[_iCheck] = function(options, fire) {
  
      // Walker
      var handle = ':' + _checkbox + ', :' + _radio,
        stack = $(),
        walker = function(object) {
          object.each(function() {
            var self = $(this);
  
            if (self.is(handle)) {
              stack = stack.add(self);
            } else {
              stack = stack.add(self.find(handle));
            };
          });
        };
  
      // Check if we should operate with some method
      if (/^(check|uncheck|toggle|indeterminate|determinate|disable|enable|update|destroy)$/i.test(options)) {
  
        // Normalize method's name
        options = options.toLowerCase();
  
        // Find checkboxes and radio buttons
        walker(this);
  
        return stack.each(function() {
          if (options == 'destroy') {
            tidy(this, 'ifDestroyed');
          } else {
            operate($(this), true, options);
          };
  
          // Fire method's callback
          if ($.isFunction(fire)) {
            fire();
          };
        });
  
      // Customization
      } else if (typeof options == 'object' || !options) {
  
        // Check if any options were passed
        var settings = $.extend({
            checkedClass: _checked,
            disabledClass: _disabled,
            indeterminateClass: _indeterminate,
            labelHover: true
          }, options),
  
          selector = settings.handle,
          hoverClass = settings.hoverClass || 'hover',
          focusClass = settings.focusClass || 'focus',
          activeClass = settings.activeClass || 'active',
          labelHover = !!settings.labelHover,
          labelHoverClass = settings.labelHoverClass || 'hover',
  
          // Setup clickable area
          area = ('' + settings.increaseArea).replace('%', '') | 0;
  
        // Selector limit
        if (selector == _checkbox || selector == _radio) {
          handle = ':' + selector;
        };
  
        // Clickable area limit
        if (area < -50) {
          area = -50;
        };
  
        // Walk around the selector
        walker(this);
  
        return stack.each(function() {
  
          // If already customized
          tidy(this);
  
          var self = $(this),
            node = this,
            id = node.id,
  
            // Layer styles
            offset = -area + '%',
            size = 100 + (area * 2) + '%',
            layer = {
              position: 'absolute',
              top: offset,
              left: offset,
              display: 'block',
              width: size,
              height: size,
              margin: 0,
              padding: 0,
              background: '#fff',
              border: 0,
              opacity: 0
            },
  
            // Choose how to hide input
            hide = _mobile ? {
              position: 'absolute',
              visibility: 'hidden'
            } : area ? layer : {
              position: 'absolute',
              opacity: 0
            },
  
            // Get proper class
            className = node[_type] == _checkbox ? settings.checkboxClass || 'i' + _checkbox : settings.radioClass || 'i' + _radio,
  
            // Find assigned labels
            label = $(_label + '[for="' + id + '"]').add(self.closest(_label)),
  
            // Wrap input
            parent = self.wrap('<div class="' + className + '"/>')[_callback]('ifCreated').parent().append(settings.insert),
  
            // Layer addition
            helper = $('<ins class="' + _iCheckHelper + '"/>').css(layer).appendTo(parent);
  
          // Finalize customization
          self.data(_iCheck, {o: settings, s: self.attr('style')}).css(hide);
          !!settings.inheritClass && parent[_add](node.className);
          !!settings.inheritID && id && parent.attr('id', _iCheck + '-' + id);
          parent.css('position') == 'static' && parent.css('position', 'relative');
          operate(self, true, _update);
  
          // Label events
          if (label.length) {
            label.on(_click + '.i mouseenter.i mouseleave.i ' + _touch, function(event) {
              var type = event[_type],
                item = $(this);
  
              // Do nothing if input is disabled
              if (!node[_disabled]) {
  
                // Click
                if (type == _click) {
                  operate(self, false, true);
  
                // Hover state
                } else if (labelHover) {
  
                  // mouseleave|touchend
                  if (/ve|nd/.test(type)) {
                    parent[_remove](hoverClass);
                    item[_remove](labelHoverClass);
                  } else {
                    parent[_add](hoverClass);
                    item[_add](labelHoverClass);
                  };
                };
  
                if (_mobile) {
                  event.stopPropagation();
                } else {
                  return false;
                };
              };
            });
          };
  
          // Input events
          self.on(_click + '.i focus.i blur.i keyup.i keydown.i keypress.i', function(event) {
            var type = event[_type],
              key = event.keyCode;
  
            // Click
            if (type == _click) {
              return false;
  
            // Keydown
            } else if (type == 'keydown' && key == 32) {
              if (!(node[_type] == _radio && node[_checked])) {
                if (node[_checked]) {
                  off(self, _checked);
                } else {
                  on(self, _checked);
                };
              };
  
              return false;
  
            // Keyup
            } else if (type == 'keyup' && node[_type] == _radio) {
              !node[_checked] && on(self, _checked);
  
            // Focus/blur
            } else if (/us|ur/.test(type)) {
              parent[type == 'blur' ? _remove : _add](focusClass);
            };
          });
  
          // Helper events
          helper.on(_click + ' mousedown mouseup mouseover mouseout ' + _touch, function(event) {
            var type = event[_type],
  
              // mousedown|mouseup
              toggle = /wn|up/.test(type) ? activeClass : hoverClass;
  
            // Do nothing if input is disabled
            if (!node[_disabled]) {
  
              // Click
              if (type == _click) {
                operate(self, false, true);
  
              // Active and hover states
              } else {
  
                // State is on
                if (/wn|er|in/.test(type)) {
  
                  // mousedown|mouseover|touchbegin
                  parent[_add](toggle);
  
                // State is off
                } else {
                  parent[_remove](toggle + ' ' + activeClass);
                };
  
                // Label hover
                if (label.length && labelHover && toggle == hoverClass) {
  
                  // mouseout|touchend
                  label[/ut|nd/.test(type) ? _remove : _add](labelHoverClass);
                };
              };
  
              if (_mobile) {
                event.stopPropagation();
              } else {
                return false;
              };
            };
          });
        });
      } else {
        return this;
      };
    };
  
    // Do something with inputs
    function operate(input, direct, method) {
      var node = input[0];
        state = /er/.test(method) ? _indeterminate : /bl/.test(method) ? _disabled : _checked,
        active = method == _update ? {
          checked: node[_checked],
          disabled: node[_disabled],
          indeterminate: input.attr(_indeterminate) == 'true' || input.attr(_determinate) == 'false'
        } : node[state];
  
      // Check, disable or indeterminate
      if (/^(ch|di|in)/.test(method) && !active) {
        on(input, state);
  
      // Uncheck, enable or determinate
      } else if (/^(un|en|de)/.test(method) && active) {
        off(input, state);
  
      // Update
      } else if (method == _update) {
  
        // Handle states
        for (var state in active) {
          if (active[state]) {
            on(input, state, true);
          } else {
            off(input, state, true);
          };
        };
  
      } else if (!direct || method == 'toggle') {
  
        // Helper or label was clicked
        if (!direct) {
          input[_callback]('ifClicked');
        };
  
        // Toggle checked state
        if (active) {
          if (node[_type] !== _radio) {
            off(input, state);
          };
        } else {
          on(input, state);
        };
      };
    };
  
    // Add checked, disabled or indeterminate state
    function on(input, state, keep) {
      var node = input[0],
        parent = input.parent(),
        checked = state == _checked,
        indeterminate = state == _indeterminate,
        callback = indeterminate ? _determinate : checked ? _unchecked : 'enabled',
        regular = option(node, callback + capitalize(node[_type])),
        specific = option(node, state + capitalize(node[_type]));
  
      // Prevent unnecessary actions
      if (node[state] !== true) {
  
        // Toggle assigned radio buttons
        if (!keep && state == _checked && node[_type] == _radio && node.name) {
          var form = input.closest('form'),
            inputs = 'input[name="' + node.name + '"]';
  
          inputs = form.length ? form.find(inputs) : $(inputs);
  
          inputs.each(function() {
            if (this !== node && $.data(this, _iCheck)) {
              off($(this), state);
            };
          });
        };
  
        // Indeterminate state
        if (indeterminate) {
  
          // Add indeterminate state
          node[state] = true;
  
          // Remove checked state
          if (node[_checked]) {
            off(input, _checked, 'force');
          };
  
        // Checked or disabled state
        } else {
  
          // Add checked or disabled state
          if (!keep) {
            node[state] = true;
          };
  
          // Remove indeterminate state
          if (checked && node[_indeterminate]) {
            off(input, _indeterminate, false);
          };
        };
  
        // Trigger callbacks
        callbacks(input, checked, state, keep);
      };
  
      // Add proper cursor
      if (node[_disabled] && !!option(node, _cursor, true)) {
        parent.find('.' + _iCheckHelper).css(_cursor, 'default');
      };
  
      // Add state class
      parent[_add](specific || option(node, state));
  
      // Remove regular state class
      parent[_remove](regular || option(node, callback) || '');
    };
  
    // Remove checked, disabled or indeterminate state
    function off(input, state, keep) {
      var node = input[0],
        parent = input.parent(),
        checked = state == _checked,
        indeterminate = state == _indeterminate,
        callback = indeterminate ? _determinate : checked ? _unchecked : 'enabled',
        regular = option(node, callback + capitalize(node[_type])),
        specific = option(node, state + capitalize(node[_type]));
  
      // Prevent unnecessary actions
      if (node[state] !== false) {
  
        // Toggle state
        if (indeterminate || !keep || keep == 'force') {
          node[state] = false;
        };
  
        // Trigger callbacks
        callbacks(input, checked, callback, keep);
      };
  
      // Add proper cursor
      if (!node[_disabled] && !!option(node, _cursor, true)) {
        parent.find('.' + _iCheckHelper).css(_cursor, 'pointer');
      };
  
      // Remove state class
      parent[_remove](specific || option(node, state) || '');
  
      // Add regular state class
      parent[_add](regular || option(node, callback));
    };
  
    // Remove all traces
    function tidy(node, callback) {
      if ($.data(node, _iCheck)) {
        var input = $(node);
  
        // Remove everything except input
        input.parent().html(input.attr('style', $.data(node, _iCheck).s || '')[_callback](callback || ''));
  
        // Unbind events
        input.off('.i').unwrap();
        $(_label + '[for="' + node.id + '"]').add(input.closest(_label)).off('.i');
      };
    };
  
    // Get some option
    function option(node, state, regular) {
      if ($.data(node, _iCheck)) {
        return $.data(node, _iCheck).o[state + (regular ? '' : 'Class')];
      };
    };
  
    // Capitalize some string
    function capitalize(string) {
      return string.charAt(0).toUpperCase() + string.slice(1);
    };
  
    // Executable handlers
    function callbacks(input, checked, callback, keep) {
      if (!keep) {
        if (checked) {
          input[_callback]('ifToggled');
        };
  
        input[_callback]('ifChanged')[_callback]('if' + capitalize(callback));
      };
    };
  })(jQuery);/*
  
  	jQuery Tags Input Plugin 1.3.3
  	
  	Copyright (c) 2011 XOXCO, Inc
  	
  	Documentation for this plugin lives here:
  	http://xoxco.com/clickable/jquery-tags-input
  	
  	Licensed under the MIT license:
  	http://www.opensource.org/licenses/mit-license.php
  
  	ben@xoxco.com
  
  */
  
  (function($) {
  
  	var delimiter = new Array();
  	var tags_callbacks = new Array();
  	$.fn.doAutosize = function(o){
  	    var minWidth = $(this).data('minwidth'),
  	        maxWidth = $(this).data('maxwidth'),
  	        val = '',
  	        input = $(this),
  	        testSubject = $('#'+$(this).data('tester_id'));
  	
  	    if (val === (val = input.val())) {return;}
  	
  	    // Enter new content into testSubject
  	    var escaped = val.replace(/&/g, '&amp;').replace(/\s/g,' ').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  	    testSubject.html(escaped);
  	    // Calculate new width + whether to change
  	    var testerWidth = testSubject.width(),
  	        newWidth = (testerWidth + o.comfortZone) >= minWidth ? testerWidth + o.comfortZone : minWidth,
  	        currentWidth = input.width(),
  	        isValidWidthChange = (newWidth < currentWidth && newWidth >= minWidth)
  	                             || (newWidth > minWidth && newWidth < maxWidth);
  	
  	    // Animate width
  	    if (isValidWidthChange) {
  	        input.width(newWidth);
  	    }
  
  
    };
    $.fn.resetAutosize = function(options){
      // alert(JSON.stringify(options));
      var minWidth =  $(this).data('minwidth') || options.minInputWidth || $(this).width(),
          maxWidth = $(this).data('maxwidth') || options.maxInputWidth || ($(this).closest('.tagsinput').width() - options.inputPadding),
          val = '',
          input = $(this),
          testSubject = $('<tester/>').css({
              position: 'absolute',
              top: -9999,
              left: -9999,
              width: 'auto',
              fontSize: input.css('fontSize'),
              fontFamily: input.css('fontFamily'),
              fontWeight: input.css('fontWeight'),
              letterSpacing: input.css('letterSpacing'),
              whiteSpace: 'nowrap'
          }),
          testerId = $(this).attr('id')+'_autosize_tester';
      if(! $('#'+testerId).length > 0){
        testSubject.attr('id', testerId);
        testSubject.appendTo('body');
      }
  
      input.data('minwidth', minWidth);
      input.data('maxwidth', maxWidth);
      input.data('tester_id', testerId);
      input.css('width', minWidth);
    };
    
  	$.fn.addTag = function(value,options) {
  			options = jQuery.extend({focus:false,callback:true},options);
  			this.each(function() { 
  				var id = $(this).attr('id');
  
  				var tagslist = $(this).val().split(delimiter[id]);
  				if (tagslist[0] == '') { 
  					tagslist = new Array();
  				}
  
  				value = jQuery.trim(value);
  		
  				if (options.unique) {
  					var skipTag = $(this).tagExist(value);
  					if(skipTag == true) {
  					    //Marks fake input as not_valid to let styling it
      				    $('#'+id+'_tag').addClass('not_valid');
      				}
  				} else {
  					var skipTag = false; 
  				}
  				
  				if (value !='' && skipTag != true) { 
                      $('<span>').addClass('tag').append(
                          $('<span>').text(value).append('&nbsp;&nbsp;'),
                          $('<a class="tagsinput-remove-link icon-remove">', {
                              href  : '#',
                              title : 'Remove tag',
                              text  : ''
                          }).click(function () {
                              return $('#' + id).removeTag(escape(value));
                          })
                      ).insertBefore('#' + id + '_addTag');
  
  					tagslist.push(value);
  				
  					$('#'+id+'_tag').val('');
  					if (options.focus) {
  						$('#'+id+'_tag').focus();
  					} else {		
  						$('#'+id+'_tag').blur();
  					}
  					
  					$.fn.tagsInput.updateTagsField(this,tagslist);
  					
  					if (options.callback && tags_callbacks[id] && tags_callbacks[id]['onAddTag']) {
  						var f = tags_callbacks[id]['onAddTag'];
  						f.call(this, value);
  					}
  					if(tags_callbacks[id] && tags_callbacks[id]['onChange'])
  					{
  						var i = tagslist.length;
  						var f = tags_callbacks[id]['onChange'];
  						f.call(this, $(this), tagslist[i-1]);
  					}					
  				}
  		
  			});		
  			
  			return false;
  		};
  		
  	$.fn.removeTag = function(value) { 
  			value = unescape(value);
  			this.each(function() { 
  				var id = $(this).attr('id');
  	
  				var old = $(this).val().split(delimiter[id]);
  					
  				$('#'+id+'_tagsinput .tag').remove();
  				str = '';
  				for (i=0; i< old.length; i++) { 
  					if (old[i]!=value) { 
  						str = str + delimiter[id] +old[i];
  					}
  				}
  				
  				$.fn.tagsInput.importTags(this,str);
  
  				if (tags_callbacks[id] && tags_callbacks[id]['onRemoveTag']) {
  					var f = tags_callbacks[id]['onRemoveTag'];
  					f.call(this, value);
  				}
  			});
  					
  			return false;
  		};
  	
  	$.fn.tagExist = function(val) {
  		var id = $(this).attr('id');
  		var tagslist = $(this).val().split(delimiter[id]);
  		return (jQuery.inArray(val, tagslist) >= 0); //true when tag exists, false when not
  	};
  	
  	// clear all existing tags and import new ones from a string
  	$.fn.importTags = function(str) {
                  id = $(this).attr('id');
  		$('#'+id+'_tagsinput .tag').remove();
  		$.fn.tagsInput.importTags(this,str);
  	}
  		
  	$.fn.tagsInput = function(options) { 
      var settings = jQuery.extend({
        interactive:true,
        defaultText:'',
        minChars:0,
        width:'',
        height:'',
        autocomplete: {selectFirst: false },
        'hide':true,
        'delimiter':',',
        'unique':true,
        removeWithBackspace:true,
        placeholderColor:'#666666',
        autosize: true,
        comfortZone: 20,
        inputPadding: 6*2
      },options);
  
  		this.each(function() { 
  			if (settings.hide) { 
  				$(this).hide();				
  			}
  			var id = $(this).attr('id');
  			if (!id || delimiter[$(this).attr('id')]) {
  				id = $(this).attr('id', 'tags' + new Date().getTime()).attr('id');
  			}
  			
  			var data = jQuery.extend({
  				pid:id,
  				real_input: '#'+id,
  				holder: '#'+id+'_tagsinput',
  				input_wrapper: '#'+id+'_addTag',
  				fake_input: '#'+id+'_tag'
  			},settings);
  	
  			delimiter[id] = data.delimiter;
  			
  			if (settings.onAddTag || settings.onRemoveTag || settings.onChange) {
  				tags_callbacks[id] = new Array();
  				tags_callbacks[id]['onAddTag'] = settings.onAddTag;
  				tags_callbacks[id]['onRemoveTag'] = settings.onRemoveTag;
  				tags_callbacks[id]['onChange'] = settings.onChange;
  			}
  	
  			var markup = '<div id="'+id+'_tagsinput" class="tagsinput"><div class="tagsinput-add-container" id="'+id+'_addTag"><div class="tagsinput-add icon-plus"></div>';
  			
  			if (settings.interactive) {
  				markup = markup + '<input id="'+id+'_tag" value="" data-default="'+settings.defaultText+'" />';
  			}
  			
  			markup = markup + '</div></div>';
  			
  			$(markup).insertAfter(this);
  
  			$(data.holder).css('width',settings.width);
  			$(data.holder).css('min-height',settings.height);
  			$(data.holder).css('height','100%');
  	
  			if ($(data.real_input).val()!='') { 
  				$.fn.tagsInput.importTags($(data.real_input),$(data.real_input).val());
  			}		
  			if (settings.interactive) { 
  				$(data.fake_input).val($(data.fake_input).attr('data-default'));
  				$(data.fake_input).css('color',settings.placeholderColor);
  		        $(data.fake_input).resetAutosize(settings);
  		
  				$(data.holder).bind('click',data,function(event) {
  					$(event.data.fake_input).focus();
  				});
  			
  				$(data.fake_input).bind('focus',data,function(event) {
  					if ($(event.data.fake_input).val()==$(event.data.fake_input).attr('data-default')) { 
  						$(event.data.fake_input).val('');
  					}
  					$(event.data.fake_input).css('color','#000000');		
  				});
  						
  				if (settings.autocomplete_url != undefined) {
  					autocomplete_options = {source: settings.autocomplete_url};
  					for (attrname in settings.autocomplete) { 
  						autocomplete_options[attrname] = settings.autocomplete[attrname]; 
  					}
  				
  					if (jQuery.Autocompleter !== undefined) {
  						$(data.fake_input).autocomplete(settings.autocomplete_url, settings.autocomplete);
  						$(data.fake_input).bind('result',data,function(event,data,formatted) {
  							if (data) {
  								$('#'+id).addTag(data[0] + "",{focus:true,unique:(settings.unique)});
  							}
  					  	});
  					} else if (jQuery.ui.autocomplete !== undefined) {
  						$(data.fake_input).autocomplete(autocomplete_options);
  						$(data.fake_input).bind('autocompleteselect',data,function(event,ui) {
  							$(event.data.real_input).addTag(ui.item.value,{focus:true,unique:(settings.unique)});
  							return false;
  						});
  					}
  				
  					
  				} else {
  						// if a user tabs out of the field, create a new tag
  						// this is only available if autocomplete is not used.
  						$(data.fake_input).bind('blur',data,function(event) { 
  							var d = $(this).attr('data-default');
  							if ($(event.data.fake_input).val()!='' && $(event.data.fake_input).val()!=d) { 
  								if( (event.data.minChars <= $(event.data.fake_input).val().length) && (!event.data.maxChars || (event.data.maxChars >= $(event.data.fake_input).val().length)) )
  									$(event.data.real_input).addTag($(event.data.fake_input).val(),{focus:true,unique:(settings.unique)});
  							} else {
  								$(event.data.fake_input).val($(event.data.fake_input).attr('data-default'));
  								$(event.data.fake_input).css('color',settings.placeholderColor);
  							}
  							return false;
  						});
  				
  				}
  				// if user types a comma, create a new tag
  				$(data.fake_input).bind('keypress',data,function(event) {
  					if (event.which==event.data.delimiter.charCodeAt(0) || event.which==13 ) {
  					    event.preventDefault();
  						if( (event.data.minChars <= $(event.data.fake_input).val().length) && (!event.data.maxChars || (event.data.maxChars >= $(event.data.fake_input).val().length)) )
  							$(event.data.real_input).addTag($(event.data.fake_input).val(),{focus:true,unique:(settings.unique)});
  					  	$(event.data.fake_input).resetAutosize(settings);
  						return false;
  					} else if (event.data.autosize) {
  			            $(event.data.fake_input).doAutosize(settings);
              
            			}
  				});
  				//Delete last tag on backspace
  				data.removeWithBackspace && $(data.fake_input).bind('keydown', function(event)
  				{
  					if(event.keyCode == 8 && $(this).val() == '')
  					{
  						 event.preventDefault();
  						 var last_tag = $(this).closest('.tagsinput').find('.tag:last').text();
  						 var id = $(this).attr('id').replace(/_tag$/, '');
  						 last_tag = last_tag.replace(/[\s\u00a0]+x$/, '');
  						 $('#' + id).removeTag(escape(last_tag));
  						 $(this).trigger('focus');
  					}
  				});
  				$(data.fake_input).blur();
  				
  				//Removes the not_valid class when user changes the value of the fake input
  				if(data.unique) {
  				    $(data.fake_input).keydown(function(event){
  				        if(event.keyCode == 8 || String.fromCharCode(event.which).match(/\w+|[áéíóúÁÉÍÓÚñÑ,/]+/)) {
  				            $(this).removeClass('not_valid');
  				        }
  				    });
  				}
  			} // if settings.interactive
  		});
  			
  		return this;
  	
  	};
  	
  	$.fn.tagsInput.updateTagsField = function(obj,tagslist) { 
  		var id = $(obj).attr('id');
  		$(obj).val(tagslist.join(delimiter[id]));
  	};
  	
  	$.fn.tagsInput.importTags = function(obj,val) {			
  		$(obj).val('');
  		var id = $(obj).attr('id');
  		var tags = val.split(delimiter[id]);
  		for (i=0; i<tags.length; i++) { 
  			$(obj).addTag(tags[i],{focus:false,callback:false});
  		}
  		if(tags_callbacks[id] && tags_callbacks[id]['onChange'])
  		{
  			var f = tags_callbacks[id]['onChange'];
  			f.call(obj, obj, tags[i]);
  		}
  	};
  
  })(jQuery);
  /**
   * Toolbar.js
   *
   * @fileoverview  jQuery plugin that creates tooltip style toolbars.
   * @link          http://paulkinzett.github.com/toolbar/
   * @author        Paul Kinzett (http://kinzett.co.nz/)
   * @version       1.0.4
   * @requires      jQuery 1.7+
   *
   * @license jQuery Toolbar Plugin v1.0.4
   * http://paulkinzett.github.com/toolbar/
   * Copyright 2013 Paul Kinzett (http://kinzett.co.nz/)
   * Released under the MIT license.
   * <https://raw.github.com/paulkinzett/toolbar/master/LICENSE.txt>
   */
  
  if ( typeof Object.create !== 'function' ) {
      Object.create = function( obj ) {
          function F() {}
          F.prototype = obj;
          return new F();
      };
  }
  
  (function( $, window, document, undefined ) {
  
      var ToolBar = {
          init: function( options, elem ) {
              var self = this;
              self.elem = elem;
              self.$elem = $( elem );
              self.options = $.extend( {}, $.fn.toolbar.options, options );
              self.toolbar = $('<div class="tool-container gradient" />')
                  .addClass('tool-'+self.options.position)
                  .addClass('tool-rounded')
                  .append('<div class="tool-items" />')
                  .append('<div class="arrow" />')
                  .appendTo('body')
                  .css('opacity', 0)
                  .hide();
              self.toolbar_arrow = self.toolbar.find('.arrow');
              self.initializeToolbar();
          },
  
          initializeToolbar: function() {
              var self = this;
              self.populateContent();
              self.setTrigger();
              self.toolbarWidth = self.toolbar.width();
          },
  
          setTrigger: function() {
              var self = this;
  
              self.$elem.on('click', function(event) {
                  event.preventDefault();
                  if(self.$elem.hasClass('pressed')) {
                      self.hide();
                  } else {
                      self.show();
                  }
              });
  
              if (self.options.hideOnClick) {
                  $('html').on("click.toolbar", function ( event ) {
                      if (event.target != self.elem &&
                          self.$elem.has(event.target).length === 0 &&
                          self.toolbar.has(event.target).length === 0 &&
                          self.toolbar.is(":visible")) {
                          self.hide();
                      }
                  });
              }
  
              $(window).resize(function( event ) {
                  event.stopPropagation();
                  if ( self.toolbar.is(":visible") ) {
                      self.toolbarCss = self.getCoordinates(self.options.position, 20);
                      self.collisionDetection();
                      self.toolbar.css( self.toolbarCss );
                      self.toolbar_arrow.css( self.arrowCss );
                  }
              });
          },
  
          populateContent: function() {
              var self = this;
              var location = self.toolbar.find('.tool-items');
              var content = $(self.options.content).clone( true ).find('a').addClass('tool-item gradient');
              location.html(content);
              location.find('.tool-item').on('click', function(event) {
                  event.preventDefault();
                  self.$elem.trigger('toolbarItemClick', this);
              });
          },
  
          calculatePosition: function() {
              var self = this;
                  self.arrowCss = {};
                  self.toolbarCss = self.getCoordinates(self.options.position, 0);
                  self.toolbarCss.position = 'absolute';
                  self.toolbarCss.zIndex = self.options.zIndex;
                  self.collisionDetection();
                  self.toolbar.css(self.toolbarCss);
                  self.toolbar_arrow.css(self.arrowCss);
          },
  
          getCoordinates: function( position, adjustment ) {
              var self = this;
              self.coordinates = self.$elem.offset();
  
              if (self.options.adjustment && self.options.adjustment[self.options.position]) {
                  adjustment = self.options.adjustment[self.options.position];
              }
  
              switch(self.options.position) {
                  case 'top':
                      return {
                          left: self.coordinates.left-(self.toolbar.width()/2)+(self.$elem.outerWidth()/2),
                          top: self.coordinates.top-self.$elem.height()-adjustment,
                          right: 'auto'
                      };
                  case 'left':
                      return {
                          left: self.coordinates.left-(self.toolbar.width()/2)-(self.$elem.width()/2)-adjustment,
                          top: self.coordinates.top-(self.toolbar.height()/2)+(self.$elem.outerHeight()/2),
                          right: 'auto'
                      };
                  case 'right':
                      return {
                          left: self.coordinates.left+(self.toolbar.width()/2)+(self.$elem.width()/3)+adjustment,
                          top: self.coordinates.top-(self.toolbar.height()/2)+(self.$elem.outerHeight()/2),
                          right: 'auto'
                      };
                  case 'bottom':
                      return {
                          left: self.coordinates.left-(self.toolbar.width()/2)+(self.$elem.outerWidth()/2),
                          top: self.coordinates.top+self.$elem.height()+adjustment,
                          right: 'auto'
                      };
              }
          },
  
          collisionDetection: function() {
              var self = this;
              var edgeOffset = 20;
              if(self.options.position == 'top' || self.options.position == 'bottom') {
                  self.arrowCss = {left: '50%', right: '50%'};
                  if( self.toolbarCss.left < edgeOffset ) {
                      self.toolbarCss.left = edgeOffset;
                      self.arrowCss.left = self.$elem.offset().left + self.$elem.width()/2-(edgeOffset);
                  }
                  else if(($(window).width() - (self.toolbarCss.left + self.toolbarWidth)) < edgeOffset) {
                      self.toolbarCss.right = edgeOffset;
                      self.toolbarCss.left = 'auto';
                      self.arrowCss.left = 'auto';
                      self.arrowCss.right = ($(window).width()-self.$elem.offset().left)-(self.$elem.width()/2)-(edgeOffset)-5;
                  }
              }
          },
  
          show: function() {
              var self = this;
              var animation = {'opacity': 1};
  
              self.$elem.addClass('pressed');
              self.calculatePosition();
  
              switch(self.options.position) {
                  case 'top':
                      animation.top = '-=20';
                      break;
                  case 'left':
                      animation.left = '-=20';
                      break;
                  case 'right':
                      animation.left = '+=20';
                      break;
                  case 'bottom':
                      animation.top = '+=20';
                      break;
              }
  
              self.toolbar.show().animate(animation, 200 );
              self.$elem.trigger('toolbarShown');
          },
  
          hide: function() {
              var self = this;
              var animation = {'opacity': 0};
  
              self.$elem.removeClass('pressed');
  
              switch(self.options.position) {
                  case 'top':
                      animation.top = '+=20';
                      break;
                  case 'left':
                      animation.left = '+=20';
                      break;
                  case 'right':
                      animation.left = '-=20';
                      break;
                  case 'bottom':
                      animation.top = '-=20';
                      break;
              }
  
              self.toolbar.animate(animation, 200, function() {
                  self.toolbar.hide();
              });
  
              self.$elem.trigger('toolbarHidden');
          },
  
          getToolbarElement: function () {
              return this.toolbar.find('.tool-items');
          }
      };
  
      $.fn.toolbar = function( options ) {
          if ($.isPlainObject( options )) {
              return this.each(function() {
                  var toolbarObj = Object.create( ToolBar );
                  toolbarObj.init( options, this );
                  $(this).data('toolbarObj', toolbarObj);
              });
          } else if ( typeof options === 'string' && options.indexOf('_') !== 0 ) {
              var toolbarObj = $(this).data('toolbarObj');
              var method = toolbarObj[options];
              return method.apply(toolbarObj, $.makeArray(arguments).slice(1));
          }
      };
  
      $.fn.toolbar.options = {
          content: '#myContent',
          position: 'top',
          hideOnClick: false,
          zIndex: 120
      };
  
  }) ( jQuery, window, document );
  
  /*jshint
     asi: true,
     unused: true,
     boss: true,
     loopfunc: true,
     eqnull: true
   */
  
  
  /*!
   * Legacy browser support
   */
  
  // isArray support
  if ( !Array.isArray ) {
      Array.isArray = function( value ) {
          return {}.toString.call( value ) == '[object Array]'
      }
  }
  
  
  // Map array support
  if ( ![].map ) {
      Array.prototype.map = function ( callback, self ) {
          var array = this, len = array.length, newArray = new Array( len )
          for ( var i = 0; i < len; i++ ) {
              if ( i in array ) {
                  newArray[ i ] = callback.call( self, array[ i ], i, array )
              }
          }
          return newArray
      }
  }
  
  
  // Filter array support
  if ( ![].filter ) {
      Array.prototype.filter = function( callback ) {
          if ( this == null ) throw new TypeError()
          var t = Object( this ), len = t.length >>> 0
          if ( typeof callback != 'function' ) throw new TypeError()
          var newArray = [], thisp = arguments[ 1 ]
          for ( var i = 0; i < len; i++ ) {
            if ( i in t ) {
              var val = t[ i ]
              if ( callback.call( thisp, val, i, t ) ) newArray.push( val )
            }
          }
          return newArray
      }
  }
  
  
  // Index of array support
  if ( ![].indexOf ) {
      Array.prototype.indexOf = function( searchElement ) {
          if ( this == null ) throw new TypeError()
          var t = Object( this ), len = t.length >>> 0
          if ( len === 0 ) return -1
          var n = 0
          if ( arguments.length > 1 ) {
              n = Number( arguments[ 1 ] )
              if ( n != n ) {
                  n = 0
              }
              else if ( n !== 0 && n != Infinity && n != -Infinity ) {
                  n = ( n > 0 || -1 ) * Math.floor( Math.abs( n ) )
              }
          }
          if ( n >= len ) return -1
          var k = n >= 0 ? n : Math.max( len - Math.abs( n ), 0 )
          for ( ; k < len; k++ ) {
              if ( k in t && t[ k ] === searchElement ) return k
          }
          return -1
      }
  }
  
  
  /*!
   * Cross-Browser Split 1.1.1
   * Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
   * Available under the MIT License
   * http://blog.stevenlevithan.com/archives/cross-browser-split
   */
  var nativeSplit = String.prototype.split, compliantExecNpcg = /()??/.exec('')[1] === undefined
  String.prototype.split = function(separator, limit) {
      var str = this
      if (Object.prototype.toString.call(separator) !== '[object RegExp]') {
          return nativeSplit.call(str, separator, limit)
      }
      var output = [],
          flags = (separator.ignoreCase ? 'i' : '') +
                  (separator.multiline  ? 'm' : '') +
                  (separator.extended   ? 'x' : '') +
                  (separator.sticky     ? 'y' : ''),
          lastLastIndex = 0,
          separator2, match, lastIndex, lastLength
      separator = new RegExp(separator.source, flags + 'g')
      str += ''
      if (!compliantExecNpcg) {
          separator2 = new RegExp('^' + separator.source + '$(?!\\s)', flags)
      }
      limit = limit === undefined ? -1 >>> 0 : limit >>> 0
      while (match = separator.exec(str)) {
          lastIndex = match.index + match[0].length
          if (lastIndex > lastLastIndex) {
              output.push(str.slice(lastLastIndex, match.index))
              if (!compliantExecNpcg && match.length > 1) {
                  match[0].replace(separator2, function () {
                      for (var i = 1; i < arguments.length - 2; i++) {
                          if (arguments[i] === undefined) {
                              match[i] = undefined
                          }
                      }
                  })
              }
              if (match.length > 1 && match.index < str.length) {
                  Array.prototype.push.apply(output, match.slice(1))
              }
              lastLength = match[0].length
              lastLastIndex = lastIndex
              if (output.length >= limit) {
                  break
              }
          }
          if (separator.lastIndex === match.index) {
              separator.lastIndex++
          }
      }
      if (lastLastIndex === str.length) {
          if (lastLength || !separator.test('')) {
              output.push('')
          }
      } else {
          output.push(str.slice(lastLastIndex))
      }
      return output.length > limit ? output.slice(0, limit) : output
  }
  
  /*!
   * pickadate.js v3.1.1, 2013/06/28
   * By Amsul, http://amsul.ca
   * Hosted on http://amsul.github.io/pickadate.js
   * Licensed under MIT
   */
  
  /*jshint
     debug: true,
     devel: true,
     browser: true,
     asi: true,
     unused: true,
     boss: true,
     eqnull: true
   */
  
  
  // Create a global scope.
  window.Picker = (function( $, $document, undefined ) {
  
  
  /**
   * The picker constructor that creates a blank picker.
   */
  function PickerConstructor( ELEMENT, NAME, COMPONENT, OPTIONS ) {
  
      // If there’s no element, return the picker constructor.
      if ( !ELEMENT ) return PickerConstructor
  
  
      var
          // The state of the picker.
          STATE = {
              id: Math.abs( ~~( Math.random() * 1e9 ) )
          },
  
  
          // Merge the defaults and options passed.
          SETTINGS = COMPONENT ? $.extend( true, {}, COMPONENT.defaults, OPTIONS ) : OPTIONS || {},
  
  
          // Merge the default classes with the settings classes.
          CLASSES = $.extend( {}, PickerConstructor.klasses(), SETTINGS.klass ),
  
  
          // The element node wrapper into a jQuery object.
          $ELEMENT = $( ELEMENT ),
  
  
          // Pseudo picker constructor.
          PickerInstance = function() {
              return this.start()
          },
  
  
          // The picker prototype.
          P = PickerInstance.prototype = {
  
              constructor: PickerInstance,
  
              $node: $ELEMENT,
  
  
              /**
               * Initialize everything
               */
              start: function() {
  
                  // If it’s already started, do nothing.
                  if ( STATE && STATE.start ) return P
  
  
                  // Update the picker states.
                  STATE.methods = {}
                  STATE.start = true
                  STATE.open = false
                  STATE.type = ELEMENT.type
  
  
                  // Confirm focus state, save original type, convert into text input
                  // to remove UA stylings, and set as readonly to prevent keyboard popup.
                  ELEMENT.autofocus = ELEMENT == document.activeElement
                  ELEMENT.type = 'text'
                  ELEMENT.readOnly = true
  
  
                  // Create a new picker component with the settings.
                  P.component = new COMPONENT( P, SETTINGS )
  
  
                  // Create the picker root with a new wrapped holder and bind the events.
                  P.$root = $( PickerConstructor._.node( 'div', createWrappedComponent(), CLASSES.picker ) ).on({
  
                      // When something within the root is focused, stop from bubbling
                      // to the doc and remove the “focused” state from the root.
                      focusin: function( event ) {
                          P.$root.removeClass( CLASSES.focused )
                          event.stopPropagation()
                      },
  
                      // If the event is not on the root holder, stop it from bubbling to the doc.
                      mousedown: function( event ) {
                          if ( event.target != P.$root.children()[ 0 ] ) {
                              event.stopPropagation()
                          }
                      },
  
                      // When something within the root holder is clicked, handle the various event.
                      click: function( event ) {
  
                          var target = event.target,
                              $target = target.attributes.length ? $( target ) : $( target ).closest( '[data-pick]' ),
                              targetData = $target.data()
  
                          // If the event is not on the root holder itself, handle the clicks within.
                          if ( target != P.$root.children()[ 0 ] ) {
  
                              // Stop it from propagating to the doc.
                              event.stopPropagation()
  
                              // If nothing inside is actively focused, re-focus the element.
                              if ( !P.$root.find( document.activeElement ).length ) {
                                  ELEMENT.focus()
                              }
  
                              // If something is superficially changed, update the `highlight` based on the `nav`.
                              if ( targetData.nav && !$target.hasClass( CLASSES.navDisabled ) ) {
                                  P.set( 'highlight', P.component.item.highlight, { nav: targetData.nav } )
                              }
  
                              // If something is picked, set `select` then close with focus.
                              else if ( PickerConstructor._.isInteger( targetData.pick ) && !$target.hasClass( CLASSES.disabled ) ) {
                                  P.set( 'select', targetData.pick ).close( true )
                              }
  
                              // If a “clear” button is pressed, empty the values and close with focus.
                              else if ( targetData.clear ) {
                                  P.clear().close( true )
                              }
                          }
                      }
                  }) //P.$root
  
  
                  // If there’s a format for the hidden input element, create the element
                  // using the name of the original input plus suffix. Otherwise set it to null.
                  // If the element has a value, use either the `data-value` or `value`.
                  P._hidden = SETTINGS.formatSubmit ? $( '<input type=hidden name=' + ELEMENT.name + ( SETTINGS.hiddenSuffix || '_submit' ) + ( $ELEMENT.data( 'value' ) ? ' value="' + PickerConstructor._.trigger( P.component.formats.toString, P.component, [ SETTINGS.formatSubmit, P.component.item.select ] ) + '"' : '' ) + '>' )[ 0 ] : undefined
  
  
                  // Add the class and bind the events on the element.
                  $ELEMENT.addClass( CLASSES.input ).
  
                      // On focus/click, open the picker and adjust the root “focused” state.
                      on( 'focus.P' + STATE.id + ' click.P' + STATE.id, focusToOpen ).
  
                      // If the value changes, update the hidden input with the correct format.
                      on( 'change.P' + STATE.id, function() {
                          if ( P._hidden ) {
                              P._hidden.value = ELEMENT.value ? PickerConstructor._.trigger( P.component.formats.toString, P.component, [ SETTINGS.formatSubmit, P.component.item.select ] ) : ''
                          }
                      }).
  
                      // Handle keyboard event based on the picker being opened or not.
                      on( 'keydown.P' + STATE.id, function( event ) {
  
                          var keycode = event.keyCode,
  
                              // Check if one of the delete keys was pressed.
                              isKeycodeDelete = /^(8|46)$/.test( keycode )
  
                          // For some reason IE clears the input value on “escape”.
                          if ( keycode == 27 ) {
                              P.close()
                              return false
                          }
  
                          // Check if `space` or `delete` was pressed or the picker is closed with a key movement.
                          if ( keycode == 32 || isKeycodeDelete || !STATE.open && P.component.key[ keycode ] ) {
  
                              // Prevent it from moving the page and bubbling to doc.
                              event.preventDefault()
                              event.stopPropagation()
  
                              // If `delete` was pressed, clear the values and close the picker.
                              // Otherwise open the picker.
                              if ( isKeycodeDelete ) { P.clear().close() }
                              else { P.open() }
                          }
                      }).
  
                      // If there’s a `data-value`, update the value of the element.
                      val( $ELEMENT.data( 'value' ) ? PickerConstructor._.trigger( P.component.formats.toString, P.component, [ SETTINGS.format, P.component.item.select ] ) : ELEMENT.value ).
  
                      // Insert the root and hidden input after the element.
                      after( P.$root, P._hidden ).
  
                      // Store the picker data by component name.
                      data( NAME, P )
  
  
                  // Bind the default component and settings events.
                  P.on({
                      start: P.component.onStart,
                      render: P.component.onRender,
                      stop: P.component.onStop,
                      open: P.component.onOpen,
                      close: P.component.onClose,
                      set: P.component.onSet
                  }).on({
                      start: SETTINGS.onStart,
                      render: SETTINGS.onRender,
                      stop: SETTINGS.onStop,
                      open: SETTINGS.onOpen,
                      close: SETTINGS.onClose,
                      set: SETTINGS.onSet
                  })
  
  
                  // If the element has autofocus, open the picker.
                  if ( ELEMENT.autofocus ) {
                      P.open()
                  }
  
  
                  // Trigger queued the “start” and “render” events.
                  return P.trigger( 'start' ).trigger( 'render' )
              }, //start
  
  
              /**
               * Render a new picker within the root
               */
              render: function() {
  
                  // Insert a new component holder in the root.
                  P.$root.html( createWrappedComponent() )
  
                  // Trigger the queued “render” events.
                  return P.trigger( 'render' )
              }, //render
  
  
              /**
               * Destroy everything
               */
              stop: function() {
  
                  // If it’s already stopped, do nothing.
                  if ( !STATE.start ) return P
  
                  // Then close the picker.
                  P.close()
  
                  // Remove the hidden field.
                  if ( P._hidden ) {
                      P._hidden.parentNode.removeChild( P._hidden )
                  }
  
                  // Remove the root.
                  P.$root.remove()
  
                  // Remove the input class, unbind the events, and remove the stored data.
                  $ELEMENT.removeClass( CLASSES.input ).off( '.P' + STATE.id ).removeData( NAME )
  
                  // Restore the element state
                  ELEMENT.type = STATE.type
                  ELEMENT.readOnly = false
  
                  // Trigger the queued “stop” events.
                  P.trigger( 'stop' )
  
                  // Reset the picker states.
                  STATE.methods = {}
                  STATE.start = false
  
                  return P
              }, //stop
  
  
              /*
               * Open up the picker
               */
              open: function( dontGiveFocus ) {
  
                  // If it’s already open, do nothing.
                  if ( STATE.open ) return P
  
                  // Add the “active” class.
                  $ELEMENT.addClass( CLASSES.active )
  
                  // Add the “opened” class to the picker root.
                  P.$root.addClass( CLASSES.opened )
  
                  // If we have to give focus, bind the element and doc events.
                  if ( dontGiveFocus !== false ) {
  
                      // Set it as open.
                      STATE.open = true
  
                      // Pass focus to the element’s jQuery object.
                      $ELEMENT.focus()
  
                      // Bind the document events.
                      $document.on( 'click.P' + STATE.id + ' focusin.P' + STATE.id, function( event ) {
  
                          // If the target of the event is not the element, close the picker picker.
                          // * Don’t worry about clicks or focusins on the root because those don’t bubble up.
                          //   Also, for Firefox, a click on an `option` element bubbles up directly
                          //   to the doc. So make sure the target wasn't the doc.
                          if ( event.target != ELEMENT && event.target != document ) P.close()
  
                      }).on( 'keydown.P' + STATE.id, function( event ) {
  
                          var
                              // Get the keycode.
                              keycode = event.keyCode,
  
                              // Translate that to a selection change.
                              keycodeToMove = P.component.key[ keycode ],
  
                              // Grab the target.
                              target = event.target
  
  
                          // On escape, close the picker and give focus.
                          if ( keycode == 27 ) {
                              P.close( true )
                          }
  
  
                          // Check if there is a key movement or “enter” keypress on the element.
                          else if ( target == ELEMENT && ( keycodeToMove || keycode == 13 ) ) {
  
                              // Prevent the default action to stop page movement.
                              event.preventDefault()
  
                              // Trigger the key movement action.
                              if ( keycodeToMove ) {
                                  PickerConstructor._.trigger( P.component.key.go, P, [ keycodeToMove ] )
                              }
  
                              // On “enter”, if the highlighted item isn’t disabled, set the value and close.
                              else if ( !P.$root.find( '.' + CLASSES.highlighted ).hasClass( CLASSES.disabled ) ) {
                                  P.set( 'select', P.component.item.highlight ).close()
                              }
                          }
  
  
                          // If the target is within the root and “enter” is pressed,
                          // prevent the default action and trigger a click on the target instead.
                          else if ( P.$root.find( target ).length && keycode == 13 ) {
                              event.preventDefault()
                              target.click()
                          }
                      })
                  }
  
                  // Trigger the queued “open” events.
                  return P.trigger( 'open' )
              }, //open
  
  
              /**
               * Close the picker
               */
              close: function( giveFocus ) {
  
                  // If we need to give focus, do it before changing states.
                  if ( giveFocus ) {
                      // ....ah yes! It would’ve been incomplete without a crazy workaround for IE :|
                      // The focus is triggered *after* the close has completed - causing it
                      // to open again. So unbind and rebind the event at the next tick.
                      $ELEMENT.off( 'focus.P' + STATE.id ).focus()
                      setTimeout( function() {
                          $ELEMENT.on( 'focus.P' + STATE.id, focusToOpen )
                      }, 0 )
                  }
  
                  // Remove the “active” class.
                  $ELEMENT.removeClass( CLASSES.active )
  
                  // Remove the “opened” and “focused” class from the picker root.
                  P.$root.removeClass( CLASSES.opened + ' ' + CLASSES.focused )
  
                  // If it’s open, update the state.
                  if ( STATE.open ) {
  
                      // Set it as closed.
                      STATE.open = false
  
                      // Unbind the document events.
                      $document.off( '.P' + STATE.id )
                  }
  
                  // Trigger the queued “close” events.
                  return P.trigger( 'close' )
              }, //close
  
  
              /**
               * Clear the values
               */
              clear: function() {
                  return P.set( 'clear' )
              }, //clear
  
  
              /**
               * Set something
               */
              set: function( thing, value, options ) {
  
                  var thingItem, thingValue,
                      thingIsObject = PickerConstructor._.isObject( thing ),
                      thingObject = thingIsObject ? thing : {}
  
                  if ( thing ) {
  
                      // If the thing isn’t an object, make it one.
                      if ( !thingIsObject ) {
                          thingObject[ thing ] = value
                      }
  
                      // Go through the things of items to set.
                      for ( thingItem in thingObject ) {
  
                          // Grab the value of the thing.
                          thingValue = thingObject[ thingItem ]
  
                          // First, if the item exists and there’s a value, set it.
                          if ( P.component.item[ thingItem ] ) {
                              P.component.set( thingItem, thingValue, options || {} )
                          }
  
                          // Then, check to update the element value and broadcast a change.
                          if ( thingItem == 'select' || thingItem == 'clear' ) {
                              $ELEMENT.val( thingItem == 'clear' ? '' :
                                  PickerConstructor._.trigger( P.component.formats.toString, P.component, [ SETTINGS.format, P.component.get( thingItem ) ] )
                              ).trigger( 'change' )
                          }
                      }
  
                      // Render a new picker.
                      P.render()
                  }
  
                  // Trigger queued “set” events and pass the `thingObject`.
                  return P.trigger( 'set', thingObject )
              }, //set
  
  
              /**
               * Get something
               */
              get: function( thing, format ) {
  
                  // Make sure there’s something to get.
                  thing = thing || 'value'
  
                  // If a picker state exists, return that.
                  if ( STATE[ thing ] != null ) {
                      return STATE[ thing ]
                  }
  
                  // Return the value, if that.
                  if ( thing == 'value' ) {
                      return ELEMENT.value
                  }
  
                  // Check if a component item exists, return that.
                  if ( P.component.item[ thing ] ) {
                      if ( typeof format == 'string' ) {
                          return PickerConstructor._.trigger( P.component.formats.toString, P.component, [ format, P.component.get( thing ) ] )
                      }
                      return P.component.get( thing )
                  }
              }, //get
  
  
  
              /**
               * Bind events on the things.
               */
              on: function( thing, method ) {
  
                  var thingName, thingMethod,
                      thingIsObject = PickerConstructor._.isObject( thing ),
                      thingObject = thingIsObject ? thing : {}
  
                  if ( thing ) {
  
                      // If the thing isn’t an object, make it one.
                      if ( !thingIsObject ) {
                          thingObject[ thing ] = method
                      }
  
                      // Go through the things to bind to.
                      for ( thingName in thingObject ) {
  
                          // Grab the method of the thing.
                          thingMethod = thingObject[ thingName ]
  
                          // Make sure the thing methods collection exists.
                          STATE.methods[ thingName ] = STATE.methods[ thingName ] || []
  
                          // Add the method to the relative method collection.
                          STATE.methods[ thingName ].push( thingMethod )
                      }
                  }
  
                  return P
              }, //on
  
  
              /**
               * Fire off method events.
               */
              trigger: function( name, data ) {
                  var methodList = STATE.methods[ name ]
                  if ( methodList ) {
                      methodList.map( function( method ) {
                          PickerConstructor._.trigger( method, P, [ data ] )
                      })
                  }
                  return P
              } //trigger
          } //PickerInstance.prototype
  
  
      /**
       * Wrap the picker holder components together.
       */
      function createWrappedComponent() {
  
          // Create a picker wrapper holder
          return PickerConstructor._.node( 'div',
  
              // Create a picker wrapper node
              PickerConstructor._.node( 'div',
  
                  // Create a picker frame
                  PickerConstructor._.node( 'div',
  
                      // Create a picker box node
                      PickerConstructor._.node( 'div',
  
                          // Create the components nodes.
                          P.component.nodes( STATE.open ),
  
                          // The picker box class
                          CLASSES.box
                      ),
  
                      // Picker wrap class
                      CLASSES.wrap
                  ),
  
                  // Picker frame class
                  CLASSES.frame
              ),
  
              // Picker holder class
              CLASSES.holder
          ) //endreturn
      } //createWrappedComponent
  
  
      // Separated for IE
      function focusToOpen( event ) {
  
          // Stop the event from propagating to the doc.
          event.stopPropagation()
  
          // If it’s a focus event, add the “focused” class to the root.
          if ( event.type == 'focus' ) P.$root.addClass( CLASSES.focused )
  
          // And then finally open the picker.
          P.open()
      }
  
  
      // Return a new picker instance.
      return new PickerInstance()
  } //PickerConstructor
  
  
  
  /**
   * The default classes and prefix to use for the HTML classes.
   */
  PickerConstructor.klasses = function( prefix ) {
      prefix = prefix || 'picker'
      return {
  
          picker: prefix,
          opened: prefix + '--opened',
          focused: prefix + '--focused',
  
          input: prefix + '__input',
          active: prefix + '__input--active',
  
          holder: prefix + '__holder',
  
          frame: prefix + '__frame',
          wrap: prefix + '__wrap',
  
          box: prefix + '__box'
      }
  } //PickerConstructor.klasses
  
  
  
  /**
   * PickerConstructor helper methods.
   */
  PickerConstructor._ = {
  
      /**
       * Create a group of nodes. Expects:
       * `
          {
              min:    {Integer},
              max:    {Integer},
              i:      {Integer},
              node:   {String},
              item:   {Function}
          }
       * `
       */
      group: function( groupObject ) {
  
          var
              // Scope for the looped object
              loopObjectScope,
  
              // Create the nodes list
              nodesList = '',
  
              // The counter starts from the `min`
              counter = PickerConstructor._.trigger( groupObject.min, groupObject )
  
  
          // Loop from the `min` to `max`, incrementing by `i`
          for ( ; counter <= PickerConstructor._.trigger( groupObject.max, groupObject, [ counter ] ); counter += groupObject.i ) {
  
              // Trigger the `item` function within scope of the object
              loopObjectScope = PickerConstructor._.trigger( groupObject.item, groupObject, [ counter ] )
  
              // Splice the subgroup and create nodes out of the sub nodes
              nodesList += PickerConstructor._.node(
                  groupObject.node,
                  loopObjectScope[ 0 ],   // the node
                  loopObjectScope[ 1 ],   // the classes
                  loopObjectScope[ 2 ]    // the attributes
              )
          }
  
          // Return the list of nodes
          return nodesList
      }, //group
  
  
      /**
       * Create a dom node string
       */
      node: function( wrapper, item, klass, attribute ) {
  
          // If the item is false-y, just return an empty string
          if ( !item ) return ''
  
          // If the item is an array, do a join
          item = Array.isArray( item ) ? item.join( '' ) : item
  
          // Check for the class
          klass = klass ? ' class="' + klass + '"' : ''
  
          // Check for any attributes
          attribute = attribute ? ' ' + attribute : ''
  
          // Return the wrapped item
          return '<' + wrapper + klass + attribute + '>' + item + '</' + wrapper + '>'
      }, //node
  
  
      /**
       * Lead numbers below 10 with a zero.
       */
      lead: function( number ) {
          return ( number < 10 ? '0': '' ) + number
      },
  
  
      /**
       * Trigger a function otherwise return the value.
       */
      trigger: function( callback, scope, args ) {
          return typeof callback == 'function' ? callback.apply( scope, args || [] ) : callback
      },
  
  
      /**
       * If the second character is a digit, length is 2 otherwise 1.
       */
      digits: function( string ) {
          return ( /\d/ ).test( string[ 1 ] ) ? 2 : 1
      },
  
  
      /**
       * Tell if something is an object.
       */
      isObject: function( value ) {
          return {}.toString.call( value ).indexOf( 'Object' ) > -1
      },
  
  
      /**
       * Tell if something is a date object.
       */
      isDate: function( value ) {
          return {}.toString.call( value ).indexOf( 'Date' ) > -1 && this.isInteger( value.getDate() )
      },
  
  
      /**
       * Tell if something is an integer.
       */
      isInteger: function( value ) {
          return {}.toString.call( value ).indexOf( 'Number' ) > -1 && value % 1 === 0
      }
  } //PickerConstructor._
  
  
  
  /**
   * Extend the picker with a component and defaults.
   */
  PickerConstructor.extend = function( name, Component ) {
  
      // Extend jQuery.
      $.fn[ name ] = function( options, action ) {
  
          // Grab the component data.
          var componentData = this.data( name )
  
          // If the picker is requested, return the data object.
          if ( options == 'picker' ) {
              return componentData
          }
  
          // If the component data exists and `options` is a string, carry out the action.
          if ( componentData && typeof options == 'string' ) {
              PickerConstructor._.trigger( componentData[ options ], componentData, [ action ] )
              return this
          }
  
          // Otherwise go through each matched element and if the component
          // doesn’t exist, create a new picker using `this` element
          // and merging the defaults and options with a deep copy.
          return this.each( function() {
              var $this = $( this )
              if ( !$this.data( name ) ) {
                  new PickerConstructor( this, name, Component, options )
              }
          })
      }
  
      // Set the defaults.
      $.fn[ name ].defaults = Component.defaults
  } //PickerConstructor.extend
  
  
  
  // Return the picker constructor.
  return PickerConstructor
  
  
  // Close the global scope.
  })( jQuery, jQuery( document ) );
  
  
  
  
  /*!
   * Date picker for pickadate.js v3.1.1
   * http://amsul.github.io/pickadate.js/date.htm
   */
  
  /*jshint
     debug: true,
     devel: true,
     browser: true,
     asi: true,
     unused: true,
     boss: true
   */
  
  
  // Create a new scope.
  (function() {
  
  
  /**
   * Globals and constants
   */
  var DAYS_IN_WEEK = 7,
      WEEKS_IN_CALENDAR = 6
  
  
  
  /**
   * The date picker constructor
   */
  function DatePicker( picker, settings ) {
  
      var calendar = this,
          elementValue = picker.$node[ 0 ].value,
          elementDataValue = picker.$node.data( 'value' ),
          valueString = elementDataValue || elementValue,
          formatString = elementDataValue ? settings.formatSubmit : settings.format
  
      calendar.settings = settings
  
      // The queue of methods that will be used to build item objects.
      calendar.queue = {
          min: 'measure create',
          max: 'measure create',
          now: 'now create',
          select: 'parse create validate',
          highlight: 'navigate create validate',
          view: 'create validate viewset',
          disable: 'flipItem',
          enable: 'flipItem'
      }
  
      // The component's item object.
      calendar.item = {}
  
      calendar.item.disable = ( settings.disable || [] ).slice( 0 )
      calendar.item.enable = -(function( collectionDisabled ) {
          return collectionDisabled[ 0 ] === true ? collectionDisabled.shift() : -1
      })( calendar.item.disable )
  
      calendar.
          set( 'min', settings.min ).
          set( 'max', settings.max ).
          set( 'now' ).
  
          // Setting the `select` also sets the `highlight` and `view`.
          set( 'select',
  
              // Use the value provided or default to selecting “today”.
              valueString || calendar.item.now,
              {
                  // Use the appropriate format.
                  format: formatString,
  
                  // Set user-provided month data as true when there is a
                  // “mm” or “m” used in the relative format string.
                  data: (function( formatArray ) {
                      return valueString && ( formatArray.indexOf( 'mm' ) > -1 || formatArray.indexOf( 'm' ) > -1 )
                  })( calendar.formats.toArray( formatString ) )
              }
          )
  
  
      // The keycode to movement mapping.
      calendar.key = {
          40: 7, // Down
          38: -7, // Up
          39: 1, // Right
          37: -1, // Left
          go: function( timeChange ) {
              calendar.set( 'highlight', [ calendar.item.highlight.year, calendar.item.highlight.month, calendar.item.highlight.date + timeChange ], { interval: timeChange } )
              this.render()
          }
      }
  
  
      // Bind some picker events.
      picker.
          on( 'render', function() {
              picker.$root.find( '.' + settings.klass.selectMonth ).on( 'change', function() {
                  picker.set( 'highlight', [ picker.get( 'view' ).year, this.value, picker.get( 'highlight' ).date ] )
                  picker.$root.find( '.' + settings.klass.selectMonth ).focus()
              })
              picker.$root.find( '.' + settings.klass.selectYear ).on( 'change', function() {
                  picker.set( 'highlight', [ this.value, picker.get( 'view' ).month, picker.get( 'highlight' ).date ] )
                  picker.$root.find( '.' + settings.klass.selectYear ).focus()
              })
          }).
          on( 'open', function() {
              picker.$root.find( 'button, select' ).attr( 'disabled', false )
          }).
          on( 'close', function() {
              picker.$root.find( 'button, select' ).attr( 'disabled', true )
          })
  
  } //DatePicker
  
  
  /**
   * Set a datepicker item object.
   */
  DatePicker.prototype.set = function( type, value, options ) {
  
      var calendar = this
  
      // Go through the queue of methods, and invoke the function. Update this
      // as the time unit, and set the final resultant as this item type.
      // * In the case of `enable`, keep the queue but set `disable` instead.
      //   And in the case of `flip`, keep the queue but set `enable` instead.
      calendar.item[ ( type == 'enable' ? 'disable' : type == 'flip' ? 'enable' : type ) ] = calendar.queue[ type ].split( ' ' ).map( function( method ) {
          return value = calendar[ method ]( type, value, options )
      }).pop()
  
      // Check if we need to cascade through more updates.
      if ( type == 'select' ) {
          calendar.set( 'highlight', calendar.item.select, options )
      }
      else if ( type == 'highlight' ) {
          calendar.set( 'view', calendar.item.highlight, options )
      }
      else if ( ( type == 'flip' || type == 'min' || type == 'max' || type == 'disable' || type == 'enable' ) && calendar.item.select && calendar.item.highlight ) {
          calendar.
              set( 'select', calendar.item.select, options ).
              set( 'highlight', calendar.item.highlight, options )
      }
  
      return calendar
  } //DatePicker.prototype.set
  
  
  /**
   * Get a datepicker item object.
   */
  DatePicker.prototype.get = function( type ) {
      return this.item[ type ]
  } //DatePicker.prototype.get
  
  
  /**
   * Create a picker date object.
   */
  DatePicker.prototype.create = function( type, value, options ) {
  
      var isInfiniteValue,
          calendar = this
  
      // If there’s no value, use the type as the value.
      value = value === undefined ? type : value
  
  
      // If it’s infinity, update the value.
      if ( value == -Infinity || value == Infinity ) {
          isInfiniteValue = value
      }
  
      // If it’s an object, use the native date object.
      else if ( Picker._.isObject( value ) && Picker._.isInteger( value.pick ) ) {
          value = value.obj
      }
  
      // If it’s an array, convert it into a date and make sure
      // that it’s a valid date – otherwise default to today.
      else if ( Array.isArray( value ) ) {
          value = new Date( value[ 0 ], value[ 1 ], value[ 2 ] )
          value = Picker._.isDate( value ) ? value : calendar.create().obj
      }
  
      // If it’s a number or date object, make a normalized date.
      else if ( Picker._.isInteger( value ) || Picker._.isDate( value ) ) {
          value = calendar.normalize( new Date( value ), options )
      }
  
      // If it’s a literal true or any other case, set it to now.
      else /*if ( value === true )*/ {
          value = calendar.now( type, value, options )
      }
  
      // Return the compiled object.
      return {
          year: isInfiniteValue || value.getFullYear(),
          month: isInfiniteValue || value.getMonth(),
          date: isInfiniteValue || value.getDate(),
          day: isInfiniteValue || value.getDay(),
          obj: isInfiniteValue || value,
          pick: isInfiniteValue || value.getTime()
      }
  } //DatePicker.prototype.create
  
  
  /**
   * Get the date today.
   */
  DatePicker.prototype.now = function( type, value, options ) {
      value = new Date()
      if ( options && options.rel ) {
          value.setDate( value.getDate() + options.rel )
      }
      return this.normalize( value, options )
  } //DatePicker.prototype.now
  
  
  /**
   * Navigate to next/prev month.
   */
  DatePicker.prototype.navigate = function( type, value, options ) {
  
      if ( Picker._.isObject( value ) ) {
  
          var targetDateObject = new Date( value.year, value.month + ( options && options.nav ? options.nav : 0 ), 1 ),
              year = targetDateObject.getFullYear(),
              month = targetDateObject.getMonth(),
              date = value.date
  
          // Make sure the date is valid and if the month we’re going to doesn’t have enough
          // days, keep decreasing the date until we reach the month’s last date.
          while ( Picker._.isDate( targetDateObject ) && new Date( year, month, date ).getMonth() !== month ) {
              date -= 1
          }
  
          value = [ year, month, date ]
      }
  
      return value
  } //DatePicker.prototype.navigate
  
  
  /**
   * Normalize a date by setting the hours to midnight.
   */
  DatePicker.prototype.normalize = function( value/*, options*/ ) {
      value.setHours( 0, 0, 0, 0 )
      return value
  }
  
  
  /**
   * Measure the range of dates.
   */
  DatePicker.prototype.measure = function( type, value/*, options*/ ) {
  
      var calendar = this
  
      // If it's anything false-y, remove the limits.
      if ( !value ) {
          value = type == 'min' ? -Infinity : Infinity
      }
  
      // If it's an integer, get a date relative to today.
      else if ( Picker._.isInteger( value ) ) {
          value = calendar.now( type, value, { rel: value } )
      }
  
      return value
  } ///DatePicker.prototype.measure
  
  
  /**
   * Create a viewset object based on navigation.
   */
  DatePicker.prototype.viewset = function( type, dateObject/*, options*/ ) {
      return this.create([ dateObject.year, dateObject.month, 1 ])
  }
  
  
  /**
   * Validate a date as enabled and shift if needed.
   */
  DatePicker.prototype.validate = function( type, dateObject, options ) {
  
      var calendar = this,
  
          // Keep a reference to the original date.
          originalDateObject = dateObject,
  
          // Make sure we have an interval.
          interval = options && options.interval ? options.interval : 1,
  
          // Check if the calendar enabled dates are inverted.
          isInverted = calendar.item.enable === -1,
  
          // Check if we have any enabled dates after/before now.
          hasEnabledBeforeTarget, hasEnabledAfterTarget,
  
          // The min & max limits.
          minLimitObject = calendar.item.min,
          maxLimitObject = calendar.item.max,
  
          // Check if we’ve reached the limit during shifting.
          reachedMin, reachedMax,
  
          // Check if the calendar is inverted and at least one weekday is enabled.
          hasEnabledWeekdays = isInverted && calendar.item.disable.filter( function( value ) {
  
              // If there’s a date, check where it is relative to the target.
              if ( Array.isArray( value ) ) {
                  var dateTime = calendar.create( value ).pick
                  if ( dateTime < dateObject.pick ) hasEnabledBeforeTarget = true
                  else if ( dateTime > dateObject.pick ) hasEnabledAfterTarget = true
              }
  
              // Return only integers for enabled weekdays.
              return Picker._.isInteger( value )
          }).length
  
  
  
      // Cases to validate for:
      // [1] Not inverted and date disabled.
      // [2] Inverted and some dates enabled.
      // [3] Out of range.
      //
      // Cases to **not** validate for:
      // • Not inverted and date enabled.
      // • Inverted and all dates disabled.
      // • Navigating months.
      // • ..and anything else.
      if (
          /* 1 */ ( !isInverted && calendar.disabled( dateObject ) ) ||
          /* 2 */ ( isInverted && calendar.disabled( dateObject ) && ( hasEnabledWeekdays || hasEnabledBeforeTarget || hasEnabledAfterTarget ) ) ||
          /* 3 */ ( dateObject.pick <= minLimitObject.pick || dateObject.pick >= maxLimitObject.pick )
      ) {
  
  
          // When inverted, flip the direction if there aren’t any enabled weekdays
          // and there are no enabled dates in the direction of the interval.
          if ( isInverted && !hasEnabledWeekdays && ( ( !hasEnabledAfterTarget && interval > 0 ) || ( !hasEnabledBeforeTarget && interval < 0 ) ) ) {
              interval *= -1
          }
  
  
          // Keep looping until we reach an enabled date.
          while ( calendar.disabled( dateObject ) ) {
  
  
              // If we’ve looped into the next/prev month, return to the original date and flatten the interval.
              if ( Math.abs( interval ) > 1 && ( dateObject.month < originalDateObject.month || dateObject.month > originalDateObject.month ) ) {
                  dateObject = originalDateObject
                  interval = Math.abs( interval ) / interval
              }
  
  
              // If we’ve reached the min/max limit, reverse the direction and flatten the interval.
              if ( dateObject.pick <= minLimitObject.pick ) {
                  reachedMin = true
                  interval = 1
              }
              else if ( dateObject.pick >= maxLimitObject.pick ) {
                  reachedMax = true
                  interval = -1
              }
  
  
              // If we’ve reached both limits, just break out of the loop.
              if ( reachedMin && reachedMax ) {
                  break
              }
  
  
              // Finally, create the shifted date using the interval and keep looping.
              dateObject = calendar.create([ dateObject.year, dateObject.month, dateObject.date + interval ])
          }
  
      } //endif
  
  
      // Return the date object settled on.
      return dateObject
  } //DatePicker.prototype.validate
  
  
  /**
   * Check if an object is disabled.
   */
  DatePicker.prototype.disabled = function( dateObject ) {
  
      var calendar = this,
  
          // Filter through the disabled dates to check if this is one.
          isDisabledDate = calendar.item.disable.filter( function( dateToDisable ) {
  
              // If the date is a number, match the weekday with 0index and `firstDay` check.
              if ( Picker._.isInteger( dateToDisable ) ) {
                  return dateObject.day === ( calendar.settings.firstDay ? dateToDisable : dateToDisable - 1 ) % 7
              }
  
              // If it's an array, create the object and match the exact date.
              if ( Array.isArray( dateToDisable ) ) {
                  return dateObject.pick === calendar.create( dateToDisable ).pick
              }
          }).length
  
  
      // It’s disabled beyond the min/max limits. If within the limits, check the
      // calendar “enabled” flag is flipped and respectively flip the condition.
      return dateObject.pick < calendar.item.min.pick ||
          dateObject.pick > calendar.item.max.pick ||
          calendar.item.enable === -1 ? !isDisabledDate : isDisabledDate
  } //DatePicker.prototype.disabled
  
  
  /**
   * Parse a string into a usable type.
   */
  DatePicker.prototype.parse = function( type, value, options ) {
  
      var calendar = this,
          parsingObject = {}
  
      if ( !value || Picker._.isInteger( value ) || Array.isArray( value ) || Picker._.isDate( value ) || Picker._.isObject( value ) && Picker._.isInteger( value.pick ) ) {
          return value
      }
  
      // We need a `.format` to parse the value.
      if ( !( options && options.format ) ) {
          // should probably default to the default format.
          throw "Need a formatting option to parse this.."
      }
  
      // Convert the format into an array and then map through it.
      calendar.formats.toArray( options.format ).map( function( label ) {
  
          var
              // Grab the formatting label.
              formattingLabel = calendar.formats[ label ],
  
              // The format length is from the formatting label function or the
              // label length without the escaping exclamation (!) mark.
              formatLength = formattingLabel ? Picker._.trigger( formattingLabel, calendar, [ value, parsingObject ] ) : label.replace( /^!/, '' ).length
  
          // If there's a format label, split the value up to the format length.
          // Then add it to the parsing object with appropriate label.
          if ( formattingLabel ) {
              parsingObject[ label ] = value.substr( 0, formatLength )
          }
  
          // Update the value as the substring from format length to end.
          value = value.substr( formatLength )
      })
  
      // If it’s parsing a user provided month value, compensate for month 0index.
      return [ parsingObject.yyyy || parsingObject.yy, +( parsingObject.mm || parsingObject.m ) - ( options.data ?  1 : 0 ), parsingObject.dd || parsingObject.d ]
  } //DatePicker.prototype.parse
  
  
  /**
   * Various formats to display the object in.
   */
  DatePicker.prototype.formats = (function() {
  
      // Return the length of the first word in a collection.
      function getWordLengthFromCollection( string, collection, dateObject ) {
  
          // Grab the first word from the string.
          var word = string.match( /\w+/ )[ 0 ]
  
          // If there's no month index, add it to the date object
          if ( !dateObject.mm && !dateObject.m ) {
              dateObject.m = collection.indexOf( word )
          }
  
          // Return the length of the word.
          return word.length
      }
  
      // Get the length of the first word in a string.
      function getFirstWordLength( string ) {
          return string.match( /\w+/ )[ 0 ].length
      }
  
      return {
  
          d: function( string, dateObject ) {
  
              // If there's string, then get the digits length.
              // Otherwise return the selected date.
              return string ? Picker._.digits( string ) : dateObject.date
          },
          dd: function( string, dateObject ) {
  
              // If there's a string, then the length is always 2.
              // Otherwise return the selected date with a leading zero.
              return string ? 2 : Picker._.lead( dateObject.date )
          },
          ddd: function( string, dateObject ) {
  
              // If there's a string, then get the length of the first word.
              // Otherwise return the short selected weekday.
              return string ? getFirstWordLength( string ) : this.settings.weekdaysShort[ dateObject.day ]
          },
          dddd: function( string, dateObject ) {
  
              // If there's a string, then get the length of the first word.
              // Otherwise return the full selected weekday.
              return string ? getFirstWordLength( string ) : this.settings.weekdaysFull[ dateObject.day ]
          },
          m: function( string, dateObject ) {
  
              // If there's a string, then get the length of the digits
              // Otherwise return the selected month with 0index compensation.
              return string ? Picker._.digits( string ) : dateObject.month + 1
          },
          mm: function( string, dateObject ) {
  
              // If there's a string, then the length is always 2.
              // Otherwise return the selected month with 0index and leading zero.
              return string ? 2 : Picker._.lead( dateObject.month + 1 )
          },
          mmm: function( string, dateObject ) {
  
              var collection = this.settings.monthsShort
  
              // If there's a string, get length of the relevant month from the short
              // months collection. Otherwise return the selected month from that collection.
              return string ? getWordLengthFromCollection( string, collection, dateObject ) : collection[ dateObject.month ]
          },
          mmmm: function( string, dateObject ) {
  
              var collection = this.settings.monthsFull
  
              // If there's a string, get length of the relevant month from the full
              // months collection. Otherwise return the selected month from that collection.
              return string ? getWordLengthFromCollection( string, collection, dateObject ) : collection[ dateObject.month ]
          },
          yy: function( string, dateObject ) {
  
              // If there's a string, then the length is always 2.
              // Otherwise return the selected year by slicing out the first 2 digits.
              return string ? 2 : ( '' + dateObject.year ).slice( 2 )
          },
          yyyy: function( string, dateObject ) {
  
              // If there's a string, then the length is always 4.
              // Otherwise return the selected year.
              return string ? 4 : dateObject.year
          },
  
          // Create an array by splitting the formatting string passed.
          toArray: function( formatString ) { return formatString.split( /(d{1,4}|m{1,4}|y{4}|yy|!.)/g ) },
  
          // Format an object into a string using the formatting options.
          toString: function ( formatString, itemObject ) {
              var calendar = this
              return calendar.formats.toArray( formatString ).map( function( label ) {
                  return Picker._.trigger( calendar.formats[ label ], calendar, [ 0, itemObject ] ) || label.replace( /^!/, '' )
              }).join( '' )
          }
      }
  })() //DatePicker.prototype.formats
  
  
  /**
   * Flip an item as enabled or disabled.
   */
  DatePicker.prototype.flipItem = function( type, value/*, options*/ ) {
  
      var calendar = this,
          collection = calendar.item.disable,
          isInverted = calendar.item.enable === -1
  
      // Flip the enabled and disabled dates.
      if ( value == 'flip' ) {
          calendar.item.enable = isInverted ? 1 : -1
      }
  
      // Check if we have to add/remove from collection.
      else if ( !isInverted && type == 'enable' || isInverted && type == 'disable' ) {
          collection = calendar.removeDisabled( collection, value )
      }
      else if ( !isInverted && type == 'disable' || isInverted && type == 'enable' ) {
          collection = calendar.addDisabled( collection, value )
      }
  
      return collection
  } //DatePicker.prototype.flipItem
  
  
  /**
   * Add an item to the disabled collection.
   */
  DatePicker.prototype.addDisabled = function( collection, item ) {
      var calendar = this
      item.map( function( timeUnit ) {
          if ( !calendar.filterDisabled( collection, timeUnit ).length ) {
              collection.push( timeUnit )
          }
      })
      return collection
  } //DatePicker.prototype.addDisabled
  
  
  /**
   * Remove an item from the disabled collection.
   */
  DatePicker.prototype.removeDisabled = function( collection, item ) {
      var calendar = this
      item.map( function( timeUnit ) {
          collection = calendar.filterDisabled( collection, timeUnit, 1 )
      })
      return collection
  } //DatePicker.prototype.removeDisabled
  
  
  /**
   * Filter through the disabled collection to find a time unit.
   */
  DatePicker.prototype.filterDisabled = function( collection, timeUnit, isRemoving ) {
      var timeIsArray = Array.isArray( timeUnit )
      return collection.filter( function( disabledTimeUnit ) {
          var isMatch = !timeIsArray && timeUnit === disabledTimeUnit ||
              timeIsArray && Array.isArray( disabledTimeUnit ) && timeUnit.toString() === disabledTimeUnit.toString()
          return isRemoving ? !isMatch : isMatch
      })
  } //DatePicker.prototype.filterDisabled
  
  
  /**
   * Create a string for the nodes in the picker.
   */
  DatePicker.prototype.nodes = function( isOpen ) {
  
      var
          calendar = this,
          settings = calendar.settings,
          nowObject = calendar.item.now,
          selectedObject = calendar.item.select,
          highlightedObject = calendar.item.highlight,
          viewsetObject = calendar.item.view,
          disabledCollection = calendar.item.disable,
          minLimitObject = calendar.item.min,
          maxLimitObject = calendar.item.max,
  
  
          // Create the calendar table head using a copy of weekday labels collection.
          // * We do a copy so we don't mutate the original array.
          tableHead = (function( collection ) {
  
              // If the first day should be Monday, move Sunday to the end.
              if ( settings.firstDay ) {
                  collection.push( collection.shift() )
              }
  
              // Create and return the table head group.
              return Picker._.node(
                  'thead',
                  Picker._.group({
                      min: 0,
                      max: DAYS_IN_WEEK - 1,
                      i: 1,
                      node: 'th',
                      item: function( counter ) {
                          return [
                              collection[ counter ],
                              settings.klass.weekdays
                          ]
                      }
                  })
              ) //endreturn
          })( ( settings.showWeekdaysFull ? settings.weekdaysFull : settings.weekdaysShort ).slice( 0 ) ), //tableHead
  
  
          // Create the nav for next/prev month.
          createMonthNav = function( next ) {
  
              // Otherwise, return the created month tag.
              return Picker._.node(
                  'div',
                  ' ',
                  settings.klass[ 'nav' + ( next ? 'Next' : 'Prev' ) ] + (
  
                      // If the focused month is outside the range, disabled the button.
                      ( next && viewsetObject.year >= maxLimitObject.year && viewsetObject.month >= maxLimitObject.month ) ||
                      ( !next && viewsetObject.year <= minLimitObject.year && viewsetObject.month <= minLimitObject.month ) ?
                      ' ' + settings.klass.navDisabled : ''
                  ),
                  'data-nav=' + ( next || -1 )
              ) //endreturn
          }, //createMonthNav
  
  
          // Create the month label.
          createMonthLabel = function( monthsCollection ) {
  
              // If there are months to select, add a dropdown menu.
              if ( settings.selectMonths ) {
  
                  return Picker._.node( 'select', Picker._.group({
                      min: 0,
                      max: 11,
                      i: 1,
                      node: 'option',
                      item: function( loopedMonth ) {
  
                          return [
  
                              // The looped month and no classes.
                              monthsCollection[ loopedMonth ], 0,
  
                              // Set the value and selected index.
                              'value=' + loopedMonth +
                              ( viewsetObject.month == loopedMonth ? ' selected' : '' ) +
                              (
                                  (
                                      ( viewsetObject.year == minLimitObject.year && loopedMonth < minLimitObject.month ) ||
                                      ( viewsetObject.year == maxLimitObject.year && loopedMonth > maxLimitObject.month )
                                  ) ?
                                  ' disabled' : ''
                              )
                          ]
                      }
                  }), settings.klass.selectMonth, isOpen ? '' : 'disabled' )
              }
  
              // If there's a need for a month selector
              return Picker._.node( 'div', monthsCollection[ viewsetObject.month ], settings.klass.month )
          }, //createMonthLabel
  
  
          // Create the year label.
          createYearLabel = function() {
  
              var focusedYear = viewsetObject.year,
  
              // If years selector is set to a literal "true", set it to 5. Otherwise
              // divide in half to get half before and half after focused year.
              numberYears = settings.selectYears === true ? 5 : ~~( settings.selectYears / 2 )
  
              // If there are years to select, add a dropdown menu.
              if ( numberYears ) {
  
                  var
                      minYear = minLimitObject.year,
                      maxYear = maxLimitObject.year,
                      lowestYear = focusedYear - numberYears,
                      highestYear = focusedYear + numberYears
  
                  // If the min year is greater than the lowest year, increase the highest year
                  // by the difference and set the lowest year to the min year.
                  if ( minYear > lowestYear ) {
                      highestYear += minYear - lowestYear
                      lowestYear = minYear
                  }
  
                  // If the max year is less than the highest year, decrease the lowest year
                  // by the lower of the two: available and needed years. Then set the
                  // highest year to the max year.
                  if ( maxYear < highestYear ) {
  
                      var availableYears = lowestYear - minYear,
                          neededYears = highestYear - maxYear
  
                      lowestYear -= availableYears > neededYears ? neededYears : availableYears
                      highestYear = maxYear
                  }
  
                  return Picker._.node( 'select', Picker._.group({
                      min: lowestYear,
                      max: highestYear,
                      i: 1,
                      node: 'option',
                      item: function( loopedYear ) {
                          return [
  
                              // The looped year and no classes.
                              loopedYear, 0,
  
                              // Set the value and selected index.
                              'value=' + loopedYear + ( focusedYear == loopedYear ? ' selected' : '' )
                          ]
                      }
                  }), settings.klass.selectYear, isOpen ? '' : 'disabled' )
              }
  
              // Otherwise just return the year focused
              return Picker._.node( 'div', focusedYear, settings.klass.year )
          } //createYearLabel
  
  
      // Create and return the entire calendar.
      return Picker._.node(
          'div',
          createMonthNav() + createMonthNav( 1 ) +
          createMonthLabel( settings.showMonthsShort ? settings.monthsShort : settings.monthsFull ) +
          createYearLabel(),
          settings.klass.header
      ) + Picker._.node(
          'table',
          tableHead +
          Picker._.node(
              'tbody',
              Picker._.group({
                  min: 0,
                  max: WEEKS_IN_CALENDAR - 1,
                  i: 1,
                  node: 'tr',
                  item: function( rowCounter ) {
  
                      // If Monday is the first day and the month starts on Sunday, shift the date back a week.
                      var shiftDateBy = settings.firstDay && calendar.create([ viewsetObject.year, viewsetObject.month, 1 ]).day === 0 ? -7 : 0
  
                      return [
                          Picker._.group({
                              min: DAYS_IN_WEEK * rowCounter - viewsetObject.day + shiftDateBy + 1, // Add 1 for weekday 0index
                              max: function() {
                                  return this.min + DAYS_IN_WEEK - 1
                              },
                              i: 1,
                              node: 'td',
                              item: function( targetDate ) {
  
                                  // Convert the time date from a relative date to a target date.
                                  targetDate = calendar.create([ viewsetObject.year, viewsetObject.month, targetDate + ( settings.firstDay ? 1 : 0 ) ])
  
                                  return [
                                      Picker._.node(
                                          'div',
                                          targetDate.date,
                                          (function( klasses ) {
  
                                              // Add the `infocus` or `outfocus` classes based on month in view.
                                              klasses.push( viewsetObject.month == targetDate.month ? settings.klass.infocus : settings.klass.outfocus )
  
                                              // Add the `today` class if needed.
                                              if ( nowObject.pick == targetDate.pick ) {
                                                  klasses.push( settings.klass.now )
                                              }
  
                                              // Add the `selected` class if something's selected and the time matches.
                                              if ( selectedObject && selectedObject.pick == targetDate.pick ) {
                                                  klasses.push( settings.klass.selected )
                                              }
  
                                              // Add the `highlighted` class if something's highlighted and the time matches.
                                              if ( highlightedObject && highlightedObject.pick == targetDate.pick ) {
                                                  klasses.push( settings.klass.highlighted )
                                              }
  
                                              // Add the `disabled` class if something's disabled and the object matches.
                                              if ( disabledCollection && calendar.disabled( targetDate ) || targetDate.pick < minLimitObject.pick || targetDate.pick > maxLimitObject.pick ) {
                                                  klasses.push( settings.klass.disabled )
                                              }
  
                                              return klasses.join( ' ' )
                                          })([ settings.klass.day ]),
                                          'data-pick=' + targetDate.pick
                                      )
                                  ] //endreturn
                              }
                          })
                      ] //endreturn
                  }
              })
          ),
          settings.klass.table
      ) +
  
      Picker._.node(
          'div',
          Picker._.node( 'button', settings.today, settings.klass.buttonToday, 'data-pick=' + nowObject.pick + ( isOpen ? '' : ' disabled' ) ) +
          Picker._.node( 'button', settings.clear, settings.klass.buttonClear, 'data-clear=1' + ( isOpen ? '' : ' disabled' ) ),
          settings.klass.footer
      ) //endreturn
  } //DatePicker.prototype.nodes
  
  
  
  
  /**
   * The date picker defaults.
   */
  DatePicker.defaults = (function( prefix ) {
  
      return {
  
          // Months and weekdays
          monthsFull: [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ],
          monthsShort: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ],
          weekdaysFull: [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ],
          weekdaysShort: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],
  
          // Today and clear
          today: 'Today',
          clear: 'Clear',
  
          // The format to show on the `input` element
          format: 'd mmmm, yyyy',
  
          // Classes
          klass: {
  
              table: prefix + 'table',
  
              header: prefix + 'header',
  
              navPrev: prefix + 'nav--prev',
              navNext: prefix + 'nav--next',
              navDisabled: prefix + 'nav--disabled',
  
              month: prefix + 'month',
              year: prefix + 'year',
  
              selectMonth: prefix + 'select--month',
              selectYear: prefix + 'select--year',
  
              weekdays: prefix + 'weekday',
  
              day: prefix + 'day',
              disabled: prefix + 'day--disabled',
              selected: prefix + 'day--selected',
              highlighted: prefix + 'day--highlighted',
              now: prefix + 'day--today',
              infocus: prefix + 'day--infocus',
              outfocus: prefix + 'day--outfocus',
  
              footer: prefix + 'footer',
  
              buttonClear: prefix + 'button--clear',
              buttonToday: prefix + 'button--today'
          }
      }
  })( Picker.klasses().picker + '__' )
  
  
  
  
  
  /**
   * Extend the picker to add the date picker.
   */
  Picker.extend( 'pickadate', DatePicker )
  
  
  // Close the scope.
  })();
  
  
  
  
  /*!
   * Time picker for pickadate.js v3.1.1
   * http://amsul.github.io/pickadate.js/time.htm
   */
  
  /*jshint
     debug: true,
     devel: true,
     browser: true,
     asi: true,
     unused: true,
     boss: true
   */
  
  
  // Create a new scope.
  (function() {
  
  
  /**
   * Globals and constants
   */
  var HOURS_IN_DAY = 24,
      MINUTES_IN_HOUR = 60,
      HOURS_TO_NOON = 12,
      MINUTES_IN_DAY = HOURS_IN_DAY * MINUTES_IN_HOUR
  
  
  
  /**
   * The time picker constructor
   */
  function TimePicker( picker, settings ) {
  
      var clock = this,
          elementDataValue = picker.$node.data( 'value' )
  
      clock.settings = settings
  
      // The queue of methods that will be used to build item objects.
      clock.queue = {
          interval: 'i',
          min: 'measure create',
          max: 'measure create',
          now: 'now create',
          select: 'parse create validate',
          highlight: 'create validate',
          view: 'create validate',
          disable: 'flipItem',
          enable: 'flipItem'
      }
  
      // The component's item object.
      clock.item = {}
  
      clock.item.interval = settings.interval || 30
      clock.item.disable = ( settings.disable || [] ).slice( 0 )
      clock.item.enable = -(function( collectionDisabled ) {
          return collectionDisabled[ 0 ] === true ? collectionDisabled.shift() : -1
      })( clock.item.disable )
  
      clock.
          set( 'min', settings.min ).
          set( 'max', settings.max ).
          set( 'now' ).
  
          // Setting the `select` also sets the `highlight` and `view`.
          set( 'select',
  
              // If there's a `value` or `data-value`, use that with formatting.
              // Otherwise default to the minimum selectable time.
              elementDataValue || picker.$node[ 0 ].value || clock.item.min,
  
              // Use the relevant format.
              { format: elementDataValue ? settings.formatSubmit : settings.format }
          )
  
      // The keycode to movement mapping.
      clock.key = {
          40: 1, // Down
          38: -1, // Up
          39: 1, // Right
          37: -1, // Left
          go: function( timeChange ) {
              clock.set( 'highlight', clock.item.highlight.pick + timeChange * clock.item.interval, { interval: timeChange * clock.item.interval } )
              this.render()
          }
      }
  
  
      // Bind some picker events.
      picker.
          on( 'render', function() {
              var $pickerHolder = picker.$root.children(),
                  $viewset = $pickerHolder.find( '.' + settings.klass.viewset )
              if ( $viewset.length ) {
                  $pickerHolder[ 0 ].scrollTop = ~~( $viewset.position().top - ( $viewset[ 0 ].clientHeight * 2 ) )
              }
              else {
                  console.warn( 'Nothing to viewset with', clock.item.view )
              }
          }).
          on( 'open', function() {
              picker.$root.find( 'button' ).attr( 'disable', false )
          }).
          on( 'close', function() {
              picker.$root.find( 'button' ).attr( 'disable', true )
          })
  
  } //TimePicker
  
  
  /**
   * Set a timepicker item object.
   */
  TimePicker.prototype.set = function( type, value, options ) {
  
      var clock = this
  
      // Go through the queue of methods, and invoke the function. Update this
      // as the time unit, and set the final resultant as this item type.
      // * In the case of `enable`, keep the queue but set `disable` instead.
      //   And in the case of `flip`, keep the queue but set `enable` instead.
      clock.item[ ( type == 'enable' ? 'disable' : type == 'flip' ? 'enable' : type ) ] = clock.queue[ type ].split( ' ' ).map( function( method ) {
          return value = clock[ method ]( type, value, options )
      }).pop()
  
      // Check if we need to cascade through more updates.
      if ( type == 'select' ) {
          clock.set( 'highlight', clock.item.select, options )
      }
      else if ( type == 'highlight' ) {
          clock.set( 'view', clock.item.highlight, options )
      }
      else if ( type == 'interval' ) {
          clock.
              set( 'min', clock.item.min, options ).
              set( 'max', clock.item.max, options )
      }
      else if ( ( type == 'flip' || type == 'min' || type == 'max' || type == 'disable' || type == 'enable' ) && clock.item.select && clock.item.highlight ) {
          if ( type == 'min' ) {
              clock.set( 'max', clock.item.max, options )
          }
          clock.
              set( 'select', clock.item.select, options ).
              set( 'highlight', clock.item.highlight, options )
      }
  
      return clock
  } //TimePicker.prototype.set
  
  
  /**
   * Get a timepicker item object.
   */
  TimePicker.prototype.get = function( type ) {
      return this.item[ type ]
  } //TimePicker.prototype.get
  
  
  /**
   * Create a picker time object.
   */
  TimePicker.prototype.create = function( type, value, options ) {
  
      var clock = this
  
      // If there's no value, use the type as the value.
      value = value === undefined ? type : value
  
      // If it's an object, use the "pick" value.
      if ( Picker._.isObject( value ) && Picker._.isInteger( value.pick ) ) {
          value = value.pick
      }
  
      // If it's an array, convert it into minutes.
      else if ( Array.isArray( value ) ) {
          value = +value[ 0 ] * MINUTES_IN_HOUR + (+value[ 1 ])
      }
  
      // If no valid value is passed, set it to "now".
      else if ( !Picker._.isInteger( value ) ) {
          value = clock.now( type, value, options )
      }
  
      // If we're setting the max, make sure it's greater than the min.
      if ( type == 'max' && value < clock.item.min.pick ) {
          value += MINUTES_IN_DAY
      }
  
      // Normalize it into a "reachable" interval.
      value = clock.normalize( value, options )
  
      // Return the compiled object.
      return {
  
          // Divide to get hours from minutes.
          hour: ~~( HOURS_IN_DAY + value / MINUTES_IN_HOUR ) % HOURS_IN_DAY,
  
          // The remainder is the minutes.
          mins: ( MINUTES_IN_HOUR + value % MINUTES_IN_HOUR ) % MINUTES_IN_HOUR,
  
          // The time in total minutes.
          time: ( MINUTES_IN_DAY + value ) % MINUTES_IN_DAY,
  
          // Reference to the "relative" value to pick.
          pick: value
      }
  } //TimePicker.prototype.create
  
  
  /**
   * Get the time relative to now.
   */
  TimePicker.prototype.now = function( type, value/*, options*/ ) {
  
      var date = new Date(),
          dateMinutes = date.getHours() * MINUTES_IN_HOUR + date.getMinutes()
  
      // If the value is a number, adjust by that many intervals because
      // the time has passed. In the case of “midnight” and a negative `min`,
      // increase the value by 2. Otherwise increase it by 1.
      if ( Picker._.isInteger( value ) ) {
          value += type == 'min' && value < 0 && dateMinutes === 0 ? 2 : 1
      }
  
      // If the value isn’t a number, default to 1 passed interval.
      else {
          value = 1
      }
  
      // Calculate the final relative time.
      return value * this.item.interval + dateMinutes
  } //TimePicker.prototype.now
  
  
  /**
   * Normalize minutes or an object to be "reachable" based on the interval.
   */
  TimePicker.prototype.normalize = function( value/*, options*/ ) {
      // If it's a negative value, add one interval to keep it as "passed".
      return value - ( ( value < 0 ? this.item.interval : 0 ) + value % this.item.interval )
  } //TimePicker.prototype.normalize
  
  
  /**
   * Measure the range of minutes.
   */
  TimePicker.prototype.measure = function( type, value, options ) {
  
      var clock = this
  
      // If it's anything false-y, set it to the default.
      if ( !value ) {
          value = type == 'min' ? [ 0, 0 ] : [ HOURS_IN_DAY - 1, MINUTES_IN_HOUR - 1 ]
      }
  
      // If it's a literal true, or an integer, make it relative to now.
      else if ( value === true || Picker._.isInteger( value ) ) {
          value = clock.now( type, value, options )
      }
  
      // If it's an object already, just normalize it.
      else if ( Picker._.isObject( value ) && Picker._.isInteger( value.pick ) ) {
          value = clock.normalize( value.pick, options )
      }
  
      return value
  } ///TimePicker.prototype.measure
  
  
  /**
   * Validate an object as enabled.
   */
  TimePicker.prototype.validate = function( type, timeObject, options ) {
  
      var clock = this,
          interval = options && options.interval ? options.interval : clock.item.interval
  
      // Check if the object is disabled.
      if ( clock.disabled( timeObject ) ) {
  
          // Shift with the interval until we reach an enabled time.
          timeObject = clock.shift( timeObject, interval )
      }
  
      // Scope the object into range.
      timeObject = clock.scope( timeObject )
  
      // Do a second check to see if we landed on a disabled min/max.
      // In that case, shift using the opposite interval as before.
      if ( clock.disabled( timeObject ) ) {
          timeObject = clock.shift( timeObject, interval * -1 )
      }
  
      // Return the final object.
      return timeObject
  } //TimePicker.prototype.validate
  
  
  /**
   * Check if an object is disabled.
   */
  TimePicker.prototype.disabled = function( timeObject ) {
  
      var
          clock = this,
  
          // Filter through the disabled times to check if this is one.
          isDisabledTime = clock.item.disable.filter( function( timeToDisable ) {
  
              // If the time is a number, match the hours.
              if ( Picker._.isInteger( timeToDisable ) ) {
                  return timeObject.hour == timeToDisable
              }
  
              // If it's an array, create the object and match the times.
              if ( Array.isArray( timeToDisable ) ) {
                  return timeObject.pick == clock.create( timeToDisable ).pick
              }
          }).length
  
      // If the clock is "enabled" flag is flipped, flip the condition.
      return clock.item.enable === -1 ? !isDisabledTime : isDisabledTime
  } //TimePicker.prototype.disabled
  
  
  /**
   * Shift an object by an interval until we reach an enabled object.
   */
  TimePicker.prototype.shift = function( timeObject, interval ) {
  
      var
          clock = this
  
      // Keep looping as long as the time is disabled.
      while ( clock.disabled( timeObject ) ) {
  
          // Increase/decrease the time by the interval and keep looping.
          timeObject = clock.create( timeObject.pick += interval || clock.item.interval )
  
          // If we've looped beyond the limits, break out of the loop.
          if ( timeObject.pick <= clock.item.min.pick || timeObject.pick >= clock.item.max.pick ) {
              break
          }
      }
  
      // Return the final object.
      return timeObject
  } //TimePicker.prototype.shift
  
  
  /**
   * Scope an object to be within range of min and max.
   */
  TimePicker.prototype.scope = function( timeObject ) {
      var minLimit = this.item.min.pick,
          maxLimit = this.item.max.pick
      return this.create( timeObject.pick > maxLimit ? maxLimit : timeObject.pick < minLimit ? minLimit : timeObject )
  } //TimePicker.prototype.scope
  
  
  /**
   * Parse a string into a usable type.
   */
  TimePicker.prototype.parse = function( type, value, options ) {
  
      var
          clock = this,
          parsingObject = {}
  
      if ( !value || Picker._.isInteger( value ) || Array.isArray( value ) || Picker._.isDate( value ) || Picker._.isObject( value ) && Picker._.isInteger( value.pick ) ) {
          return value
      }
  
      // We need a `.format` to parse the value.
      if ( !( options && options.format ) ) {
          throw "Need a formatting option to parse this.."
      }
  
      // Convert the format into an array and then map through it.
      clock.formats.toArray( options.format ).map( function( label ) {
  
          var
              // Grab the formatting label.
              formattingLabel = clock.formats[ label ],
  
              // The format length is from the formatting label function or the
              // label length without the escaping exclamation (!) mark.
              formatLength = formattingLabel ? Picker._.trigger( formattingLabel, clock, [ value, parsingObject ] ) : label.replace( /^!/, '' ).length
  
          // If there's a format label, split the value up to the format length.
          // Then add it to the parsing object with appropriate label.
          if ( formattingLabel ) {
              parsingObject[ label ] = value.substr( 0, formatLength )
          }
  
          // Update the time value as the substring from format length to end.
          value = value.substr( formatLength )
      })
  
      return +parsingObject.i + MINUTES_IN_HOUR * (
  
          +( parsingObject.H || parsingObject.HH ) ||
  
          ( +( parsingObject.h || parsingObject.hh ) % 12 + ( /^p/i.test( parsingObject.A || parsingObject.a ) ? 12 : 0 ) )
      )
  } //TimePicker.prototype.parse
  
  
  /**
   * Various formats to display the object in.
   */
  TimePicker.prototype.formats = {
  
      h: function( string, timeObject ) {
  
          // If there's string, then get the digits length.
          // Otherwise return the selected hour in "standard" format.
          return string ? Picker._.digits( string ) : timeObject.hour % HOURS_TO_NOON || HOURS_TO_NOON
      },
      hh: function( string, timeObject ) {
  
          // If there's a string, then the length is always 2.
          // Otherwise return the selected hour in "standard" format with a leading zero.
          return string ? 2 : Picker._.lead( timeObject.hour % HOURS_TO_NOON || HOURS_TO_NOON )
      },
      H: function( string, timeObject ) {
  
          // If there's string, then get the digits length.
          // Otherwise return the selected hour in "military" format as a string.
          return string ? Picker._.digits( string ) : '' + timeObject.hour
      },
      HH: function( string, timeObject ) {
  
          // If there's string, then get the digits length.
          // Otherwise return the selected hour in "military" format with a leading zero.
          return string ? Picker._.digits( string ) : Picker._.lead( timeObject.hour )
      },
      i: function( string, timeObject ) {
  
          // If there's a string, then the length is always 2.
          // Otherwise return the selected minutes.
          return string ? 2 : Picker._.lead( timeObject.mins )
      },
      a: function( string, timeObject ) {
  
          // If there's a string, then the length is always 4.
          // Otherwise check if it's more than "noon" and return either am/pm.
          return string ? 4 : MINUTES_IN_DAY / 2 > timeObject.time % MINUTES_IN_DAY ? 'a.m.' : 'p.m.'
      },
      A: function( string, timeObject ) {
  
          // If there's a string, then the length is always 2.
          // Otherwise check if it's more than "noon" and return either am/pm.
          return string ? 2 : MINUTES_IN_DAY / 2 > timeObject.time % MINUTES_IN_DAY ? 'AM' : 'PM'
      },
  
      // Create an array by splitting the formatting string passed.
      toArray: function( formatString ) { return formatString.split( /(h{1,2}|H{1,2}|i|a|A|!.)/g ) },
  
      // Format an object into a string using the formatting options.
      toString: function ( formatString, itemObject ) {
          var clock = this
          return clock.formats.toArray( formatString ).map( function( label ) {
              return Picker._.trigger( clock.formats[ label ], clock, [ 0, itemObject ] ) || label.replace( /^!/, '' )
          }).join( '' )
      }
  } //TimePicker.prototype.formats
  
  
  /**
   * Flip an item as enabled or disabled.
   */
  TimePicker.prototype.flipItem = function( type, value/*, options*/ ) {
  
      var clock = this,
          collection = clock.item.disable,
          isFlipped = clock.item.enable === -1
  
      // Flip the enabled and disabled times.
      if ( value == 'flip' ) {
          clock.item.enable = isFlipped ? 1 : -1
      }
  
      // Check if we have to add/remove from collection.
      else if ( !isFlipped && type == 'enable' || isFlipped && type == 'disable' ) {
          collection = clock.removeDisabled( collection, value )
      }
      else if ( !isFlipped && type == 'disable' || isFlipped && type == 'enable' ) {
          collection = clock.addDisabled( collection, value )
      }
  
      return collection
  } //TimePicker.prototype.flipItem
  
  
  /**
   * Add an item to the disabled collection.
   */
  TimePicker.prototype.addDisabled = function( collection, item ) {
      var clock = this
      item.map( function( timeUnit ) {
          if ( !clock.filterDisabled( collection, timeUnit ).length ) {
              collection.push( timeUnit )
          }
      })
      return collection
  } //TimePicker.prototype.addDisabled
  
  
  /**
   * Remove an item from the disabled collection.
   */
  TimePicker.prototype.removeDisabled = function( collection, item ) {
      var clock = this
      item.map( function( timeUnit ) {
          collection = clock.filterDisabled( collection, timeUnit, 1 )
      })
      return collection
  } //TimePicker.prototype.removeDisabled
  
  
  /**
   * Filter through the disabled collection to find a time unit.
   */
  TimePicker.prototype.filterDisabled = function( collection, timeUnit, isRemoving ) {
      var timeIsArray = Array.isArray( timeUnit )
      return collection.filter( function( disabledTimeUnit ) {
          var isMatch = !timeIsArray && timeUnit === disabledTimeUnit ||
              timeIsArray && Array.isArray( disabledTimeUnit ) && timeUnit.toString() === disabledTimeUnit.toString()
          return isRemoving ? !isMatch : isMatch
      })
  } //TimePicker.prototype.filterDisabled
  
  
  /**
   * The division to use for the range intervals.
   */
  TimePicker.prototype.i = function( type, value/*, options*/ ) {
      return Picker._.isInteger( value ) && value > 0 ? value : this.item.interval
  }
  
  
  /**
   * Create a string for the nodes in the picker.
   */
  TimePicker.prototype.nodes = function( isOpen ) {
  
      var
          clock = this,
          settings = clock.settings,
          selectedObject = clock.item.select,
          highlightedObject = clock.item.highlight,
          viewsetObject = clock.item.view,
          disabledCollection = clock.item.disable
  
      return Picker._.node( 'ul', Picker._.group({
          min: clock.item.min.pick,
          max: clock.item.max.pick,
          i: clock.item.interval,
          node: 'li',
          item: function( loopedTime ) {
              loopedTime = clock.create( loopedTime )
              return [
                  Picker._.trigger( clock.formats.toString, clock, [ Picker._.trigger( settings.formatLabel, clock, [ loopedTime ] ) || settings.format, loopedTime ] ),
                  (function( klasses, timeMinutes ) {
  
                      if ( selectedObject && selectedObject.pick == timeMinutes ) {
                          klasses.push( settings.klass.selected )
                      }
  
                      if ( highlightedObject && highlightedObject.pick == timeMinutes ) {
                          klasses.push( settings.klass.highlighted )
                      }
  
                      if ( viewsetObject && viewsetObject.pick == timeMinutes ) {
                          klasses.push( settings.klass.viewset )
                      }
  
                      if ( disabledCollection && clock.disabled( loopedTime ) ) {
                          klasses.push( settings.klass.disabled )
                      }
  
                      return klasses.join( ' ' )
                  })( [ settings.klass.listItem ], loopedTime.pick ),
                  'data-pick=' + loopedTime.pick
              ]
          }
      }) + Picker._.node( 'li', Picker._.node( 'button', settings.clear, settings.klass.buttonClear, 'data-clear=1' + ( isOpen ? '' : ' disable' ) ) ), settings.klass.list )
  } //TimePicker.prototype.nodes
  
  
  
  
  
  
  
  /* ==========================================================================
     Extend the picker to add the component with the defaults.
     ========================================================================== */
  
  TimePicker.defaults = (function( prefix ) {
  
      return {
  
          // Clear
          clear: 'Clear',
  
          // The format to show on the `input` element
          format: 'h:i A',
  
          // The interval between each time
          interval: 30,
  
          // Classes
          klass: {
  
              picker: prefix + ' ' + prefix + '--time',
              holder: prefix + '__holder',
  
              list: prefix + '__list',
              listItem: prefix + '__list-item',
  
              disabled: prefix + '__list-item--disabled',
              selected: prefix + '__list-item--selected',
              highlighted: prefix + '__list-item--highlighted',
              viewset: prefix + '__list-item--viewset',
              now: prefix + '__list-item--now',
  
              buttonClear: prefix + '__button--clear'
          }
      }
  })( Picker.klasses().picker )
  
  
  
  
  
  /**
   * Extend the picker to add the date picker.
   */
  Picker.extend( 'pickatime', TimePicker )
  
  
  // Close the scope.
  })();
  
  
  
  /* Rainbow v1.2 rainbowco.de | included languages: generic, javascript, html, css */
  window.Rainbow=function(){function q(a){var b,c=a.getAttribute&&a.getAttribute("data-language")||0;if(!c){a=a.attributes;for(b=0;b<a.length;++b)if("data-language"===a[b].nodeName)return a[b].nodeValue}return c}function B(a){var b=q(a)||q(a.parentNode);if(!b){var c=/\blang(?:uage)?-(\w+)/;(a=a.className.match(c)||a.parentNode.className.match(c))&&(b=a[1])}return b}function C(a,b){for(var c in f[d]){c=parseInt(c,10);if(a==c&&b==f[d][c]?0:a<=c&&b>=f[d][c])delete f[d][c],delete j[d][c];if(a>=c&&a<f[d][c]||
  b>c&&b<f[d][c])return!0}return!1}function r(a,b){return'<span class="'+a.replace(/\./g," ")+(l?" "+l:"")+'">'+b+"</span>"}function s(a,b,c,i){var e=a.exec(c);if(e){++t;!b.name&&"string"==typeof b.matches[0]&&(b.name=b.matches[0],delete b.matches[0]);var k=e[0],g=e.index,u=e[0].length+g,h=function(){function e(){s(a,b,c,i)}t%100>0?e():setTimeout(e,0)};if(C(g,u))h();else{var m=v(b.matches),l=function(a,c,i){if(a>=c.length)i(k);else{var d=e[c[a]];if(d){var g=b.matches[c[a]],f=g.language,h=g.name&&g.matches?
  g.matches:g,j=function(b,d,g){var f;f=0;var h;for(h=1;h<c[a];++h)e[h]&&(f=f+e[h].length);d=g?r(g,d):d;k=k.substr(0,f)+k.substr(f).replace(b,d);l(++a,c,i)};f?n(d,f,function(a){j(d,a)}):typeof g==="string"?j(d,d,g):w(d,h.length?h:[h],function(a){j(d,a,g.matches?g.name:0)})}else l(++a,c,i)}};l(0,m,function(a){b.name&&(a=r(b.name,a));if(!j[d]){j[d]={};f[d]={}}j[d][g]={replace:e[0],"with":a};f[d][g]=u;h()})}}else i()}function v(a){var b=[],c;for(c in a)a.hasOwnProperty(c)&&b.push(c);return b.sort(function(a,
  b){return b-a})}function w(a,b,c){function i(b,k){k<b.length?s(b[k].pattern,b[k],a,function(){i(b,++k)}):D(a,function(a){delete j[d];delete f[d];--d;c(a)})}++d;i(b,0)}function D(a,b){function c(a,b,i,f){if(i<b.length){++x;var h=b[i],l=j[d][h],a=a.substr(0,h)+a.substr(h).replace(l.replace,l["with"]),h=function(){c(a,b,++i,f)};0<x%250?h():setTimeout(h,0)}else f(a)}var i=v(j[d]);c(a,i,0,b)}function n(a,b,c){var d=m[b]||[],e=m[y]||[],b=z[b]?d:d.concat(e);w(a.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/&(?![\w\#]+;)/g,
  "&amp;"),b,c)}function o(a,b,c){if(b<a.length){var d=a[b],e=B(d);return!(-1<(" "+d.className+" ").indexOf(" rainbow "))&&e?(e=e.toLowerCase(),d.className+=d.className?" rainbow":"rainbow",n(d.innerHTML,e,function(k){d.innerHTML=k;j={};f={};p&&p(d,e);setTimeout(function(){o(a,++b,c)},0)})):o(a,++b,c)}c&&c()}function A(a,b){var a=a&&"function"==typeof a.getElementsByTagName?a:document,c=a.getElementsByTagName("pre"),d=a.getElementsByTagName("code"),e,f=[],g=[];for(e=0;e<c.length;++e)c[e].getElementsByTagName("code").length?
  c[e].innerHTML=c[e].innerHTML.replace(/^\s+/,"").replace(/\s+$/,""):f.push(c[e]);for(e=0;e<d.length;++e)g.push(d[e]);o(g.concat(f),0,b)}var j={},f={},m={},z={},d=0,y=0,t=0,x=0,l,p;return{extend:function(a,b,c){1==arguments.length&&(b=a,a=y);z[a]=c;m[a]=b.concat(m[a]||[])},b:function(a){p=a},a:function(a){l=a},color:function(a,b,c){if("string"==typeof a)return n(a,b,c);if("function"==typeof a)return A(0,a);A(a,b)}}}();
  document.addEventListener?document.addEventListener("DOMContentLoaded",Rainbow.color,!1):window.attachEvent("onload",Rainbow.color);Rainbow.onHighlight=Rainbow.b;Rainbow.addClass=Rainbow.a;Rainbow.extend([{matches:{1:{name:"keyword.operator",pattern:/\=/g},2:{name:"string",matches:{name:"constant.character.escape",pattern:/\\('|"){1}/g}}},pattern:/(\(|\s|\[|\=|:)(('|")([^\\\1]|\\.)*?(\3))/gm},{name:"comment",pattern:/\/\*[\s\S]*?\*\/|(\/\/|\#)[\s\S]*?$/gm},{name:"constant.numeric",pattern:/\b(\d+(\.\d+)?(e(\+|\-)?\d+)?(f|d)?|0x[\da-f]+)\b/gi},{matches:{1:"keyword"},pattern:/\b(and|array|as|b(ool(ean)?|reak)|c(ase|atch|har|lass|on(st|tinue))|d(ef|elete|o(uble)?)|e(cho|lse(if)?|xit|xtends|xcept)|f(inally|loat|or(each)?|unction)|global|if|import|int(eger)?|long|new|object|or|pr(int|ivate|otected)|public|return|self|st(ring|ruct|atic)|switch|th(en|is|row)|try|(un)?signed|var|void|while)(?=\(|\b)/gi},
  {name:"constant.language",pattern:/true|false|null/g},{name:"keyword.operator",pattern:/\+|\!|\-|&(gt|lt|amp);|\||\*|\=/g},{matches:{1:"function.call"},pattern:/(\w+?)(?=\()/g},{matches:{1:"storage.function",2:"entity.name.function"},pattern:/(function)\s(.*?)(?=\()/g}]);Rainbow.extend("javascript",[{name:"selector",pattern:/(\s|^)\$(?=\.|\()/g},{name:"support",pattern:/\b(window|document)\b/g},{matches:{1:"support.property"},pattern:/\.(length|node(Name|Value))\b/g},{matches:{1:"support.function"},pattern:/(setTimeout|setInterval)(?=\()/g},{matches:{1:"support.method"},pattern:/\.(getAttribute|push|getElementById|getElementsByClassName|log|setTimeout|setInterval)(?=\()/g},{matches:{1:"support.tag.script",2:[{name:"string",pattern:/('|")(.*?)(\1)/g},{name:"entity.tag.script",
  pattern:/(\w+)/g}],3:"support.tag.script"},pattern:/(&lt;\/?)(script.*?)(&gt;)/g},{name:"string.regexp",matches:{1:"string.regexp.open",2:{name:"constant.regexp.escape",pattern:/\\(.){1}/g},3:"string.regexp.close",4:"string.regexp.modifier"},pattern:/(\/)(?!\*)(.+)(\/)([igm]{0,3})/g},{matches:{1:"storage",3:"entity.function"},pattern:/(var)?(\s|^)(\S*)(?=\s?=\s?function\()/g},{matches:{1:"keyword",2:"entity.function"},pattern:/(new)\s+(.*)(?=\()/g},{name:"entity.function",pattern:/(\w+)(?=:\s{0,}function)/g}]);Rainbow.extend("html",[{name:"source.php.embedded",matches:{2:{language:"php"}},pattern:/&lt;\?=?(?!xml)(php)?([\s\S]*?)(\?&gt;)/gm},{name:"source.css.embedded",matches:{"0":{language:"css"}},pattern:/&lt;style(.*?)&gt;([\s\S]*?)&lt;\/style&gt;/gm},{name:"source.js.embedded",matches:{"0":{language:"javascript"}},pattern:/&lt;script(?! src)(.*?)&gt;([\s\S]*?)&lt;\/script&gt;/gm},{name:"comment.html",pattern:/&lt;\!--[\S\s]*?--&gt;/g},{matches:{1:"support.tag.open",2:"support.tag.close"},pattern:/(&lt;)|(\/?\??&gt;)/g},
  {name:"support.tag",matches:{1:"support.tag",2:"support.tag.special",3:"support.tag-name"},pattern:/(&lt;\??)(\/|\!?)(\w+)/g},{matches:{1:"support.attribute"},pattern:/([a-z-]+)(?=\=)/gi},{matches:{1:"support.operator",2:"string.quote",3:"string.value",4:"string.quote"},pattern:/(=)('|")(.*?)(\2)/g},{matches:{1:"support.operator",2:"support.value"},pattern:/(=)([a-zA-Z\-0-9]*)\b/g},{matches:{1:"support.attribute"},pattern:/\s(\w+)(?=\s|&gt;)(?![\s\S]*&lt;)/g}],!0);Rainbow.extend("css",[{name:"comment",pattern:/\/\*[\s\S]*?\*\//gm},{name:"constant.hex-color",pattern:/#([a-f0-9]{3}|[a-f0-9]{6})(?=;|\s|,|\))/gi},{matches:{1:"constant.numeric",2:"keyword.unit"},pattern:/(\d+)(px|em|cm|s|%)?/g},{name:"string",pattern:/('|")(.*?)\1/g},{name:"support.css-property",matches:{1:"support.vendor-prefix"},pattern:/(-o-|-moz-|-webkit-|-ms-)?[\w-]+(?=\s?:)(?!.*\{)/g},{matches:{1:[{name:"entity.name.sass",pattern:/&amp;/g},{name:"direct-descendant",pattern:/&gt;/g},{name:"entity.name.class",
  pattern:/\.[\w\-_]+/g},{name:"entity.name.id",pattern:/\#[\w\-_]+/g},{name:"entity.name.pseudo",pattern:/:[\w\-_]+/g},{name:"entity.name.tag",pattern:/\w+/g}]},pattern:/([\w\ ,:\.\#\&\;\-_]+)(?=.*\{)/g},{matches:{2:"support.vendor-prefix",3:"support.css-value"},pattern:/(:|,)\s*(-o-|-moz-|-webkit-|-ms-)?([a-zA-Z-]*)(?=\b)(?!.*\{)/g},{matches:{1:"support.tag.style",2:[{name:"string",pattern:/('|")(.*?)(\1)/g},{name:"entity.tag.style",pattern:/(\w+)/g}],3:"support.tag.style"},pattern:/(&lt;\/?)(style.*?)(&gt;)/g}],
  !0);
  $(document).ready(function() {
    var switched = false;
    var updateTables = function() {
      if (($(window).width() <= 768) && !switched ){
        switched = true;
        $("table.responsive").each(function(i, element) {
          splitTable($(element));
        });
        return true;
      }
      else if (switched && ($(window).width() > 767)) {
        switched = false;
        $("table.responsive").each(function(i, element) {
          unsplitTable($(element));
        });
      }
    };
     
    $(window).load(updateTables);
    $(window).on("redraw",function(){switched=false;updateTables();}); // An event to listen for
    $(window).on("resize", updateTables);
     
  	
  	function splitTable(original)
  	{
  		original.wrap("<div class='table-wrapper' />");
  		
  		var copy = original.clone();
  		copy.find("td:not(:first-child), th:not(:first-child)").css("display", "none");
  		copy.removeClass("responsive");
  		
  		original.closest(".table-wrapper").append(copy);
  		copy.wrap("<div class='pinned' />");
  		original.wrap("<div class='scrollable' />");
  
      setCellHeights(original, copy);
  	}
  	
  	function unsplitTable(original) {
      original.closest(".table-wrapper").find(".pinned").remove();
      original.unwrap();
      original.unwrap();
  	}
  
    function setCellHeights(original, copy) {
      var tr = original.find('tr'),
          tr_copy = copy.find('tr'),
          heights = [];
  
      tr.each(function (index) {
        var self = $(this),
            tx = self.find('th, td');
  
        tx.each(function () {
          var height = $(this).outerHeight(true);
          heights[index] = heights[index] || 0;
          if (height > heights[index]) heights[index] = height;
        });
  
      });
  
      tr_copy.each(function (index) {
        $(this).height(heights[index]);
      });
    }
  
  });
  /*! ResponsiveSlides.js v1.54
   * http://responsiveslides.com
   * http://viljamis.com
   *
   * Copyright (c) 2011-2012 @viljamis
   * Available under the MIT license
   */
  
  /*jslint browser: true, sloppy: true, vars: true, plusplus: true, indent: 2 */
  
  (function ($, window, i) {
    $.fn.responsiveSlides = function (options) {
  
      // Default settings
      var settings = $.extend({
        "auto": true,             // Boolean: Animate automatically, true or false
        "speed": 500,             // Integer: Speed of the transition, in milliseconds
        "timeout": 4000,          // Integer: Time between slide transitions, in milliseconds
        "pager": false,           // Boolean: Show pager, true or false
        "nav": false,             // Boolean: Show navigation, true or false
        "random": false,          // Boolean: Randomize the order of the slides, true or false
        "pause": false,           // Boolean: Pause on hover, true or false
        "pauseControls": true,    // Boolean: Pause when hovering controls, true or false
        "prevText": "Previous",   // String: Text for the "previous" button
        "nextText": "Next",       // String: Text for the "next" button
        "maxwidth": "",           // Integer: Max-width of the slideshow, in pixels
        "navContainer": "",       // Selector: Where auto generated controls should be appended to, default is after the <ul>
        "manualControls": "",     // Selector: Declare custom pager navigation
        "namespace": "rslides",   // String: change the default namespace used
        "before": $.noop,         // Function: Before callback
        "after": $.noop           // Function: After callback
      }, options);
  
      return this.each(function () {
  
        // Index for namespacing
        i++;
  
        var $this = $(this),
  
          // Local variables
          vendor,
          selectTab,
          startCycle,
          restartCycle,
          rotate,
          $tabs,
  
          // Helpers
          index = 0,
          $slide = $this.children(),
          length = $slide.size(),
          fadeTime = parseFloat(settings.speed),
          waitTime = parseFloat(settings.timeout),
          maxw = parseFloat(settings.maxwidth),
  
          // Namespacing
          namespace = settings.namespace,
          namespaceIdx = namespace + i,
  
          // Classes
          navClass = namespace + "_nav " + namespaceIdx + "_nav",
          activeClass = namespace + "_here",
          visibleClass = namespaceIdx + "_on",
          slideClassPrefix = namespaceIdx + "_s",
  
          // Pager
          $pager = $("<ul class='" + namespace + "_tabs " + namespaceIdx + "_tabs' />"),
  
          // Styles for visible and hidden slides
          visible = {"float": "left", "position": "relative", "opacity": 1, "zIndex": 2},
          hidden = {"float": "none", "position": "absolute", "opacity": 0, "zIndex": 1},
  
          // Detect transition support
          supportsTransitions = (function () {
            var docBody = document.body || document.documentElement;
            var styles = docBody.style;
            var prop = "transition";
            if (typeof styles[prop] === "string") {
              return true;
            }
            // Tests for vendor specific prop
            vendor = ["Moz", "Webkit", "Khtml", "O", "ms"];
            prop = prop.charAt(0).toUpperCase() + prop.substr(1);
            var i;
            for (i = 0; i < vendor.length; i++) {
              if (typeof styles[vendor[i] + prop] === "string") {
                return true;
              }
            }
            return false;
          })(),
  
          // Fading animation
          slideTo = function (idx) {
            settings.before(idx);
            // If CSS3 transitions are supported
            if (supportsTransitions) {
              $slide
                .removeClass(visibleClass)
                .css(hidden)
                .eq(idx)
                .addClass(visibleClass)
                .css(visible);
              index = idx;
              setTimeout(function () {
                settings.after(idx);
              }, fadeTime);
            // If not, use jQuery fallback
            } else {
              $slide
                .stop()
                .fadeOut(fadeTime, function () {
                  $(this)
                    .removeClass(visibleClass)
                    .css(hidden)
                    .css("opacity", 1);
                })
                .eq(idx)
                .fadeIn(fadeTime, function () {
                  $(this)
                    .addClass(visibleClass)
                    .css(visible);
                  settings.after(idx);
                  index = idx;
                });
            }
          };
  
        // Random order
        if (settings.random) {
          $slide.sort(function () {
            return (Math.round(Math.random()) - 0.5);
          });
          $this
            .empty()
            .append($slide);
        }
  
        // Add ID's to each slide
        $slide.each(function (i) {
          this.id = slideClassPrefix + i;
        });
  
        // Add max-width and classes
        $this.addClass(namespace + " " + namespaceIdx);
        if (options && options.maxwidth) {
          $this.css("max-width", maxw);
        }
  
        // Hide all slides, then show first one
        $slide
          .hide()
          .css(hidden)
          .eq(0)
          .addClass(visibleClass)
          .css(visible)
          .show();
  
        // CSS transitions
        if (supportsTransitions) {
          $slide
            .show()
            .css({
              // -ms prefix isn't needed as IE10 uses prefix free version
              "-webkit-transition": "opacity " + fadeTime + "ms ease-in-out",
              "-moz-transition": "opacity " + fadeTime + "ms ease-in-out",
              "-o-transition": "opacity " + fadeTime + "ms ease-in-out",
              "transition": "opacity " + fadeTime + "ms ease-in-out"
            });
        }
  
        // Only run if there's more than one slide
        if ($slide.size() > 1) {
  
          // Make sure the timeout is at least 100ms longer than the fade
          if (waitTime < fadeTime + 100) {
            return;
          }
  
          // Pager
          if (settings.pager && !settings.manualControls) {
            var tabMarkup = [];
            $slide.each(function (i) {
              var n = i + 1;
              tabMarkup +=
                "<li>" +
                "<a href='#' class='" + slideClassPrefix + n + "'>" + n + "</a>" +
                "</li>";
            });
            $pager.append(tabMarkup);
  
            // Inject pager
            if (options.navContainer) {
              $(settings.navContainer).append($pager);
            } else {
              $this.after($pager);
            }
          }
  
          // Manual pager controls
          if (settings.manualControls) {
            $pager = $(settings.manualControls);
            $pager.addClass(namespace + "_tabs " + namespaceIdx + "_tabs");
          }
  
          // Add pager slide class prefixes
          if (settings.pager || settings.manualControls) {
            $pager.find('li').each(function (i) {
              $(this).addClass(slideClassPrefix + (i + 1));
            });
          }
  
          // If we have a pager, we need to set up the selectTab function
          if (settings.pager || settings.manualControls) {
            $tabs = $pager.find('a');
  
            // Select pager item
            selectTab = function (idx) {
              $tabs
                .closest("li")
                .removeClass(activeClass)
                .eq(idx)
                .addClass(activeClass);
            };
          }
  
          // Auto cycle
          if (settings.auto) {
  
            startCycle = function () {
              rotate = setInterval(function () {
  
                // Clear the event queue
                $slide.stop(true, true);
  
                var idx = index + 1 < length ? index + 1 : 0;
  
                // Remove active state and set new if pager is set
                if (settings.pager || settings.manualControls) {
                  selectTab(idx);
                }
  
                slideTo(idx);
              }, waitTime);
            };
  
            // Init cycle
            startCycle();
          }
  
          // Restarting cycle
          restartCycle = function () {
            if (settings.auto) {
              // Stop
              clearInterval(rotate);
              // Restart
              startCycle();
            }
          };
  
          // Pause on hover
          if (settings.pause) {
            $this.hover(function () {
              clearInterval(rotate);
            }, function () {
              restartCycle();
            });
          }
  
          // Pager click event handler
          if (settings.pager || settings.manualControls) {
            $tabs.bind("click", function (e) {
              e.preventDefault();
  
              if (!settings.pauseControls) {
                restartCycle();
              }
  
              // Get index of clicked tab
              var idx = $tabs.index(this);
  
              // Break if element is already active or currently animated
              if (index === idx || $("." + visibleClass).queue('fx').length) {
                return;
              }
  
              // Remove active state from old tab and set new one
              selectTab(idx);
  
              // Do the animation
              slideTo(idx);
            })
              .eq(0)
              .closest("li")
              .addClass(activeClass);
  
            // Pause when hovering pager
            if (settings.pauseControls) {
              $tabs.hover(function () {
                clearInterval(rotate);
              }, function () {
                restartCycle();
              });
            }
          }
  
          // Navigation
          if (settings.nav) {
            var navMarkup =
              "<a href='#' class='" + navClass + " prev'>" + settings.prevText + "</a>" +
              "<a href='#' class='" + navClass + " next'>" + settings.nextText + "</a>";
  
            // Inject navigation
            if (options.navContainer) {
              $(settings.navContainer).append(navMarkup);
            } else {
              $this.after(navMarkup);
            }
  
            var $trigger = $("." + namespaceIdx + "_nav"),
              $prev = $trigger.filter(".prev");
  
            // Click event handler
            $trigger.bind("click", function (e) {
              e.preventDefault();
  
              var $visibleClass = $("." + visibleClass);
  
              // Prevent clicking if currently animated
              if ($visibleClass.queue('fx').length) {
                return;
              }
  
              //  Adds active class during slide animation
              //  $(this)
              //    .addClass(namespace + "_active")
              //    .delay(fadeTime)
              //    .queue(function (next) {
              //      $(this).removeClass(namespace + "_active");
              //      next();
              //  });
  
              // Determine where to slide
              var idx = $slide.index($visibleClass),
                prevIdx = idx - 1,
                nextIdx = idx + 1 < length ? index + 1 : 0;
  
              // Go to slide
              slideTo($(this)[0] === $prev[0] ? prevIdx : nextIdx);
              if (settings.pager || settings.manualControls) {
                selectTab($(this)[0] === $prev[0] ? prevIdx : nextIdx);
              }
  
              if (!settings.pauseControls) {
                restartCycle();
              }
            });
  
            // Pause when hovering navigation
            if (settings.pauseControls) {
              $trigger.hover(function () {
                clearInterval(rotate);
              }, function () {
                restartCycle();
              });
            }
          }
  
        }
  
        // Max-width fallback
        if (typeof document.body.style.maxWidth === "undefined" && options.maxwidth) {
          var widthSupport = function () {
            $this.css("width", "100%");
            if ($this.width() > maxw) {
              $this.css("width", maxw);
            }
          };
  
          // Init fallback
          widthSupport();
          $(window).bind("resize", function () {
            widthSupport();
          });
        }
  
      });
  
    };
  })(jQuery, this, 0);
  /* ===========================================================
   * bootstrap-tooltip.js v2.3.0
   * http://twitter.github.com/bootstrap/javascript.html#tooltips
   * Inspired by the original jQuery.tipsy by Jason Frame
   * ===========================================================
   * Copyright 2012 Twitter, Inc.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   * http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   * ========================================================== */
  
  
  !function ($) {
  
    "use strict"; // jshint ;_;
  
  
   /* TOOLTIP PUBLIC CLASS DEFINITION
    * =============================== */
  
    var Tooltip = function (element, options) {
      this.init('tooltip', element, options)
    }
  
    Tooltip.prototype = {
  
      constructor: Tooltip
  
    , init: function (type, element, options) {
        var eventIn
          , eventOut
          , triggers
          , trigger
          , i
  
        this.type = type
        this.$element = $(element)
        this.options = this.getOptions(options)
        this.enabled = true
  
        triggers = this.options.trigger.split(' ')
  
        for (i = triggers.length; i--;) {
          trigger = triggers[i]
          if (trigger == 'click') {
            this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
          } else if (trigger != 'manual') {
            eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
            eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
            this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
            this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
          }
        }
  
        this.options.selector ?
          (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
          this.fixTitle()
      }
  
    , getOptions: function (options) {
        options = $.extend({}, $.fn[this.type].defaults, this.$element.data(), options)
  
        if (options.delay && typeof options.delay == 'number') {
          options.delay = {
            show: options.delay
          , hide: options.delay
          }
        }
  
        return options
      }
  
    , enter: function (e) {
        var self = $(e.currentTarget)[this.type](this._options).data(this.type)
  
        if (!self.options.delay || !self.options.delay.show) return self.show()
  
        clearTimeout(this.timeout)
        self.hoverState = 'in'
        this.timeout = setTimeout(function() {
          if (self.hoverState == 'in') self.show()
        }, self.options.delay.show)
      }
  
    , leave: function (e) {
        var self = $(e.currentTarget)[this.type](this._options).data(this.type)
  
        if (this.timeout) clearTimeout(this.timeout)
        if (!self.options.delay || !self.options.delay.hide) return self.hide()
  
        self.hoverState = 'out'
        this.timeout = setTimeout(function() {
          if (self.hoverState == 'out') self.hide()
        }, self.options.delay.hide)
      }
  
    , show: function () {
        var $tip
          , pos
          , actualWidth
          , actualHeight
          , placement
          , tp
          , e = $.Event('show')
  
        if (this.hasContent() && this.enabled) {
          this.$element.trigger(e)
          if (e.isDefaultPrevented()) return
          $tip = this.tip()
          this.setContent()
  
          if (this.options.animation) {
            $tip.addClass('fade')
          }
  
          placement = typeof this.options.placement == 'function' ?
            this.options.placement.call(this, $tip[0], this.$element[0]) :
            this.options.placement
  
          $tip
            .detach()
            .css({ top: 0, left: 0, display: 'block' })
  
          this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
  
          pos = this.getPosition()
  
          actualWidth = $tip[0].offsetWidth
          actualHeight = $tip[0].offsetHeight
  
          switch (placement) {
            case 'bottom':
              tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
              break
            case 'top':
              tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
              break
            case 'left':
              tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
              break
            case 'right':
              tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
              break
          }
  
          this.applyPlacement(tp, placement)
          this.$element.trigger('shown')
        }
      }
  
    , applyPlacement: function(offset, placement){
        var $tip = this.tip()
          , width = $tip[0].offsetWidth
          , height = $tip[0].offsetHeight
          , actualWidth
          , actualHeight
          , delta
          , replace
  
        $tip
          .offset(offset)
          .addClass(placement)
          .addClass('in')
  
        actualWidth = $tip[0].offsetWidth
        actualHeight = $tip[0].offsetHeight
  
        if (placement == 'top' && actualHeight != height) {
          offset.top = offset.top + height - actualHeight
          replace = true
        }
  
        if (placement == 'bottom' || placement == 'top') {
          delta = 0
  
          if (offset.left < 0){
            delta = offset.left * -2
            offset.left = 0
            $tip.offset(offset)
            actualWidth = $tip[0].offsetWidth
            actualHeight = $tip[0].offsetHeight
          }
  
          this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
        } else {
          this.replaceArrow(actualHeight - height, actualHeight, 'top')
        }
  
        if (replace) $tip.offset(offset)
      }
  
    , replaceArrow: function(delta, dimension, position){
        this
          .arrow()
          .css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
      }
  
    , setContent: function () {
        var $tip = this.tip()
          , title = this.getTitle()
  
        $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
        $tip.removeClass('fade in top bottom left right')
      }
  
    , hide: function () {
        var that = this
          , $tip = this.tip()
          , e = $.Event('hide')
  
        this.$element.trigger(e)
        if (e.isDefaultPrevented()) return
  
        $tip.removeClass('in')
  
        function removeWithAnimation() {
          var timeout = setTimeout(function () {
            $tip.off($.support.transition.end).detach()
          }, 500)
  
          $tip.one($.support.transition.end, function () {
            clearTimeout(timeout)
            $tip.detach()
          })
        }
  
        $.support.transition && this.$tip.hasClass('fade') ?
          removeWithAnimation() :
          $tip.detach()
  
        this.$element.trigger('hidden')
  
        return this
      }
  
    , fixTitle: function () {
        var $e = this.$element
        if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
          $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
        }
      }
  
    , hasContent: function () {
        return this.getTitle()
      }
  
    , getPosition: function () {
        var el = this.$element[0]
        return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
          width: el.offsetWidth
        , height: el.offsetHeight
        }, this.$element.offset())
      }
  
    , getTitle: function () {
        var title
          , $e = this.$element
          , o = this.options
  
        title = $e.attr('data-original-title')
          || (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)
  
        return title
      }
  
    , tip: function () {
        return this.$tip = this.$tip || $(this.options.template)
      }
  
    , arrow: function(){
        return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
      }
  
    , validate: function () {
        if (!this.$element[0].parentNode) {
          this.hide()
          this.$element = null
          this.options = null
        }
      }
  
    , enable: function () {
        this.enabled = true
      }
  
    , disable: function () {
        this.enabled = false
      }
  
    , toggleEnabled: function () {
        this.enabled = !this.enabled
      }
  
    , toggle: function (e) {
        var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this
        self.tip().hasClass('in') ? self.hide() : self.show()
      }
  
    , destroy: function () {
        this.hide().$element.off('.' + this.type).removeData(this.type)
      }
  
    }
  
  
   /* TOOLTIP PLUGIN DEFINITION
    * ========================= */
  
    var old = $.fn.tooltip
  
    $.fn.tooltip = function ( option ) {
      return this.each(function () {
        var $this = $(this)
          , data = $this.data('tooltip')
          , options = typeof option == 'object' && option
        if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
        if (typeof option == 'string') data[option]()
      })
    }
  
    $.fn.tooltip.Constructor = Tooltip
  
    $.fn.tooltip.defaults = {
      animation: true
    , placement: 'top'
    , selector: false
    , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
    , trigger: 'hover focus'
    , title: ''
    , delay: 0
    , html: false
    , container: false
    }
  
  
   /* TOOLTIP NO CONFLICT
    * =================== */
  
    $.fn.tooltip.noConflict = function () {
      $.fn.tooltip = old
      return this
    }
  
  }(window.jQuery);
  