/**
 * @preserve jquery.fullscreen 1.1.5
 * https://github.com/kayahr/jquery-fullscreen-plugin
 * Copyright (C) 2012-2013 Klaus Reimer <k@ailis.de>
 * Licensed under the MIT license
 * (See http://www.opensource.org/licenses/mit-license)
 */
!function(jQuery) {
  function fullScreen(state) {
    var e, func, doc;
    return this.length ? (e = this[0], e.ownerDocument ? doc = e.ownerDocument : (doc = e,
    e = doc.documentElement), null == state ? doc.exitFullscreen || doc.webkitExitFullscreen || doc.webkitCancelFullScreen || doc.msExitFullscreen || doc.mozCancelFullScreen ? (state = !!(doc.fullscreenElement || doc.msFullscreenElement || doc.webkitIsFullScreen || doc.mozFullScreen),
    state ? doc.fullscreenElement || doc.webkitFullscreenElement || doc.webkitCurrentFullScreenElement || doc.msFullscreenElement || doc.mozFullScreenElement || state : state) : null : state ? (func = e.requestFullscreen || e.webkitRequestFullscreen || e.webkitRequestFullScreen || e.msRequestFullscreen || e.mozRequestFullScreen,
    func && func.call(e), this) : (state = !!(doc.fullscreenElement || doc.msFullscreenElement || doc.webkitIsFullScreen || doc.mozFullScreen),
    func = doc.exitFullscreen || doc.webkitExitFullscreen || doc.webkitCancelFullScreen || doc.msExitFullscreen || doc.mozCancelFullScreen,
    func && state && func.call(doc), this)) : this;
  }
  function toggleFullScreen() {
    return fullScreen.call(this, !fullScreen.call(this));
  }
  function fullScreenChangeHandler(event) {
    jQuery(document).trigger(new jQuery.Event("fullscreenchange"));
  }
  function fullScreenErrorHandler(event) {
    jQuery(document).trigger(new jQuery.Event("fullscreenerror"));
  }
  function installFullScreenHandlers() {
    var e, change, error;
    e = document, e.webkitCancelFullScreen ? (change = "webkitfullscreenchange", error = "webkitfullscreenerror") : e.msExitFullscreen ? (change = "MSFullscreenChange",
    error = "MSFullscreenError") : e.mozCancelFullScreen ? (change = "mozfullscreenchange",
    error = "mozfullscreenerror") : (change = "fullscreenchange", error = "fullscreenerror"),
    jQuery(document).on(change, fullScreenChangeHandler), jQuery(document).on(error, fullScreenErrorHandler);
  }
  jQuery.fn.fullScreen = fullScreen, jQuery.fn.toggleFullScreen = toggleFullScreen,
  installFullScreenHandlers();
}(jQuery);