try {
(function() {
  var OO = {};
OO.playerParams={"auth_server":"http://player.ooyala.com/sas","api_server":"http://player.ooyala.com","next_version":"459cc1efa548f07efe5374317e801a10bfe1fddf","vast_proxy_url":"http://player.ooyala.com/adinsertion/vast_proxy","auth_ssl_server":"https://player.ooyala.com/sas","next_version_percentage":0,"backlot_api_server":"cdn-api.ooyala.com","hastur_qos_percentage":0,"pcode":"xmeXI683N_24muU9ZQrWrQE-QgXE","analytics_server":"http://player.ooyala.com","flash_performance":false,"platform":"html5-fallback","api_ssl_server":"https://player.ooyala.com","branding":{"text_color":16777215,"accent_color":39423},"attributes":{},"analytics_ssl_server":"https://player.ooyala.com","module_params":{"modules":{"visible-measures-other":{"type":"visible-measures-other","mjolnir_plugin":"","metadata":{"visible_measures_key":"a5975310954f11e286500019b9f157b5"}},"omniture-15upgrade-other":{"type":"omniture-15upgrade-other","mjolnir_plugin":"omniture.js","metadata":{"s_code_url":"http://assets.bizjournals.com/lib/js/omnitureooyala.js","omniture_root":"s"}},"discovery-ui":{"type":"discovery-ui","mjolnir_plugin":"discovery_toaster.js","metadata":{"countdownSeconds":"10","enableToasterPause":"true"}}},"base":{}},"playerBrandingId":"44c8c5a04d6945eb8592fa7e2cb072eb","namespace":"oov_rrplayerwrapper","request_url":"http://player.ooyala.com/v3/44c8c5a04d6945eb8592fa7e2cb072eb?platform=html5-fallback&namespace=oov_rrplayerwrapper","environment":"prod_us_east_1","use_asp_flash_route":false,"v3_version":"09996aa4c2283151d32c217ca3ce3e276d7bf1dd","v3_version_source":"default"};
  OO.publicApi = OO.publicApi || {};

  // used for inserting player_params in dev harness version
  // please don't remove
  // the corresponding insertion code is found at start.js

  /*INSERT_PLAYER_PARAMS*/
  OO.playerParams = OO.playerParams || {};

  OO.log = function() {
    if (typeof(window.console) != "undefined" && typeof(window.console.log) == "function") {
      if(OO.playerParams.debug) {
        window.console.log.apply(window.console, arguments);
      }
    }
  };

  // Compatibility for browsers without native JSON library (IE)
  if(!window.JSON) {
    window.JSON = {
        stringify: function(obj) {return '<object>';},
        __end_marker: true
    };
  }

  // Compatibility for browsers without native Array.prototype.indexOf (IE..)
  if(!Array.prototype.indexOf) {
    Array.prototype.indexOf = function(obj, start) {
      var i, j = this.length;
      for (i = (start || 0); i < j; i++) {
         if (this[i] === obj) { return i; }
      }
      return -1;
    };
  }

  // namespace resolution
  var namespace = OO.playerParams.namespace || 'OO'; // default namespace is OO
  // Check if there is any conflicts here. (If we load one version of player already.)
  if (window[namespace] && window[namespace].Player) {
    OO.log("PlayerV3 is loaded already!!!");
    if (window[namespace].REV != OO.publicApi.REV) {
      OO.log("there is a different VERSION loaded:", window[namespace].REV, OO.publicApi.REV);
    }
    throw "PlayerV3 already defined!!";
  }

  //we want to maintain a subset of the namespace so that OO.ready is available
  //as soon as this first script loads
  //do not clobber namespace.__static
  if (window[namespace] && window[namespace].__static) {
    OO.publicApi.__static = window[namespace].__static;
  } else {
    OO.publicApi.__static = {
      readyList:[],
      docReady: false,
      apiReady: false
   };
  }
  window[namespace] = OO.publicApi;
  window[namespace].__internal = OO;

  OO.isReady = function() {
    return OO.publicApi.__static.apiReady && OO.publicApi.__static.docReady;
  };

  OO.tryCallReady = function() {
    if (!OO.isReady()) { return;}
    while (OO.publicApi.__static.readyList.length > 0) {
      var fn = OO.publicApi.__static.readyList.pop();
      if (typeof fn === "function") {
        try {
          fn(OO.publicApi);
        } catch(e) {
          OO.log("Error executing ready function", e, e.stack);
        }
      }
    }
    return;
  };

  OO.publicApi.ready = function(fn) {
    OO.publicApi.__static.readyList.unshift(fn);
    OO.tryCallReady();
  };

  var curOO = OO;
  OO.publicApi.plugin = function(moduleName, moduleClassFactory) {
    // This is to make sure side load module will register to the correct canary code.
    if (curOO.isReady()) {
      OO.log("plugin is ready to register", curOO, moduleName);
      curOO.plugin(moduleName, moduleClassFactory);
    } else {
      OO.log("plugin", moduleName);
      // Make sure third party module is evaluated before normal ready callback.
      OO.publicApi.__static.readyList.push(function(ns){ ns.plugin(moduleName, moduleClassFactory); });
    }

  };
(function(OO) {
  function readCookie(name) {
    var i, c;
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(i = 0; i < ca.length; i++) {
      c = ca[i];
      while (c.charAt(0) == ' ') {
        c = c.substring(1, c.length);
      }
      if (c.indexOf(nameEQ) == 0) {
        return c.substring(nameEQ.length, c.length);
      }
    }
    return null;
  }

  if (window[namespace] && !window[namespace].__static.canary &&
      OO.playerParams.request_url && !OO.playerParams.request_url.match(/[?&]version=/) &&
      OO.playerParams.next_version) {
    var canaryChance = Math.random() * 100;

    if (readCookie("ooversionchance")) {
      canaryChance = parseInt(readCookie("ooversionchance"), 10);
    } else {
      document.cookie = "ooversionchance=" + canaryChance.toString() + "; path=/";
    }

    if (canaryChance < parseInt(OO.playerParams.next_version_percentage || 0, 10)) {
      window[namespace].__static.canary = true;
      var script = document.createElement('script');
      script.type = 'text/javascript';
      script.src = OO.playerParams.request_url + (OO.playerParams.request_url.indexOf('?') > 0 ? '&' : '?') +
                   'version=' + OO.playerParams.next_version;
      document.getElementsByTagName('head')[0].appendChild(script);
      throw null;
    }
  }
}(OO));//     Underscore.js 1.3.3
//     (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
//     Underscore is freely distributable under the MIT license.
//     Portions of Underscore are inspired or borrowed from Prototype,
//     Oliver Steele's Functional, and John Resig's Micro-Templating.
//     For all details and documentation:
//     http://documentcloud.github.com/underscore

(function() {

  // Baseline setup
  // --------------

  // Establish the root object, `window` in the browser, or `global` on the server.
  var root = this;

  // Save the previous value of the `_` variable.
  var previousUnderscore = root._;

  // Establish the object that gets returned to break out of a loop iteration.
  var breaker = {};

  // Save bytes in the minified (but not gzipped) version:
  var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;

  // Create quick reference variables for speed access to core prototypes.
  var slice            = ArrayProto.slice,
      unshift          = ArrayProto.unshift,
      toString         = ObjProto.toString,
      hasOwnProperty   = ObjProto.hasOwnProperty;

  // All **ECMAScript 5** native function implementations that we hope to use
  // are declared here.
  var
    nativeForEach      = ArrayProto.forEach,
    nativeMap          = ArrayProto.map,
    nativeReduce       = ArrayProto.reduce,
    nativeReduceRight  = ArrayProto.reduceRight,
    nativeFilter       = ArrayProto.filter,
    nativeEvery        = ArrayProto.every,
    nativeSome         = ArrayProto.some,
    nativeIndexOf      = ArrayProto.indexOf,
    nativeLastIndexOf  = ArrayProto.lastIndexOf,
    nativeIsArray      = Array.isArray,
    nativeKeys         = Object.keys,
    nativeBind         = FuncProto.bind;

  // Create a safe reference to the Underscore object for use below.
  var _ = function(obj) { return new wrapper(obj); };

  // Export the Underscore object for **Node.js**, with
  // backwards-compatibility for the old `require()` API. If we're in
  // the browser, add `_` as a global object via a string identifier,
  // for Closure Compiler "advanced" mode.
  if (typeof exports !== 'undefined') {
    if (typeof module !== 'undefined' && module.exports) {
      exports = module.exports = _;
    }
    exports._ = _;
  } else {
    root['_'] = _;
  }

  // Current version.
  _.VERSION = '1.3.3';

  // Collection Functions
  // --------------------

  // The cornerstone, an `each` implementation, aka `forEach`.
  // Handles objects with the built-in `forEach`, arrays, and raw objects.
  // Delegates to **ECMAScript 5**'s native `forEach` if available.
  var each = _.each = _.forEach = function(obj, iterator, context) {
    if (obj == null) return;
    if (nativeForEach && obj.forEach === nativeForEach) {
      obj.forEach(iterator, context);
    } else if (obj.length === +obj.length) {
      for (var i = 0, l = obj.length; i < l; i++) {
        if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) return;
      }
    } else {
      for (var key in obj) {
        if (_.has(obj, key)) {
          if (iterator.call(context, obj[key], key, obj) === breaker) return;
        }
      }
    }
  };

  // Return the results of applying the iterator to each element.
  // Delegates to **ECMAScript 5**'s native `map` if available.
  _.map = _.collect = function(obj, iterator, context) {
    var results = [];
    if (obj == null) return results;
    if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
    each(obj, function(value, index, list) {
      results[results.length] = iterator.call(context, value, index, list);
    });
    if (obj.length === +obj.length) results.length = obj.length;
    return results;
  };

  // **Reduce** builds up a single result from a list of values, aka `inject`,
  // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.
  _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
    var initial = arguments.length > 2;
    if (obj == null) obj = [];
    if (nativeReduce && obj.reduce === nativeReduce) {
      if (context) iterator = _.bind(iterator, context);
      return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator);
    }
    each(obj, function(value, index, list) {
      if (!initial) {
        memo = value;
        initial = true;
      } else {
        memo = iterator.call(context, memo, value, index, list);
      }
    });
    if (!initial) throw new TypeError('Reduce of empty array with no initial value');
    return memo;
  };

  // The right-associative version of reduce, also known as `foldr`.
  // Delegates to **ECMAScript 5**'s native `reduceRight` if available.
  _.reduceRight = _.foldr = function(obj, iterator, memo, context) {
    var initial = arguments.length > 2;
    if (obj == null) obj = [];
    if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {
      if (context) iterator = _.bind(iterator, context);
      return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);
    }
    var reversed = _.toArray(obj).reverse();
    if (context && !initial) iterator = _.bind(iterator, context);
    return initial ? _.reduce(reversed, iterator, memo, context) : _.reduce(reversed, iterator);
  };

  // Return the first value which passes a truth test. Aliased as `detect`.
  _.find = _.detect = function(obj, iterator, context) {
    var result;
    any(obj, function(value, index, list) {
      if (iterator.call(context, value, index, list)) {
        result = value;
        return true;
      }
    });
    return result;
  };

  // Return all the elements that pass a truth test.
  // Delegates to **ECMAScript 5**'s native `filter` if available.
  // Aliased as `select`.
  _.filter = _.select = function(obj, iterator, context) {
    var results = [];
    if (obj == null) return results;
    if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context);
    each(obj, function(value, index, list) {
      if (iterator.call(context, value, index, list)) results[results.length] = value;
    });
    return results;
  };

  // Return all the elements for which a truth test fails.
  _.reject = function(obj, iterator, context) {
    var results = [];
    if (obj == null) return results;
    each(obj, function(value, index, list) {
      if (!iterator.call(context, value, index, list)) results[results.length] = value;
    });
    return results;
  };

  // Determine whether all of the elements match a truth test.
  // Delegates to **ECMAScript 5**'s native `every` if available.
  // Aliased as `all`.
  _.every = _.all = function(obj, iterator, context) {
    var result = true;
    if (obj == null) return result;
    if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context);
    each(obj, function(value, index, list) {
      if (!(result = result && iterator.call(context, value, index, list))) return breaker;
    });
    return !!result;
  };

  // Determine if at least one element in the object matches a truth test.
  // Delegates to **ECMAScript 5**'s native `some` if available.
  // Aliased as `any`.
  var any = _.some = _.any = function(obj, iterator, context) {
    iterator || (iterator = _.identity);
    var result = false;
    if (obj == null) return result;
    if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context);
    each(obj, function(value, index, list) {
      if (result || (result = iterator.call(context, value, index, list))) return breaker;
    });
    return !!result;
  };

  // Determine if a given value is included in the array or object using `===`.
  // Aliased as `contains`.
  _.include = _.contains = function(obj, target) {
    var found = false;
    if (obj == null) return found;
    if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;
    found = any(obj, function(value) {
      return value === target;
    });
    return found;
  };

  // Invoke a method (with arguments) on every item in a collection.
  _.invoke = function(obj, method) {
    var args = slice.call(arguments, 2);
    return _.map(obj, function(value) {
      return (_.isFunction(method) ? method || value : value[method]).apply(value, args);
    });
  };

  // Convenience version of a common use case of `map`: fetching a property.
  _.pluck = function(obj, key) {
    return _.map(obj, function(value){ return value[key]; });
  };

  // Return the maximum element or (element-based computation).
  _.max = function(obj, iterator, context) {
    if (!iterator && _.isArray(obj) && obj[0] === +obj[0]) return Math.max.apply(Math, obj);
    if (!iterator && _.isEmpty(obj)) return -Infinity;
    var result = {computed : -Infinity};
    each(obj, function(value, index, list) {
      var computed = iterator ? iterator.call(context, value, index, list) : value;
      computed >= result.computed && (result = {value : value, computed : computed});
    });
    return result.value;
  };

  // Return the minimum element (or element-based computation).
  _.min = function(obj, iterator, context) {
    if (!iterator && _.isArray(obj) && obj[0] === +obj[0]) return Math.min.apply(Math, obj);
    if (!iterator && _.isEmpty(obj)) return Infinity;
    var result = {computed : Infinity};
    each(obj, function(value, index, list) {
      var computed = iterator ? iterator.call(context, value, index, list) : value;
      computed < result.computed && (result = {value : value, computed : computed});
    });
    return result.value;
  };

  // Shuffle an array.
  _.shuffle = function(obj) {
    var shuffled = [], rand;
    each(obj, function(value, index, list) {
      rand = Math.floor(Math.random() * (index + 1));
      shuffled[index] = shuffled[rand];
      shuffled[rand] = value;
    });
    return shuffled;
  };

  // Sort the object's values by a criterion produced by an iterator.
  _.sortBy = function(obj, val, context) {
    var iterator = _.isFunction(val) ? val : function(obj) { return obj[val]; };
    return _.pluck(_.map(obj, function(value, index, list) {
      return {
        value : value,
        criteria : iterator.call(context, value, index, list)
      };
    }).sort(function(left, right) {
      var a = left.criteria, b = right.criteria;
      if (a === void 0) return 1;
      if (b === void 0) return -1;
      return a < b ? -1 : a > b ? 1 : 0;
    }), 'value');
  };

  // Groups the object's values by a criterion. Pass either a string attribute
  // to group by, or a function that returns the criterion.
  _.groupBy = function(obj, val) {
    var result = {};
    var iterator = _.isFunction(val) ? val : function(obj) { return obj[val]; };
    each(obj, function(value, index) {
      var key = iterator(value, index);
      (result[key] || (result[key] = [])).push(value);
    });
    return result;
  };

  // Use a comparator function to figure out at what index an object should
  // be inserted so as to maintain order. Uses binary search.
  _.sortedIndex = function(array, obj, iterator) {
    iterator || (iterator = _.identity);
    var low = 0, high = array.length;
    while (low < high) {
      var mid = (low + high) >> 1;
      iterator(array[mid]) < iterator(obj) ? low = mid + 1 : high = mid;
    }
    return low;
  };

  // Safely convert anything iterable into a real, live array.
  _.toArray = function(obj) {
    if (!obj)                                     return [];
    if (_.isArray(obj))                           return slice.call(obj);
    if (_.isArguments(obj))                       return slice.call(obj);
    if (obj.toArray && _.isFunction(obj.toArray)) return obj.toArray();
    return _.values(obj);
  };

  // Return the number of elements in an object.
  _.size = function(obj) {
    return _.isArray(obj) ? obj.length : _.keys(obj).length;
  };

  // Array Functions
  // ---------------

  // Get the first element of an array. Passing **n** will return the first N
  // values in the array. Aliased as `head` and `take`. The **guard** check
  // allows it to work with `_.map`.
  _.first = _.head = _.take = function(array, n, guard) {
    return (n != null) && !guard ? slice.call(array, 0, n) : array[0];
  };

  // Returns everything but the last entry of the array. Especcialy useful on
  // the arguments object. Passing **n** will return all the values in
  // the array, excluding the last N. The **guard** check allows it to work with
  // `_.map`.
  _.initial = function(array, n, guard) {
    return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n));
  };

  // Get the last element of an array. Passing **n** will return the last N
  // values in the array. The **guard** check allows it to work with `_.map`.
  _.last = function(array, n, guard) {
    if ((n != null) && !guard) {
      return slice.call(array, Math.max(array.length - n, 0));
    } else {
      return array[array.length - 1];
    }
  };

  // Returns everything but the first entry of the array. Aliased as `tail`.
  // Especially useful on the arguments object. Passing an **index** will return
  // the rest of the values in the array from that index onward. The **guard**
  // check allows it to work with `_.map`.
  _.rest = _.tail = function(array, index, guard) {
    return slice.call(array, (index == null) || guard ? 1 : index);
  };

  // Trim out all falsy values from an array.
  _.compact = function(array) {
    return _.filter(array, function(value){ return !!value; });
  };

  // Return a completely flattened version of an array.
  _.flatten = function(array, shallow) {
    return _.reduce(array, function(memo, value) {
      if (_.isArray(value)) return memo.concat(shallow ? value : _.flatten(value));
      memo[memo.length] = value;
      return memo;
    }, []);
  };

  // Return a version of the array that does not contain the specified value(s).
  _.without = function(array) {
    return _.difference(array, slice.call(arguments, 1));
  };

  // Produce a duplicate-free version of the array. If the array has already
  // been sorted, you have the option of using a faster algorithm.
  // Aliased as `unique`.
  _.uniq = _.unique = function(array, isSorted, iterator) {
    var initial = iterator ? _.map(array, iterator) : array;
    var results = [];
    // The `isSorted` flag is irrelevant if the array only contains two elements.
    if (array.length < 3) isSorted = true;
    _.reduce(initial, function (memo, value, index) {
      if (isSorted ? _.last(memo) !== value || !memo.length : !_.include(memo, value)) {
        memo.push(value);
        results.push(array[index]);
      }
      return memo;
    }, []);
    return results;
  };

  // Produce an array that contains the union: each distinct element from all of
  // the passed-in arrays.
  _.union = function() {
    return _.uniq(_.flatten(arguments, true));
  };

  // Produce an array that contains every item shared between all the
  // passed-in arrays. (Aliased as "intersect" for back-compat.)
  _.intersection = _.intersect = function(array) {
    var rest = slice.call(arguments, 1);
    return _.filter(_.uniq(array), function(item) {
      return _.every(rest, function(other) {
        return _.indexOf(other, item) >= 0;
      });
    });
  };

  // Take the difference between one array and a number of other arrays.
  // Only the elements present in just the first array will remain.
  _.difference = function(array) {
    var rest = _.flatten(slice.call(arguments, 1), true);
    return _.filter(array, function(value){ return !_.include(rest, value); });
  };

  // Zip together multiple lists into a single array -- elements that share
  // an index go together.
  _.zip = function() {
    var args = slice.call(arguments);
    var length = _.max(_.pluck(args, 'length'));
    var results = new Array(length);
    for (var i = 0; i < length; i++) results[i] = _.pluck(args, "" + i);
    return results;
  };

  // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**),
  // we need this function. Return the position of the first occurrence of an
  // item in an array, or -1 if the item is not included in the array.
  // Delegates to **ECMAScript 5**'s native `indexOf` if available.
  // If the array is large and already in sort order, pass `true`
  // for **isSorted** to use binary search.
  _.indexOf = function(array, item, isSorted) {
    if (array == null) return -1;
    var i, l;
    if (isSorted) {
      i = _.sortedIndex(array, item);
      return array[i] === item ? i : -1;
    }
    if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item);
    for (i = 0, l = array.length; i < l; i++) if (i in array && array[i] === item) return i;
    return -1;
  };

  // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available.
  _.lastIndexOf = function(array, item) {
    if (array == null) return -1;
    if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) return array.lastIndexOf(item);
    var i = array.length;
    while (i--) if (i in array && array[i] === item) return i;
    return -1;
  };

  // Generate an integer Array containing an arithmetic progression. A port of
  // the native Python `range()` function. See
  // [the Python documentation](http://docs.python.org/library/functions.html#range).
  _.range = function(start, stop, step) {
    if (arguments.length <= 1) {
      stop = start || 0;
      start = 0;
    }
    step = arguments[2] || 1;

    var len = Math.max(Math.ceil((stop - start) / step), 0);
    var idx = 0;
    var range = new Array(len);

    while(idx < len) {
      range[idx++] = start;
      start += step;
    }

    return range;
  };

  // Function (ahem) Functions
  // ------------------

  // Reusable constructor function for prototype setting.
  var ctor = function(){};

  // Create a function bound to a given object (assigning `this`, and arguments,
  // optionally). Binding with arguments is also known as `curry`.
  // Delegates to **ECMAScript 5**'s native `Function.bind` if available.
  // We check for `func.bind` first, to fail fast when `func` is undefined.
  _.bind = function bind(func, context) {
    var bound, args;
    if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
    if (!_.isFunction(func)) throw new TypeError;
    args = slice.call(arguments, 2);
    return bound = function() {
      if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));
      ctor.prototype = func.prototype;
      var self = new ctor;
      var result = func.apply(self, args.concat(slice.call(arguments)));
      if (Object(result) === result) return result;
      return self;
    };
  };

  // Bind all of an object's methods to that object. Useful for ensuring that
  // all callbacks defined on an object belong to it.
  _.bindAll = function(obj) {
    var funcs = slice.call(arguments, 1);
    if (funcs.length == 0) funcs = _.functions(obj);
    each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
    return obj;
  };

  // Memoize an expensive function by storing its results.
  _.memoize = function(func, hasher) {
    var memo = {};
    hasher || (hasher = _.identity);
    return function() {
      var key = hasher.apply(this, arguments);
      return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
    };
  };

  // Delays a function for the given number of milliseconds, and then calls
  // it with the arguments supplied.
  _.delay = function(func, wait) {
    var args = slice.call(arguments, 2);
    return setTimeout(function(){ return func.apply(null, args); }, wait);
  };

  // Defers a function, scheduling it to run after the current call stack has
  // cleared.
  _.defer = function(func) {
    return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1)));
  };

  // Returns a function, that, when invoked, will only be triggered at most once
  // during a given window of time.
  _.throttle = function(func, wait) {
    var context, args, timeout, throttling, more, result;
    var whenDone = _.debounce(function(){ more = throttling = false; }, wait);
    return function() {
      context = this; args = arguments;
      var later = function() {
        timeout = null;
        if (more) func.apply(context, args);
        whenDone();
      };
      if (!timeout) timeout = setTimeout(later, wait);
      if (throttling) {
        more = true;
      } else {
        result = func.apply(context, args);
      }
      whenDone();
      throttling = true;
      return result;
    };
  };

  // Returns a function, that, as long as it continues to be invoked, will not
  // be triggered. The function will be called after it stops being called for
  // N milliseconds. If `immediate` is passed, trigger the function on the
  // leading edge, instead of the trailing.
  _.debounce = function(func, wait, immediate) {
    var timeout;
    return function() {
      var context = this, args = arguments;
      var later = function() {
        timeout = null;
        if (!immediate) func.apply(context, args);
      };
      if (immediate && !timeout) func.apply(context, args);
      clearTimeout(timeout);
      timeout = setTimeout(later, wait);
    };
  };

  // Returns a function that will be executed at most one time, no matter how
  // often you call it. Useful for lazy initialization.
  _.once = function(func) {
    var ran = false, memo;
    return function() {
      if (ran) return memo;
      ran = true;
      return memo = func.apply(this, arguments);
    };
  };

  // Returns the first function passed as an argument to the second,
  // allowing you to adjust arguments, run code before and after, and
  // conditionally execute the original function.
  _.wrap = function(func, wrapper) {
    return function() {
      var args = [func].concat(slice.call(arguments, 0));
      return wrapper.apply(this, args);
    };
  };

  // Returns a function that is the composition of a list of functions, each
  // consuming the return value of the function that follows.
  _.compose = function() {
    var funcs = arguments;
    return function() {
      var args = arguments;
      for (var i = funcs.length - 1; i >= 0; i--) {
        args = [funcs[i].apply(this, args)];
      }
      return args[0];
    };
  };

  // Returns a function that will only be executed after being called N times.
  _.after = function(times, func) {
    if (times <= 0) return func();
    return function() {
      if (--times < 1) { return func.apply(this, arguments); }
    };
  };

  // Object Functions
  // ----------------

  // Retrieve the names of an object's properties.
  // Delegates to **ECMAScript 5**'s native `Object.keys`
  _.keys = nativeKeys || function(obj) {
    if (obj !== Object(obj)) throw new TypeError('Invalid object');
    var keys = [];
    for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key;
    return keys;
  };

  // Retrieve the values of an object's properties.
  _.values = function(obj) {
    return _.map(obj, _.identity);
  };

  // Return a sorted list of the function names available on the object.
  // Aliased as `methods`
  _.functions = _.methods = function(obj) {
    var names = [];
    for (var key in obj) {
      if (_.isFunction(obj[key])) names.push(key);
    }
    return names.sort();
  };

  // Extend a given object with all the properties in passed-in object(s).
  _.extend = function(obj) {
    each(slice.call(arguments, 1), function(source) {
      for (var prop in source) {
        obj[prop] = source[prop];
      }
    });
    return obj;
  };

  // Return a copy of the object only containing the whitelisted properties.
  _.pick = function(obj) {
    var result = {};
    each(_.flatten(slice.call(arguments, 1)), function(key) {
      if (key in obj) result[key] = obj[key];
    });
    return result;
  };

  // Fill in a given object with default properties.
  _.defaults = function(obj) {
    each(slice.call(arguments, 1), function(source) {
      for (var prop in source) {
        if (obj[prop] == null) obj[prop] = source[prop];
      }
    });
    return obj;
  };

  // Create a (shallow-cloned) duplicate of an object.
  _.clone = function(obj) {
    if (!_.isObject(obj)) return obj;
    return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
  };

  // Invokes interceptor with the obj, and then returns obj.
  // The primary purpose of this method is to "tap into" a method chain, in
  // order to perform operations on intermediate results within the chain.
  _.tap = function(obj, interceptor) {
    interceptor(obj);
    return obj;
  };

  // Internal recursive comparison function.
  function eq(a, b, stack) {
    // Identical objects are equal. `0 === -0`, but they aren't identical.
    // See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal.
    if (a === b) return a !== 0 || 1 / a == 1 / b;
    // A strict comparison is necessary because `null == undefined`.
    if (a == null || b == null) return a === b;
    // Unwrap any wrapped objects.
    if (a._chain) a = a._wrapped;
    if (b._chain) b = b._wrapped;
    // Invoke a custom `isEqual` method if one is provided.
    if (a.isEqual && _.isFunction(a.isEqual)) return a.isEqual(b);
    if (b.isEqual && _.isFunction(b.isEqual)) return b.isEqual(a);
    // Compare `[[Class]]` names.
    var className = toString.call(a);
    if (className != toString.call(b)) return false;
    switch (className) {
      // Strings, numbers, dates, and booleans are compared by value.
      case '[object String]':
        // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
        // equivalent to `new String("5")`.
        return a == String(b);
      case '[object Number]':
        // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
        // other numeric values.
        return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
      case '[object Date]':
      case '[object Boolean]':
        // Coerce dates and booleans to numeric primitive values. Dates are compared by their
        // millisecond representations. Note that invalid dates with millisecond representations
        // of `NaN` are not equivalent.
        return +a == +b;
      // RegExps are compared by their source patterns and flags.
      case '[object RegExp]':
        return a.source == b.source &&
               a.global == b.global &&
               a.multiline == b.multiline &&
               a.ignoreCase == b.ignoreCase;
    }
    if (typeof a != 'object' || typeof b != 'object') return false;
    // Assume equality for cyclic structures. The algorithm for detecting cyclic
    // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
    var length = stack.length;
    while (length--) {
      // Linear search. Performance is inversely proportional to the number of
      // unique nested structures.
      if (stack[length] == a) return true;
    }
    // Add the first object to the stack of traversed objects.
    stack.push(a);
    var size = 0, result = true;
    // Recursively compare objects and arrays.
    if (className == '[object Array]') {
      // Compare array lengths to determine if a deep comparison is necessary.
      size = a.length;
      result = size == b.length;
      if (result) {
        // Deep compare the contents, ignoring non-numeric properties.
        while (size--) {
          // Ensure commutative equality for sparse arrays.
          if (!(result = size in a == size in b && eq(a[size], b[size], stack))) break;
        }
      }
    } else {
      // Objects with different constructors are not equivalent.
      if ('constructor' in a != 'constructor' in b || a.constructor != b.constructor) return false;
      // Deep compare objects.
      for (var key in a) {
        if (_.has(a, key)) {
          // Count the expected number of properties.
          size++;
          // Deep compare each member.
          if (!(result = _.has(b, key) && eq(a[key], b[key], stack))) break;
        }
      }
      // Ensure that both objects contain the same number of properties.
      if (result) {
        for (key in b) {
          if (_.has(b, key) && !(size--)) break;
        }
        result = !size;
      }
    }
    // Remove the first object from the stack of traversed objects.
    stack.pop();
    return result;
  }

  // Perform a deep comparison to check if two objects are equal.
  _.isEqual = function(a, b) {
    return eq(a, b, []);
  };

  // Is a given array, string, or object empty?
  // An "empty" object has no enumerable own-properties.
  _.isEmpty = function(obj) {
    if (obj == null) return true;
    if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;
    for (var key in obj) if (_.has(obj, key)) return false;
    return true;
  };

  // Is a given value a DOM element?
  _.isElement = function(obj) {
    return !!(obj && obj.nodeType == 1);
  };

  // Is a given value an array?
  // Delegates to ECMA5's native Array.isArray
  _.isArray = nativeIsArray || function(obj) {
    return toString.call(obj) == '[object Array]';
  };

  // Is a given variable an object?
  _.isObject = function(obj) {
    return obj === Object(obj);
  };

  // Is a given variable an arguments object?
  _.isArguments = function(obj) {
    return toString.call(obj) == '[object Arguments]';
  };
  if (!_.isArguments(arguments)) {
    _.isArguments = function(obj) {
      return !!(obj && _.has(obj, 'callee'));
    };
  }

  // Is a given value a function?
  _.isFunction = function(obj) {
    return toString.call(obj) == '[object Function]';
  };

  // Is a given value a string?
  _.isString = function(obj) {
    return toString.call(obj) == '[object String]';
  };

  // Is a given value a number?
  _.isNumber = function(obj) {
    return toString.call(obj) == '[object Number]';
  };

  // Is a given object a finite number?
  _.isFinite = function(obj) {
    return _.isNumber(obj) && isFinite(obj);
  };

  // Is the given value `NaN`?
  _.isNaN = function(obj) {
    // `NaN` is the only value for which `===` is not reflexive.
    return obj !== obj;
  };

  // Is a given value a boolean?
  _.isBoolean = function(obj) {
    return obj === true || obj === false || toString.call(obj) == '[object Boolean]';
  };

  // Is a given value a date?
  _.isDate = function(obj) {
    return toString.call(obj) == '[object Date]';
  };

  // Is the given value a regular expression?
  _.isRegExp = function(obj) {
    return toString.call(obj) == '[object RegExp]';
  };

  // Is a given value equal to null?
  _.isNull = function(obj) {
    return obj === null;
  };

  // Is a given variable undefined?
  _.isUndefined = function(obj) {
    return obj === void 0;
  };

  // Has own property?
  _.has = function(obj, key) {
    // Original Underscore Code
    //return hasOwnProperty.call(obj, key);

    // Replacement code (the reason for this is that IE<9 don't define hasOwnProperty on DOM nodes)
    if(typeof (obj.hasOwnProperty) === "function") {
      return obj.hasOwnProperty(key);
    } else {
      return !(typeof (obj[key]) === undefined);
    }
  };

  // Utility Functions
  // -----------------

  // Run Underscore.js in *noConflict* mode, returning the `_` variable to its
  // previous owner. Returns a reference to the Underscore object.
  _.noConflict = function() {
    root._ = previousUnderscore;
    return this;
  };

  // Keep the identity function around for default iterators.
  _.identity = function(value) {
    return value;
  };

  // Run a function **n** times.
  _.times = function (n, iterator, context) {
    for (var i = 0; i < n; i++) iterator.call(context, i);
  };

  // Escape a string for HTML interpolation.
  _.escape = function(string) {
    return (''+string).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g,'&#x2F;');
  };

  // If the value of the named property is a function then invoke it;
  // otherwise, return it.
  _.result = function(object, property) {
    if (object == null) return null;
    var value = object[property];
    return _.isFunction(value) ? value.call(object) : value;
  };

  // Add your own custom functions to the Underscore object, ensuring that
  // they're correctly added to the OOP wrapper as well.
  _.mixin = function(obj) {
    each(_.functions(obj), function(name){
      addToWrapper(name, _[name] = obj[name]);
    });
  };

  // Generate a unique integer id (unique within the entire client session).
  // Useful for temporary DOM ids.
  var idCounter = 0;
  _.uniqueId = function(prefix) {
    var id = idCounter++;
    return prefix ? prefix + id : id;
  };

  // By default, Underscore uses ERB-style template delimiters, change the
  // following template settings to use alternative delimiters.
  _.templateSettings = {
    evaluate    : /<%([\s\S]+?)%>/g,
    interpolate : /<%=([\s\S]+?)%>/g,
    escape      : /<%-([\s\S]+?)%>/g
  };

  // When customizing `templateSettings`, if you don't want to define an
  // interpolation, evaluation or escaping regex, we need one that is
  // guaranteed not to match.
  var noMatch = /.^/;

  // Certain characters need to be escaped so that they can be put into a
  // string literal.
  var escapes = {
    '\\': '\\',
    "'": "'",
    'r': '\r',
    'n': '\n',
    't': '\t',
    'u2028': '\u2028',
    'u2029': '\u2029'
  };

  for (var p in escapes) escapes[escapes[p]] = p;
  var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g;
  var unescaper = /\\(\\|'|r|n|t|u2028|u2029)/g;

  // Within an interpolation, evaluation, or escaping, remove HTML escaping
  // that had been previously added.
  var unescape = function(code) {
    return code.replace(unescaper, function(match, escape) {
      return escapes[escape];
    });
  };

  // JavaScript micro-templating, similar to John Resig's implementation.
  // Underscore templating handles arbitrary delimiters, preserves whitespace,
  // and correctly escapes quotes within interpolated code.
  _.template = function(text, data, settings) {
    settings = _.defaults(settings || {}, _.templateSettings);

    // Compile the template source, taking care to escape characters that
    // cannot be included in a string literal and then unescape them in code
    // blocks.
    var source = "__p+='" + text
      .replace(escaper, function(match) {
        return '\\' + escapes[match];
      })
      .replace(settings.escape || noMatch, function(match, code) {
        return "'+\n_.escape(" + unescape(code) + ")+\n'";
      })
      .replace(settings.interpolate || noMatch, function(match, code) {
        return "'+\n(" + unescape(code) + ")+\n'";
      })
      .replace(settings.evaluate || noMatch, function(match, code) {
        return "';\n" + unescape(code) + "\n;__p+='";
      }) + "';\n";

    // If a variable is not specified, place data values in local scope.
    if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';

    source = "var __p='';" +
      "var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n" +
      source + "return __p;\n";

    var render = new Function(settings.variable || 'obj', '_', source);
    if (data) return render(data, _);
    var template = function(data) {
      return render.call(this, data, _);
    };

    // Provide the compiled function source as a convenience for build time
    // precompilation.
    template.source = 'function(' + (settings.variable || 'obj') + '){\n' +
      source + '}';

    return template;
  };

  // Add a "chain" function, which will delegate to the wrapper.
  _.chain = function(obj) {
    return _(obj).chain();
  };

  // The OOP Wrapper
  // ---------------

  // If Underscore is called as a function, it returns a wrapped object that
  // can be used OO-style. This wrapper holds altered versions of all the
  // underscore functions. Wrapped objects may be chained.
  var wrapper = function(obj) { this._wrapped = obj; };

  // Expose `wrapper.prototype` as `_.prototype`
  _.prototype = wrapper.prototype;

  // Helper function to continue chaining intermediate results.
  var result = function(obj, chain) {
    return chain ? _(obj).chain() : obj;
  };

  // A method to easily add functions to the OOP wrapper.
  var addToWrapper = function(name, func) {
    wrapper.prototype[name] = function() {
      var args = slice.call(arguments);
      unshift.call(args, this._wrapped);
      return result(func.apply(_, args), this._chain);
    };
  };

  // Add all of the Underscore functions to the wrapper object.
  _.mixin(_);

  // Add all mutator Array functions to the wrapper.
  each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
    var method = ArrayProto[name];
    wrapper.prototype[name] = function() {
      var wrapped = this._wrapped;
      method.apply(wrapped, arguments);
      var length = wrapped.length;
      if ((name == 'shift' || name == 'splice') && length === 0) delete wrapped[0];
      return result(wrapped, this._chain);
    };
  });

  // Add all accessor Array functions to the wrapper.
  each(['concat', 'join', 'slice'], function(name) {
    var method = ArrayProto[name];
    wrapper.prototype[name] = function() {
      return result(method.apply(this._wrapped, arguments), this._chain);
    };
  });

  // Start chaining a wrapped Underscore object.
  wrapper.prototype.chain = function() {
    this._chain = true;
    return this;
  };

  // Extracts the result from a wrapped and chained object.
  wrapper.prototype.value = function() {
    return this._wrapped;
  };

}).call(this);
/*!
 * jQuery JavaScript Library v1.8.3
 * http://jquery.com/
 *
 * Includes Sizzle.js
 * http://sizzlejs.com/
 *
 * Copyright 2012 jQuery Foundation and other contributors
 * Released under the MIT license
 * http://jquery.org/license
 *
 * Date: Tue Nov 13 2012 08:20:33 GMT-0500 (Eastern Standard Time)
 */
(function( window, undefined ) {
var
	// A central reference to the root jQuery(document)
	rootjQuery,

	// The deferred used on DOM ready
	readyList,

	// Use the correct document accordingly with window argument (sandbox)
	document = window.document,
	location = window.location,
	navigator = window.navigator,

	// Map over jQuery in case of overwrite
	_jQuery = window.jQuery,

	// Map over the $ in case of overwrite
	_$ = window.$,

	// Save a reference to some core methods
	core_push = Array.prototype.push,
	core_slice = Array.prototype.slice,
	core_indexOf = Array.prototype.indexOf,
	core_toString = Object.prototype.toString,
	core_hasOwn = Object.prototype.hasOwnProperty,
	core_trim = String.prototype.trim,

	// Define a local copy of jQuery
	jQuery = function( selector, context ) {
		// The jQuery object is actually just the init constructor 'enhanced'
		return new jQuery.fn.init( selector, context, rootjQuery );
	},

	// Used for matching numbers
	core_pnum = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,

	// Used for detecting and trimming whitespace
	core_rnotwhite = /\S/,
	core_rspace = /\s+/,

	// Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
	rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,

	// A simple way to check for HTML strings
	// Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
	rquickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,

	// Match a standalone tag
	rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,

	// JSON RegExp
	rvalidchars = /^[\],:{}\s]*$/,
	rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
	rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
	rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,

	// Matches dashed string for camelizing
	rmsPrefix = /^-ms-/,
	rdashAlpha = /-([\da-z])/gi,

	// Used by jQuery.camelCase as callback to replace()
	fcamelCase = function( all, letter ) {
		return ( letter + "" ).toUpperCase();
	},

	// The ready event handler and self cleanup method
	DOMContentLoaded = function() {
		if ( document.addEventListener ) {
			document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
			jQuery.ready();
		} else if ( document.readyState === "complete" ) {
			// we're here because readyState === "complete" in oldIE
			// which is good enough for us to call the dom ready!
			document.detachEvent( "onreadystatechange", DOMContentLoaded );
			jQuery.ready();
		}
	},

	// [[Class]] -> type pairs
	class2type = {};

jQuery.fn = jQuery.prototype = {
	constructor: jQuery,
	init: function( selector, context, rootjQuery ) {
		var match, elem, ret, doc;

		// Handle $(""), $(null), $(undefined), $(false)
		if ( !selector ) {
			return this;
		}

		// Handle $(DOMElement)
		if ( selector.nodeType ) {
			this.context = this[0] = selector;
			this.length = 1;
			return this;
		}

		// Handle HTML strings
		if ( typeof selector === "string" ) {
			if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
				// Assume that strings that start and end with <> are HTML and skip the regex check
				match = [ null, selector, null ];

			} else {
				match = rquickExpr.exec( selector );
			}

			// Match html or make sure no context is specified for #id
			if ( match && (match[1] || !context) ) {

				// HANDLE: $(html) -> $(array)
				if ( match[1] ) {
					context = context instanceof jQuery ? context[0] : context;
					doc = ( context && context.nodeType ? context.ownerDocument || context : document );

					// scripts is true for back-compat
					selector = jQuery.parseHTML( match[1], doc, true );
					if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
						this.attr.call( selector, context, true );
					}

					return jQuery.merge( this, selector );

				// HANDLE: $(#id)
				} else {
					elem = document.getElementById( match[2] );

					// Check parentNode to catch when Blackberry 4.6 returns
					// nodes that are no longer in the document #6963
					if ( elem && elem.parentNode ) {
						// Handle the case where IE and Opera return items
						// by name instead of ID
						if ( elem.id !== match[2] ) {
							return rootjQuery.find( selector );
						}

						// Otherwise, we inject the element directly into the jQuery object
						this.length = 1;
						this[0] = elem;
					}

					this.context = document;
					this.selector = selector;
					return this;
				}

			// HANDLE: $(expr, $(...))
			} else if ( !context || context.jquery ) {
				return ( context || rootjQuery ).find( selector );

			// HANDLE: $(expr, context)
			// (which is just equivalent to: $(context).find(expr)
			} else {
				return this.constructor( context ).find( selector );
			}

		// HANDLE: $(function)
		// Shortcut for document ready
		} else if ( jQuery.isFunction( selector ) ) {
			return rootjQuery.ready( selector );
		}

		if ( selector.selector !== undefined ) {
			this.selector = selector.selector;
			this.context = selector.context;
		}

		return jQuery.makeArray( selector, this );
	},

	// Start with an empty selector
	selector: "",

	// The current version of jQuery being used
	jquery: "1.8.3",

	// The default length of a jQuery object is 0
	length: 0,

	// The number of elements contained in the matched element set
	size: function() {
		return this.length;
	},

	toArray: function() {
		return core_slice.call( this );
	},

	// Get the Nth element in the matched element set OR
	// Get the whole matched element set as a clean array
	get: function( num ) {
		return num == null ?

			// Return a 'clean' array
			this.toArray() :

			// Return just the object
			( num < 0 ? this[ this.length + num ] : this[ num ] );
	},

	// Take an array of elements and push it onto the stack
	// (returning the new matched element set)
	pushStack: function( elems, name, selector ) {

		// Build a new jQuery matched element set
		var ret = jQuery.merge( this.constructor(), elems );

		// Add the old object onto the stack (as a reference)
		ret.prevObject = this;

		ret.context = this.context;

		if ( name === "find" ) {
			ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
		} else if ( name ) {
			ret.selector = this.selector + "." + name + "(" + selector + ")";
		}

		// Return the newly-formed element set
		return ret;
	},

	// Execute a callback for every element in the matched set.
	// (You can seed the arguments with an array of args, but this is
	// only used internally.)
	each: function( callback, args ) {
		return jQuery.each( this, callback, args );
	},

	ready: function( fn ) {
		// Add the callback
		jQuery.ready.promise().done( fn );

		return this;
	},

	eq: function( i ) {
		i = +i;
		return i === -1 ?
			this.slice( i ) :
			this.slice( i, i + 1 );
	},

	first: function() {
		return this.eq( 0 );
	},

	last: function() {
		return this.eq( -1 );
	},

	slice: function() {
		return this.pushStack( core_slice.apply( this, arguments ),
			"slice", core_slice.call(arguments).join(",") );
	},

	map: function( callback ) {
		return this.pushStack( jQuery.map(this, function( elem, i ) {
			return callback.call( elem, i, elem );
		}));
	},

	end: function() {
		return this.prevObject || this.constructor(null);
	},

	// For internal use only.
	// Behaves like an Array's method, not like a jQuery method.
	push: core_push,
	sort: [].sort,
	splice: [].splice
};

// Give the init function the jQuery prototype for later instantiation
jQuery.fn.init.prototype = jQuery.fn;

jQuery.extend = jQuery.fn.extend = function() {
	var options, name, src, copy, copyIsArray, clone,
		target = arguments[0] || {},
		i = 1,
		length = arguments.length,
		deep = false;

	// Handle a deep copy situation
	if ( typeof target === "boolean" ) {
		deep = target;
		target = arguments[1] || {};
		// skip the boolean and the target
		i = 2;
	}

	// Handle case when target is a string or something (possible in deep copy)
	if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
		target = {};
	}

	// extend jQuery itself if only one argument is passed
	if ( length === i ) {
		target = this;
		--i;
	}

	for ( ; i < length; i++ ) {
		// Only deal with non-null/undefined values
		if ( (options = arguments[ i ]) != null ) {
			// Extend the base object
			for ( name in options ) {
				src = target[ name ];
				copy = options[ name ];

				// Prevent never-ending loop
				if ( target === copy ) {
					continue;
				}

				// Recurse if we're merging plain objects or arrays
				if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
					if ( copyIsArray ) {
						copyIsArray = false;
						clone = src && jQuery.isArray(src) ? src : [];

					} else {
						clone = src && jQuery.isPlainObject(src) ? src : {};
					}

					// Never move original objects, clone them
					target[ name ] = jQuery.extend( deep, clone, copy );

				// Don't bring in undefined values
				} else if ( copy !== undefined ) {
					target[ name ] = copy;
				}
			}
		}
	}

	// Return the modified object
	return target;
};

jQuery.extend({
	noConflict: function( deep ) {
		if ( window.$ === jQuery ) {
			window.$ = _$;
		}

		if ( deep && window.jQuery === jQuery ) {
			window.jQuery = _jQuery;
		}

		return jQuery;
	},

	// Is the DOM ready to be used? Set to true once it occurs.
	isReady: false,

	// A counter to track how many items to wait for before
	// the ready event fires. See #6781
	readyWait: 1,

	// Hold (or release) the ready event
	holdReady: function( hold ) {
		if ( hold ) {
			jQuery.readyWait++;
		} else {
			jQuery.ready( true );
		}
	},

	// Handle when the DOM is ready
	ready: function( wait ) {

		// Abort if there are pending holds or we're already ready
		if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
			return;
		}

		// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
		if ( !document.body ) {
			return setTimeout( jQuery.ready, 1 );
		}

		// Remember that the DOM is ready
		jQuery.isReady = true;

		// If a normal DOM Ready event fired, decrement, and wait if need be
		if ( wait !== true && --jQuery.readyWait > 0 ) {
			return;
		}

		// If there are functions bound, to execute
		readyList.resolveWith( document, [ jQuery ] );

		// Trigger any bound ready events
		if ( jQuery.fn.trigger ) {
			jQuery( document ).trigger("ready").off("ready");
		}
	},

	// See test/unit/core.js for details concerning isFunction.
	// Since version 1.3, DOM methods and functions like alert
	// aren't supported. They return false on IE (#2968).
	isFunction: function( obj ) {
		return jQuery.type(obj) === "function";
	},

	isArray: Array.isArray || function( obj ) {
		return jQuery.type(obj) === "array";
	},

	isWindow: function( obj ) {
		return obj != null && obj == obj.window;
	},

	isNumeric: function( obj ) {
		return !isNaN( parseFloat(obj) ) && isFinite( obj );
	},

	type: function( obj ) {
		return obj == null ?
			String( obj ) :
			class2type[ core_toString.call(obj) ] || "object";
	},

	isPlainObject: function( obj ) {
		// Must be an Object.
		// Because of IE, we also have to check the presence of the constructor property.
		// Make sure that DOM nodes and window objects don't pass through, as well
		if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
			return false;
		}

		try {
			// Not own constructor property must be Object
			if ( obj.constructor &&
				!core_hasOwn.call(obj, "constructor") &&
				!core_hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
				return false;
			}
		} catch ( e ) {
			// IE8,9 Will throw exceptions on certain host objects #9897
			return false;
		}

		// Own properties are enumerated firstly, so to speed up,
		// if last one is own, then all properties are own.

		var key;
		for ( key in obj ) {}

		return key === undefined || core_hasOwn.call( obj, key );
	},

	isEmptyObject: function( obj ) {
		var name;
		for ( name in obj ) {
			return false;
		}
		return true;
	},

	error: function( msg ) {
		throw new Error( msg );
	},

	// data: string of html
	// context (optional): If specified, the fragment will be created in this context, defaults to document
	// scripts (optional): If true, will include scripts passed in the html string
	parseHTML: function( data, context, scripts ) {
		var parsed;
		if ( !data || typeof data !== "string" ) {
			return null;
		}
		if ( typeof context === "boolean" ) {
			scripts = context;
			context = 0;
		}
		context = context || document;

		// Single tag
		if ( (parsed = rsingleTag.exec( data )) ) {
			return [ context.createElement( parsed[1] ) ];
		}

		parsed = jQuery.buildFragment( [ data ], context, scripts ? null : [] );
		return jQuery.merge( [],
			(parsed.cacheable ? jQuery.clone( parsed.fragment ) : parsed.fragment).childNodes );
	},

	parseJSON: function( data ) {
		if ( !data || typeof data !== "string") {
			return null;
		}

		// Make sure leading/trailing whitespace is removed (IE can't handle it)
		data = jQuery.trim( data );

		// Attempt to parse using the native JSON parser first
		if ( window.JSON && window.JSON.parse ) {
			return window.JSON.parse( data );
		}

		// Make sure the incoming data is actual JSON
		// Logic borrowed from http://json.org/json2.js
		if ( rvalidchars.test( data.replace( rvalidescape, "@" )
			.replace( rvalidtokens, "]" )
			.replace( rvalidbraces, "")) ) {

			return ( new Function( "return " + data ) )();

		}
		jQuery.error( "Invalid JSON: " + data );
	},

	// Cross-browser xml parsing
	parseXML: function( data ) {
		var xml, tmp;
		if ( !data || typeof data !== "string" ) {
			return null;
		}
		try {
			if ( window.DOMParser ) { // Standard
				tmp = new DOMParser();
				xml = tmp.parseFromString( data , "text/xml" );
			} else { // IE
				xml = new ActiveXObject( "Microsoft.XMLDOM" );
				xml.async = "false";
				xml.loadXML( data );
			}
		} catch( e ) {
			xml = undefined;
		}
		if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
			jQuery.error( "Invalid XML: " + data );
		}
		return xml;
	},

	noop: function() {},

	// Evaluates a script in a global context
	// Workarounds based on findings by Jim Driscoll
	// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
	globalEval: function( data ) {
		if ( data && core_rnotwhite.test( data ) ) {
			// We use execScript on Internet Explorer
			// We use an anonymous function so that context is window
			// rather than jQuery in Firefox
			( window.execScript || function( data ) {
				window[ "eval" ].call( window, data );
			} )( data );
		}
	},

	// Convert dashed to camelCase; used by the css and data modules
	// Microsoft forgot to hump their vendor prefix (#9572)
	camelCase: function( string ) {
		return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
	},

	nodeName: function( elem, name ) {
		return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
	},

	// args is for internal usage only
	each: function( obj, callback, args ) {
		var name,
			i = 0,
			length = obj.length,
			isObj = length === undefined || jQuery.isFunction( obj );

		if ( args ) {
			if ( isObj ) {
				for ( name in obj ) {
					if ( callback.apply( obj[ name ], args ) === false ) {
						break;
					}
				}
			} else {
				for ( ; i < length; ) {
					if ( callback.apply( obj[ i++ ], args ) === false ) {
						break;
					}
				}
			}

		// A special, fast, case for the most common use of each
		} else {
			if ( isObj ) {
				for ( name in obj ) {
					if ( callback.call( obj[ name ], name, obj[ name ] ) === false ) {
						break;
					}
				}
			} else {
				for ( ; i < length; ) {
					if ( callback.call( obj[ i ], i, obj[ i++ ] ) === false ) {
						break;
					}
				}
			}
		}

		return obj;
	},

	// Use native String.trim function wherever possible
	trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
		function( text ) {
			return text == null ?
				"" :
				core_trim.call( text );
		} :

		// Otherwise use our own trimming functionality
		function( text ) {
			return text == null ?
				"" :
				( text + "" ).replace( rtrim, "" );
		},

	// results is for internal usage only
	makeArray: function( arr, results ) {
		var type,
			ret = results || [];

		if ( arr != null ) {
			// The window, strings (and functions) also have 'length'
			// Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
			type = jQuery.type( arr );

			if ( arr.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( arr ) ) {
				core_push.call( ret, arr );
			} else {
				jQuery.merge( ret, arr );
			}
		}

		return ret;
	},

	inArray: function( elem, arr, i ) {
		var len;

		if ( arr ) {
			if ( core_indexOf ) {
				return core_indexOf.call( arr, elem, i );
			}

			len = arr.length;
			i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;

			for ( ; i < len; i++ ) {
				// Skip accessing in sparse arrays
				if ( i in arr && arr[ i ] === elem ) {
					return i;
				}
			}
		}

		return -1;
	},

	merge: function( first, second ) {
		var l = second.length,
			i = first.length,
			j = 0;

		if ( typeof l === "number" ) {
			for ( ; j < l; j++ ) {
				first[ i++ ] = second[ j ];
			}

		} else {
			while ( second[j] !== undefined ) {
				first[ i++ ] = second[ j++ ];
			}
		}

		first.length = i;

		return first;
	},

	grep: function( elems, callback, inv ) {
		var retVal,
			ret = [],
			i = 0,
			length = elems.length;
		inv = !!inv;

		// Go through the array, only saving the items
		// that pass the validator function
		for ( ; i < length; i++ ) {
			retVal = !!callback( elems[ i ], i );
			if ( inv !== retVal ) {
				ret.push( elems[ i ] );
			}
		}

		return ret;
	},

	// arg is for internal usage only
	map: function( elems, callback, arg ) {
		var value, key,
			ret = [],
			i = 0,
			length = elems.length,
			// jquery objects are treated as arrays
			isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;

		// Go through the array, translating each of the items to their
		if ( isArray ) {
			for ( ; i < length; i++ ) {
				value = callback( elems[ i ], i, arg );

				if ( value != null ) {
					ret[ ret.length ] = value;
				}
			}

		// Go through every key on the object,
		} else {
			for ( key in elems ) {
				value = callback( elems[ key ], key, arg );

				if ( value != null ) {
					ret[ ret.length ] = value;
				}
			}
		}

		// Flatten any nested arrays
		return ret.concat.apply( [], ret );
	},

	// A global GUID counter for objects
	guid: 1,

	// Bind a function to a context, optionally partially applying any
	// arguments.
	proxy: function( fn, context ) {
		var tmp, args, proxy;

		if ( typeof context === "string" ) {
			tmp = fn[ context ];
			context = fn;
			fn = tmp;
		}

		// Quick check to determine if target is callable, in the spec
		// this throws a TypeError, but we will just return undefined.
		if ( !jQuery.isFunction( fn ) ) {
			return undefined;
		}

		// Simulated bind
		args = core_slice.call( arguments, 2 );
		proxy = function() {
			return fn.apply( context, args.concat( core_slice.call( arguments ) ) );
		};

		// Set the guid of unique handler to the same of original handler, so it can be removed
		proxy.guid = fn.guid = fn.guid || jQuery.guid++;

		return proxy;
	},

	// Multifunctional method to get and set values of a collection
	// The value/s can optionally be executed if it's a function
	access: function( elems, fn, key, value, chainable, emptyGet, pass ) {
		var exec,
			bulk = key == null,
			i = 0,
			length = elems.length;

		// Sets many values
		if ( key && typeof key === "object" ) {
			for ( i in key ) {
				jQuery.access( elems, fn, i, key[i], 1, emptyGet, value );
			}
			chainable = 1;

		// Sets one value
		} else if ( value !== undefined ) {
			// Optionally, function values get executed if exec is true
			exec = pass === undefined && jQuery.isFunction( value );

			if ( bulk ) {
				// Bulk operations only iterate when executing function values
				if ( exec ) {
					exec = fn;
					fn = function( elem, key, value ) {
						return exec.call( jQuery( elem ), value );
					};

				// Otherwise they run against the entire set
				} else {
					fn.call( elems, value );
					fn = null;
				}
			}

			if ( fn ) {
				for (; i < length; i++ ) {
					fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
				}
			}

			chainable = 1;
		}

		return chainable ?
			elems :

			// Gets
			bulk ?
				fn.call( elems ) :
				length ? fn( elems[0], key ) : emptyGet;
	},

	now: function() {
		return ( new Date() ).getTime();
	}
});

jQuery.ready.promise = function( obj ) {
	if ( !readyList ) {

		readyList = jQuery.Deferred();

		// Catch cases where $(document).ready() is called after the browser event has already occurred.
		// we once tried to use readyState "interactive" here, but it caused issues like the one
		// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
		if ( document.readyState === "complete" ) {
			// Handle it asynchronously to allow scripts the opportunity to delay ready
			setTimeout( jQuery.ready, 1 );

		// Standards-based browsers support DOMContentLoaded
		} else if ( document.addEventListener ) {
			// Use the handy event callback
			document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );

			// A fallback to window.onload, that will always work
			window.addEventListener( "load", jQuery.ready, false );

		// If IE event model is used
		} else {
			// Ensure firing before onload, maybe late but safe also for iframes
			document.attachEvent( "onreadystatechange", DOMContentLoaded );

			// A fallback to window.onload, that will always work
			window.attachEvent( "onload", jQuery.ready );

			// If IE and not a frame
			// continually check to see if the document is ready
			var top = false;

			try {
				top = window.frameElement == null && document.documentElement;
			} catch(e) {}

			if ( top && top.doScroll ) {
				(function doScrollCheck() {
					if ( !jQuery.isReady ) {

						try {
							// Use the trick by Diego Perini
							// http://javascript.nwbox.com/IEContentLoaded/
							top.doScroll("left");
						} catch(e) {
							return setTimeout( doScrollCheck, 50 );
						}

						// and execute any waiting functions
						jQuery.ready();
					}
				})();
			}
		}
	}
	return readyList.promise( obj );
};

// Populate the class2type map
jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
	class2type[ "[object " + name + "]" ] = name.toLowerCase();
});

// All jQuery objects should point back to these
rootjQuery = jQuery(document);
// String to Object options format cache
var optionsCache = {};

// Convert String-formatted options into Object-formatted ones and store in cache
function createOptions( options ) {
	var object = optionsCache[ options ] = {};
	jQuery.each( options.split( core_rspace ), function( _, flag ) {
		object[ flag ] = true;
	});
	return object;
}

/*
 * Create a callback list using the following parameters:
 *
 *	options: an optional list of space-separated options that will change how
 *			the callback list behaves or a more traditional option object
 *
 * By default a callback list will act like an event callback list and can be
 * "fired" multiple times.
 *
 * Possible options:
 *
 *	once:			will ensure the callback list can only be fired once (like a Deferred)
 *
 *	memory:			will keep track of previous values and will call any callback added
 *					after the list has been fired right away with the latest "memorized"
 *					values (like a Deferred)
 *
 *	unique:			will ensure a callback can only be added once (no duplicate in the list)
 *
 *	stopOnFalse:	interrupt callings when a callback returns false
 *
 */
jQuery.Callbacks = function( options ) {

	// Convert options from String-formatted to Object-formatted if needed
	// (we check in cache first)
	options = typeof options === "string" ?
		( optionsCache[ options ] || createOptions( options ) ) :
		jQuery.extend( {}, options );

	var // Last fire value (for non-forgettable lists)
		memory,
		// Flag to know if list was already fired
		fired,
		// Flag to know if list is currently firing
		firing,
		// First callback to fire (used internally by add and fireWith)
		firingStart,
		// End of the loop when firing
		firingLength,
		// Index of currently firing callback (modified by remove if needed)
		firingIndex,
		// Actual callback list
		list = [],
		// Stack of fire calls for repeatable lists
		stack = !options.once && [],
		// Fire callbacks
		fire = function( data ) {
			memory = options.memory && data;
			fired = true;
			firingIndex = firingStart || 0;
			firingStart = 0;
			firingLength = list.length;
			firing = true;
			for ( ; list && firingIndex < firingLength; firingIndex++ ) {
				if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
					memory = false; // To prevent further calls using add
					break;
				}
			}
			firing = false;
			if ( list ) {
				if ( stack ) {
					if ( stack.length ) {
						fire( stack.shift() );
					}
				} else if ( memory ) {
					list = [];
				} else {
					self.disable();
				}
			}
		},
		// Actual Callbacks object
		self = {
			// Add a callback or a collection of callbacks to the list
			add: function() {
				if ( list ) {
					// First, we save the current length
					var start = list.length;
					(function add( args ) {
						jQuery.each( args, function( _, arg ) {
							var type = jQuery.type( arg );
							if ( type === "function" ) {
								if ( !options.unique || !self.has( arg ) ) {
									list.push( arg );
								}
							} else if ( arg && arg.length && type !== "string" ) {
								// Inspect recursively
								add( arg );
							}
						});
					})( arguments );
					// Do we need to add the callbacks to the
					// current firing batch?
					if ( firing ) {
						firingLength = list.length;
					// With memory, if we're not firing then
					// we should call right away
					} else if ( memory ) {
						firingStart = start;
						fire( memory );
					}
				}
				return this;
			},
			// Remove a callback from the list
			remove: function() {
				if ( list ) {
					jQuery.each( arguments, function( _, arg ) {
						var index;
						while( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
							list.splice( index, 1 );
							// Handle firing indexes
							if ( firing ) {
								if ( index <= firingLength ) {
									firingLength--;
								}
								if ( index <= firingIndex ) {
									firingIndex--;
								}
							}
						}
					});
				}
				return this;
			},
			// Control if a given callback is in the list
			has: function( fn ) {
				return jQuery.inArray( fn, list ) > -1;
			},
			// Remove all callbacks from the list
			empty: function() {
				list = [];
				return this;
			},
			// Have the list do nothing anymore
			disable: function() {
				list = stack = memory = undefined;
				return this;
			},
			// Is it disabled?
			disabled: function() {
				return !list;
			},
			// Lock the list in its current state
			lock: function() {
				stack = undefined;
				if ( !memory ) {
					self.disable();
				}
				return this;
			},
			// Is it locked?
			locked: function() {
				return !stack;
			},
			// Call all callbacks with the given context and arguments
			fireWith: function( context, args ) {
				args = args || [];
				args = [ context, args.slice ? args.slice() : args ];
				if ( list && ( !fired || stack ) ) {
					if ( firing ) {
						stack.push( args );
					} else {
						fire( args );
					}
				}
				return this;
			},
			// Call all the callbacks with the given arguments
			fire: function() {
				self.fireWith( this, arguments );
				return this;
			},
			// To know if the callbacks have already been called at least once
			fired: function() {
				return !!fired;
			}
		};

	return self;
};
jQuery.extend({

	Deferred: function( func ) {
		var tuples = [
				// action, add listener, listener list, final state
				[ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
				[ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
				[ "notify", "progress", jQuery.Callbacks("memory") ]
			],
			state = "pending",
			promise = {
				state: function() {
					return state;
				},
				always: function() {
					deferred.done( arguments ).fail( arguments );
					return this;
				},
				then: function( /* fnDone, fnFail, fnProgress */ ) {
					var fns = arguments;
					return jQuery.Deferred(function( newDefer ) {
						jQuery.each( tuples, function( i, tuple ) {
							var action = tuple[ 0 ],
								fn = fns[ i ];
							// deferred[ done | fail | progress ] for forwarding actions to newDefer
							deferred[ tuple[1] ]( jQuery.isFunction( fn ) ?
								function() {
									var returned = fn.apply( this, arguments );
									if ( returned && jQuery.isFunction( returned.promise ) ) {
										returned.promise()
											.done( newDefer.resolve )
											.fail( newDefer.reject )
											.progress( newDefer.notify );
									} else {
										newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
									}
								} :
								newDefer[ action ]
							);
						});
						fns = null;
					}).promise();
				},
				// Get a promise for this deferred
				// If obj is provided, the promise aspect is added to the object
				promise: function( obj ) {
					return obj != null ? jQuery.extend( obj, promise ) : promise;
				}
			},
			deferred = {};

		// Keep pipe for back-compat
		promise.pipe = promise.then;

		// Add list-specific methods
		jQuery.each( tuples, function( i, tuple ) {
			var list = tuple[ 2 ],
				stateString = tuple[ 3 ];

			// promise[ done | fail | progress ] = list.add
			promise[ tuple[1] ] = list.add;

			// Handle state
			if ( stateString ) {
				list.add(function() {
					// state = [ resolved | rejected ]
					state = stateString;

				// [ reject_list | resolve_list ].disable; progress_list.lock
				}, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
			}

			// deferred[ resolve | reject | notify ] = list.fire
			deferred[ tuple[0] ] = list.fire;
			deferred[ tuple[0] + "With" ] = list.fireWith;
		});

		// Make the deferred a promise
		promise.promise( deferred );

		// Call given func if any
		if ( func ) {
			func.call( deferred, deferred );
		}

		// All done!
		return deferred;
	},

	// Deferred helper
	when: function( subordinate /* , ..., subordinateN */ ) {
		var i = 0,
			resolveValues = core_slice.call( arguments ),
			length = resolveValues.length,

			// the count of uncompleted subordinates
			remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,

			// the master Deferred. If resolveValues consist of only a single Deferred, just use that.
			deferred = remaining === 1 ? subordinate : jQuery.Deferred(),

			// Update function for both resolve and progress values
			updateFunc = function( i, contexts, values ) {
				return function( value ) {
					contexts[ i ] = this;
					values[ i ] = arguments.length > 1 ? core_slice.call( arguments ) : value;
					if( values === progressValues ) {
						deferred.notifyWith( contexts, values );
					} else if ( !( --remaining ) ) {
						deferred.resolveWith( contexts, values );
					}
				};
			},

			progressValues, progressContexts, resolveContexts;

		// add listeners to Deferred subordinates; treat others as resolved
		if ( length > 1 ) {
			progressValues = new Array( length );
			progressContexts = new Array( length );
			resolveContexts = new Array( length );
			for ( ; i < length; i++ ) {
				if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
					resolveValues[ i ].promise()
						.done( updateFunc( i, resolveContexts, resolveValues ) )
						.fail( deferred.reject )
						.progress( updateFunc( i, progressContexts, progressValues ) );
				} else {
					--remaining;
				}
			}
		}

		// if we're not waiting on anything, resolve the master
		if ( !remaining ) {
			deferred.resolveWith( resolveContexts, resolveValues );
		}

		return deferred.promise();
	}
});
jQuery.support = (function() {

	var support,
		all,
		a,
		select,
		opt,
		input,
		fragment,
		eventName,
		i,
		isSupported,
		clickFn,
		div = document.createElement("div");

	// Setup
	div.setAttribute( "className", "t" );
	div.innerHTML = "  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";

	// Support tests won't run in some limited or non-browser environments
	all = div.getElementsByTagName("*");
	a = div.getElementsByTagName("a")[ 0 ];
	if ( !all || !a || !all.length ) {
		return {};
	}

	// First batch of tests
	select = document.createElement("select");
	opt = select.appendChild( document.createElement("option") );
	input = div.getElementsByTagName("input")[ 0 ];

	a.style.cssText = "top:1px;float:left;opacity:.5";
	support = {
		// IE strips leading whitespace when .innerHTML is used
		leadingWhitespace: ( div.firstChild.nodeType === 3 ),

		// Make sure that tbody elements aren't automatically inserted
		// IE will insert them into empty tables
		tbody: !div.getElementsByTagName("tbody").length,

		// Make sure that link elements get serialized correctly by innerHTML
		// This requires a wrapper element in IE
		htmlSerialize: !!div.getElementsByTagName("link").length,

		// Get the style information from getAttribute
		// (IE uses .cssText instead)
		style: /top/.test( a.getAttribute("style") ),

		// Make sure that URLs aren't manipulated
		// (IE normalizes it by default)
		hrefNormalized: ( a.getAttribute("href") === "/a" ),

		// Make sure that element opacity exists
		// (IE uses filter instead)
		// Use a regex to work around a WebKit issue. See #5145
		opacity: /^0.5/.test( a.style.opacity ),

		// Verify style float existence
		// (IE uses styleFloat instead of cssFloat)
		cssFloat: !!a.style.cssFloat,

		// Make sure that if no value is specified for a checkbox
		// that it defaults to "on".
		// (WebKit defaults to "" instead)
		checkOn: ( input.value === "on" ),

		// Make sure that a selected-by-default option has a working selected property.
		// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
		optSelected: opt.selected,

		// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
		getSetAttribute: div.className !== "t",

		// Tests for enctype support on a form (#6743)
		enctype: !!document.createElement("form").enctype,

		// Makes sure cloning an html5 element does not cause problems
		// Where outerHTML is undefined, this still works
		html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",

		// jQuery.support.boxModel DEPRECATED in 1.8 since we don't support Quirks Mode
		boxModel: ( document.compatMode === "CSS1Compat" ),

		// Will be defined later
		submitBubbles: true,
		changeBubbles: true,
		focusinBubbles: false,
		deleteExpando: true,
		noCloneEvent: true,
		inlineBlockNeedsLayout: false,
		shrinkWrapBlocks: false,
		reliableMarginRight: true,
		boxSizingReliable: true,
		pixelPosition: false
	};

	// Make sure checked status is properly cloned
	input.checked = true;
	support.noCloneChecked = input.cloneNode( true ).checked;

	// Make sure that the options inside disabled selects aren't marked as disabled
	// (WebKit marks them as disabled)
	select.disabled = true;
	support.optDisabled = !opt.disabled;

	// Test to see if it's possible to delete an expando from an element
	// Fails in Internet Explorer
	try {
		delete div.test;
	} catch( e ) {
		support.deleteExpando = false;
	}

	if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
		div.attachEvent( "onclick", clickFn = function() {
			// Cloning a node shouldn't copy over any
			// bound event handlers (IE does this)
			support.noCloneEvent = false;
		});
		div.cloneNode( true ).fireEvent("onclick");
		div.detachEvent( "onclick", clickFn );
	}

	// Check if a radio maintains its value
	// after being appended to the DOM
	input = document.createElement("input");
	input.value = "t";
	input.setAttribute( "type", "radio" );
	support.radioValue = input.value === "t";

	input.setAttribute( "checked", "checked" );

	// #11217 - WebKit loses check when the name is after the checked attribute
	input.setAttribute( "name", "t" );

	div.appendChild( input );
	fragment = document.createDocumentFragment();
	fragment.appendChild( div.lastChild );

	// WebKit doesn't clone checked state correctly in fragments
	support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;

	// Check if a disconnected checkbox will retain its checked
	// value of true after appended to the DOM (IE6/7)
	support.appendChecked = input.checked;

	fragment.removeChild( input );
	fragment.appendChild( div );

	// Technique from Juriy Zaytsev
	// http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
	// We only care about the case where non-standard event systems
	// are used, namely in IE. Short-circuiting here helps us to
	// avoid an eval call (in setAttribute) which can cause CSP
	// to go haywire. See: https://developer.mozilla.org/en/Security/CSP
	if ( div.attachEvent ) {
		for ( i in {
			submit: true,
			change: true,
			focusin: true
		}) {
			eventName = "on" + i;
			isSupported = ( eventName in div );
			if ( !isSupported ) {
				div.setAttribute( eventName, "return;" );
				isSupported = ( typeof div[ eventName ] === "function" );
			}
			support[ i + "Bubbles" ] = isSupported;
		}
	}

	// Run tests that need a body at doc ready
	jQuery(function() {
		var container, div, tds, marginDiv,
			divReset = "padding:0;margin:0;border:0;display:block;overflow:hidden;",
			body = document.getElementsByTagName("body")[0];

		if ( !body ) {
			// Return for frameset docs that don't have a body
			return;
		}

		container = document.createElement("div");
		container.style.cssText = "visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px";
		body.insertBefore( container, body.firstChild );

		// Construct the test element
		div = document.createElement("div");
		container.appendChild( div );

		// Check if table cells still have offsetWidth/Height when they are set
		// to display:none and there are still other visible table cells in a
		// table row; if so, offsetWidth/Height are not reliable for use when
		// determining if an element has been hidden directly using
		// display:none (it is still safe to use offsets if a parent element is
		// hidden; don safety goggles and see bug #4512 for more information).
		// (only IE 8 fails this test)
		div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
		tds = div.getElementsByTagName("td");
		tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
		isSupported = ( tds[ 0 ].offsetHeight === 0 );

		tds[ 0 ].style.display = "";
		tds[ 1 ].style.display = "none";

		// Check if empty table cells still have offsetWidth/Height
		// (IE <= 8 fail this test)
		support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );

		// Check box-sizing and margin behavior
		div.innerHTML = "";
		div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;";
		support.boxSizing = ( div.offsetWidth === 4 );
		support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 );

		// NOTE: To any future maintainer, we've window.getComputedStyle
		// because jsdom on node.js will break without it.
		if ( window.getComputedStyle ) {
			support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
			support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";

			// Check if div with explicit width and no margin-right incorrectly
			// gets computed margin-right based on width of container. For more
			// info see bug #3333
			// Fails in WebKit before Feb 2011 nightlies
			// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
			marginDiv = document.createElement("div");
			marginDiv.style.cssText = div.style.cssText = divReset;
			marginDiv.style.marginRight = marginDiv.style.width = "0";
			div.style.width = "1px";
			div.appendChild( marginDiv );
			support.reliableMarginRight =
				!parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
		}

		if ( typeof div.style.zoom !== "undefined" ) {
			// Check if natively block-level elements act like inline-block
			// elements when setting their display to 'inline' and giving
			// them layout
			// (IE < 8 does this)
			div.innerHTML = "";
			div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
			support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );

			// Check if elements with layout shrink-wrap their children
			// (IE 6 does this)
			div.style.display = "block";
			div.style.overflow = "visible";
			div.innerHTML = "<div></div>";
			div.firstChild.style.width = "5px";
			support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );

			container.style.zoom = 1;
		}

		// Null elements to avoid leaks in IE
		body.removeChild( container );
		container = div = tds = marginDiv = null;
	});

	// Null elements to avoid leaks in IE
	fragment.removeChild( div );
	all = a = select = opt = input = fragment = div = null;

	return support;
})();
var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
	rmultiDash = /([A-Z])/g;

jQuery.extend({
	cache: {},

	deletedIds: [],

	// Remove at next major release (1.9/2.0)
	uuid: 0,

	// Unique for each copy of jQuery on the page
	// Non-digits removed to match rinlinejQuery
	expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),

	// The following elements throw uncatchable exceptions if you
	// attempt to add expando properties to them.
	noData: {
		"embed": true,
		// Ban all objects except for Flash (which handle expandos)
		"object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
		"applet": true
	},

	hasData: function( elem ) {
		elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
		return !!elem && !isEmptyDataObject( elem );
	},

	data: function( elem, name, data, pvt /* Internal Use Only */ ) {
		if ( !jQuery.acceptData( elem ) ) {
			return;
		}

		var thisCache, ret,
			internalKey = jQuery.expando,
			getByName = typeof name === "string",

			// We have to handle DOM nodes and JS objects differently because IE6-7
			// can't GC object references properly across the DOM-JS boundary
			isNode = elem.nodeType,

			// Only DOM nodes need the global jQuery cache; JS object data is
			// attached directly to the object so GC can occur automatically
			cache = isNode ? jQuery.cache : elem,

			// Only defining an ID for JS objects if its cache already exists allows
			// the code to shortcut on the same path as a DOM node with no cache
			id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;

		// Avoid doing any more work than we need to when trying to get data on an
		// object that has no data at all
		if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) {
			return;
		}

		if ( !id ) {
			// Only DOM nodes need a new unique ID for each element since their data
			// ends up in the global cache
			if ( isNode ) {
				elem[ internalKey ] = id = jQuery.deletedIds.pop() || jQuery.guid++;
			} else {
				id = internalKey;
			}
		}

		if ( !cache[ id ] ) {
			cache[ id ] = {};

			// Avoids exposing jQuery metadata on plain JS objects when the object
			// is serialized using JSON.stringify
			if ( !isNode ) {
				cache[ id ].toJSON = jQuery.noop;
			}
		}

		// An object can be passed to jQuery.data instead of a key/value pair; this gets
		// shallow copied over onto the existing cache
		if ( typeof name === "object" || typeof name === "function" ) {
			if ( pvt ) {
				cache[ id ] = jQuery.extend( cache[ id ], name );
			} else {
				cache[ id ].data = jQuery.extend( cache[ id ].data, name );
			}
		}

		thisCache = cache[ id ];

		// jQuery data() is stored in a separate object inside the object's internal data
		// cache in order to avoid key collisions between internal data and user-defined
		// data.
		if ( !pvt ) {
			if ( !thisCache.data ) {
				thisCache.data = {};
			}

			thisCache = thisCache.data;
		}

		if ( data !== undefined ) {
			thisCache[ jQuery.camelCase( name ) ] = data;
		}

		// Check for both converted-to-camel and non-converted data property names
		// If a data property was specified
		if ( getByName ) {

			// First Try to find as-is property data
			ret = thisCache[ name ];

			// Test for null|undefined property data
			if ( ret == null ) {

				// Try to find the camelCased property
				ret = thisCache[ jQuery.camelCase( name ) ];
			}
		} else {
			ret = thisCache;
		}

		return ret;
	},

	removeData: function( elem, name, pvt /* Internal Use Only */ ) {
		if ( !jQuery.acceptData( elem ) ) {
			return;
		}

		var thisCache, i, l,

			isNode = elem.nodeType,

			// See jQuery.data for more information
			cache = isNode ? jQuery.cache : elem,
			id = isNode ? elem[ jQuery.expando ] : jQuery.expando;

		// If there is already no cache entry for this object, there is no
		// purpose in continuing
		if ( !cache[ id ] ) {
			return;
		}

		if ( name ) {

			thisCache = pvt ? cache[ id ] : cache[ id ].data;

			if ( thisCache ) {

				// Support array or space separated string names for data keys
				if ( !jQuery.isArray( name ) ) {

					// try the string as a key before any manipulation
					if ( name in thisCache ) {
						name = [ name ];
					} else {

						// split the camel cased version by spaces unless a key with the spaces exists
						name = jQuery.camelCase( name );
						if ( name in thisCache ) {
							name = [ name ];
						} else {
							name = name.split(" ");
						}
					}
				}

				for ( i = 0, l = name.length; i < l; i++ ) {
					delete thisCache[ name[i] ];
				}

				// If there is no data left in the cache, we want to continue
				// and let the cache object itself get destroyed
				if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) {
					return;
				}
			}
		}

		// See jQuery.data for more information
		if ( !pvt ) {
			delete cache[ id ].data;

			// Don't destroy the parent cache unless the internal data object
			// had been the only thing left in it
			if ( !isEmptyDataObject( cache[ id ] ) ) {
				return;
			}
		}

		// Destroy the cache
		if ( isNode ) {
			jQuery.cleanData( [ elem ], true );

		// Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
		} else if ( jQuery.support.deleteExpando || cache != cache.window ) {
			delete cache[ id ];

		// When all else fails, null
		} else {
			cache[ id ] = null;
		}
	},

	// For internal use only.
	_data: function( elem, name, data ) {
		return jQuery.data( elem, name, data, true );
	},

	// A method for determining if a DOM node can handle the data expando
	acceptData: function( elem ) {
		var noData = elem.nodeName && jQuery.noData[ elem.nodeName.toLowerCase() ];

		// nodes accept data unless otherwise specified; rejection can be conditional
		return !noData || noData !== true && elem.getAttribute("classid") === noData;
	}
});

jQuery.fn.extend({
	data: function( key, value ) {
		var parts, part, attr, name, l,
			elem = this[0],
			i = 0,
			data = null;

		// Gets all values
		if ( key === undefined ) {
			if ( this.length ) {
				data = jQuery.data( elem );

				if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
					attr = elem.attributes;
					for ( l = attr.length; i < l; i++ ) {
						name = attr[i].name;

						if ( !name.indexOf( "data-" ) ) {
							name = jQuery.camelCase( name.substring(5) );

							dataAttr( elem, name, data[ name ] );
						}
					}
					jQuery._data( elem, "parsedAttrs", true );
				}
			}

			return data;
		}

		// Sets multiple values
		if ( typeof key === "object" ) {
			return this.each(function() {
				jQuery.data( this, key );
			});
		}

		parts = key.split( ".", 2 );
		parts[1] = parts[1] ? "." + parts[1] : "";
		part = parts[1] + "!";

		return jQuery.access( this, function( value ) {

			if ( value === undefined ) {
				data = this.triggerHandler( "getData" + part, [ parts[0] ] );

				// Try to fetch any internally stored data first
				if ( data === undefined && elem ) {
					data = jQuery.data( elem, key );
					data = dataAttr( elem, key, data );
				}

				return data === undefined && parts[1] ?
					this.data( parts[0] ) :
					data;
			}

			parts[1] = value;
			this.each(function() {
				var self = jQuery( this );

				self.triggerHandler( "setData" + part, parts );
				jQuery.data( this, key, value );
				self.triggerHandler( "changeData" + part, parts );
			});
		}, null, value, arguments.length > 1, null, false );
	},

	removeData: function( key ) {
		return this.each(function() {
			jQuery.removeData( this, key );
		});
	}
});

function dataAttr( elem, key, data ) {
	// If nothing was found internally, try to fetch any
	// data from the HTML5 data-* attribute
	if ( data === undefined && elem.nodeType === 1 ) {

		var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();

		data = elem.getAttribute( name );

		if ( typeof data === "string" ) {
			try {
				data = data === "true" ? true :
				data === "false" ? false :
				data === "null" ? null :
				// Only convert to a number if it doesn't change the string
				+data + "" === data ? +data :
				rbrace.test( data ) ? jQuery.parseJSON( data ) :
					data;
			} catch( e ) {}

			// Make sure we set the data so it isn't changed later
			jQuery.data( elem, key, data );

		} else {
			data = undefined;
		}
	}

	return data;
}

// checks a cache object for emptiness
function isEmptyDataObject( obj ) {
	var name;
	for ( name in obj ) {

		// if the public data object is empty, the private is still empty
		if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
			continue;
		}
		if ( name !== "toJSON" ) {
			return false;
		}
	}

	return true;
}
jQuery.extend({
	queue: function( elem, type, data ) {
		var queue;

		if ( elem ) {
			type = ( type || "fx" ) + "queue";
			queue = jQuery._data( elem, type );

			// Speed up dequeue by getting out quickly if this is just a lookup
			if ( data ) {
				if ( !queue || jQuery.isArray(data) ) {
					queue = jQuery._data( elem, type, jQuery.makeArray(data) );
				} else {
					queue.push( data );
				}
			}
			return queue || [];
		}
	},

	dequeue: function( elem, type ) {
		type = type || "fx";

		var queue = jQuery.queue( elem, type ),
			startLength = queue.length,
			fn = queue.shift(),
			hooks = jQuery._queueHooks( elem, type ),
			next = function() {
				jQuery.dequeue( elem, type );
			};

		// If the fx queue is dequeued, always remove the progress sentinel
		if ( fn === "inprogress" ) {
			fn = queue.shift();
			startLength--;
		}

		if ( fn ) {

			// Add a progress sentinel to prevent the fx queue from being
			// automatically dequeued
			if ( type === "fx" ) {
				queue.unshift( "inprogress" );
			}

			// clear up the last queue stop function
			delete hooks.stop;
			fn.call( elem, next, hooks );
		}

		if ( !startLength && hooks ) {
			hooks.empty.fire();
		}
	},

	// not intended for public consumption - generates a queueHooks object, or returns the current one
	_queueHooks: function( elem, type ) {
		var key = type + "queueHooks";
		return jQuery._data( elem, key ) || jQuery._data( elem, key, {
			empty: jQuery.Callbacks("once memory").add(function() {
				jQuery.removeData( elem, type + "queue", true );
				jQuery.removeData( elem, key, true );
			})
		});
	}
});

jQuery.fn.extend({
	queue: function( type, data ) {
		var setter = 2;

		if ( typeof type !== "string" ) {
			data = type;
			type = "fx";
			setter--;
		}

		if ( arguments.length < setter ) {
			return jQuery.queue( this[0], type );
		}

		return data === undefined ?
			this :
			this.each(function() {
				var queue = jQuery.queue( this, type, data );

				// ensure a hooks for this queue
				jQuery._queueHooks( this, type );

				if ( type === "fx" && queue[0] !== "inprogress" ) {
					jQuery.dequeue( this, type );
				}
			});
	},
	dequeue: function( type ) {
		return this.each(function() {
			jQuery.dequeue( this, type );
		});
	},
	// Based off of the plugin by Clint Helfers, with permission.
	// http://blindsignals.com/index.php/2009/07/jquery-delay/
	delay: function( time, type ) {
		time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
		type = type || "fx";

		return this.queue( type, function( next, hooks ) {
			var timeout = setTimeout( next, time );
			hooks.stop = function() {
				clearTimeout( timeout );
			};
		});
	},
	clearQueue: function( type ) {
		return this.queue( type || "fx", [] );
	},
	// Get a promise resolved when queues of a certain type
	// are emptied (fx is the type by default)
	promise: function( type, obj ) {
		var tmp,
			count = 1,
			defer = jQuery.Deferred(),
			elements = this,
			i = this.length,
			resolve = function() {
				if ( !( --count ) ) {
					defer.resolveWith( elements, [ elements ] );
				}
			};

		if ( typeof type !== "string" ) {
			obj = type;
			type = undefined;
		}
		type = type || "fx";

		while( i-- ) {
			tmp = jQuery._data( elements[ i ], type + "queueHooks" );
			if ( tmp && tmp.empty ) {
				count++;
				tmp.empty.add( resolve );
			}
		}
		resolve();
		return defer.promise( obj );
	}
});
var nodeHook, boolHook, fixSpecified,
	rclass = /[\t\r\n]/g,
	rreturn = /\r/g,
	rtype = /^(?:button|input)$/i,
	rfocusable = /^(?:button|input|object|select|textarea)$/i,
	rclickable = /^a(?:rea|)$/i,
	rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
	getSetAttribute = jQuery.support.getSetAttribute;

jQuery.fn.extend({
	attr: function( name, value ) {
		return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
	},

	removeAttr: function( name ) {
		return this.each(function() {
			jQuery.removeAttr( this, name );
		});
	},

	prop: function( name, value ) {
		return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
	},

	removeProp: function( name ) {
		name = jQuery.propFix[ name ] || name;
		return this.each(function() {
			// try/catch handles cases where IE balks (such as removing a property on window)
			try {
				this[ name ] = undefined;
				delete this[ name ];
			} catch( e ) {}
		});
	},

	addClass: function( value ) {
		var classNames, i, l, elem,
			setClass, c, cl;

		if ( jQuery.isFunction( value ) ) {
			return this.each(function( j ) {
				jQuery( this ).addClass( value.call(this, j, this.className) );
			});
		}

		if ( value && typeof value === "string" ) {
			classNames = value.split( core_rspace );

			for ( i = 0, l = this.length; i < l; i++ ) {
				elem = this[ i ];

				if ( elem.nodeType === 1 ) {
					if ( !elem.className && classNames.length === 1 ) {
						elem.className = value;

					} else {
						setClass = " " + elem.className + " ";

						for ( c = 0, cl = classNames.length; c < cl; c++ ) {
							if ( setClass.indexOf( " " + classNames[ c ] + " " ) < 0 ) {
								setClass += classNames[ c ] + " ";
							}
						}
						elem.className = jQuery.trim( setClass );
					}
				}
			}
		}

		return this;
	},

	removeClass: function( value ) {
		var removes, className, elem, c, cl, i, l;

		if ( jQuery.isFunction( value ) ) {
			return this.each(function( j ) {
				jQuery( this ).removeClass( value.call(this, j, this.className) );
			});
		}
		if ( (value && typeof value === "string") || value === undefined ) {
			removes = ( value || "" ).split( core_rspace );

			for ( i = 0, l = this.length; i < l; i++ ) {
				elem = this[ i ];
				if ( elem.nodeType === 1 && elem.className ) {

					className = (" " + elem.className + " ").replace( rclass, " " );

					// loop over each item in the removal list
					for ( c = 0, cl = removes.length; c < cl; c++ ) {
						// Remove until there is nothing to remove,
						while ( className.indexOf(" " + removes[ c ] + " ") >= 0 ) {
							className = className.replace( " " + removes[ c ] + " " , " " );
						}
					}
					elem.className = value ? jQuery.trim( className ) : "";
				}
			}
		}

		return this;
	},

	toggleClass: function( value, stateVal ) {
		var type = typeof value,
			isBool = typeof stateVal === "boolean";

		if ( jQuery.isFunction( value ) ) {
			return this.each(function( i ) {
				jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
			});
		}

		return this.each(function() {
			if ( type === "string" ) {
				// toggle individual class names
				var className,
					i = 0,
					self = jQuery( this ),
					state = stateVal,
					classNames = value.split( core_rspace );

				while ( (className = classNames[ i++ ]) ) {
					// check each className given, space separated list
					state = isBool ? state : !self.hasClass( className );
					self[ state ? "addClass" : "removeClass" ]( className );
				}

			} else if ( type === "undefined" || type === "boolean" ) {
				if ( this.className ) {
					// store className if set
					jQuery._data( this, "__className__", this.className );
				}

				// toggle whole className
				this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
			}
		});
	},

	hasClass: function( selector ) {
		var className = " " + selector + " ",
			i = 0,
			l = this.length;
		for ( ; i < l; i++ ) {
			if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
				return true;
			}
		}

		return false;
	},

	val: function( value ) {
		var hooks, ret, isFunction,
			elem = this[0];

		if ( !arguments.length ) {
			if ( elem ) {
				hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];

				if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
					return ret;
				}

				ret = elem.value;

				return typeof ret === "string" ?
					// handle most common string cases
					ret.replace(rreturn, "") :
					// handle cases where value is null/undef or number
					ret == null ? "" : ret;
			}

			return;
		}

		isFunction = jQuery.isFunction( value );

		return this.each(function( i ) {
			var val,
				self = jQuery(this);

			if ( this.nodeType !== 1 ) {
				return;
			}

			if ( isFunction ) {
				val = value.call( this, i, self.val() );
			} else {
				val = value;
			}

			// Treat null/undefined as ""; convert numbers to string
			if ( val == null ) {
				val = "";
			} else if ( typeof val === "number" ) {
				val += "";
			} else if ( jQuery.isArray( val ) ) {
				val = jQuery.map(val, function ( value ) {
					return value == null ? "" : value + "";
				});
			}

			hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];

			// If set returns undefined, fall back to normal setting
			if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
				this.value = val;
			}
		});
	}
});

jQuery.extend({
	valHooks: {
		option: {
			get: function( elem ) {
				// attributes.value is undefined in Blackberry 4.7 but
				// uses .value. See #6932
				var val = elem.attributes.value;
				return !val || val.specified ? elem.value : elem.text;
			}
		},
		select: {
			get: function( elem ) {
				var value, option,
					options = elem.options,
					index = elem.selectedIndex,
					one = elem.type === "select-one" || index < 0,
					values = one ? null : [],
					max = one ? index + 1 : options.length,
					i = index < 0 ?
						max :
						one ? index : 0;

				// Loop through all the selected options
				for ( ; i < max; i++ ) {
					option = options[ i ];

					// oldIE doesn't update selected after form reset (#2551)
					if ( ( option.selected || i === index ) &&
							// Don't return options that are disabled or in a disabled optgroup
							( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
							( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {

						// Get the specific value for the option
						value = jQuery( option ).val();

						// We don't need an array for one selects
						if ( one ) {
							return value;
						}

						// Multi-Selects return an array
						values.push( value );
					}
				}

				return values;
			},

			set: function( elem, value ) {
				var values = jQuery.makeArray( value );

				jQuery(elem).find("option").each(function() {
					this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
				});

				if ( !values.length ) {
					elem.selectedIndex = -1;
				}
				return values;
			}
		}
	},

	// Unused in 1.8, left in so attrFn-stabbers won't die; remove in 1.9
	attrFn: {},

	attr: function( elem, name, value, pass ) {
		var ret, hooks, notxml,
			nType = elem.nodeType;

		// don't get/set attributes on text, comment and attribute nodes
		if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
			return;
		}

		if ( pass && jQuery.isFunction( jQuery.fn[ name ] ) ) {
			return jQuery( elem )[ name ]( value );
		}

		// Fallback to prop when attributes are not supported
		if ( typeof elem.getAttribute === "undefined" ) {
			return jQuery.prop( elem, name, value );
		}

		notxml = nType !== 1 || !jQuery.isXMLDoc( elem );

		// All attributes are lowercase
		// Grab necessary hook if one is defined
		if ( notxml ) {
			name = name.toLowerCase();
			hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
		}

		if ( value !== undefined ) {

			if ( value === null ) {
				jQuery.removeAttr( elem, name );
				return;

			} else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
				return ret;

			} else {
				elem.setAttribute( name, value + "" );
				return value;
			}

		} else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
			return ret;

		} else {

			ret = elem.getAttribute( name );

			// Non-existent attributes return null, we normalize to undefined
			return ret === null ?
				undefined :
				ret;
		}
	},

	removeAttr: function( elem, value ) {
		var propName, attrNames, name, isBool,
			i = 0;

		if ( value && elem.nodeType === 1 ) {

			attrNames = value.split( core_rspace );

			for ( ; i < attrNames.length; i++ ) {
				name = attrNames[ i ];

				if ( name ) {
					propName = jQuery.propFix[ name ] || name;
					isBool = rboolean.test( name );

					// See #9699 for explanation of this approach (setting first, then removal)
					// Do not do this for boolean attributes (see #10870)
					if ( !isBool ) {
						jQuery.attr( elem, name, "" );
					}
					elem.removeAttribute( getSetAttribute ? name : propName );

					// Set corresponding property to false for boolean attributes
					if ( isBool && propName in elem ) {
						elem[ propName ] = false;
					}
				}
			}
		}
	},

	attrHooks: {
		type: {
			set: function( elem, value ) {
				// We can't allow the type property to be changed (since it causes problems in IE)
				if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
					jQuery.error( "type property can't be changed" );
				} else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
					// Setting the type on a radio button after the value resets the value in IE6-9
					// Reset value to it's default in case type is set after value
					// This is for element creation
					var val = elem.value;
					elem.setAttribute( "type", value );
					if ( val ) {
						elem.value = val;
					}
					return value;
				}
			}
		},
		// Use the value property for back compat
		// Use the nodeHook for button elements in IE6/7 (#1954)
		value: {
			get: function( elem, name ) {
				if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
					return nodeHook.get( elem, name );
				}
				return name in elem ?
					elem.value :
					null;
			},
			set: function( elem, value, name ) {
				if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
					return nodeHook.set( elem, value, name );
				}
				// Does not return so that setAttribute is also used
				elem.value = value;
			}
		}
	},

	propFix: {
		tabindex: "tabIndex",
		readonly: "readOnly",
		"for": "htmlFor",
		"class": "className",
		maxlength: "maxLength",
		cellspacing: "cellSpacing",
		cellpadding: "cellPadding",
		rowspan: "rowSpan",
		colspan: "colSpan",
		usemap: "useMap",
		frameborder: "frameBorder",
		contenteditable: "contentEditable"
	},

	prop: function( elem, name, value ) {
		var ret, hooks, notxml,
			nType = elem.nodeType;

		// don't get/set properties on text, comment and attribute nodes
		if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
			return;
		}

		notxml = nType !== 1 || !jQuery.isXMLDoc( elem );

		if ( notxml ) {
			// Fix name and attach hooks
			name = jQuery.propFix[ name ] || name;
			hooks = jQuery.propHooks[ name ];
		}

		if ( value !== undefined ) {
			if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
				return ret;

			} else {
				return ( elem[ name ] = value );
			}

		} else {
			if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
				return ret;

			} else {
				return elem[ name ];
			}
		}
	},

	propHooks: {
		tabIndex: {
			get: function( elem ) {
				// elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
				// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
				var attributeNode = elem.getAttributeNode("tabindex");

				return attributeNode && attributeNode.specified ?
					parseInt( attributeNode.value, 10 ) :
					rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
						0 :
						undefined;
			}
		}
	}
});

// Hook for boolean attributes
boolHook = {
	get: function( elem, name ) {
		// Align boolean attributes with corresponding properties
		// Fall back to attribute presence where some booleans are not supported
		var attrNode,
			property = jQuery.prop( elem, name );
		return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
			name.toLowerCase() :
			undefined;
	},
	set: function( elem, value, name ) {
		var propName;
		if ( value === false ) {
			// Remove boolean attributes when set to false
			jQuery.removeAttr( elem, name );
		} else {
			// value is true since we know at this point it's type boolean and not false
			// Set boolean attributes to the same name and set the DOM property
			propName = jQuery.propFix[ name ] || name;
			if ( propName in elem ) {
				// Only set the IDL specifically if it already exists on the element
				elem[ propName ] = true;
			}

			elem.setAttribute( name, name.toLowerCase() );
		}
		return name;
	}
};

// IE6/7 do not support getting/setting some attributes with get/setAttribute
if ( !getSetAttribute ) {

	fixSpecified = {
		name: true,
		id: true,
		coords: true
	};

	// Use this for any attribute in IE6/7
	// This fixes almost every IE6/7 issue
	nodeHook = jQuery.valHooks.button = {
		get: function( elem, name ) {
			var ret;
			ret = elem.getAttributeNode( name );
			return ret && ( fixSpecified[ name ] ? ret.value !== "" : ret.specified ) ?
				ret.value :
				undefined;
		},
		set: function( elem, value, name ) {
			// Set the existing or create a new attribute node
			var ret = elem.getAttributeNode( name );
			if ( !ret ) {
				ret = document.createAttribute( name );
				elem.setAttributeNode( ret );
			}
			return ( ret.value = value + "" );
		}
	};

	// Set width and height to auto instead of 0 on empty string( Bug #8150 )
	// This is for removals
	jQuery.each([ "width", "height" ], function( i, name ) {
		jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
			set: function( elem, value ) {
				if ( value === "" ) {
					elem.setAttribute( name, "auto" );
					return value;
				}
			}
		});
	});

	// Set contenteditable to false on removals(#10429)
	// Setting to empty string throws an error as an invalid value
	jQuery.attrHooks.contenteditable = {
		get: nodeHook.get,
		set: function( elem, value, name ) {
			if ( value === "" ) {
				value = "false";
			}
			nodeHook.set( elem, value, name );
		}
	};
}


// Some attributes require a special call on IE
if ( !jQuery.support.hrefNormalized ) {
	jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
		jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
			get: function( elem ) {
				var ret = elem.getAttribute( name, 2 );
				return ret === null ? undefined : ret;
			}
		});
	});
}

if ( !jQuery.support.style ) {
	jQuery.attrHooks.style = {
		get: function( elem ) {
			// Return undefined in the case of empty string
			// Normalize to lowercase since IE uppercases css property names
			return elem.style.cssText.toLowerCase() || undefined;
		},
		set: function( elem, value ) {
			return ( elem.style.cssText = value + "" );
		}
	};
}

// Safari mis-reports the default selected property of an option
// Accessing the parent's selectedIndex property fixes it
if ( !jQuery.support.optSelected ) {
	jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
		get: function( elem ) {
			var parent = elem.parentNode;

			if ( parent ) {
				parent.selectedIndex;

				// Make sure that it also works with optgroups, see #5701
				if ( parent.parentNode ) {
					parent.parentNode.selectedIndex;
				}
			}
			return null;
		}
	});
}

// IE6/7 call enctype encoding
if ( !jQuery.support.enctype ) {
	jQuery.propFix.enctype = "encoding";
}

// Radios and checkboxes getter/setter
if ( !jQuery.support.checkOn ) {
	jQuery.each([ "radio", "checkbox" ], function() {
		jQuery.valHooks[ this ] = {
			get: function( elem ) {
				// Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
				return elem.getAttribute("value") === null ? "on" : elem.value;
			}
		};
	});
}
jQuery.each([ "radio", "checkbox" ], function() {
	jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
		set: function( elem, value ) {
			if ( jQuery.isArray( value ) ) {
				return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
			}
		}
	});
});
var rformElems = /^(?:textarea|input|select)$/i,
	rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/,
	rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
	rkeyEvent = /^key/,
	rmouseEvent = /^(?:mouse|contextmenu)|click/,
	rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
	hoverHack = function( events ) {
		return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
	};

/*
 * Helper functions for managing events -- not part of the public interface.
 * Props to Dean Edwards' addEvent library for many of the ideas.
 */
jQuery.event = {

	add: function( elem, types, handler, data, selector ) {

		var elemData, eventHandle, events,
			t, tns, type, namespaces, handleObj,
			handleObjIn, handlers, special;

		// Don't attach events to noData or text/comment nodes (allow plain objects tho)
		if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
			return;
		}

		// Caller can pass in an object of custom data in lieu of the handler
		if ( handler.handler ) {
			handleObjIn = handler;
			handler = handleObjIn.handler;
			selector = handleObjIn.selector;
		}

		// Make sure that the handler has a unique ID, used to find/remove it later
		if ( !handler.guid ) {
			handler.guid = jQuery.guid++;
		}

		// Init the element's event structure and main handler, if this is the first
		events = elemData.events;
		if ( !events ) {
			elemData.events = events = {};
		}
		eventHandle = elemData.handle;
		if ( !eventHandle ) {
			elemData.handle = eventHandle = function( e ) {
				// Discard the second event of a jQuery.event.trigger() and
				// when an event is called after a page has unloaded
				return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
					jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
					undefined;
			};
			// Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
			eventHandle.elem = elem;
		}

		// Handle multiple events separated by a space
		// jQuery(...).bind("mouseover mouseout", fn);
		types = jQuery.trim( hoverHack(types) ).split( " " );
		for ( t = 0; t < types.length; t++ ) {

			tns = rtypenamespace.exec( types[t] ) || [];
			type = tns[1];
			namespaces = ( tns[2] || "" ).split( "." ).sort();

			// If event changes its type, use the special event handlers for the changed type
			special = jQuery.event.special[ type ] || {};

			// If selector defined, determine special event api type, otherwise given type
			type = ( selector ? special.delegateType : special.bindType ) || type;

			// Update special based on newly reset type
			special = jQuery.event.special[ type ] || {};

			// handleObj is passed to all event handlers
			handleObj = jQuery.extend({
				type: type,
				origType: tns[1],
				data: data,
				handler: handler,
				guid: handler.guid,
				selector: selector,
				needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
				namespace: namespaces.join(".")
			}, handleObjIn );

			// Init the event handler queue if we're the first
			handlers = events[ type ];
			if ( !handlers ) {
				handlers = events[ type ] = [];
				handlers.delegateCount = 0;

				// Only use addEventListener/attachEvent if the special events handler returns false
				if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
					// Bind the global event handler to the element
					if ( elem.addEventListener ) {
						elem.addEventListener( type, eventHandle, false );

					} else if ( elem.attachEvent ) {
						elem.attachEvent( "on" + type, eventHandle );
					}
				}
			}

			if ( special.add ) {
				special.add.call( elem, handleObj );

				if ( !handleObj.handler.guid ) {
					handleObj.handler.guid = handler.guid;
				}
			}

			// Add to the element's handler list, delegates in front
			if ( selector ) {
				handlers.splice( handlers.delegateCount++, 0, handleObj );
			} else {
				handlers.push( handleObj );
			}

			// Keep track of which events have ever been used, for event optimization
			jQuery.event.global[ type ] = true;
		}

		// Nullify elem to prevent memory leaks in IE
		elem = null;
	},

	global: {},

	// Detach an event or set of events from an element
	remove: function( elem, types, handler, selector, mappedTypes ) {

		var t, tns, type, origType, namespaces, origCount,
			j, events, special, eventType, handleObj,
			elemData = jQuery.hasData( elem ) && jQuery._data( elem );

		if ( !elemData || !(events = elemData.events) ) {
			return;
		}

		// Once for each type.namespace in types; type may be omitted
		types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
		for ( t = 0; t < types.length; t++ ) {
			tns = rtypenamespace.exec( types[t] ) || [];
			type = origType = tns[1];
			namespaces = tns[2];

			// Unbind all events (on this namespace, if provided) for the element
			if ( !type ) {
				for ( type in events ) {
					jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
				}
				continue;
			}

			special = jQuery.event.special[ type ] || {};
			type = ( selector? special.delegateType : special.bindType ) || type;
			eventType = events[ type ] || [];
			origCount = eventType.length;
			namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.|)") + "(\\.|$)") : null;

			// Remove matching events
			for ( j = 0; j < eventType.length; j++ ) {
				handleObj = eventType[ j ];

				if ( ( mappedTypes || origType === handleObj.origType ) &&
					 ( !handler || handler.guid === handleObj.guid ) &&
					 ( !namespaces || namespaces.test( handleObj.namespace ) ) &&
					 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
					eventType.splice( j--, 1 );

					if ( handleObj.selector ) {
						eventType.delegateCount--;
					}
					if ( special.remove ) {
						special.remove.call( elem, handleObj );
					}
				}
			}

			// Remove generic event handler if we removed something and no more handlers exist
			// (avoids potential for endless recursion during removal of special event handlers)
			if ( eventType.length === 0 && origCount !== eventType.length ) {
				if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
					jQuery.removeEvent( elem, type, elemData.handle );
				}

				delete events[ type ];
			}
		}

		// Remove the expando if it's no longer used
		if ( jQuery.isEmptyObject( events ) ) {
			delete elemData.handle;

			// removeData also checks for emptiness and clears the expando if empty
			// so use it instead of delete
			jQuery.removeData( elem, "events", true );
		}
	},

	// Events that are safe to short-circuit if no handlers are attached.
	// Native DOM events should not be added, they may have inline handlers.
	customEvent: {
		"getData": true,
		"setData": true,
		"changeData": true
	},

	trigger: function( event, data, elem, onlyHandlers ) {
		// Don't do events on text and comment nodes
		if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) {
			return;
		}

		// Event object or event type
		var cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType,
			type = event.type || event,
			namespaces = [];

		// focus/blur morphs to focusin/out; ensure we're not firing them right now
		if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
			return;
		}

		if ( type.indexOf( "!" ) >= 0 ) {
			// Exclusive events trigger only for the exact event (no namespaces)
			type = type.slice(0, -1);
			exclusive = true;
		}

		if ( type.indexOf( "." ) >= 0 ) {
			// Namespaced trigger; create a regexp to match event type in handle()
			namespaces = type.split(".");
			type = namespaces.shift();
			namespaces.sort();
		}

		if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
			// No jQuery handlers for this event type, and it can't have inline handlers
			return;
		}

		// Caller can pass in an Event, Object, or just an event type string
		event = typeof event === "object" ?
			// jQuery.Event object
			event[ jQuery.expando ] ? event :
			// Object literal
			new jQuery.Event( type, event ) :
			// Just the event type (string)
			new jQuery.Event( type );

		event.type = type;
		event.isTrigger = true;
		event.exclusive = exclusive;
		event.namespace = namespaces.join( "." );
		event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)") : null;
		ontype = type.indexOf( ":" ) < 0 ? "on" + type : "";

		// Handle a global trigger
		if ( !elem ) {

			// TODO: Stop taunting the data cache; remove global events and always attach to document
			cache = jQuery.cache;
			for ( i in cache ) {
				if ( cache[ i ].events && cache[ i ].events[ type ] ) {
					jQuery.event.trigger( event, data, cache[ i ].handle.elem, true );
				}
			}
			return;
		}

		// Clean up the event in case it is being reused
		event.result = undefined;
		if ( !event.target ) {
			event.target = elem;
		}

		// Clone any incoming data and prepend the event, creating the handler arg list
		data = data != null ? jQuery.makeArray( data ) : [];
		data.unshift( event );

		// Allow special events to draw outside the lines
		special = jQuery.event.special[ type ] || {};
		if ( special.trigger && special.trigger.apply( elem, data ) === false ) {
			return;
		}

		// Determine event propagation path in advance, per W3C events spec (#9951)
		// Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
		eventPath = [[ elem, special.bindType || type ]];
		if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {

			bubbleType = special.delegateType || type;
			cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode;
			for ( old = elem; cur; cur = cur.parentNode ) {
				eventPath.push([ cur, bubbleType ]);
				old = cur;
			}

			// Only add window if we got to document (e.g., not plain obj or detached DOM)
			if ( old === (elem.ownerDocument || document) ) {
				eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]);
			}
		}

		// Fire handlers on the event path
		for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) {

			cur = eventPath[i][0];
			event.type = eventPath[i][1];

			handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
			if ( handle ) {
				handle.apply( cur, data );
			}
			// Note that this is a bare JS function and not a jQuery handler
			handle = ontype && cur[ ontype ];
			if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
				event.preventDefault();
			}
		}
		event.type = type;

		// If nobody prevented the default action, do it now
		if ( !onlyHandlers && !event.isDefaultPrevented() ) {

			if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) &&
				!(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {

				// Call a native DOM method on the target with the same name name as the event.
				// Can't use an .isFunction() check here because IE6/7 fails that test.
				// Don't do default actions on window, that's where global variables be (#6170)
				// IE<9 dies on focus/blur to hidden element (#1486)
				if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) {

					// Don't re-trigger an onFOO event when we call its FOO() method
					old = elem[ ontype ];

					if ( old ) {
						elem[ ontype ] = null;
					}

					// Prevent re-triggering of the same event, since we already bubbled it above
					jQuery.event.triggered = type;
					elem[ type ]();
					jQuery.event.triggered = undefined;

					if ( old ) {
						elem[ ontype ] = old;
					}
				}
			}
		}

		return event.result;
	},

	dispatch: function( event ) {

		// Make a writable jQuery.Event from the native event object
		event = jQuery.event.fix( event || window.event );

		var i, j, cur, ret, selMatch, matched, matches, handleObj, sel, related,
			handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
			delegateCount = handlers.delegateCount,
			args = core_slice.call( arguments ),
			run_all = !event.exclusive && !event.namespace,
			special = jQuery.event.special[ event.type ] || {},
			handlerQueue = [];

		// Use the fix-ed jQuery.Event rather than the (read-only) native event
		args[0] = event;
		event.delegateTarget = this;

		// Call the preDispatch hook for the mapped type, and let it bail if desired
		if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
			return;
		}

		// Determine handlers that should run if there are delegated events
		// Avoid non-left-click bubbling in Firefox (#3861)
		if ( delegateCount && !(event.button && event.type === "click") ) {

			for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {

				// Don't process clicks (ONLY) on disabled elements (#6911, #8165, #11382, #11764)
				if ( cur.disabled !== true || event.type !== "click" ) {
					selMatch = {};
					matches = [];
					for ( i = 0; i < delegateCount; i++ ) {
						handleObj = handlers[ i ];
						sel = handleObj.selector;

						if ( selMatch[ sel ] === undefined ) {
							selMatch[ sel ] = handleObj.needsContext ?
								jQuery( sel, this ).index( cur ) >= 0 :
								jQuery.find( sel, this, null, [ cur ] ).length;
						}
						if ( selMatch[ sel ] ) {
							matches.push( handleObj );
						}
					}
					if ( matches.length ) {
						handlerQueue.push({ elem: cur, matches: matches });
					}
				}
			}
		}

		// Add the remaining (directly-bound) handlers
		if ( handlers.length > delegateCount ) {
			handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) });
		}

		// Run delegates first; they may want to stop propagation beneath us
		for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) {
			matched = handlerQueue[ i ];
			event.currentTarget = matched.elem;

			for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) {
				handleObj = matched.matches[ j ];

				// Triggered event must either 1) be non-exclusive and have no namespace, or
				// 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
				if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) {

					event.data = handleObj.data;
					event.handleObj = handleObj;

					ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
							.apply( matched.elem, args );

					if ( ret !== undefined ) {
						event.result = ret;
						if ( ret === false ) {
							event.preventDefault();
							event.stopPropagation();
						}
					}
				}
			}
		}

		// Call the postDispatch hook for the mapped type
		if ( special.postDispatch ) {
			special.postDispatch.call( this, event );
		}

		return event.result;
	},

	// Includes some event props shared by KeyEvent and MouseEvent
	// *** attrChange attrName relatedNode srcElement  are not normalized, non-W3C, deprecated, will be removed in 1.8 ***
	props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),

	fixHooks: {},

	keyHooks: {
		props: "char charCode key keyCode".split(" "),
		filter: function( event, original ) {

			// Add which for key events
			if ( event.which == null ) {
				event.which = original.charCode != null ? original.charCode : original.keyCode;
			}

			return event;
		}
	},

	mouseHooks: {
		props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
		filter: function( event, original ) {
			var eventDoc, doc, body,
				button = original.button,
				fromElement = original.fromElement;

			// Calculate pageX/Y if missing and clientX/Y available
			if ( event.pageX == null && original.clientX != null ) {
				eventDoc = event.target.ownerDocument || document;
				doc = eventDoc.documentElement;
				body = eventDoc.body;

				event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
				event.pageY = original.clientY + ( doc && doc.scrollTop  || body && body.scrollTop  || 0 ) - ( doc && doc.clientTop  || body && body.clientTop  || 0 );
			}

			// Add relatedTarget, if necessary
			if ( !event.relatedTarget && fromElement ) {
				event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
			}

			// Add which for click: 1 === left; 2 === middle; 3 === right
			// Note: button is not normalized, so don't use it
			if ( !event.which && button !== undefined ) {
				event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
			}

			return event;
		}
	},

	fix: function( event ) {
		if ( event[ jQuery.expando ] ) {
			return event;
		}

		// Create a writable copy of the event object and normalize some properties
		var i, prop,
			originalEvent = event,
			fixHook = jQuery.event.fixHooks[ event.type ] || {},
			copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;

		event = jQuery.Event( originalEvent );

		for ( i = copy.length; i; ) {
			prop = copy[ --i ];
			event[ prop ] = originalEvent[ prop ];
		}

		// Fix target property, if necessary (#1925, IE 6/7/8 & Safari2)
		if ( !event.target ) {
			event.target = originalEvent.srcElement || document;
		}

		// Target should not be a text node (#504, Safari)
		if ( event.target.nodeType === 3 ) {
			event.target = event.target.parentNode;
		}

		// For mouse/key events, metaKey==false if it's undefined (#3368, #11328; IE6/7/8)
		event.metaKey = !!event.metaKey;

		return fixHook.filter? fixHook.filter( event, originalEvent ) : event;
	},

	special: {
		load: {
			// Prevent triggered image.load events from bubbling to window.load
			noBubble: true
		},

		focus: {
			delegateType: "focusin"
		},
		blur: {
			delegateType: "focusout"
		},

		beforeunload: {
			setup: function( data, namespaces, eventHandle ) {
				// We only want to do this special case on windows
				if ( jQuery.isWindow( this ) ) {
					this.onbeforeunload = eventHandle;
				}
			},

			teardown: function( namespaces, eventHandle ) {
				if ( this.onbeforeunload === eventHandle ) {
					this.onbeforeunload = null;
				}
			}
		}
	},

	simulate: function( type, elem, event, bubble ) {
		// Piggyback on a donor event to simulate a different one.
		// Fake originalEvent to avoid donor's stopPropagation, but if the
		// simulated event prevents default then we do the same on the donor.
		var e = jQuery.extend(
			new jQuery.Event(),
			event,
			{ type: type,
				isSimulated: true,
				originalEvent: {}
			}
		);
		if ( bubble ) {
			jQuery.event.trigger( e, null, elem );
		} else {
			jQuery.event.dispatch.call( elem, e );
		}
		if ( e.isDefaultPrevented() ) {
			event.preventDefault();
		}
	}
};

// Some plugins are using, but it's undocumented/deprecated and will be removed.
// The 1.7 special event interface should provide all the hooks needed now.
jQuery.event.handle = jQuery.event.dispatch;

jQuery.removeEvent = document.removeEventListener ?
	function( elem, type, handle ) {
		if ( elem.removeEventListener ) {
			elem.removeEventListener( type, handle, false );
		}
	} :
	function( elem, type, handle ) {
		var name = "on" + type;

		if ( elem.detachEvent ) {

			// #8545, #7054, preventing memory leaks for custom events in IE6-8
			// detachEvent needed property on element, by name of that event, to properly expose it to GC
			if ( typeof elem[ name ] === "undefined" ) {
				elem[ name ] = null;
			}

			elem.detachEvent( name, handle );
		}
	};

jQuery.Event = function( src, props ) {
	// Allow instantiation without the 'new' keyword
	if ( !(this instanceof jQuery.Event) ) {
		return new jQuery.Event( src, props );
	}

	// Event object
	if ( src && src.type ) {
		this.originalEvent = src;
		this.type = src.type;

		// Events bubbling up the document may have been marked as prevented
		// by a handler lower down the tree; reflect the correct value.
		this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
			src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;

	// Event type
	} else {
		this.type = src;
	}

	// Put explicitly provided properties onto the event object
	if ( props ) {
		jQuery.extend( this, props );
	}

	// Create a timestamp if incoming event doesn't have one
	this.timeStamp = src && src.timeStamp || jQuery.now();

	// Mark it as fixed
	this[ jQuery.expando ] = true;
};

function returnFalse() {
	return false;
}
function returnTrue() {
	return true;
}

// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
jQuery.Event.prototype = {
	preventDefault: function() {
		this.isDefaultPrevented = returnTrue;

		var e = this.originalEvent;
		if ( !e ) {
			return;
		}

		// if preventDefault exists run it on the original event
		if ( e.preventDefault ) {
			e.preventDefault();

		// otherwise set the returnValue property of the original event to false (IE)
		} else {
			e.returnValue = false;
		}
	},
	stopPropagation: function() {
		this.isPropagationStopped = returnTrue;

		var e = this.originalEvent;
		if ( !e ) {
			return;
		}
		// if stopPropagation exists run it on the original event
		if ( e.stopPropagation ) {
			e.stopPropagation();
		}
		// otherwise set the cancelBubble property of the original event to true (IE)
		e.cancelBubble = true;
	},
	stopImmediatePropagation: function() {
		this.isImmediatePropagationStopped = returnTrue;
		this.stopPropagation();
	},
	isDefaultPrevented: returnFalse,
	isPropagationStopped: returnFalse,
	isImmediatePropagationStopped: returnFalse
};

// Create mouseenter/leave events using mouseover/out and event-time checks
jQuery.each({
	mouseenter: "mouseover",
	mouseleave: "mouseout"
}, function( orig, fix ) {
	jQuery.event.special[ orig ] = {
		delegateType: fix,
		bindType: fix,

		handle: function( event ) {
			var ret,
				target = this,
				related = event.relatedTarget,
				handleObj = event.handleObj,
				selector = handleObj.selector;

			// For mousenter/leave call the handler if related is outside the target.
			// NB: No relatedTarget if the mouse left/entered the browser window
			if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
				event.type = handleObj.origType;
				ret = handleObj.handler.apply( this, arguments );
				event.type = fix;
			}
			return ret;
		}
	};
});

// IE submit delegation
if ( !jQuery.support.submitBubbles ) {

	jQuery.event.special.submit = {
		setup: function() {
			// Only need this for delegated form submit events
			if ( jQuery.nodeName( this, "form" ) ) {
				return false;
			}

			// Lazy-add a submit handler when a descendant form may potentially be submitted
			jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
				// Node name check avoids a VML-related crash in IE (#9807)
				var elem = e.target,
					form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
				if ( form && !jQuery._data( form, "_submit_attached" ) ) {
					jQuery.event.add( form, "submit._submit", function( event ) {
						event._submit_bubble = true;
					});
					jQuery._data( form, "_submit_attached", true );
				}
			});
			// return undefined since we don't need an event listener
		},

		postDispatch: function( event ) {
			// If form was submitted by the user, bubble the event up the tree
			if ( event._submit_bubble ) {
				delete event._submit_bubble;
				if ( this.parentNode && !event.isTrigger ) {
					jQuery.event.simulate( "submit", this.parentNode, event, true );
				}
			}
		},

		teardown: function() {
			// Only need this for delegated form submit events
			if ( jQuery.nodeName( this, "form" ) ) {
				return false;
			}

			// Remove delegated handlers; cleanData eventually reaps submit handlers attached above
			jQuery.event.remove( this, "._submit" );
		}
	};
}

// IE change delegation and checkbox/radio fix
if ( !jQuery.support.changeBubbles ) {

	jQuery.event.special.change = {

		setup: function() {

			if ( rformElems.test( this.nodeName ) ) {
				// IE doesn't fire change on a check/radio until blur; trigger it on click
				// after a propertychange. Eat the blur-change in special.change.handle.
				// This still fires onchange a second time for check/radio after blur.
				if ( this.type === "checkbox" || this.type === "radio" ) {
					jQuery.event.add( this, "propertychange._change", function( event ) {
						if ( event.originalEvent.propertyName === "checked" ) {
							this._just_changed = true;
						}
					});
					jQuery.event.add( this, "click._change", function( event ) {
						if ( this._just_changed && !event.isTrigger ) {
							this._just_changed = false;
						}
						// Allow triggered, simulated change events (#11500)
						jQuery.event.simulate( "change", this, event, true );
					});
				}
				return false;
			}
			// Delegated event; lazy-add a change handler on descendant inputs
			jQuery.event.add( this, "beforeactivate._change", function( e ) {
				var elem = e.target;

				if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "_change_attached" ) ) {
					jQuery.event.add( elem, "change._change", function( event ) {
						if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
							jQuery.event.simulate( "change", this.parentNode, event, true );
						}
					});
					jQuery._data( elem, "_change_attached", true );
				}
			});
		},

		handle: function( event ) {
			var elem = event.target;

			// Swallow native change events from checkbox/radio, we already triggered them above
			if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
				return event.handleObj.handler.apply( this, arguments );
			}
		},

		teardown: function() {
			jQuery.event.remove( this, "._change" );

			return !rformElems.test( this.nodeName );
		}
	};
}

// Create "bubbling" focus and blur events
if ( !jQuery.support.focusinBubbles ) {
	jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {

		// Attach a single capturing handler while someone wants focusin/focusout
		var attaches = 0,
			handler = function( event ) {
				jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
			};

		jQuery.event.special[ fix ] = {
			setup: function() {
				if ( attaches++ === 0 ) {
					document.addEventListener( orig, handler, true );
				}
			},
			teardown: function() {
				if ( --attaches === 0 ) {
					document.removeEventListener( orig, handler, true );
				}
			}
		};
	});
}

jQuery.fn.extend({

	on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
		var origFn, type;

		// Types can be a map of types/handlers
		if ( typeof types === "object" ) {
			// ( types-Object, selector, data )
			if ( typeof selector !== "string" ) { // && selector != null
				// ( types-Object, data )
				data = data || selector;
				selector = undefined;
			}
			for ( type in types ) {
				this.on( type, selector, data, types[ type ], one );
			}
			return this;
		}

		if ( data == null && fn == null ) {
			// ( types, fn )
			fn = selector;
			data = selector = undefined;
		} else if ( fn == null ) {
			if ( typeof selector === "string" ) {
				// ( types, selector, fn )
				fn = data;
				data = undefined;
			} else {
				// ( types, data, fn )
				fn = data;
				data = selector;
				selector = undefined;
			}
		}
		if ( fn === false ) {
			fn = returnFalse;
		} else if ( !fn ) {
			return this;
		}

		if ( one === 1 ) {
			origFn = fn;
			fn = function( event ) {
				// Can use an empty set, since event contains the info
				jQuery().off( event );
				return origFn.apply( this, arguments );
			};
			// Use same guid so caller can remove using origFn
			fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
		}
		return this.each( function() {
			jQuery.event.add( this, types, fn, data, selector );
		});
	},
	one: function( types, selector, data, fn ) {
		return this.on( types, selector, data, fn, 1 );
	},
	off: function( types, selector, fn ) {
		var handleObj, type;
		if ( types && types.preventDefault && types.handleObj ) {
			// ( event )  dispatched jQuery.Event
			handleObj = types.handleObj;
			jQuery( types.delegateTarget ).off(
				handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
				handleObj.selector,
				handleObj.handler
			);
			return this;
		}
		if ( typeof types === "object" ) {
			// ( types-object [, selector] )
			for ( type in types ) {
				this.off( type, selector, types[ type ] );
			}
			return this;
		}
		if ( selector === false || typeof selector === "function" ) {
			// ( types [, fn] )
			fn = selector;
			selector = undefined;
		}
		if ( fn === false ) {
			fn = returnFalse;
		}
		return this.each(function() {
			jQuery.event.remove( this, types, fn, selector );
		});
	},

	bind: function( types, data, fn ) {
		return this.on( types, null, data, fn );
	},
	unbind: function( types, fn ) {
		return this.off( types, null, fn );
	},

	live: function( types, data, fn ) {
		jQuery( this.context ).on( types, this.selector, data, fn );
		return this;
	},
	die: function( types, fn ) {
		jQuery( this.context ).off( types, this.selector || "**", fn );
		return this;
	},

	delegate: function( selector, types, data, fn ) {
		return this.on( types, selector, data, fn );
	},
	undelegate: function( selector, types, fn ) {
		// ( namespace ) or ( selector, types [, fn] )
		return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
	},

	trigger: function( type, data ) {
		return this.each(function() {
			jQuery.event.trigger( type, data, this );
		});
	},
	triggerHandler: function( type, data ) {
		if ( this[0] ) {
			return jQuery.event.trigger( type, data, this[0], true );
		}
	},

	toggle: function( fn ) {
		// Save reference to arguments for access in closure
		var args = arguments,
			guid = fn.guid || jQuery.guid++,
			i = 0,
			toggler = function( event ) {
				// Figure out which function to execute
				var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
				jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );

				// Make sure that clicks stop
				event.preventDefault();

				// and execute the function
				return args[ lastToggle ].apply( this, arguments ) || false;
			};

		// link all the functions, so any of them can unbind this click handler
		toggler.guid = guid;
		while ( i < args.length ) {
			args[ i++ ].guid = guid;
		}

		return this.click( toggler );
	},

	hover: function( fnOver, fnOut ) {
		return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
	}
});

jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
	"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
	"change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {

	// Handle event binding
	jQuery.fn[ name ] = function( data, fn ) {
		if ( fn == null ) {
			fn = data;
			data = null;
		}

		return arguments.length > 0 ?
			this.on( name, null, data, fn ) :
			this.trigger( name );
	};

	if ( rkeyEvent.test( name ) ) {
		jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;
	}

	if ( rmouseEvent.test( name ) ) {
		jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
	}
});
/*!
 * Sizzle CSS Selector Engine
 * Copyright 2012 jQuery Foundation and other contributors
 * Released under the MIT license
 * http://sizzlejs.com/
 */
(function( window, undefined ) {

var cachedruns,
	assertGetIdNotName,
	Expr,
	getText,
	isXML,
	contains,
	compile,
	sortOrder,
	hasDuplicate,
	outermostContext,

	baseHasDuplicate = true,
	strundefined = "undefined",

	expando = ( "sizcache" + Math.random() ).replace( ".", "" ),

	Token = String,
	document = window.document,
	docElem = document.documentElement,
	dirruns = 0,
	done = 0,
	pop = [].pop,
	push = [].push,
	slice = [].slice,
	// Use a stripped-down indexOf if a native one is unavailable
	indexOf = [].indexOf || function( elem ) {
		var i = 0,
			len = this.length;
		for ( ; i < len; i++ ) {
			if ( this[i] === elem ) {
				return i;
			}
		}
		return -1;
	},

	// Augment a function for special use by Sizzle
	markFunction = function( fn, value ) {
		fn[ expando ] = value == null || value;
		return fn;
	},

	createCache = function() {
		var cache = {},
			keys = [];

		return markFunction(function( key, value ) {
			// Only keep the most recent entries
			if ( keys.push( key ) > Expr.cacheLength ) {
				delete cache[ keys.shift() ];
			}

			// Retrieve with (key + " ") to avoid collision with native Object.prototype properties (see Issue #157)
			return (cache[ key + " " ] = value);
		}, cache );
	},

	classCache = createCache(),
	tokenCache = createCache(),
	compilerCache = createCache(),

	// Regex

	// Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
	whitespace = "[\\x20\\t\\r\\n\\f]",
	// http://www.w3.org/TR/css3-syntax/#characters
	characterEncoding = "(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",

	// Loosely modeled on CSS identifier characters
	// An unquoted value should be a CSS identifier (http://www.w3.org/TR/css3-selectors/#attribute-selectors)
	// Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
	identifier = characterEncoding.replace( "w", "w#" ),

	// Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
	operators = "([*^$|!~]?=)",
	attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
		"*(?:" + operators + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",

	// Prefer arguments not in parens/brackets,
	//   then attribute selectors and non-pseudos (denoted by :),
	//   then anything else
	// These preferences are here to reduce the number of selectors
	//   needing tokenize in the PSEUDO preFilter
	pseudos = ":(" + characterEncoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + attributes + ")|[^:]|\\\\.)*|.*))\\)|)",

	// For matchExpr.POS and matchExpr.needsContext
	pos = ":(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
		"*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)",

	// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
	rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),

	rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
	rcombinators = new RegExp( "^" + whitespace + "*([\\x20\\t\\r\\n\\f>+~])" + whitespace + "*" ),
	rpseudo = new RegExp( pseudos ),

	// Easily-parseable/retrievable ID or TAG or CLASS selectors
	rquickExpr = /^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,

	rnot = /^:not/,
	rsibling = /[\x20\t\r\n\f]*[+~]/,
	rendsWithNot = /:not\($/,

	rheader = /h\d/i,
	rinputs = /input|select|textarea|button/i,

	rbackslash = /\\(?!\\)/g,

	matchExpr = {
		"ID": new RegExp( "^#(" + characterEncoding + ")" ),
		"CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
		"NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ),
		"TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
		"ATTR": new RegExp( "^" + attributes ),
		"PSEUDO": new RegExp( "^" + pseudos ),
		"POS": new RegExp( pos, "i" ),
		"CHILD": new RegExp( "^:(only|nth|first|last)-child(?:\\(" + whitespace +
			"*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
			"*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
		// For use in libraries implementing .is()
		"needsContext": new RegExp( "^" + whitespace + "*[>+~]|" + pos, "i" )
	},

	// Support

	// Used for testing something on an element
	assert = function( fn ) {
		var div = document.createElement("div");

		try {
			return fn( div );
		} catch (e) {
			return false;
		} finally {
			// release memory in IE
			div = null;
		}
	},

	// Check if getElementsByTagName("*") returns only elements
	assertTagNameNoComments = assert(function( div ) {
		div.appendChild( document.createComment("") );
		return !div.getElementsByTagName("*").length;
	}),

	// Check if getAttribute returns normalized href attributes
	assertHrefNotNormalized = assert(function( div ) {
		div.innerHTML = "<a href='#'></a>";
		return div.firstChild && typeof div.firstChild.getAttribute !== strundefined &&
			div.firstChild.getAttribute("href") === "#";
	}),

	// Check if attributes should be retrieved by attribute nodes
	assertAttributes = assert(function( div ) {
		div.innerHTML = "<select></select>";
		var type = typeof div.lastChild.getAttribute("multiple");
		// IE8 returns a string for some attributes even when not present
		return type !== "boolean" && type !== "string";
	}),

	// Check if getElementsByClassName can be trusted
	assertUsableClassName = assert(function( div ) {
		// Opera can't find a second classname (in 9.6)
		div.innerHTML = "<div class='hidden e'></div><div class='hidden'></div>";
		if ( !div.getElementsByClassName || !div.getElementsByClassName("e").length ) {
			return false;
		}

		// Safari 3.2 caches class attributes and doesn't catch changes
		div.lastChild.className = "e";
		return div.getElementsByClassName("e").length === 2;
	}),

	// Check if getElementById returns elements by name
	// Check if getElementsByName privileges form controls or returns elements by ID
	assertUsableName = assert(function( div ) {
		// Inject content
		div.id = expando + 0;
		div.innerHTML = "<a name='" + expando + "'></a><div name='" + expando + "'></div>";
		docElem.insertBefore( div, docElem.firstChild );

		// Test
		var pass = document.getElementsByName &&
			// buggy browsers will return fewer than the correct 2
			document.getElementsByName( expando ).length === 2 +
			// buggy browsers will return more than the correct 0
			document.getElementsByName( expando + 0 ).length;
		assertGetIdNotName = !document.getElementById( expando );

		// Cleanup
		docElem.removeChild( div );

		return pass;
	});

// If slice is not available, provide a backup
try {
	slice.call( docElem.childNodes, 0 )[0].nodeType;
} catch ( e ) {
	slice = function( i ) {
		var elem,
			results = [];
		for ( ; (elem = this[i]); i++ ) {
			results.push( elem );
		}
		return results;
	};
}

function Sizzle( selector, context, results, seed ) {
	results = results || [];
	context = context || document;
	var match, elem, xml, m,
		nodeType = context.nodeType;

	if ( !selector || typeof selector !== "string" ) {
		return results;
	}

	if ( nodeType !== 1 && nodeType !== 9 ) {
		return [];
	}

	xml = isXML( context );

	if ( !xml && !seed ) {
		if ( (match = rquickExpr.exec( selector )) ) {
			// Speed-up: Sizzle("#ID")
			if ( (m = match[1]) ) {
				if ( nodeType === 9 ) {
					elem = context.getElementById( m );
					// Check parentNode to catch when Blackberry 4.6 returns
					// nodes that are no longer in the document #6963
					if ( elem && elem.parentNode ) {
						// Handle the case where IE, Opera, and Webkit return items
						// by name instead of ID
						if ( elem.id === m ) {
							results.push( elem );
							return results;
						}
					} else {
						return results;
					}
				} else {
					// Context is not a document
					if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
						contains( context, elem ) && elem.id === m ) {
						results.push( elem );
						return results;
					}
				}

			// Speed-up: Sizzle("TAG")
			} else if ( match[2] ) {
				push.apply( results, slice.call(context.getElementsByTagName( selector ), 0) );
				return results;

			// Speed-up: Sizzle(".CLASS")
			} else if ( (m = match[3]) && assertUsableClassName && context.getElementsByClassName ) {
				push.apply( results, slice.call(context.getElementsByClassName( m ), 0) );
				return results;
			}
		}
	}

	// All others
	return select( selector.replace( rtrim, "$1" ), context, results, seed, xml );
}

Sizzle.matches = function( expr, elements ) {
	return Sizzle( expr, null, null, elements );
};

Sizzle.matchesSelector = function( elem, expr ) {
	return Sizzle( expr, null, null, [ elem ] ).length > 0;
};

// Returns a function to use in pseudos for input types
function createInputPseudo( type ) {
	return function( elem ) {
		var name = elem.nodeName.toLowerCase();
		return name === "input" && elem.type === type;
	};
}

// Returns a function to use in pseudos for buttons
function createButtonPseudo( type ) {
	return function( elem ) {
		var name = elem.nodeName.toLowerCase();
		return (name === "input" || name === "button") && elem.type === type;
	};
}

// Returns a function to use in pseudos for positionals
function createPositionalPseudo( fn ) {
	return markFunction(function( argument ) {
		argument = +argument;
		return markFunction(function( seed, matches ) {
			var j,
				matchIndexes = fn( [], seed.length, argument ),
				i = matchIndexes.length;

			// Match elements found at the specified indexes
			while ( i-- ) {
				if ( seed[ (j = matchIndexes[i]) ] ) {
					seed[j] = !(matches[j] = seed[j]);
				}
			}
		});
	});
}

/**
 * Utility function for retrieving the text value of an array of DOM nodes
 * @param {Array|Element} elem
 */
getText = Sizzle.getText = function( elem ) {
	var node,
		ret = "",
		i = 0,
		nodeType = elem.nodeType;

	if ( nodeType ) {
		if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
			// Use textContent for elements
			// innerText usage removed for consistency of new lines (see #11153)
			if ( typeof elem.textContent === "string" ) {
				return elem.textContent;
			} else {
				// Traverse its children
				for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
					ret += getText( elem );
				}
			}
		} else if ( nodeType === 3 || nodeType === 4 ) {
			return elem.nodeValue;
		}
		// Do not include comment or processing instruction nodes
	} else {

		// If no nodeType, this is expected to be an array
		for ( ; (node = elem[i]); i++ ) {
			// Do not traverse comment nodes
			ret += getText( node );
		}
	}
	return ret;
};

isXML = Sizzle.isXML = function( elem ) {
	// documentElement is verified for cases where it doesn't yet exist
	// (such as loading iframes in IE - #4833)
	var documentElement = elem && (elem.ownerDocument || elem).documentElement;
	return documentElement ? documentElement.nodeName !== "HTML" : false;
};

// Element contains another
contains = Sizzle.contains = docElem.contains ?
	function( a, b ) {
		var adown = a.nodeType === 9 ? a.documentElement : a,
			bup = b && b.parentNode;
		return a === bup || !!( bup && bup.nodeType === 1 && adown.contains && adown.contains(bup) );
	} :
	docElem.compareDocumentPosition ?
	function( a, b ) {
		return b && !!( a.compareDocumentPosition( b ) & 16 );
	} :
	function( a, b ) {
		while ( (b = b.parentNode) ) {
			if ( b === a ) {
				return true;
			}
		}
		return false;
	};

Sizzle.attr = function( elem, name ) {
	var val,
		xml = isXML( elem );

	if ( !xml ) {
		name = name.toLowerCase();
	}
	if ( (val = Expr.attrHandle[ name ]) ) {
		return val( elem );
	}
	if ( xml || assertAttributes ) {
		return elem.getAttribute( name );
	}
	val = elem.getAttributeNode( name );
	return val ?
		typeof elem[ name ] === "boolean" ?
			elem[ name ] ? name : null :
			val.specified ? val.value : null :
		null;
};

Expr = Sizzle.selectors = {

	// Can be adjusted by the user
	cacheLength: 50,

	createPseudo: markFunction,

	match: matchExpr,

	// IE6/7 return a modified href
	attrHandle: assertHrefNotNormalized ?
		{} :
		{
			"href": function( elem ) {
				return elem.getAttribute( "href", 2 );
			},
			"type": function( elem ) {
				return elem.getAttribute("type");
			}
		},

	find: {
		"ID": assertGetIdNotName ?
			function( id, context, xml ) {
				if ( typeof context.getElementById !== strundefined && !xml ) {
					var m = context.getElementById( id );
					// Check parentNode to catch when Blackberry 4.6 returns
					// nodes that are no longer in the document #6963
					return m && m.parentNode ? [m] : [];
				}
			} :
			function( id, context, xml ) {
				if ( typeof context.getElementById !== strundefined && !xml ) {
					var m = context.getElementById( id );

					return m ?
						m.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode("id").value === id ?
							[m] :
							undefined :
						[];
				}
			},

		"TAG": assertTagNameNoComments ?
			function( tag, context ) {
				if ( typeof context.getElementsByTagName !== strundefined ) {
					return context.getElementsByTagName( tag );
				}
			} :
			function( tag, context ) {
				var results = context.getElementsByTagName( tag );

				// Filter out possible comments
				if ( tag === "*" ) {
					var elem,
						tmp = [],
						i = 0;

					for ( ; (elem = results[i]); i++ ) {
						if ( elem.nodeType === 1 ) {
							tmp.push( elem );
						}
					}

					return tmp;
				}
				return results;
			},

		"NAME": assertUsableName && function( tag, context ) {
			if ( typeof context.getElementsByName !== strundefined ) {
				return context.getElementsByName( name );
			}
		},

		"CLASS": assertUsableClassName && function( className, context, xml ) {
			if ( typeof context.getElementsByClassName !== strundefined && !xml ) {
				return context.getElementsByClassName( className );
			}
		}
	},

	relative: {
		">": { dir: "parentNode", first: true },
		" ": { dir: "parentNode" },
		"+": { dir: "previousSibling", first: true },
		"~": { dir: "previousSibling" }
	},

	preFilter: {
		"ATTR": function( match ) {
			match[1] = match[1].replace( rbackslash, "" );

			// Move the given value to match[3] whether quoted or unquoted
			match[3] = ( match[4] || match[5] || "" ).replace( rbackslash, "" );

			if ( match[2] === "~=" ) {
				match[3] = " " + match[3] + " ";
			}

			return match.slice( 0, 4 );
		},

		"CHILD": function( match ) {
			/* matches from matchExpr["CHILD"]
				1 type (only|nth|...)
				2 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
				3 xn-component of xn+y argument ([+-]?\d*n|)
				4 sign of xn-component
				5 x of xn-component
				6 sign of y-component
				7 y of y-component
			*/
			match[1] = match[1].toLowerCase();

			if ( match[1] === "nth" ) {
				// nth-child requires argument
				if ( !match[2] ) {
					Sizzle.error( match[0] );
				}

				// numeric x and y parameters for Expr.filter.CHILD
				// remember that false/true cast respectively to 0/1
				match[3] = +( match[3] ? match[4] + (match[5] || 1) : 2 * ( match[2] === "even" || match[2] === "odd" ) );
				match[4] = +( ( match[6] + match[7] ) || match[2] === "odd" );

			// other types prohibit arguments
			} else if ( match[2] ) {
				Sizzle.error( match[0] );
			}

			return match;
		},

		"PSEUDO": function( match ) {
			var unquoted, excess;
			if ( matchExpr["CHILD"].test( match[0] ) ) {
				return null;
			}

			if ( match[3] ) {
				match[2] = match[3];
			} else if ( (unquoted = match[4]) ) {
				// Only check arguments that contain a pseudo
				if ( rpseudo.test(unquoted) &&
					// Get excess from tokenize (recursively)
					(excess = tokenize( unquoted, true )) &&
					// advance to the next closing parenthesis
					(excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {

					// excess is a negative index
					unquoted = unquoted.slice( 0, excess );
					match[0] = match[0].slice( 0, excess );
				}
				match[2] = unquoted;
			}

			// Return only captures needed by the pseudo filter method (type and argument)
			return match.slice( 0, 3 );
		}
	},

	filter: {
		"ID": assertGetIdNotName ?
			function( id ) {
				id = id.replace( rbackslash, "" );
				return function( elem ) {
					return elem.getAttribute("id") === id;
				};
			} :
			function( id ) {
				id = id.replace( rbackslash, "" );
				return function( elem ) {
					var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
					return node && node.value === id;
				};
			},

		"TAG": function( nodeName ) {
			if ( nodeName === "*" ) {
				return function() { return true; };
			}
			nodeName = nodeName.replace( rbackslash, "" ).toLowerCase();

			return function( elem ) {
				return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
			};
		},

		"CLASS": function( className ) {
			var pattern = classCache[ expando ][ className + " " ];

			return pattern ||
				(pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
				classCache( className, function( elem ) {
					return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" );
				});
		},

		"ATTR": function( name, operator, check ) {
			return function( elem, context ) {
				var result = Sizzle.attr( elem, name );

				if ( result == null ) {
					return operator === "!=";
				}
				if ( !operator ) {
					return true;
				}

				result += "";

				return operator === "=" ? result === check :
					operator === "!=" ? result !== check :
					operator === "^=" ? check && result.indexOf( check ) === 0 :
					operator === "*=" ? check && result.indexOf( check ) > -1 :
					operator === "$=" ? check && result.substr( result.length - check.length ) === check :
					operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
					operator === "|=" ? result === check || result.substr( 0, check.length + 1 ) === check + "-" :
					false;
			};
		},

		"CHILD": function( type, argument, first, last ) {

			if ( type === "nth" ) {
				return function( elem ) {
					var node, diff,
						parent = elem.parentNode;

					if ( first === 1 && last === 0 ) {
						return true;
					}

					if ( parent ) {
						diff = 0;
						for ( node = parent.firstChild; node; node = node.nextSibling ) {
							if ( node.nodeType === 1 ) {
								diff++;
								if ( elem === node ) {
									break;
								}
							}
						}
					}

					// Incorporate the offset (or cast to NaN), then check against cycle size
					diff -= last;
					return diff === first || ( diff % first === 0 && diff / first >= 0 );
				};
			}

			return function( elem ) {
				var node = elem;

				switch ( type ) {
					case "only":
					case "first":
						while ( (node = node.previousSibling) ) {
							if ( node.nodeType === 1 ) {
								return false;
							}
						}

						if ( type === "first" ) {
							return true;
						}

						node = elem;

						/* falls through */
					case "last":
						while ( (node = node.nextSibling) ) {
							if ( node.nodeType === 1 ) {
								return false;
							}
						}

						return true;
				}
			};
		},

		"PSEUDO": function( pseudo, argument ) {
			// pseudo-class names are case-insensitive
			// http://www.w3.org/TR/selectors/#pseudo-classes
			// Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
			// Remember that setFilters inherits from pseudos
			var args,
				fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
					Sizzle.error( "unsupported pseudo: " + pseudo );

			// The user may use createPseudo to indicate that
			// arguments are needed to create the filter function
			// just as Sizzle does
			if ( fn[ expando ] ) {
				return fn( argument );
			}

			// But maintain support for old signatures
			if ( fn.length > 1 ) {
				args = [ pseudo, pseudo, "", argument ];
				return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
					markFunction(function( seed, matches ) {
						var idx,
							matched = fn( seed, argument ),
							i = matched.length;
						while ( i-- ) {
							idx = indexOf.call( seed, matched[i] );
							seed[ idx ] = !( matches[ idx ] = matched[i] );
						}
					}) :
					function( elem ) {
						return fn( elem, 0, args );
					};
			}

			return fn;
		}
	},

	pseudos: {
		"not": markFunction(function( selector ) {
			// Trim the selector passed to compile
			// to avoid treating leading and trailing
			// spaces as combinators
			var input = [],
				results = [],
				matcher = compile( selector.replace( rtrim, "$1" ) );

			return matcher[ expando ] ?
				markFunction(function( seed, matches, context, xml ) {
					var elem,
						unmatched = matcher( seed, null, xml, [] ),
						i = seed.length;

					// Match elements unmatched by `matcher`
					while ( i-- ) {
						if ( (elem = unmatched[i]) ) {
							seed[i] = !(matches[i] = elem);
						}
					}
				}) :
				function( elem, context, xml ) {
					input[0] = elem;
					matcher( input, null, xml, results );
					return !results.pop();
				};
		}),

		"has": markFunction(function( selector ) {
			return function( elem ) {
				return Sizzle( selector, elem ).length > 0;
			};
		}),

		"contains": markFunction(function( text ) {
			return function( elem ) {
				return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
			};
		}),

		"enabled": function( elem ) {
			return elem.disabled === false;
		},

		"disabled": function( elem ) {
			return elem.disabled === true;
		},

		"checked": function( elem ) {
			// In CSS3, :checked should return both checked and selected elements
			// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
			var nodeName = elem.nodeName.toLowerCase();
			return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
		},

		"selected": function( elem ) {
			// Accessing this property makes selected-by-default
			// options in Safari work properly
			if ( elem.parentNode ) {
				elem.parentNode.selectedIndex;
			}

			return elem.selected === true;
		},

		"parent": function( elem ) {
			return !Expr.pseudos["empty"]( elem );
		},

		"empty": function( elem ) {
			// http://www.w3.org/TR/selectors/#empty-pseudo
			// :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),
			//   not comment, processing instructions, or others
			// Thanks to Diego Perini for the nodeName shortcut
			//   Greater than "@" means alpha characters (specifically not starting with "#" or "?")
			var nodeType;
			elem = elem.firstChild;
			while ( elem ) {
				if ( elem.nodeName > "@" || (nodeType = elem.nodeType) === 3 || nodeType === 4 ) {
					return false;
				}
				elem = elem.nextSibling;
			}
			return true;
		},

		"header": function( elem ) {
			return rheader.test( elem.nodeName );
		},

		"text": function( elem ) {
			var type, attr;
			// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
			// use getAttribute instead to test this case
			return elem.nodeName.toLowerCase() === "input" &&
				(type = elem.type) === "text" &&
				( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === type );
		},

		// Input types
		"radio": createInputPseudo("radio"),
		"checkbox": createInputPseudo("checkbox"),
		"file": createInputPseudo("file"),
		"password": createInputPseudo("password"),
		"image": createInputPseudo("image"),

		"submit": createButtonPseudo("submit"),
		"reset": createButtonPseudo("reset"),

		"button": function( elem ) {
			var name = elem.nodeName.toLowerCase();
			return name === "input" && elem.type === "button" || name === "button";
		},

		"input": function( elem ) {
			return rinputs.test( elem.nodeName );
		},

		"focus": function( elem ) {
			var doc = elem.ownerDocument;
			return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
		},

		"active": function( elem ) {
			return elem === elem.ownerDocument.activeElement;
		},

		// Positional types
		"first": createPositionalPseudo(function() {
			return [ 0 ];
		}),

		"last": createPositionalPseudo(function( matchIndexes, length ) {
			return [ length - 1 ];
		}),

		"eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
			return [ argument < 0 ? argument + length : argument ];
		}),

		"even": createPositionalPseudo(function( matchIndexes, length ) {
			for ( var i = 0; i < length; i += 2 ) {
				matchIndexes.push( i );
			}
			return matchIndexes;
		}),

		"odd": createPositionalPseudo(function( matchIndexes, length ) {
			for ( var i = 1; i < length; i += 2 ) {
				matchIndexes.push( i );
			}
			return matchIndexes;
		}),

		"lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
			for ( var i = argument < 0 ? argument + length : argument; --i >= 0; ) {
				matchIndexes.push( i );
			}
			return matchIndexes;
		}),

		"gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
			for ( var i = argument < 0 ? argument + length : argument; ++i < length; ) {
				matchIndexes.push( i );
			}
			return matchIndexes;
		})
	}
};

function siblingCheck( a, b, ret ) {
	if ( a === b ) {
		return ret;
	}

	var cur = a.nextSibling;

	while ( cur ) {
		if ( cur === b ) {
			return -1;
		}

		cur = cur.nextSibling;
	}

	return 1;
}

sortOrder = docElem.compareDocumentPosition ?
	function( a, b ) {
		if ( a === b ) {
			hasDuplicate = true;
			return 0;
		}

		return ( !a.compareDocumentPosition || !b.compareDocumentPosition ?
			a.compareDocumentPosition :
			a.compareDocumentPosition(b) & 4
		) ? -1 : 1;
	} :
	function( a, b ) {
		// The nodes are identical, we can exit early
		if ( a === b ) {
			hasDuplicate = true;
			return 0;

		// Fallback to using sourceIndex (in IE) if it's available on both nodes
		} else if ( a.sourceIndex && b.sourceIndex ) {
			return a.sourceIndex - b.sourceIndex;
		}

		var al, bl,
			ap = [],
			bp = [],
			aup = a.parentNode,
			bup = b.parentNode,
			cur = aup;

		// If the nodes are siblings (or identical) we can do a quick check
		if ( aup === bup ) {
			return siblingCheck( a, b );

		// If no parents were found then the nodes are disconnected
		} else if ( !aup ) {
			return -1;

		} else if ( !bup ) {
			return 1;
		}

		// Otherwise they're somewhere else in the tree so we need
		// to build up a full list of the parentNodes for comparison
		while ( cur ) {
			ap.unshift( cur );
			cur = cur.parentNode;
		}

		cur = bup;

		while ( cur ) {
			bp.unshift( cur );
			cur = cur.parentNode;
		}

		al = ap.length;
		bl = bp.length;

		// Start walking down the tree looking for a discrepancy
		for ( var i = 0; i < al && i < bl; i++ ) {
			if ( ap[i] !== bp[i] ) {
				return siblingCheck( ap[i], bp[i] );
			}
		}

		// We ended someplace up the tree so do a sibling check
		return i === al ?
			siblingCheck( a, bp[i], -1 ) :
			siblingCheck( ap[i], b, 1 );
	};

// Always assume the presence of duplicates if sort doesn't
// pass them to our comparison function (as in Google Chrome).
[0, 0].sort( sortOrder );
baseHasDuplicate = !hasDuplicate;

// Document sorting and removing duplicates
Sizzle.uniqueSort = function( results ) {
	var elem,
		duplicates = [],
		i = 1,
		j = 0;

	hasDuplicate = baseHasDuplicate;
	results.sort( sortOrder );

	if ( hasDuplicate ) {
		for ( ; (elem = results[i]); i++ ) {
			if ( elem === results[ i - 1 ] ) {
				j = duplicates.push( i );
			}
		}
		while ( j-- ) {
			results.splice( duplicates[ j ], 1 );
		}
	}

	return results;
};

Sizzle.error = function( msg ) {
	throw new Error( "Syntax error, unrecognized expression: " + msg );
};

function tokenize( selector, parseOnly ) {
	var matched, match, tokens, type,
		soFar, groups, preFilters,
		cached = tokenCache[ expando ][ selector + " " ];

	if ( cached ) {
		return parseOnly ? 0 : cached.slice( 0 );
	}

	soFar = selector;
	groups = [];
	preFilters = Expr.preFilter;

	while ( soFar ) {

		// Comma and first run
		if ( !matched || (match = rcomma.exec( soFar )) ) {
			if ( match ) {
				// Don't consume trailing commas as valid
				soFar = soFar.slice( match[0].length ) || soFar;
			}
			groups.push( tokens = [] );
		}

		matched = false;

		// Combinators
		if ( (match = rcombinators.exec( soFar )) ) {
			tokens.push( matched = new Token( match.shift() ) );
			soFar = soFar.slice( matched.length );

			// Cast descendant combinators to space
			matched.type = match[0].replace( rtrim, " " );
		}

		// Filters
		for ( type in Expr.filter ) {
			if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
				(match = preFilters[ type ]( match ))) ) {

				tokens.push( matched = new Token( match.shift() ) );
				soFar = soFar.slice( matched.length );
				matched.type = type;
				matched.matches = match;
			}
		}

		if ( !matched ) {
			break;
		}
	}

	// Return the length of the invalid excess
	// if we're just parsing
	// Otherwise, throw an error or return tokens
	return parseOnly ?
		soFar.length :
		soFar ?
			Sizzle.error( selector ) :
			// Cache the tokens
			tokenCache( selector, groups ).slice( 0 );
}

function addCombinator( matcher, combinator, base ) {
	var dir = combinator.dir,
		checkNonElements = base && combinator.dir === "parentNode",
		doneName = done++;

	return combinator.first ?
		// Check against closest ancestor/preceding element
		function( elem, context, xml ) {
			while ( (elem = elem[ dir ]) ) {
				if ( checkNonElements || elem.nodeType === 1  ) {
					return matcher( elem, context, xml );
				}
			}
		} :

		// Check against all ancestor/preceding elements
		function( elem, context, xml ) {
			// We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
			if ( !xml ) {
				var cache,
					dirkey = dirruns + " " + doneName + " ",
					cachedkey = dirkey + cachedruns;
				while ( (elem = elem[ dir ]) ) {
					if ( checkNonElements || elem.nodeType === 1 ) {
						if ( (cache = elem[ expando ]) === cachedkey ) {
							return elem.sizset;
						} else if ( typeof cache === "string" && cache.indexOf(dirkey) === 0 ) {
							if ( elem.sizset ) {
								return elem;
							}
						} else {
							elem[ expando ] = cachedkey;
							if ( matcher( elem, context, xml ) ) {
								elem.sizset = true;
								return elem;
							}
							elem.sizset = false;
						}
					}
				}
			} else {
				while ( (elem = elem[ dir ]) ) {
					if ( checkNonElements || elem.nodeType === 1 ) {
						if ( matcher( elem, context, xml ) ) {
							return elem;
						}
					}
				}
			}
		};
}

function elementMatcher( matchers ) {
	return matchers.length > 1 ?
		function( elem, context, xml ) {
			var i = matchers.length;
			while ( i-- ) {
				if ( !matchers[i]( elem, context, xml ) ) {
					return false;
				}
			}
			return true;
		} :
		matchers[0];
}

function condense( unmatched, map, filter, context, xml ) {
	var elem,
		newUnmatched = [],
		i = 0,
		len = unmatched.length,
		mapped = map != null;

	for ( ; i < len; i++ ) {
		if ( (elem = unmatched[i]) ) {
			if ( !filter || filter( elem, context, xml ) ) {
				newUnmatched.push( elem );
				if ( mapped ) {
					map.push( i );
				}
			}
		}
	}

	return newUnmatched;
}

function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
	if ( postFilter && !postFilter[ expando ] ) {
		postFilter = setMatcher( postFilter );
	}
	if ( postFinder && !postFinder[ expando ] ) {
		postFinder = setMatcher( postFinder, postSelector );
	}
	return markFunction(function( seed, results, context, xml ) {
		var temp, i, elem,
			preMap = [],
			postMap = [],
			preexisting = results.length,

			// Get initial elements from seed or context
			elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),

			// Prefilter to get matcher input, preserving a map for seed-results synchronization
			matcherIn = preFilter && ( seed || !selector ) ?
				condense( elems, preMap, preFilter, context, xml ) :
				elems,

			matcherOut = matcher ?
				// If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
				postFinder || ( seed ? preFilter : preexisting || postFilter ) ?

					// ...intermediate processing is necessary
					[] :

					// ...otherwise use results directly
					results :
				matcherIn;

		// Find primary matches
		if ( matcher ) {
			matcher( matcherIn, matcherOut, context, xml );
		}

		// Apply postFilter
		if ( postFilter ) {
			temp = condense( matcherOut, postMap );
			postFilter( temp, [], context, xml );

			// Un-match failing elements by moving them back to matcherIn
			i = temp.length;
			while ( i-- ) {
				if ( (elem = temp[i]) ) {
					matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
				}
			}
		}

		if ( seed ) {
			if ( postFinder || preFilter ) {
				if ( postFinder ) {
					// Get the final matcherOut by condensing this intermediate into postFinder contexts
					temp = [];
					i = matcherOut.length;
					while ( i-- ) {
						if ( (elem = matcherOut[i]) ) {
							// Restore matcherIn since elem is not yet a final match
							temp.push( (matcherIn[i] = elem) );
						}
					}
					postFinder( null, (matcherOut = []), temp, xml );
				}

				// Move matched elements from seed to results to keep them synchronized
				i = matcherOut.length;
				while ( i-- ) {
					if ( (elem = matcherOut[i]) &&
						(temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {

						seed[temp] = !(results[temp] = elem);
					}
				}
			}

		// Add elements to results, through postFinder if defined
		} else {
			matcherOut = condense(
				matcherOut === results ?
					matcherOut.splice( preexisting, matcherOut.length ) :
					matcherOut
			);
			if ( postFinder ) {
				postFinder( null, results, matcherOut, xml );
			} else {
				push.apply( results, matcherOut );
			}
		}
	});
}

function matcherFromTokens( tokens ) {
	var checkContext, matcher, j,
		len = tokens.length,
		leadingRelative = Expr.relative[ tokens[0].type ],
		implicitRelative = leadingRelative || Expr.relative[" "],
		i = leadingRelative ? 1 : 0,

		// The foundational matcher ensures that elements are reachable from top-level context(s)
		matchContext = addCombinator( function( elem ) {
			return elem === checkContext;
		}, implicitRelative, true ),
		matchAnyContext = addCombinator( function( elem ) {
			return indexOf.call( checkContext, elem ) > -1;
		}, implicitRelative, true ),
		matchers = [ function( elem, context, xml ) {
			return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
				(checkContext = context).nodeType ?
					matchContext( elem, context, xml ) :
					matchAnyContext( elem, context, xml ) );
		} ];

	for ( ; i < len; i++ ) {
		if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
			matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
		} else {
			matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );

			// Return special upon seeing a positional matcher
			if ( matcher[ expando ] ) {
				// Find the next relative operator (if any) for proper handling
				j = ++i;
				for ( ; j < len; j++ ) {
					if ( Expr.relative[ tokens[j].type ] ) {
						break;
					}
				}
				return setMatcher(
					i > 1 && elementMatcher( matchers ),
					i > 1 && tokens.slice( 0, i - 1 ).join("").replace( rtrim, "$1" ),
					matcher,
					i < j && matcherFromTokens( tokens.slice( i, j ) ),
					j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
					j < len && tokens.join("")
				);
			}
			matchers.push( matcher );
		}
	}

	return elementMatcher( matchers );
}

function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
	var bySet = setMatchers.length > 0,
		byElement = elementMatchers.length > 0,
		superMatcher = function( seed, context, xml, results, expandContext ) {
			var elem, j, matcher,
				setMatched = [],
				matchedCount = 0,
				i = "0",
				unmatched = seed && [],
				outermost = expandContext != null,
				contextBackup = outermostContext,
				// We must always have either seed elements or context
				elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
				// Nested matchers should use non-integer dirruns
				dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.E);

			if ( outermost ) {
				outermostContext = context !== document && context;
				cachedruns = superMatcher.el;
			}

			// Add elements passing elementMatchers directly to results
			for ( ; (elem = elems[i]) != null; i++ ) {
				if ( byElement && elem ) {
					for ( j = 0; (matcher = elementMatchers[j]); j++ ) {
						if ( matcher( elem, context, xml ) ) {
							results.push( elem );
							break;
						}
					}
					if ( outermost ) {
						dirruns = dirrunsUnique;
						cachedruns = ++superMatcher.el;
					}
				}

				// Track unmatched elements for set filters
				if ( bySet ) {
					// They will have gone through all possible matchers
					if ( (elem = !matcher && elem) ) {
						matchedCount--;
					}

					// Lengthen the array for every element, matched or not
					if ( seed ) {
						unmatched.push( elem );
					}
				}
			}

			// Apply set filters to unmatched elements
			matchedCount += i;
			if ( bySet && i !== matchedCount ) {
				for ( j = 0; (matcher = setMatchers[j]); j++ ) {
					matcher( unmatched, setMatched, context, xml );
				}

				if ( seed ) {
					// Reintegrate element matches to eliminate the need for sorting
					if ( matchedCount > 0 ) {
						while ( i-- ) {
							if ( !(unmatched[i] || setMatched[i]) ) {
								setMatched[i] = pop.call( results );
							}
						}
					}

					// Discard index placeholder values to get only actual matches
					setMatched = condense( setMatched );
				}

				// Add matches to results
				push.apply( results, setMatched );

				// Seedless set matches succeeding multiple successful matchers stipulate sorting
				if ( outermost && !seed && setMatched.length > 0 &&
					( matchedCount + setMatchers.length ) > 1 ) {

					Sizzle.uniqueSort( results );
				}
			}

			// Override manipulation of globals by nested matchers
			if ( outermost ) {
				dirruns = dirrunsUnique;
				outermostContext = contextBackup;
			}

			return unmatched;
		};

	superMatcher.el = 0;
	return bySet ?
		markFunction( superMatcher ) :
		superMatcher;
}

compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
	var i,
		setMatchers = [],
		elementMatchers = [],
		cached = compilerCache[ expando ][ selector + " " ];

	if ( !cached ) {
		// Generate a function of recursive functions that can be used to check each element
		if ( !group ) {
			group = tokenize( selector );
		}
		i = group.length;
		while ( i-- ) {
			cached = matcherFromTokens( group[i] );
			if ( cached[ expando ] ) {
				setMatchers.push( cached );
			} else {
				elementMatchers.push( cached );
			}
		}

		// Cache the compiled function
		cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
	}
	return cached;
};

function multipleContexts( selector, contexts, results ) {
	var i = 0,
		len = contexts.length;
	for ( ; i < len; i++ ) {
		Sizzle( selector, contexts[i], results );
	}
	return results;
}

function select( selector, context, results, seed, xml ) {
	var i, tokens, token, type, find,
		match = tokenize( selector ),
		j = match.length;

	if ( !seed ) {
		// Try to minimize operations if there is only one group
		if ( match.length === 1 ) {

			// Take a shortcut and set the context if the root selector is an ID
			tokens = match[0] = match[0].slice( 0 );
			if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
					context.nodeType === 9 && !xml &&
					Expr.relative[ tokens[1].type ] ) {

				context = Expr.find["ID"]( token.matches[0].replace( rbackslash, "" ), context, xml )[0];
				if ( !context ) {
					return results;
				}

				selector = selector.slice( tokens.shift().length );
			}

			// Fetch a seed set for right-to-left matching
			for ( i = matchExpr["POS"].test( selector ) ? -1 : tokens.length - 1; i >= 0; i-- ) {
				token = tokens[i];

				// Abort if we hit a combinator
				if ( Expr.relative[ (type = token.type) ] ) {
					break;
				}
				if ( (find = Expr.find[ type ]) ) {
					// Search, expanding context for leading sibling combinators
					if ( (seed = find(
						token.matches[0].replace( rbackslash, "" ),
						rsibling.test( tokens[0].type ) && context.parentNode || context,
						xml
					)) ) {

						// If seed is empty or no tokens remain, we can return early
						tokens.splice( i, 1 );
						selector = seed.length && tokens.join("");
						if ( !selector ) {
							push.apply( results, slice.call( seed, 0 ) );
							return results;
						}

						break;
					}
				}
			}
		}
	}

	// Compile and execute a filtering function
	// Provide `match` to avoid retokenization if we modified the selector above
	compile( selector, match )(
		seed,
		context,
		xml,
		results,
		rsibling.test( selector )
	);
	return results;
}

if ( document.querySelectorAll ) {
	(function() {
		var disconnectedMatch,
			oldSelect = select,
			rescape = /'|\\/g,
			rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,

			// qSa(:focus) reports false when true (Chrome 21), no need to also add to buggyMatches since matches checks buggyQSA
			// A support test would require too much code (would include document ready)
			rbuggyQSA = [ ":focus" ],

			// matchesSelector(:active) reports false when true (IE9/Opera 11.5)
			// A support test would require too much code (would include document ready)
			// just skip matchesSelector for :active
			rbuggyMatches = [ ":active" ],
			matches = docElem.matchesSelector ||
				docElem.mozMatchesSelector ||
				docElem.webkitMatchesSelector ||
				docElem.oMatchesSelector ||
				docElem.msMatchesSelector;

		// Build QSA regex
		// Regex strategy adopted from Diego Perini
		assert(function( div ) {
			// Select is set to empty string on purpose
			// This is to test IE's treatment of not explictly
			// setting a boolean content attribute,
			// since its presence should be enough
			// http://bugs.jquery.com/ticket/12359
			div.innerHTML = "<select><option selected=''></option></select>";

			// IE8 - Some boolean attributes are not treated correctly
			if ( !div.querySelectorAll("[selected]").length ) {
				rbuggyQSA.push( "\\[" + whitespace + "*(?:checked|disabled|ismap|multiple|readonly|selected|value)" );
			}

			// Webkit/Opera - :checked should return selected option elements
			// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
			// IE8 throws error here (do not put tests after this one)
			if ( !div.querySelectorAll(":checked").length ) {
				rbuggyQSA.push(":checked");
			}
		});

		assert(function( div ) {

			// Opera 10-12/IE9 - ^= $= *= and empty values
			// Should not select anything
			div.innerHTML = "<p test=''></p>";
			if ( div.querySelectorAll("[test^='']").length ) {
				rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:\"\"|'')" );
			}

			// FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
			// IE8 throws error here (do not put tests after this one)
			div.innerHTML = "<input type='hidden'/>";
			if ( !div.querySelectorAll(":enabled").length ) {
				rbuggyQSA.push(":enabled", ":disabled");
			}
		});

		// rbuggyQSA always contains :focus, so no need for a length check
		rbuggyQSA = /* rbuggyQSA.length && */ new RegExp( rbuggyQSA.join("|") );

		select = function( selector, context, results, seed, xml ) {
			// Only use querySelectorAll when not filtering,
			// when this is not xml,
			// and when no QSA bugs apply
			if ( !seed && !xml && !rbuggyQSA.test( selector ) ) {
				var groups, i,
					old = true,
					nid = expando,
					newContext = context,
					newSelector = context.nodeType === 9 && selector;

				// qSA works strangely on Element-rooted queries
				// We can work around this by specifying an extra ID on the root
				// and working up from there (Thanks to Andrew Dupont for the technique)
				// IE 8 doesn't work on object elements
				if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
					groups = tokenize( selector );

					if ( (old = context.getAttribute("id")) ) {
						nid = old.replace( rescape, "\\$&" );
					} else {
						context.setAttribute( "id", nid );
					}
					nid = "[id='" + nid + "'] ";

					i = groups.length;
					while ( i-- ) {
						groups[i] = nid + groups[i].join("");
					}
					newContext = rsibling.test( selector ) && context.parentNode || context;
					newSelector = groups.join(",");
				}

				if ( newSelector ) {
					try {
						push.apply( results, slice.call( newContext.querySelectorAll(
							newSelector
						), 0 ) );
						return results;
					} catch(qsaError) {
					} finally {
						if ( !old ) {
							context.removeAttribute("id");
						}
					}
				}
			}

			return oldSelect( selector, context, results, seed, xml );
		};

		if ( matches ) {
			assert(function( div ) {
				// Check to see if it's possible to do matchesSelector
				// on a disconnected node (IE 9)
				disconnectedMatch = matches.call( div, "div" );

				// This should fail with an exception
				// Gecko does not error, returns false instead
				try {
					matches.call( div, "[test!='']:sizzle" );
					rbuggyMatches.push( "!=", pseudos );
				} catch ( e ) {}
			});

			// rbuggyMatches always contains :active and :focus, so no need for a length check
			rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") );

			Sizzle.matchesSelector = function( elem, expr ) {
				// Make sure that attribute selectors are quoted
				expr = expr.replace( rattributeQuotes, "='$1']" );

				// rbuggyMatches always contains :active, so no need for an existence check
				if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && !rbuggyQSA.test( expr ) ) {
					try {
						var ret = matches.call( elem, expr );

						// IE 9's matchesSelector returns false on disconnected nodes
						if ( ret || disconnectedMatch ||
								// As well, disconnected nodes are said to be in a document
								// fragment in IE 9
								elem.document && elem.document.nodeType !== 11 ) {
							return ret;
						}
					} catch(e) {}
				}

				return Sizzle( expr, null, null, [ elem ] ).length > 0;
			};
		}
	})();
}

// Deprecated
Expr.pseudos["nth"] = Expr.pseudos["eq"];

// Back-compat
function setFilters() {}
Expr.filters = setFilters.prototype = Expr.pseudos;
Expr.setFilters = new setFilters();

// Override sizzle attribute retrieval
Sizzle.attr = jQuery.attr;
jQuery.find = Sizzle;
jQuery.expr = Sizzle.selectors;
jQuery.expr[":"] = jQuery.expr.pseudos;
jQuery.unique = Sizzle.uniqueSort;
jQuery.text = Sizzle.getText;
jQuery.isXMLDoc = Sizzle.isXML;
jQuery.contains = Sizzle.contains;


})( window );
var runtil = /Until$/,
	rparentsprev = /^(?:parents|prev(?:Until|All))/,
	isSimple = /^.[^:#\[\.,]*$/,
	rneedsContext = jQuery.expr.match.needsContext,
	// methods guaranteed to produce a unique set when starting from a unique set
	guaranteedUnique = {
		children: true,
		contents: true,
		next: true,
		prev: true
	};

jQuery.fn.extend({
	find: function( selector ) {
		var i, l, length, n, r, ret,
			self = this;

		if ( typeof selector !== "string" ) {
			return jQuery( selector ).filter(function() {
				for ( i = 0, l = self.length; i < l; i++ ) {
					if ( jQuery.contains( self[ i ], this ) ) {
						return true;
					}
				}
			});
		}

		ret = this.pushStack( "", "find", selector );

		for ( i = 0, l = this.length; i < l; i++ ) {
			length = ret.length;
			jQuery.find( selector, this[i], ret );

			if ( i > 0 ) {
				// Make sure that the results are unique
				for ( n = length; n < ret.length; n++ ) {
					for ( r = 0; r < length; r++ ) {
						if ( ret[r] === ret[n] ) {
							ret.splice(n--, 1);
							break;
						}
					}
				}
			}
		}

		return ret;
	},

	has: function( target ) {
		var i,
			targets = jQuery( target, this ),
			len = targets.length;

		return this.filter(function() {
			for ( i = 0; i < len; i++ ) {
				if ( jQuery.contains( this, targets[i] ) ) {
					return true;
				}
			}
		});
	},

	not: function( selector ) {
		return this.pushStack( winnow(this, selector, false), "not", selector);
	},

	filter: function( selector ) {
		return this.pushStack( winnow(this, selector, true), "filter", selector );
	},

	is: function( selector ) {
		return !!selector && (
			typeof selector === "string" ?
				// If this is a positional/relative selector, check membership in the returned set
				// so $("p:first").is("p:last") won't return true for a doc with two "p".
				rneedsContext.test( selector ) ?
					jQuery( selector, this.context ).index( this[0] ) >= 0 :
					jQuery.filter( selector, this ).length > 0 :
				this.filter( selector ).length > 0 );
	},

	closest: function( selectors, context ) {
		var cur,
			i = 0,
			l = this.length,
			ret = [],
			pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
				jQuery( selectors, context || this.context ) :
				0;

		for ( ; i < l; i++ ) {
			cur = this[i];

			while ( cur && cur.ownerDocument && cur !== context && cur.nodeType !== 11 ) {
				if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
					ret.push( cur );
					break;
				}
				cur = cur.parentNode;
			}
		}

		ret = ret.length > 1 ? jQuery.unique( ret ) : ret;

		return this.pushStack( ret, "closest", selectors );
	},

	// Determine the position of an element within
	// the matched set of elements
	index: function( elem ) {

		// No argument, return index in parent
		if ( !elem ) {
			return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
		}

		// index in selector
		if ( typeof elem === "string" ) {
			return jQuery.inArray( this[0], jQuery( elem ) );
		}

		// Locate the position of the desired element
		return jQuery.inArray(
			// If it receives a jQuery object, the first element is used
			elem.jquery ? elem[0] : elem, this );
	},

	add: function( selector, context ) {
		var set = typeof selector === "string" ?
				jQuery( selector, context ) :
				jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
			all = jQuery.merge( this.get(), set );

		return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
			all :
			jQuery.unique( all ) );
	},

	addBack: function( selector ) {
		return this.add( selector == null ?
			this.prevObject : this.prevObject.filter(selector)
		);
	}
});

jQuery.fn.andSelf = jQuery.fn.addBack;

// A painfully simple check to see if an element is disconnected
// from a document (should be improved, where feasible).
function isDisconnected( node ) {
	return !node || !node.parentNode || node.parentNode.nodeType === 11;
}

function sibling( cur, dir ) {
	do {
		cur = cur[ dir ];
	} while ( cur && cur.nodeType !== 1 );

	return cur;
}

jQuery.each({
	parent: function( elem ) {
		var parent = elem.parentNode;
		return parent && parent.nodeType !== 11 ? parent : null;
	},
	parents: function( elem ) {
		return jQuery.dir( elem, "parentNode" );
	},
	parentsUntil: function( elem, i, until ) {
		return jQuery.dir( elem, "parentNode", until );
	},
	next: function( elem ) {
		return sibling( elem, "nextSibling" );
	},
	prev: function( elem ) {
		return sibling( elem, "previousSibling" );
	},
	nextAll: function( elem ) {
		return jQuery.dir( elem, "nextSibling" );
	},
	prevAll: function( elem ) {
		return jQuery.dir( elem, "previousSibling" );
	},
	nextUntil: function( elem, i, until ) {
		return jQuery.dir( elem, "nextSibling", until );
	},
	prevUntil: function( elem, i, until ) {
		return jQuery.dir( elem, "previousSibling", until );
	},
	siblings: function( elem ) {
		return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
	},
	children: function( elem ) {
		return jQuery.sibling( elem.firstChild );
	},
	contents: function( elem ) {
		return jQuery.nodeName( elem, "iframe" ) ?
			elem.contentDocument || elem.contentWindow.document :
			jQuery.merge( [], elem.childNodes );
	}
}, function( name, fn ) {
	jQuery.fn[ name ] = function( until, selector ) {
		var ret = jQuery.map( this, fn, until );

		if ( !runtil.test( name ) ) {
			selector = until;
		}

		if ( selector && typeof selector === "string" ) {
			ret = jQuery.filter( selector, ret );
		}

		ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;

		if ( this.length > 1 && rparentsprev.test( name ) ) {
			ret = ret.reverse();
		}

		return this.pushStack( ret, name, core_slice.call( arguments ).join(",") );
	};
});

jQuery.extend({
	filter: function( expr, elems, not ) {
		if ( not ) {
			expr = ":not(" + expr + ")";
		}

		return elems.length === 1 ?
			jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
			jQuery.find.matches(expr, elems);
	},

	dir: function( elem, dir, until ) {
		var matched = [],
			cur = elem[ dir ];

		while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
			if ( cur.nodeType === 1 ) {
				matched.push( cur );
			}
			cur = cur[dir];
		}
		return matched;
	},

	sibling: function( n, elem ) {
		var r = [];

		for ( ; n; n = n.nextSibling ) {
			if ( n.nodeType === 1 && n !== elem ) {
				r.push( n );
			}
		}

		return r;
	}
});

// Implement the identical functionality for filter and not
function winnow( elements, qualifier, keep ) {

	// Can't pass null or undefined to indexOf in Firefox 4
	// Set to 0 to skip string check
	qualifier = qualifier || 0;

	if ( jQuery.isFunction( qualifier ) ) {
		return jQuery.grep(elements, function( elem, i ) {
			var retVal = !!qualifier.call( elem, i, elem );
			return retVal === keep;
		});

	} else if ( qualifier.nodeType ) {
		return jQuery.grep(elements, function( elem, i ) {
			return ( elem === qualifier ) === keep;
		});

	} else if ( typeof qualifier === "string" ) {
		var filtered = jQuery.grep(elements, function( elem ) {
			return elem.nodeType === 1;
		});

		if ( isSimple.test( qualifier ) ) {
			return jQuery.filter(qualifier, filtered, !keep);
		} else {
			qualifier = jQuery.filter( qualifier, filtered );
		}
	}

	return jQuery.grep(elements, function( elem, i ) {
		return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep;
	});
}
function createSafeFragment( document ) {
	var list = nodeNames.split( "|" ),
	safeFrag = document.createDocumentFragment();

	if ( safeFrag.createElement ) {
		while ( list.length ) {
			safeFrag.createElement(
				list.pop()
			);
		}
	}
	return safeFrag;
}

var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
		"header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
	rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
	rleadingWhitespace = /^\s+/,
	rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
	rtagName = /<([\w:]+)/,
	rtbody = /<tbody/i,
	rhtml = /<|&#?\w+;/,
	rnoInnerhtml = /<(?:script|style|link)/i,
	rnocache = /<(?:script|object|embed|option|style)/i,
	rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
	rcheckableType = /^(?:checkbox|radio)$/,
	// checked="checked" or checked
	rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
	rscriptType = /\/(java|ecma)script/i,
	rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,
	wrapMap = {
		option: [ 1, "<select multiple='multiple'>", "</select>" ],
		legend: [ 1, "<fieldset>", "</fieldset>" ],
		thead: [ 1, "<table>", "</table>" ],
		tr: [ 2, "<table><tbody>", "</tbody></table>" ],
		td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
		col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
		area: [ 1, "<map>", "</map>" ],
		_default: [ 0, "", "" ]
	},
	safeFragment = createSafeFragment( document ),
	fragmentDiv = safeFragment.appendChild( document.createElement("div") );

wrapMap.optgroup = wrapMap.option;
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
wrapMap.th = wrapMap.td;

// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
// unless wrapped in a div with non-breaking characters in front of it.
if ( !jQuery.support.htmlSerialize ) {
	wrapMap._default = [ 1, "X<div>", "</div>" ];
}

jQuery.fn.extend({
	text: function( value ) {
		return jQuery.access( this, function( value ) {
			return value === undefined ?
				jQuery.text( this ) :
				this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
		}, null, value, arguments.length );
	},

	wrapAll: function( html ) {
		if ( jQuery.isFunction( html ) ) {
			return this.each(function(i) {
				jQuery(this).wrapAll( html.call(this, i) );
			});
		}

		if ( this[0] ) {
			// The elements to wrap the target around
			var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);

			if ( this[0].parentNode ) {
				wrap.insertBefore( this[0] );
			}

			wrap.map(function() {
				var elem = this;

				while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
					elem = elem.firstChild;
				}

				return elem;
			}).append( this );
		}

		return this;
	},

	wrapInner: function( html ) {
		if ( jQuery.isFunction( html ) ) {
			return this.each(function(i) {
				jQuery(this).wrapInner( html.call(this, i) );
			});
		}

		return this.each(function() {
			var self = jQuery( this ),
				contents = self.contents();

			if ( contents.length ) {
				contents.wrapAll( html );

			} else {
				self.append( html );
			}
		});
	},

	wrap: function( html ) {
		var isFunction = jQuery.isFunction( html );

		return this.each(function(i) {
			jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
		});
	},

	unwrap: function() {
		return this.parent().each(function() {
			if ( !jQuery.nodeName( this, "body" ) ) {
				jQuery( this ).replaceWith( this.childNodes );
			}
		}).end();
	},

	append: function() {
		return this.domManip(arguments, true, function( elem ) {
			if ( this.nodeType === 1 || this.nodeType === 11 ) {
				this.appendChild( elem );
			}
		});
	},

	prepend: function() {
		return this.domManip(arguments, true, function( elem ) {
			if ( this.nodeType === 1 || this.nodeType === 11 ) {
				this.insertBefore( elem, this.firstChild );
			}
		});
	},

	before: function() {
		if ( !isDisconnected( this[0] ) ) {
			return this.domManip(arguments, false, function( elem ) {
				this.parentNode.insertBefore( elem, this );
			});
		}

		if ( arguments.length ) {
			var set = jQuery.clean( arguments );
			return this.pushStack( jQuery.merge( set, this ), "before", this.selector );
		}
	},

	after: function() {
		if ( !isDisconnected( this[0] ) ) {
			return this.domManip(arguments, false, function( elem ) {
				this.parentNode.insertBefore( elem, this.nextSibling );
			});
		}

		if ( arguments.length ) {
			var set = jQuery.clean( arguments );
			return this.pushStack( jQuery.merge( this, set ), "after", this.selector );
		}
	},

	// keepData is for internal use only--do not document
	remove: function( selector, keepData ) {
		var elem,
			i = 0;

		for ( ; (elem = this[i]) != null; i++ ) {
			if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
				if ( !keepData && elem.nodeType === 1 ) {
					jQuery.cleanData( elem.getElementsByTagName("*") );
					jQuery.cleanData( [ elem ] );
				}

				if ( elem.parentNode ) {
					elem.parentNode.removeChild( elem );
				}
			}
		}

		return this;
	},

	empty: function() {
		var elem,
			i = 0;

		for ( ; (elem = this[i]) != null; i++ ) {
			// Remove element nodes and prevent memory leaks
			if ( elem.nodeType === 1 ) {
				jQuery.cleanData( elem.getElementsByTagName("*") );
			}

			// Remove any remaining nodes
			while ( elem.firstChild ) {
				elem.removeChild( elem.firstChild );
			}
		}

		return this;
	},

	clone: function( dataAndEvents, deepDataAndEvents ) {
		dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
		deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;

		return this.map( function () {
			return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
		});
	},

	html: function( value ) {
		return jQuery.access( this, function( value ) {
			var elem = this[0] || {},
				i = 0,
				l = this.length;

			if ( value === undefined ) {
				return elem.nodeType === 1 ?
					elem.innerHTML.replace( rinlinejQuery, "" ) :
					undefined;
			}

			// See if we can take a shortcut and just use innerHTML
			if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
				( jQuery.support.htmlSerialize || !rnoshimcache.test( value )  ) &&
				( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
				!wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {

				value = value.replace( rxhtmlTag, "<$1></$2>" );

				try {
					for (; i < l; i++ ) {
						// Remove element nodes and prevent memory leaks
						elem = this[i] || {};
						if ( elem.nodeType === 1 ) {
							jQuery.cleanData( elem.getElementsByTagName( "*" ) );
							elem.innerHTML = value;
						}
					}

					elem = 0;

				// If using innerHTML throws an exception, use the fallback method
				} catch(e) {}
			}

			if ( elem ) {
				this.empty().append( value );
			}
		}, null, value, arguments.length );
	},

	replaceWith: function( value ) {
		if ( !isDisconnected( this[0] ) ) {
			// Make sure that the elements are removed from the DOM before they are inserted
			// this can help fix replacing a parent with child elements
			if ( jQuery.isFunction( value ) ) {
				return this.each(function(i) {
					var self = jQuery(this), old = self.html();
					self.replaceWith( value.call( this, i, old ) );
				});
			}

			if ( typeof value !== "string" ) {
				value = jQuery( value ).detach();
			}

			return this.each(function() {
				var next = this.nextSibling,
					parent = this.parentNode;

				jQuery( this ).remove();

				if ( next ) {
					jQuery(next).before( value );
				} else {
					jQuery(parent).append( value );
				}
			});
		}

		return this.length ?
			this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
			this;
	},

	detach: function( selector ) {
		return this.remove( selector, true );
	},

	domManip: function( args, table, callback ) {

		// Flatten any nested arrays
		args = [].concat.apply( [], args );

		var results, first, fragment, iNoClone,
			i = 0,
			value = args[0],
			scripts = [],
			l = this.length;

		// We can't cloneNode fragments that contain checked, in WebKit
		if ( !jQuery.support.checkClone && l > 1 && typeof value === "string" && rchecked.test( value ) ) {
			return this.each(function() {
				jQuery(this).domManip( args, table, callback );
			});
		}

		if ( jQuery.isFunction(value) ) {
			return this.each(function(i) {
				var self = jQuery(this);
				args[0] = value.call( this, i, table ? self.html() : undefined );
				self.domManip( args, table, callback );
			});
		}

		if ( this[0] ) {
			results = jQuery.buildFragment( args, this, scripts );
			fragment = results.fragment;
			first = fragment.firstChild;

			if ( fragment.childNodes.length === 1 ) {
				fragment = first;
			}

			if ( first ) {
				table = table && jQuery.nodeName( first, "tr" );

				// Use the original fragment for the last item instead of the first because it can end up
				// being emptied incorrectly in certain situations (#8070).
				// Fragments from the fragment cache must always be cloned and never used in place.
				for ( iNoClone = results.cacheable || l - 1; i < l; i++ ) {
					callback.call(
						table && jQuery.nodeName( this[i], "table" ) ?
							findOrAppend( this[i], "tbody" ) :
							this[i],
						i === iNoClone ?
							fragment :
							jQuery.clone( fragment, true, true )
					);
				}
			}

			// Fix #11809: Avoid leaking memory
			fragment = first = null;

			if ( scripts.length ) {
				jQuery.each( scripts, function( i, elem ) {
					if ( elem.src ) {
						if ( jQuery.ajax ) {
							jQuery.ajax({
								url: elem.src,
								type: "GET",
								dataType: "script",
								async: false,
								global: false,
								"throws": true
							});
						} else {
							jQuery.error("no ajax");
						}
					} else {
						jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "" ) );
					}

					if ( elem.parentNode ) {
						elem.parentNode.removeChild( elem );
					}
				});
			}
		}

		return this;
	}
});

function findOrAppend( elem, tag ) {
	return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) );
}

function cloneCopyEvent( src, dest ) {

	if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
		return;
	}

	var type, i, l,
		oldData = jQuery._data( src ),
		curData = jQuery._data( dest, oldData ),
		events = oldData.events;

	if ( events ) {
		delete curData.handle;
		curData.events = {};

		for ( type in events ) {
			for ( i = 0, l = events[ type ].length; i < l; i++ ) {
				jQuery.event.add( dest, type, events[ type ][ i ] );
			}
		}
	}

	// make the cloned public data object a copy from the original
	if ( curData.data ) {
		curData.data = jQuery.extend( {}, curData.data );
	}
}

function cloneFixAttributes( src, dest ) {
	var nodeName;

	// We do not need to do anything for non-Elements
	if ( dest.nodeType !== 1 ) {
		return;
	}

	// clearAttributes removes the attributes, which we don't want,
	// but also removes the attachEvent events, which we *do* want
	if ( dest.clearAttributes ) {
		dest.clearAttributes();
	}

	// mergeAttributes, in contrast, only merges back on the
	// original attributes, not the events
	if ( dest.mergeAttributes ) {
		dest.mergeAttributes( src );
	}

	nodeName = dest.nodeName.toLowerCase();

	if ( nodeName === "object" ) {
		// IE6-10 improperly clones children of object elements using classid.
		// IE10 throws NoModificationAllowedError if parent is null, #12132.
		if ( dest.parentNode ) {
			dest.outerHTML = src.outerHTML;
		}

		// This path appears unavoidable for IE9. When cloning an object
		// element in IE9, the outerHTML strategy above is not sufficient.
		// If the src has innerHTML and the destination does not,
		// copy the src.innerHTML into the dest.innerHTML. #10324
		if ( jQuery.support.html5Clone && (src.innerHTML && !jQuery.trim(dest.innerHTML)) ) {
			dest.innerHTML = src.innerHTML;
		}

	} else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
		// IE6-8 fails to persist the checked state of a cloned checkbox
		// or radio button. Worse, IE6-7 fail to give the cloned element
		// a checked appearance if the defaultChecked value isn't also set

		dest.defaultChecked = dest.checked = src.checked;

		// IE6-7 get confused and end up setting the value of a cloned
		// checkbox/radio button to an empty string instead of "on"
		if ( dest.value !== src.value ) {
			dest.value = src.value;
		}

	// IE6-8 fails to return the selected option to the default selected
	// state when cloning options
	} else if ( nodeName === "option" ) {
		dest.selected = src.defaultSelected;

	// IE6-8 fails to set the defaultValue to the correct value when
	// cloning other types of input fields
	} else if ( nodeName === "input" || nodeName === "textarea" ) {
		dest.defaultValue = src.defaultValue;

	// IE blanks contents when cloning scripts
	} else if ( nodeName === "script" && dest.text !== src.text ) {
		dest.text = src.text;
	}

	// Event data gets referenced instead of copied if the expando
	// gets copied too
	dest.removeAttribute( jQuery.expando );
}

jQuery.buildFragment = function( args, context, scripts ) {
	var fragment, cacheable, cachehit,
		first = args[ 0 ];

	// Set context from what may come in as undefined or a jQuery collection or a node
	// Updated to fix #12266 where accessing context[0] could throw an exception in IE9/10 &
	// also doubles as fix for #8950 where plain objects caused createDocumentFragment exception
	context = context || document;
	context = !context.nodeType && context[0] || context;
	context = context.ownerDocument || context;

	// Only cache "small" (1/2 KB) HTML strings that are associated with the main document
	// Cloning options loses the selected state, so don't cache them
	// IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
	// Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
	// Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501
	if ( args.length === 1 && typeof first === "string" && first.length < 512 && context === document &&
		first.charAt(0) === "<" && !rnocache.test( first ) &&
		(jQuery.support.checkClone || !rchecked.test( first )) &&
		(jQuery.support.html5Clone || !rnoshimcache.test( first )) ) {

		// Mark cacheable and look for a hit
		cacheable = true;
		fragment = jQuery.fragments[ first ];
		cachehit = fragment !== undefined;
	}

	if ( !fragment ) {
		fragment = context.createDocumentFragment();
		jQuery.clean( args, context, fragment, scripts );

		// Update the cache, but only store false
		// unless this is a second parsing of the same content
		if ( cacheable ) {
			jQuery.fragments[ first ] = cachehit && fragment;
		}
	}

	return { fragment: fragment, cacheable: cacheable };
};

jQuery.fragments = {};

jQuery.each({
	appendTo: "append",
	prependTo: "prepend",
	insertBefore: "before",
	insertAfter: "after",
	replaceAll: "replaceWith"
}, function( name, original ) {
	jQuery.fn[ name ] = function( selector ) {
		var elems,
			i = 0,
			ret = [],
			insert = jQuery( selector ),
			l = insert.length,
			parent = this.length === 1 && this[0].parentNode;

		if ( (parent == null || parent && parent.nodeType === 11 && parent.childNodes.length === 1) && l === 1 ) {
			insert[ original ]( this[0] );
			return this;
		} else {
			for ( ; i < l; i++ ) {
				elems = ( i > 0 ? this.clone(true) : this ).get();
				jQuery( insert[i] )[ original ]( elems );
				ret = ret.concat( elems );
			}

			return this.pushStack( ret, name, insert.selector );
		}
	};
});

function getAll( elem ) {
	if ( typeof elem.getElementsByTagName !== "undefined" ) {
		return elem.getElementsByTagName( "*" );

	} else if ( typeof elem.querySelectorAll !== "undefined" ) {
		return elem.querySelectorAll( "*" );

	} else {
		return [];
	}
}

// Used in clean, fixes the defaultChecked property
function fixDefaultChecked( elem ) {
	if ( rcheckableType.test( elem.type ) ) {
		elem.defaultChecked = elem.checked;
	}
}

jQuery.extend({
	clone: function( elem, dataAndEvents, deepDataAndEvents ) {
		var srcElements,
			destElements,
			i,
			clone;

		if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
			clone = elem.cloneNode( true );

		// IE<=8 does not properly clone detached, unknown element nodes
		} else {
			fragmentDiv.innerHTML = elem.outerHTML;
			fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
		}

		if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
				(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
			// IE copies events bound via attachEvent when using cloneNode.
			// Calling detachEvent on the clone will also remove the events
			// from the original. In order to get around this, we use some
			// proprietary methods to clear the events. Thanks to MooTools
			// guys for this hotness.

			cloneFixAttributes( elem, clone );

			// Using Sizzle here is crazy slow, so we use getElementsByTagName instead
			srcElements = getAll( elem );
			destElements = getAll( clone );

			// Weird iteration because IE will replace the length property
			// with an element if you are cloning the body and one of the
			// elements on the page has a name or id of "length"
			for ( i = 0; srcElements[i]; ++i ) {
				// Ensure that the destination node is not null; Fixes #9587
				if ( destElements[i] ) {
					cloneFixAttributes( srcElements[i], destElements[i] );
				}
			}
		}

		// Copy the events from the original to the clone
		if ( dataAndEvents ) {
			cloneCopyEvent( elem, clone );

			if ( deepDataAndEvents ) {
				srcElements = getAll( elem );
				destElements = getAll( clone );

				for ( i = 0; srcElements[i]; ++i ) {
					cloneCopyEvent( srcElements[i], destElements[i] );
				}
			}
		}

		srcElements = destElements = null;

		// Return the cloned set
		return clone;
	},

	clean: function( elems, context, fragment, scripts ) {
		var i, j, elem, tag, wrap, depth, div, hasBody, tbody, len, handleScript, jsTags,
			safe = context === document && safeFragment,
			ret = [];

		// Ensure that context is a document
		if ( !context || typeof context.createDocumentFragment === "undefined" ) {
			context = document;
		}

		// Use the already-created safe fragment if context permits
		for ( i = 0; (elem = elems[i]) != null; i++ ) {
			if ( typeof elem === "number" ) {
				elem += "";
			}

			if ( !elem ) {
				continue;
			}

			// Convert html string into DOM nodes
			if ( typeof elem === "string" ) {
				if ( !rhtml.test( elem ) ) {
					elem = context.createTextNode( elem );
				} else {
					// Ensure a safe container in which to render the html
					safe = safe || createSafeFragment( context );
					div = context.createElement("div");
					safe.appendChild( div );

					// Fix "XHTML"-style tags in all browsers
					elem = elem.replace(rxhtmlTag, "<$1></$2>");

					// Go to html and back, then peel off extra wrappers
					tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
					wrap = wrapMap[ tag ] || wrapMap._default;
					depth = wrap[0];
					div.innerHTML = wrap[1] + elem + wrap[2];

					// Move to the right depth
					while ( depth-- ) {
						div = div.lastChild;
					}

					// Remove IE's autoinserted <tbody> from table fragments
					if ( !jQuery.support.tbody ) {

						// String was a <table>, *may* have spurious <tbody>
						hasBody = rtbody.test(elem);
							tbody = tag === "table" && !hasBody ?
								div.firstChild && div.firstChild.childNodes :

								// String was a bare <thead> or <tfoot>
								wrap[1] === "<table>" && !hasBody ?
									div.childNodes :
									[];

						for ( j = tbody.length - 1; j >= 0 ; --j ) {
							if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
								tbody[ j ].parentNode.removeChild( tbody[ j ] );
							}
						}
					}

					// IE completely kills leading whitespace when innerHTML is used
					if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
						div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
					}

					elem = div.childNodes;

					// Take out of fragment container (we need a fresh div each time)
					div.parentNode.removeChild( div );
				}
			}

			if ( elem.nodeType ) {
				ret.push( elem );
			} else {
				jQuery.merge( ret, elem );
			}
		}

		// Fix #11356: Clear elements from safeFragment
		if ( div ) {
			elem = div = safe = null;
		}

		// Reset defaultChecked for any radios and checkboxes
		// about to be appended to the DOM in IE 6/7 (#8060)
		if ( !jQuery.support.appendChecked ) {
			for ( i = 0; (elem = ret[i]) != null; i++ ) {
				if ( jQuery.nodeName( elem, "input" ) ) {
					fixDefaultChecked( elem );
				} else if ( typeof elem.getElementsByTagName !== "undefined" ) {
					jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
				}
			}
		}

		// Append elements to a provided document fragment
		if ( fragment ) {
			// Special handling of each script element
			handleScript = function( elem ) {
				// Check if we consider it executable
				if ( !elem.type || rscriptType.test( elem.type ) ) {
					// Detach the script and store it in the scripts array (if provided) or the fragment
					// Return truthy to indicate that it has been handled
					return scripts ?
						scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
						fragment.appendChild( elem );
				}
			};

			for ( i = 0; (elem = ret[i]) != null; i++ ) {
				// Check if we're done after handling an executable script
				if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) {
					// Append to fragment and handle embedded scripts
					fragment.appendChild( elem );
					if ( typeof elem.getElementsByTagName !== "undefined" ) {
						// handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
						jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );

						// Splice the scripts into ret after their former ancestor and advance our index beyond them
						ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
						i += jsTags.length;
					}
				}
			}
		}

		return ret;
	},

	cleanData: function( elems, /* internal */ acceptData ) {
		var data, id, elem, type,
			i = 0,
			internalKey = jQuery.expando,
			cache = jQuery.cache,
			deleteExpando = jQuery.support.deleteExpando,
			special = jQuery.event.special;

		for ( ; (elem = elems[i]) != null; i++ ) {

			if ( acceptData || jQuery.acceptData( elem ) ) {

				id = elem[ internalKey ];
				data = id && cache[ id ];

				if ( data ) {
					if ( data.events ) {
						for ( type in data.events ) {
							if ( special[ type ] ) {
								jQuery.event.remove( elem, type );

							// This is a shortcut to avoid jQuery.event.remove's overhead
							} else {
								jQuery.removeEvent( elem, type, data.handle );
							}
						}
					}

					// Remove cache only if it was not already removed by jQuery.event.remove
					if ( cache[ id ] ) {

						delete cache[ id ];

						// IE does not allow us to delete expando properties from nodes,
						// nor does it have a removeAttribute function on Document nodes;
						// we must handle all of these cases
						if ( deleteExpando ) {
							delete elem[ internalKey ];

						} else if ( elem.removeAttribute ) {
							elem.removeAttribute( internalKey );

						} else {
							elem[ internalKey ] = null;
						}

						jQuery.deletedIds.push( id );
					}
				}
			}
		}
	}
});
// Limit scope pollution from any deprecated API
(function() {

var matched, browser;

// Use of jQuery.browser is frowned upon.
// More details: http://api.jquery.com/jQuery.browser
// jQuery.uaMatch maintained for back-compat
jQuery.uaMatch = function( ua ) {
	ua = ua.toLowerCase();

	var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
		/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
		/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
		/(msie) ([\w.]+)/.exec( ua ) ||
		ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
		[];

	return {
		browser: match[ 1 ] || "",
		version: match[ 2 ] || "0"
	};
};

matched = jQuery.uaMatch( navigator.userAgent );
browser = {};

if ( matched.browser ) {
	browser[ matched.browser ] = true;
	browser.version = matched.version;
}

// Chrome is Webkit, but Webkit is also Safari.
if ( browser.chrome ) {
	browser.webkit = true;
} else if ( browser.webkit ) {
	browser.safari = true;
}

jQuery.browser = browser;

jQuery.sub = function() {
	function jQuerySub( selector, context ) {
		return new jQuerySub.fn.init( selector, context );
	}
	jQuery.extend( true, jQuerySub, this );
	jQuerySub.superclass = this;
	jQuerySub.fn = jQuerySub.prototype = this();
	jQuerySub.fn.constructor = jQuerySub;
	jQuerySub.sub = this.sub;
	jQuerySub.fn.init = function init( selector, context ) {
		if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
			context = jQuerySub( context );
		}

		return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
	};
	jQuerySub.fn.init.prototype = jQuerySub.fn;
	var rootjQuerySub = jQuerySub(document);
	return jQuerySub;
};

})();
var curCSS, iframe, iframeDoc,
	ralpha = /alpha\([^)]*\)/i,
	ropacity = /opacity=([^)]*)/,
	rposition = /^(top|right|bottom|left)$/,
	// swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
	// see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
	rdisplayswap = /^(none|table(?!-c[ea]).+)/,
	rmargin = /^margin/,
	rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
	rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
	rrelNum = new RegExp( "^([-+])=(" + core_pnum + ")", "i" ),
	elemdisplay = { BODY: "block" },

	cssShow = { position: "absolute", visibility: "hidden", display: "block" },
	cssNormalTransform = {
		letterSpacing: 0,
		fontWeight: 400
	},

	cssExpand = [ "Top", "Right", "Bottom", "Left" ],
	cssPrefixes = [ "Webkit", "O", "Moz", "ms" ],

	eventsToggle = jQuery.fn.toggle;

// return a css property mapped to a potentially vendor prefixed property
function vendorPropName( style, name ) {

	// shortcut for names that are not vendor prefixed
	if ( name in style ) {
		return name;
	}

	// check for vendor prefixed names
	var capName = name.charAt(0).toUpperCase() + name.slice(1),
		origName = name,
		i = cssPrefixes.length;

	while ( i-- ) {
		name = cssPrefixes[ i ] + capName;
		if ( name in style ) {
			return name;
		}
	}

	return origName;
}

function isHidden( elem, el ) {
	elem = el || elem;
	return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
}

function showHide( elements, show ) {
	var elem, display,
		values = [],
		index = 0,
		length = elements.length;

	for ( ; index < length; index++ ) {
		elem = elements[ index ];
		if ( !elem.style ) {
			continue;
		}
		values[ index ] = jQuery._data( elem, "olddisplay" );
		if ( show ) {
			// Reset the inline display of this element to learn if it is
			// being hidden by cascaded rules or not
			if ( !values[ index ] && elem.style.display === "none" ) {
				elem.style.display = "";
			}

			// Set elements which have been overridden with display: none
			// in a stylesheet to whatever the default browser style is
			// for such an element
			if ( elem.style.display === "" && isHidden( elem ) ) {
				values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
			}
		} else {
			display = curCSS( elem, "display" );

			if ( !values[ index ] && display !== "none" ) {
				jQuery._data( elem, "olddisplay", display );
			}
		}
	}

	// Set the display of most of the elements in a second loop
	// to avoid the constant reflow
	for ( index = 0; index < length; index++ ) {
		elem = elements[ index ];
		if ( !elem.style ) {
			continue;
		}
		if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
			elem.style.display = show ? values[ index ] || "" : "none";
		}
	}

	return elements;
}

jQuery.fn.extend({
	css: function( name, value ) {
		return jQuery.access( this, function( elem, name, value ) {
			return value !== undefined ?
				jQuery.style( elem, name, value ) :
				jQuery.css( elem, name );
		}, name, value, arguments.length > 1 );
	},
	show: function() {
		return showHide( this, true );
	},
	hide: function() {
		return showHide( this );
	},
	toggle: function( state, fn2 ) {
		var bool = typeof state === "boolean";

		if ( jQuery.isFunction( state ) && jQuery.isFunction( fn2 ) ) {
			return eventsToggle.apply( this, arguments );
		}

		return this.each(function() {
			if ( bool ? state : isHidden( this ) ) {
				jQuery( this ).show();
			} else {
				jQuery( this ).hide();
			}
		});
	}
});

jQuery.extend({
	// Add in style property hooks for overriding the default
	// behavior of getting and setting a style property
	cssHooks: {
		opacity: {
			get: function( elem, computed ) {
				if ( computed ) {
					// We should always get a number back from opacity
					var ret = curCSS( elem, "opacity" );
					return ret === "" ? "1" : ret;

				}
			}
		}
	},

	// Exclude the following css properties to add px
	cssNumber: {
		"fillOpacity": true,
		"fontWeight": true,
		"lineHeight": true,
		"opacity": true,
		"orphans": true,
		"widows": true,
		"zIndex": true,
		"zoom": true
	},

	// Add in properties whose names you wish to fix before
	// setting or getting the value
	cssProps: {
		// normalize float css property
		"float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
	},

	// Get and set the style property on a DOM Node
	style: function( elem, name, value, extra ) {
		// Don't set styles on text and comment nodes
		if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
			return;
		}

		// Make sure that we're working with the right name
		var ret, type, hooks,
			origName = jQuery.camelCase( name ),
			style = elem.style;

		name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );

		// gets hook for the prefixed version
		// followed by the unprefixed version
		hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];

		// Check if we're setting a value
		if ( value !== undefined ) {
			type = typeof value;

			// convert relative number strings (+= or -=) to relative numbers. #7345
			if ( type === "string" && (ret = rrelNum.exec( value )) ) {
				value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
				// Fixes bug #9237
				type = "number";
			}

			// Make sure that NaN and null values aren't set. See: #7116
			if ( value == null || type === "number" && isNaN( value ) ) {
				return;
			}

			// If a number was passed in, add 'px' to the (except for certain CSS properties)
			if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
				value += "px";
			}

			// If a hook was provided, use that value, otherwise just set the specified value
			if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
				// Wrapped to prevent IE from throwing errors when 'invalid' values are provided
				// Fixes bug #5509
				try {
					style[ name ] = value;
				} catch(e) {}
			}

		} else {
			// If a hook was provided get the non-computed value from there
			if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
				return ret;
			}

			// Otherwise just get the value from the style object
			return style[ name ];
		}
	},

	css: function( elem, name, numeric, extra ) {
		var val, num, hooks,
			origName = jQuery.camelCase( name );

		// Make sure that we're working with the right name
		name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );

		// gets hook for the prefixed version
		// followed by the unprefixed version
		hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];

		// If a hook was provided get the computed value from there
		if ( hooks && "get" in hooks ) {
			val = hooks.get( elem, true, extra );
		}

		// Otherwise, if a way to get the computed value exists, use that
		if ( val === undefined ) {
			val = curCSS( elem, name );
		}

		//convert "normal" to computed value
		if ( val === "normal" && name in cssNormalTransform ) {
			val = cssNormalTransform[ name ];
		}

		// Return, converting to number if forced or a qualifier was provided and val looks numeric
		if ( numeric || extra !== undefined ) {
			num = parseFloat( val );
			return numeric || jQuery.isNumeric( num ) ? num || 0 : val;
		}
		return val;
	},

	// A method for quickly swapping in/out CSS properties to get correct calculations
	swap: function( elem, options, callback ) {
		var ret, name,
			old = {};

		// Remember the old values, and insert the new ones
		for ( name in options ) {
			old[ name ] = elem.style[ name ];
			elem.style[ name ] = options[ name ];
		}

		ret = callback.call( elem );

		// Revert the old values
		for ( name in options ) {
			elem.style[ name ] = old[ name ];
		}

		return ret;
	}
});

// NOTE: To any future maintainer, we've window.getComputedStyle
// because jsdom on node.js will break without it.
if ( window.getComputedStyle ) {
	curCSS = function( elem, name ) {
		var ret, width, minWidth, maxWidth,
			computed = window.getComputedStyle( elem, null ),
			style = elem.style;

		if ( computed ) {

			// getPropertyValue is only needed for .css('filter') in IE9, see #12537
			ret = computed.getPropertyValue( name ) || computed[ name ];

			if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
				ret = jQuery.style( elem, name );
			}

			// A tribute to the "awesome hack by Dean Edwards"
			// Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
			// Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
			// this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
			if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
				width = style.width;
				minWidth = style.minWidth;
				maxWidth = style.maxWidth;

				style.minWidth = style.maxWidth = style.width = ret;
				ret = computed.width;

				style.width = width;
				style.minWidth = minWidth;
				style.maxWidth = maxWidth;
			}
		}

		return ret;
	};
} else if ( document.documentElement.currentStyle ) {
	curCSS = function( elem, name ) {
		var left, rsLeft,
			ret = elem.currentStyle && elem.currentStyle[ name ],
			style = elem.style;

		// Avoid setting ret to empty string here
		// so we don't default to auto
		if ( ret == null && style && style[ name ] ) {
			ret = style[ name ];
		}

		// From the awesome hack by Dean Edwards
		// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291

		// If we're not dealing with a regular pixel number
		// but a number that has a weird ending, we need to convert it to pixels
		// but not position css attributes, as those are proportional to the parent element instead
		// and we can't measure the parent instead because it might trigger a "stacking dolls" problem
		if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {

			// Remember the original values
			left = style.left;
			rsLeft = elem.runtimeStyle && elem.runtimeStyle.left;

			// Put in the new values to get a computed value out
			if ( rsLeft ) {
				elem.runtimeStyle.left = elem.currentStyle.left;
			}
			style.left = name === "fontSize" ? "1em" : ret;
			ret = style.pixelLeft + "px";

			// Revert the changed values
			style.left = left;
			if ( rsLeft ) {
				elem.runtimeStyle.left = rsLeft;
			}
		}

		return ret === "" ? "auto" : ret;
	};
}

function setPositiveNumber( elem, value, subtract ) {
	var matches = rnumsplit.exec( value );
	return matches ?
			Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
			value;
}

function augmentWidthOrHeight( elem, name, extra, isBorderBox ) {
	var i = extra === ( isBorderBox ? "border" : "content" ) ?
		// If we already have the right measurement, avoid augmentation
		4 :
		// Otherwise initialize for horizontal or vertical properties
		name === "width" ? 1 : 0,

		val = 0;

	for ( ; i < 4; i += 2 ) {
		// both box models exclude margin, so add it if we want it
		if ( extra === "margin" ) {
			// we use jQuery.css instead of curCSS here
			// because of the reliableMarginRight CSS hook!
			val += jQuery.css( elem, extra + cssExpand[ i ], true );
		}

		// From this point on we use curCSS for maximum performance (relevant in animations)
		if ( isBorderBox ) {
			// border-box includes padding, so remove it if we want content
			if ( extra === "content" ) {
				val -= parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;
			}

			// at this point, extra isn't border nor margin, so remove border
			if ( extra !== "margin" ) {
				val -= parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
			}
		} else {
			// at this point, extra isn't content, so add padding
			val += parseFloat( curCSS( elem, "padding" + cssExpand[ i ] ) ) || 0;

			// at this point, extra isn't content nor padding, so add border
			if ( extra !== "padding" ) {
				val += parseFloat( curCSS( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
			}
		}
	}

	return val;
}

function getWidthOrHeight( elem, name, extra ) {

	// Start with offset property, which is equivalent to the border-box value
	var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
		valueIsBorderBox = true,
		isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box";

	// some non-html elements return undefined for offsetWidth, so check for null/undefined
	// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
	// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
	if ( val <= 0 || val == null ) {
		// Fall back to computed then uncomputed css if necessary
		val = curCSS( elem, name );
		if ( val < 0 || val == null ) {
			val = elem.style[ name ];
		}

		// Computed unit is not pixels. Stop here and return.
		if ( rnumnonpx.test(val) ) {
			return val;
		}

		// we need the check for style in case a browser which returns unreliable values
		// for getComputedStyle silently falls back to the reliable elem.style
		valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );

		// Normalize "", auto, and prepare for extra
		val = parseFloat( val ) || 0;
	}

	// use the active box-sizing model to add/subtract irrelevant styles
	return ( val +
		augmentWidthOrHeight(
			elem,
			name,
			extra || ( isBorderBox ? "border" : "content" ),
			valueIsBorderBox
		)
	) + "px";
}


// Try to determine the default display value of an element
function css_defaultDisplay( nodeName ) {
	if ( elemdisplay[ nodeName ] ) {
		return elemdisplay[ nodeName ];
	}

	var elem = jQuery( "<" + nodeName + ">" ).appendTo( document.body ),
		display = elem.css("display");
	elem.remove();

	// If the simple way fails,
	// get element's real default display by attaching it to a temp iframe
	if ( display === "none" || display === "" ) {
		// Use the already-created iframe if possible
		iframe = document.body.appendChild(
			iframe || jQuery.extend( document.createElement("iframe"), {
				frameBorder: 0,
				width: 0,
				height: 0
			})
		);

		// Create a cacheable copy of the iframe document on first call.
		// IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
		// document to it; WebKit & Firefox won't allow reusing the iframe document.
		if ( !iframeDoc || !iframe.createElement ) {
			iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
			iframeDoc.write("<!doctype html><html><body>");
			iframeDoc.close();
		}

		elem = iframeDoc.body.appendChild( iframeDoc.createElement(nodeName) );

		display = curCSS( elem, "display" );
		document.body.removeChild( iframe );
	}

	// Store the correct default display
	elemdisplay[ nodeName ] = display;

	return display;
}

jQuery.each([ "height", "width" ], function( i, name ) {
	jQuery.cssHooks[ name ] = {
		get: function( elem, computed, extra ) {
			if ( computed ) {
				// certain elements can have dimension info if we invisibly show them
				// however, it must have a current display style that would benefit from this
				if ( elem.offsetWidth === 0 && rdisplayswap.test( curCSS( elem, "display" ) ) ) {
					return jQuery.swap( elem, cssShow, function() {
						return getWidthOrHeight( elem, name, extra );
					});
				} else {
					return getWidthOrHeight( elem, name, extra );
				}
			}
		},

		set: function( elem, value, extra ) {
			return setPositiveNumber( elem, value, extra ?
				augmentWidthOrHeight(
					elem,
					name,
					extra,
					jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box"
				) : 0
			);
		}
	};
});

if ( !jQuery.support.opacity ) {
	jQuery.cssHooks.opacity = {
		get: function( elem, computed ) {
			// IE uses filters for opacity
			return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
				( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
				computed ? "1" : "";
		},

		set: function( elem, value ) {
			var style = elem.style,
				currentStyle = elem.currentStyle,
				opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
				filter = currentStyle && currentStyle.filter || style.filter || "";

			// IE has trouble with opacity if it does not have layout
			// Force it by setting the zoom level
			style.zoom = 1;

			// if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
			if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
				style.removeAttribute ) {

				// Setting style.filter to null, "" & " " still leave "filter:" in the cssText
				// if "filter:" is present at all, clearType is disabled, we want to avoid this
				// style.removeAttribute is IE Only, but so apparently is this code path...
				style.removeAttribute( "filter" );

				// if there there is no filter style applied in a css rule, we are done
				if ( currentStyle && !currentStyle.filter ) {
					return;
				}
			}

			// otherwise, set new filter values
			style.filter = ralpha.test( filter ) ?
				filter.replace( ralpha, opacity ) :
				filter + " " + opacity;
		}
	};
}

// These hooks cannot be added until DOM ready because the support test
// for it is not run until after DOM ready
jQuery(function() {
	if ( !jQuery.support.reliableMarginRight ) {
		jQuery.cssHooks.marginRight = {
			get: function( elem, computed ) {
				// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
				// Work around by temporarily setting element display to inline-block
				return jQuery.swap( elem, { "display": "inline-block" }, function() {
					if ( computed ) {
						return curCSS( elem, "marginRight" );
					}
				});
			}
		};
	}

	// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
	// getComputedStyle returns percent when specified for top/left/bottom/right
	// rather than make the css module depend on the offset module, we just check for it here
	if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
		jQuery.each( [ "top", "left" ], function( i, prop ) {
			jQuery.cssHooks[ prop ] = {
				get: function( elem, computed ) {
					if ( computed ) {
						var ret = curCSS( elem, prop );
						// if curCSS returns percentage, fallback to offset
						return rnumnonpx.test( ret ) ? jQuery( elem ).position()[ prop ] + "px" : ret;
					}
				}
			};
		});
	}

});

if ( jQuery.expr && jQuery.expr.filters ) {
	jQuery.expr.filters.hidden = function( elem ) {
		return ( elem.offsetWidth === 0 && elem.offsetHeight === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || curCSS( elem, "display" )) === "none");
	};

	jQuery.expr.filters.visible = function( elem ) {
		return !jQuery.expr.filters.hidden( elem );
	};
}

// These hooks are used by animate to expand properties
jQuery.each({
	margin: "",
	padding: "",
	border: "Width"
}, function( prefix, suffix ) {
	jQuery.cssHooks[ prefix + suffix ] = {
		expand: function( value ) {
			var i,

				// assumes a single number if not a string
				parts = typeof value === "string" ? value.split(" ") : [ value ],
				expanded = {};

			for ( i = 0; i < 4; i++ ) {
				expanded[ prefix + cssExpand[ i ] + suffix ] =
					parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
			}

			return expanded;
		}
	};

	if ( !rmargin.test( prefix ) ) {
		jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
	}
});
var r20 = /%20/g,
	rbracket = /\[\]$/,
	rCRLF = /\r?\n/g,
	rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
	rselectTextarea = /^(?:select|textarea)/i;

jQuery.fn.extend({
	serialize: function() {
		return jQuery.param( this.serializeArray() );
	},
	serializeArray: function() {
		return this.map(function(){
			return this.elements ? jQuery.makeArray( this.elements ) : this;
		})
		.filter(function(){
			return this.name && !this.disabled &&
				( this.checked || rselectTextarea.test( this.nodeName ) ||
					rinput.test( this.type ) );
		})
		.map(function( i, elem ){
			var val = jQuery( this ).val();

			return val == null ?
				null :
				jQuery.isArray( val ) ?
					jQuery.map( val, function( val, i ){
						return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
					}) :
					{ name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
		}).get();
	}
});

//Serialize an array of form elements or a set of
//key/values into a query string
jQuery.param = function( a, traditional ) {
	var prefix,
		s = [],
		add = function( key, value ) {
			// If value is a function, invoke it and return its value
			value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
			s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
		};

	// Set traditional to true for jQuery <= 1.3.2 behavior.
	if ( traditional === undefined ) {
		traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
	}

	// If an array was passed in, assume that it is an array of form elements.
	if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
		// Serialize the form elements
		jQuery.each( a, function() {
			add( this.name, this.value );
		});

	} else {
		// If traditional, encode the "old" way (the way 1.3.2 or older
		// did it), otherwise encode params recursively.
		for ( prefix in a ) {
			buildParams( prefix, a[ prefix ], traditional, add );
		}
	}

	// Return the resulting serialization
	return s.join( "&" ).replace( r20, "+" );
};

function buildParams( prefix, obj, traditional, add ) {
	var name;

	if ( jQuery.isArray( obj ) ) {
		// Serialize array item.
		jQuery.each( obj, function( i, v ) {
			if ( traditional || rbracket.test( prefix ) ) {
				// Treat each array item as a scalar.
				add( prefix, v );

			} else {
				// If array item is non-scalar (array or object), encode its
				// numeric index to resolve deserialization ambiguity issues.
				// Note that rack (as of 1.0.0) can't currently deserialize
				// nested arrays properly, and attempting to do so may cause
				// a server error. Possible fixes are to modify rack's
				// deserialization algorithm or to provide an option or flag
				// to force array serialization to be shallow.
				buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
			}
		});

	} else if ( !traditional && jQuery.type( obj ) === "object" ) {
		// Serialize object item.
		for ( name in obj ) {
			buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
		}

	} else {
		// Serialize scalar item.
		add( prefix, obj );
	}
}
var
	// Document location
	ajaxLocParts,
	ajaxLocation,

	rhash = /#.*$/,
	rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
	// #7653, #8125, #8152: local protocol detection
	rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
	rnoContent = /^(?:GET|HEAD)$/,
	rprotocol = /^\/\//,
	rquery = /\?/,
	rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
	rts = /([?&])_=[^&]*/,
	rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,

	// Keep a copy of the old load method
	_load = jQuery.fn.load,

	/* Prefilters
	 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
	 * 2) These are called:
	 *    - BEFORE asking for a transport
	 *    - AFTER param serialization (s.data is a string if s.processData is true)
	 * 3) key is the dataType
	 * 4) the catchall symbol "*" can be used
	 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
	 */
	prefilters = {},

	/* Transports bindings
	 * 1) key is the dataType
	 * 2) the catchall symbol "*" can be used
	 * 3) selection will start with transport dataType and THEN go to "*" if needed
	 */
	transports = {},

	// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
	allTypes = ["*/"] + ["*"];

// #8138, IE may throw an exception when accessing
// a field from window.location if document.domain has been set
try {
	ajaxLocation = location.href;
} catch( e ) {
	// Use the href attribute of an A element
	// since IE will modify it given document.location
	ajaxLocation = document.createElement( "a" );
	ajaxLocation.href = "";
	ajaxLocation = ajaxLocation.href;
}

// Segment location into parts
ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];

// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
function addToPrefiltersOrTransports( structure ) {

	// dataTypeExpression is optional and defaults to "*"
	return function( dataTypeExpression, func ) {

		if ( typeof dataTypeExpression !== "string" ) {
			func = dataTypeExpression;
			dataTypeExpression = "*";
		}

		var dataType, list, placeBefore,
			dataTypes = dataTypeExpression.toLowerCase().split( core_rspace ),
			i = 0,
			length = dataTypes.length;

		if ( jQuery.isFunction( func ) ) {
			// For each dataType in the dataTypeExpression
			for ( ; i < length; i++ ) {
				dataType = dataTypes[ i ];
				// We control if we're asked to add before
				// any existing element
				placeBefore = /^\+/.test( dataType );
				if ( placeBefore ) {
					dataType = dataType.substr( 1 ) || "*";
				}
				list = structure[ dataType ] = structure[ dataType ] || [];
				// then we add to the structure accordingly
				list[ placeBefore ? "unshift" : "push" ]( func );
			}
		}
	};
}

// Base inspection function for prefilters and transports
function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
		dataType /* internal */, inspected /* internal */ ) {

	dataType = dataType || options.dataTypes[ 0 ];
	inspected = inspected || {};

	inspected[ dataType ] = true;

	var selection,
		list = structure[ dataType ],
		i = 0,
		length = list ? list.length : 0,
		executeOnly = ( structure === prefilters );

	for ( ; i < length && ( executeOnly || !selection ); i++ ) {
		selection = list[ i ]( options, originalOptions, jqXHR );
		// If we got redirected to another dataType
		// we try there if executing only and not done already
		if ( typeof selection === "string" ) {
			if ( !executeOnly || inspected[ selection ] ) {
				selection = undefined;
			} else {
				options.dataTypes.unshift( selection );
				selection = inspectPrefiltersOrTransports(
						structure, options, originalOptions, jqXHR, selection, inspected );
			}
		}
	}
	// If we're only executing or nothing was selected
	// we try the catchall dataType if not done already
	if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
		selection = inspectPrefiltersOrTransports(
				structure, options, originalOptions, jqXHR, "*", inspected );
	}
	// unnecessary when only executing (prefilters)
	// but it'll be ignored by the caller in that case
	return selection;
}

// A special extend for ajax options
// that takes "flat" options (not to be deep extended)
// Fixes #9887
function ajaxExtend( target, src ) {
	var key, deep,
		flatOptions = jQuery.ajaxSettings.flatOptions || {};
	for ( key in src ) {
		if ( src[ key ] !== undefined ) {
			( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
		}
	}
	if ( deep ) {
		jQuery.extend( true, target, deep );
	}
}

jQuery.fn.load = function( url, params, callback ) {
	if ( typeof url !== "string" && _load ) {
		return _load.apply( this, arguments );
	}

	// Don't do a request if no elements are being requested
	if ( !this.length ) {
		return this;
	}

	var selector, type, response,
		self = this,
		off = url.indexOf(" ");

	if ( off >= 0 ) {
		selector = url.slice( off, url.length );
		url = url.slice( 0, off );
	}

	// If it's a function
	if ( jQuery.isFunction( params ) ) {

		// We assume that it's the callback
		callback = params;
		params = undefined;

	// Otherwise, build a param string
	} else if ( params && typeof params === "object" ) {
		type = "POST";
	}

	// Request the remote document
	jQuery.ajax({
		url: url,

		// if "type" variable is undefined, then "GET" method will be used
		type: type,
		dataType: "html",
		data: params,
		complete: function( jqXHR, status ) {
			if ( callback ) {
				self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
			}
		}
	}).done(function( responseText ) {

		// Save response for use in complete callback
		response = arguments;

		// See if a selector was specified
		self.html( selector ?

			// Create a dummy div to hold the results
			jQuery("<div>")

				// inject the contents of the document in, removing the scripts
				// to avoid any 'Permission Denied' errors in IE
				.append( responseText.replace( rscript, "" ) )

				// Locate the specified elements
				.find( selector ) :

			// If not, just inject the full result
			responseText );

	});

	return this;
};

// Attach a bunch of functions for handling common AJAX events
jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
	jQuery.fn[ o ] = function( f ){
		return this.on( o, f );
	};
});

jQuery.each( [ "get", "post" ], function( i, method ) {
	jQuery[ method ] = function( url, data, callback, type ) {
		// shift arguments if data argument was omitted
		if ( jQuery.isFunction( data ) ) {
			type = type || callback;
			callback = data;
			data = undefined;
		}

		return jQuery.ajax({
			type: method,
			url: url,
			data: data,
			success: callback,
			dataType: type
		});
	};
});

jQuery.extend({

	getScript: function( url, callback ) {
		return jQuery.get( url, undefined, callback, "script" );
	},

	getJSON: function( url, data, callback ) {
		return jQuery.get( url, data, callback, "json" );
	},

	// Creates a full fledged settings object into target
	// with both ajaxSettings and settings fields.
	// If target is omitted, writes into ajaxSettings.
	ajaxSetup: function( target, settings ) {
		if ( settings ) {
			// Building a settings object
			ajaxExtend( target, jQuery.ajaxSettings );
		} else {
			// Extending ajaxSettings
			settings = target;
			target = jQuery.ajaxSettings;
		}
		ajaxExtend( target, settings );
		return target;
	},

	ajaxSettings: {
		url: ajaxLocation,
		isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
		global: true,
		type: "GET",
		contentType: "application/x-www-form-urlencoded; charset=UTF-8",
		processData: true,
		async: true,
		/*
		timeout: 0,
		data: null,
		dataType: null,
		username: null,
		password: null,
		cache: null,
		throws: false,
		traditional: false,
		headers: {},
		*/

		accepts: {
			xml: "application/xml, text/xml",
			html: "text/html",
			text: "text/plain",
			json: "application/json, text/javascript",
			"*": allTypes
		},

		contents: {
			xml: /xml/,
			html: /html/,
			json: /json/
		},

		responseFields: {
			xml: "responseXML",
			text: "responseText"
		},

		// List of data converters
		// 1) key format is "source_type destination_type" (a single space in-between)
		// 2) the catchall symbol "*" can be used for source_type
		converters: {

			// Convert anything to text
			"* text": window.String,

			// Text to html (true = no transformation)
			"text html": true,

			// Evaluate text as a json expression
			"text json": jQuery.parseJSON,

			// Parse text as xml
			"text xml": jQuery.parseXML
		},

		// For options that shouldn't be deep extended:
		// you can add your own custom options here if
		// and when you create one that shouldn't be
		// deep extended (see ajaxExtend)
		flatOptions: {
			context: true,
			url: true
		}
	},

	ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
	ajaxTransport: addToPrefiltersOrTransports( transports ),

	// Main method
	ajax: function( url, options ) {

		// If url is an object, simulate pre-1.5 signature
		if ( typeof url === "object" ) {
			options = url;
			url = undefined;
		}

		// Force options to be an object
		options = options || {};

		var // ifModified key
			ifModifiedKey,
			// Response headers
			responseHeadersString,
			responseHeaders,
			// transport
			transport,
			// timeout handle
			timeoutTimer,
			// Cross-domain detection vars
			parts,
			// To know if global events are to be dispatched
			fireGlobals,
			// Loop variable
			i,
			// Create the final options object
			s = jQuery.ajaxSetup( {}, options ),
			// Callbacks context
			callbackContext = s.context || s,
			// Context for global events
			// It's the callbackContext if one was provided in the options
			// and if it's a DOM node or a jQuery collection
			globalEventContext = callbackContext !== s &&
				( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
						jQuery( callbackContext ) : jQuery.event,
			// Deferreds
			deferred = jQuery.Deferred(),
			completeDeferred = jQuery.Callbacks( "once memory" ),
			// Status-dependent callbacks
			statusCode = s.statusCode || {},
			// Headers (they are sent all at once)
			requestHeaders = {},
			requestHeadersNames = {},
			// The jqXHR state
			state = 0,
			// Default abort message
			strAbort = "canceled",
			// Fake xhr
			jqXHR = {

				readyState: 0,

				// Caches the header
				setRequestHeader: function( name, value ) {
					if ( !state ) {
						var lname = name.toLowerCase();
						name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
						requestHeaders[ name ] = value;
					}
					return this;
				},

				// Raw string
				getAllResponseHeaders: function() {
					return state === 2 ? responseHeadersString : null;
				},

				// Builds headers hashtable if needed
				getResponseHeader: function( key ) {
					var match;
					if ( state === 2 ) {
						if ( !responseHeaders ) {
							responseHeaders = {};
							while( ( match = rheaders.exec( responseHeadersString ) ) ) {
								responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
							}
						}
						match = responseHeaders[ key.toLowerCase() ];
					}
					return match === undefined ? null : match;
				},

				// Overrides response content-type header
				overrideMimeType: function( type ) {
					if ( !state ) {
						s.mimeType = type;
					}
					return this;
				},

				// Cancel the request
				abort: function( statusText ) {
					statusText = statusText || strAbort;
					if ( transport ) {
						transport.abort( statusText );
					}
					done( 0, statusText );
					return this;
				}
			};

		// Callback for when everything is done
		// It is defined here because jslint complains if it is declared
		// at the end of the function (which would be more logical and readable)
		function done( status, nativeStatusText, responses, headers ) {
			var isSuccess, success, error, response, modified,
				statusText = nativeStatusText;

			// Called once
			if ( state === 2 ) {
				return;
			}

			// State is "done" now
			state = 2;

			// Clear timeout if it exists
			if ( timeoutTimer ) {
				clearTimeout( timeoutTimer );
			}

			// Dereference transport for early garbage collection
			// (no matter how long the jqXHR object will be used)
			transport = undefined;

			// Cache response headers
			responseHeadersString = headers || "";

			// Set readyState
			jqXHR.readyState = status > 0 ? 4 : 0;

			// Get response data
			if ( responses ) {
				response = ajaxHandleResponses( s, jqXHR, responses );
			}

			// If successful, handle type chaining
			if ( status >= 200 && status < 300 || status === 304 ) {

				// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
				if ( s.ifModified ) {

					modified = jqXHR.getResponseHeader("Last-Modified");
					if ( modified ) {
						jQuery.lastModified[ ifModifiedKey ] = modified;
					}
					modified = jqXHR.getResponseHeader("Etag");
					if ( modified ) {
						jQuery.etag[ ifModifiedKey ] = modified;
					}
				}

				// If not modified
				if ( status === 304 ) {

					statusText = "notmodified";
					isSuccess = true;

				// If we have data
				} else {

					isSuccess = ajaxConvert( s, response );
					statusText = isSuccess.state;
					success = isSuccess.data;
					error = isSuccess.error;
					isSuccess = !error;
				}
			} else {
				// We extract error from statusText
				// then normalize statusText and status for non-aborts
				error = statusText;
				if ( !statusText || status ) {
					statusText = "error";
					if ( status < 0 ) {
						status = 0;
					}
				}
			}

			// Set data for the fake xhr object
			jqXHR.status = status;
			jqXHR.statusText = ( nativeStatusText || statusText ) + "";

			// Success/Error
			if ( isSuccess ) {
				deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
			} else {
				deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
			}

			// Status-dependent callbacks
			jqXHR.statusCode( statusCode );
			statusCode = undefined;

			if ( fireGlobals ) {
				globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
						[ jqXHR, s, isSuccess ? success : error ] );
			}

			// Complete
			completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );

			if ( fireGlobals ) {
				globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
				// Handle the global AJAX counter
				if ( !( --jQuery.active ) ) {
					jQuery.event.trigger( "ajaxStop" );
				}
			}
		}

		// Attach deferreds
		deferred.promise( jqXHR );
		jqXHR.success = jqXHR.done;
		jqXHR.error = jqXHR.fail;
		jqXHR.complete = completeDeferred.add;

		// Status-dependent callbacks
		jqXHR.statusCode = function( map ) {
			if ( map ) {
				var tmp;
				if ( state < 2 ) {
					for ( tmp in map ) {
						statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
					}
				} else {
					tmp = map[ jqXHR.status ];
					jqXHR.always( tmp );
				}
			}
			return this;
		};

		// Remove hash character (#7531: and string promotion)
		// Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
		// We also use the url parameter if available
		s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );

		// Extract dataTypes list
		s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace );

		// A cross-domain request is in order when we have a protocol:host:port mismatch
		if ( s.crossDomain == null ) {
			parts = rurl.exec( s.url.toLowerCase() );
			s.crossDomain = !!( parts &&
				( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
					( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
						( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
			);
		}

		// Convert data if not already a string
		if ( s.data && s.processData && typeof s.data !== "string" ) {
			s.data = jQuery.param( s.data, s.traditional );
		}

		// Apply prefilters
		inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );

		// If request was aborted inside a prefilter, stop there
		if ( state === 2 ) {
			return jqXHR;
		}

		// We can fire global events as of now if asked to
		fireGlobals = s.global;

		// Uppercase the type
		s.type = s.type.toUpperCase();

		// Determine if request has content
		s.hasContent = !rnoContent.test( s.type );

		// Watch for a new set of requests
		if ( fireGlobals && jQuery.active++ === 0 ) {
			jQuery.event.trigger( "ajaxStart" );
		}

		// More options handling for requests with no content
		if ( !s.hasContent ) {

			// If data is available, append data to url
			if ( s.data ) {
				s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
				// #9682: remove data so that it's not used in an eventual retry
				delete s.data;
			}

			// Get ifModifiedKey before adding the anti-cache parameter
			ifModifiedKey = s.url;

			// Add anti-cache in url if needed
			if ( s.cache === false ) {

				var ts = jQuery.now(),
					// try replacing _= if it is there
					ret = s.url.replace( rts, "$1_=" + ts );

				// if nothing was replaced, add timestamp to the end
				s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
			}
		}

		// Set the correct header, if data is being sent
		if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
			jqXHR.setRequestHeader( "Content-Type", s.contentType );
		}

		// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
		if ( s.ifModified ) {
			ifModifiedKey = ifModifiedKey || s.url;
			if ( jQuery.lastModified[ ifModifiedKey ] ) {
				jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
			}
			if ( jQuery.etag[ ifModifiedKey ] ) {
				jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
			}
		}

		// Set the Accepts header for the server, depending on the dataType
		jqXHR.setRequestHeader(
			"Accept",
			s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
				s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
				s.accepts[ "*" ]
		);

		// Check for headers option
		for ( i in s.headers ) {
			jqXHR.setRequestHeader( i, s.headers[ i ] );
		}

		// Allow custom headers/mimetypes and early abort
		if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
				// Abort if not done already and return
				return jqXHR.abort();

		}

		// aborting is no longer a cancellation
		strAbort = "abort";

		// Install callbacks on deferreds
		for ( i in { success: 1, error: 1, complete: 1 } ) {
			jqXHR[ i ]( s[ i ] );
		}

		// Get transport
		transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );

		// If no transport, we auto-abort
		if ( !transport ) {
			done( -1, "No Transport" );
		} else {
			jqXHR.readyState = 1;
			// Send global event
			if ( fireGlobals ) {
				globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
			}
			// Timeout
			if ( s.async && s.timeout > 0 ) {
				timeoutTimer = setTimeout( function(){
					jqXHR.abort( "timeout" );
				}, s.timeout );
			}

			try {
				state = 1;
				transport.send( requestHeaders, done );
			} catch (e) {
				// Propagate exception as error if not done
				if ( state < 2 ) {
					done( -1, e );
				// Simply rethrow otherwise
				} else {
					throw e;
				}
			}
		}

		return jqXHR;
	},

	// Counter for holding the number of active queries
	active: 0,

	// Last-Modified header cache for next request
	lastModified: {},
	etag: {}

});

/* Handles responses to an ajax request:
 * - sets all responseXXX fields accordingly
 * - finds the right dataType (mediates between content-type and expected dataType)
 * - returns the corresponding response
 */
function ajaxHandleResponses( s, jqXHR, responses ) {

	var ct, type, finalDataType, firstDataType,
		contents = s.contents,
		dataTypes = s.dataTypes,
		responseFields = s.responseFields;

	// Fill responseXXX fields
	for ( type in responseFields ) {
		if ( type in responses ) {
			jqXHR[ responseFields[type] ] = responses[ type ];
		}
	}

	// Remove auto dataType and get content-type in the process
	while( dataTypes[ 0 ] === "*" ) {
		dataTypes.shift();
		if ( ct === undefined ) {
			ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
		}
	}

	// Check if we're dealing with a known content-type
	if ( ct ) {
		for ( type in contents ) {
			if ( contents[ type ] && contents[ type ].test( ct ) ) {
				dataTypes.unshift( type );
				break;
			}
		}
	}

	// Check to see if we have a response for the expected dataType
	if ( dataTypes[ 0 ] in responses ) {
		finalDataType = dataTypes[ 0 ];
	} else {
		// Try convertible dataTypes
		for ( type in responses ) {
			if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
				finalDataType = type;
				break;
			}
			if ( !firstDataType ) {
				firstDataType = type;
			}
		}
		// Or just use first one
		finalDataType = finalDataType || firstDataType;
	}

	// If we found a dataType
	// We add the dataType to the list if needed
	// and return the corresponding response
	if ( finalDataType ) {
		if ( finalDataType !== dataTypes[ 0 ] ) {
			dataTypes.unshift( finalDataType );
		}
		return responses[ finalDataType ];
	}
}

// Chain conversions given the request and the original response
function ajaxConvert( s, response ) {

	var conv, conv2, current, tmp,
		// Work with a copy of dataTypes in case we need to modify it for conversion
		dataTypes = s.dataTypes.slice(),
		prev = dataTypes[ 0 ],
		converters = {},
		i = 0;

	// Apply the dataFilter if provided
	if ( s.dataFilter ) {
		response = s.dataFilter( response, s.dataType );
	}

	// Create converters map with lowercased keys
	if ( dataTypes[ 1 ] ) {
		for ( conv in s.converters ) {
			converters[ conv.toLowerCase() ] = s.converters[ conv ];
		}
	}

	// Convert to each sequential dataType, tolerating list modification
	for ( ; (current = dataTypes[++i]); ) {

		// There's only work to do if current dataType is non-auto
		if ( current !== "*" ) {

			// Convert response if prev dataType is non-auto and differs from current
			if ( prev !== "*" && prev !== current ) {

				// Seek a direct converter
				conv = converters[ prev + " " + current ] || converters[ "* " + current ];

				// If none found, seek a pair
				if ( !conv ) {
					for ( conv2 in converters ) {

						// If conv2 outputs current
						tmp = conv2.split(" ");
						if ( tmp[ 1 ] === current ) {

							// If prev can be converted to accepted input
							conv = converters[ prev + " " + tmp[ 0 ] ] ||
								converters[ "* " + tmp[ 0 ] ];
							if ( conv ) {
								// Condense equivalence converters
								if ( conv === true ) {
									conv = converters[ conv2 ];

								// Otherwise, insert the intermediate dataType
								} else if ( converters[ conv2 ] !== true ) {
									current = tmp[ 0 ];
									dataTypes.splice( i--, 0, current );
								}

								break;
							}
						}
					}
				}

				// Apply converter (if not an equivalence)
				if ( conv !== true ) {

					// Unless errors are allowed to bubble, catch and return them
					if ( conv && s["throws"] ) {
						response = conv( response );
					} else {
						try {
							response = conv( response );
						} catch ( e ) {
							return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
						}
					}
				}
			}

			// Update prev for next iteration
			prev = current;
		}
	}

	return { state: "success", data: response };
}
var oldCallbacks = [],
	rquestion = /\?/,
	rjsonp = /(=)\?(?=&|$)|\?\?/,
	nonce = jQuery.now();

// Default jsonp settings
jQuery.ajaxSetup({
	jsonp: "callback",
	jsonpCallback: function() {
		var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
		this[ callback ] = true;
		return callback;
	}
});

// Detect, normalize options and install callbacks for jsonp requests
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {

	var callbackName, overwritten, responseContainer,
		data = s.data,
		url = s.url,
		hasCallback = s.jsonp !== false,
		replaceInUrl = hasCallback && rjsonp.test( url ),
		replaceInData = hasCallback && !replaceInUrl && typeof data === "string" &&
			!( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") &&
			rjsonp.test( data );

	// Handle iff the expected data type is "jsonp" or we have a parameter to set
	if ( s.dataTypes[ 0 ] === "jsonp" || replaceInUrl || replaceInData ) {

		// Get callback name, remembering preexisting value associated with it
		callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
			s.jsonpCallback() :
			s.jsonpCallback;
		overwritten = window[ callbackName ];

		// Insert callback into url or form data
		if ( replaceInUrl ) {
			s.url = url.replace( rjsonp, "$1" + callbackName );
		} else if ( replaceInData ) {
			s.data = data.replace( rjsonp, "$1" + callbackName );
		} else if ( hasCallback ) {
			s.url += ( rquestion.test( url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
		}

		// Use data converter to retrieve json after script execution
		s.converters["script json"] = function() {
			if ( !responseContainer ) {
				jQuery.error( callbackName + " was not called" );
			}
			return responseContainer[ 0 ];
		};

		// force json dataType
		s.dataTypes[ 0 ] = "json";

		// Install callback
		window[ callbackName ] = function() {
			responseContainer = arguments;
		};

		// Clean-up function (fires after converters)
		jqXHR.always(function() {
			// Restore preexisting value
			window[ callbackName ] = overwritten;

			// Save back as free
			if ( s[ callbackName ] ) {
				// make sure that re-using the options doesn't screw things around
				s.jsonpCallback = originalSettings.jsonpCallback;

				// save the callback name for future use
				oldCallbacks.push( callbackName );
			}

			// Call if it was a function and we have a response
			if ( responseContainer && jQuery.isFunction( overwritten ) ) {
				overwritten( responseContainer[ 0 ] );
			}

			responseContainer = overwritten = undefined;
		});

		// Delegate to script
		return "script";
	}
});
// Install script dataType
jQuery.ajaxSetup({
	accepts: {
		script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
	},
	contents: {
		script: /javascript|ecmascript/
	},
	converters: {
		"text script": function( text ) {
			jQuery.globalEval( text );
			return text;
		}
	}
});

// Handle cache's special case and global
jQuery.ajaxPrefilter( "script", function( s ) {
	if ( s.cache === undefined ) {
		s.cache = false;
	}
	if ( s.crossDomain ) {
		s.type = "GET";
		s.global = false;
	}
});

// Bind script tag hack transport
jQuery.ajaxTransport( "script", function(s) {

	// This transport only deals with cross domain requests
	if ( s.crossDomain ) {

		var script,
			head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;

		return {

			send: function( _, callback ) {

				script = document.createElement( "script" );

				script.async = "async";

				if ( s.scriptCharset ) {
					script.charset = s.scriptCharset;
				}

				script.src = s.url;

				// Attach handlers for all browsers
				script.onload = script.onreadystatechange = function( _, isAbort ) {

					if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {

						// Handle memory leak in IE
						script.onload = script.onreadystatechange = null;

						// Remove the script
						if ( head && script.parentNode ) {
							head.removeChild( script );
						}

						// Dereference the script
						script = undefined;

						// Callback if not abort
						if ( !isAbort ) {
							callback( 200, "success" );
						}
					}
				};
				// Use insertBefore instead of appendChild  to circumvent an IE6 bug.
				// This arises when a base node is used (#2709 and #4378).
				head.insertBefore( script, head.firstChild );
			},

			abort: function() {
				if ( script ) {
					script.onload( 0, 1 );
				}
			}
		};
	}
});
var xhrCallbacks,
	// #5280: Internet Explorer will keep connections alive if we don't abort on unload
	xhrOnUnloadAbort = window.ActiveXObject ? function() {
		// Abort all pending requests
		for ( var key in xhrCallbacks ) {
			xhrCallbacks[ key ]( 0, 1 );
		}
	} : false,
	xhrId = 0;

// Functions to create xhrs
function createStandardXHR() {
	try {
		return new window.XMLHttpRequest();
	} catch( e ) {}
}

function createActiveXHR() {
	try {
		return new window.ActiveXObject( "Microsoft.XMLHTTP" );
	} catch( e ) {}
}

// Create the request object
// (This is still attached to ajaxSettings for backward compatibility)
jQuery.ajaxSettings.xhr = window.ActiveXObject ?
	/* Microsoft failed to properly
	 * implement the XMLHttpRequest in IE7 (can't request local files),
	 * so we use the ActiveXObject when it is available
	 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
	 * we need a fallback.
	 */
	function() {
		return !this.isLocal && createStandardXHR() || createActiveXHR();
	} :
	// For all other browsers, use the standard XMLHttpRequest object
	createStandardXHR;

// Determine support properties
(function( xhr ) {
	jQuery.extend( jQuery.support, {
		ajax: !!xhr,
		cors: !!xhr && ( "withCredentials" in xhr )
	});
})( jQuery.ajaxSettings.xhr() );

// Create transport if the browser can provide an xhr
if ( jQuery.support.ajax ) {

	jQuery.ajaxTransport(function( s ) {
		// Cross domain only allowed if supported through XMLHttpRequest
		if ( !s.crossDomain || jQuery.support.cors ) {

			var callback;

			return {
				send: function( headers, complete ) {

					// Get a new xhr
					var handle, i,
						xhr = s.xhr();

					// Open the socket
					// Passing null username, generates a login popup on Opera (#2865)
					if ( s.username ) {
						xhr.open( s.type, s.url, s.async, s.username, s.password );
					} else {
						xhr.open( s.type, s.url, s.async );
					}

					// Apply custom fields if provided
					if ( s.xhrFields ) {
						for ( i in s.xhrFields ) {
							xhr[ i ] = s.xhrFields[ i ];
						}
					}

					// Override mime type if needed
					if ( s.mimeType && xhr.overrideMimeType ) {
						xhr.overrideMimeType( s.mimeType );
					}

					// X-Requested-With header
					// For cross-domain requests, seeing as conditions for a preflight are
					// akin to a jigsaw puzzle, we simply never set it to be sure.
					// (it can always be set on a per-request basis or even using ajaxSetup)
					// For same-domain requests, won't change header if already provided.
					if ( !s.crossDomain && !headers["X-Requested-With"] ) {
						headers[ "X-Requested-With" ] = "XMLHttpRequest";
					}

					// Need an extra try/catch for cross domain requests in Firefox 3
					try {
						for ( i in headers ) {
							xhr.setRequestHeader( i, headers[ i ] );
						}
					} catch( _ ) {}

					// Do send the request
					// This may raise an exception which is actually
					// handled in jQuery.ajax (so no try/catch here)
					xhr.send( ( s.hasContent && s.data ) || null );

					// Listener
					callback = function( _, isAbort ) {

						var status,
							statusText,
							responseHeaders,
							responses,
							xml;

						// Firefox throws exceptions when accessing properties
						// of an xhr when a network error occurred
						// http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
						try {

							// Was never called and is aborted or complete
							if ( callback && ( isAbort || xhr.readyState === 4 ) ) {

								// Only called once
								callback = undefined;

								// Do not keep as active anymore
								if ( handle ) {
									xhr.onreadystatechange = jQuery.noop;
									if ( xhrOnUnloadAbort ) {
										delete xhrCallbacks[ handle ];
									}
								}

								// If it's an abort
								if ( isAbort ) {
									// Abort it manually if needed
									if ( xhr.readyState !== 4 ) {
										xhr.abort();
									}
								} else {
									status = xhr.status;
									responseHeaders = xhr.getAllResponseHeaders();
									responses = {};
									xml = xhr.responseXML;

									// Construct response list
									if ( xml && xml.documentElement /* #4958 */ ) {
										responses.xml = xml;
									}

									// When requesting binary data, IE6-9 will throw an exception
									// on any attempt to access responseText (#11426)
									try {
										responses.text = xhr.responseText;
									} catch( e ) {
									}

									// Firefox throws an exception when accessing
									// statusText for faulty cross-domain requests
									try {
										statusText = xhr.statusText;
									} catch( e ) {
										// We normalize with Webkit giving an empty statusText
										statusText = "";
									}

									// Filter status for non standard behaviors

									// If the request is local and we have data: assume a success
									// (success with no data won't get notified, that's the best we
									// can do given current implementations)
									if ( !status && s.isLocal && !s.crossDomain ) {
										status = responses.text ? 200 : 404;
									// IE - #1450: sometimes returns 1223 when it should be 204
									} else if ( status === 1223 ) {
										status = 204;
									}
								}
							}
						} catch( firefoxAccessException ) {
							if ( !isAbort ) {
								complete( -1, firefoxAccessException );
							}
						}

						// Call complete if needed
						if ( responses ) {
							complete( status, statusText, responses, responseHeaders );
						}
					};

					if ( !s.async ) {
						// if we're in sync mode we fire the callback
						callback();
					} else if ( xhr.readyState === 4 ) {
						// (IE6 & IE7) if it's in cache and has been
						// retrieved directly we need to fire the callback
						setTimeout( callback, 0 );
					} else {
						handle = ++xhrId;
						if ( xhrOnUnloadAbort ) {
							// Create the active xhrs callbacks list if needed
							// and attach the unload handler
							if ( !xhrCallbacks ) {
								xhrCallbacks = {};
								jQuery( window ).unload( xhrOnUnloadAbort );
							}
							// Add to list of active xhrs callbacks
							xhrCallbacks[ handle ] = callback;
						}
						xhr.onreadystatechange = callback;
					}
				},

				abort: function() {
					if ( callback ) {
						callback(0,1);
					}
				}
			};
		}
	});
}
var fxNow, timerId,
	rfxtypes = /^(?:toggle|show|hide)$/,
	rfxnum = new RegExp( "^(?:([-+])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
	rrun = /queueHooks$/,
	animationPrefilters = [ defaultPrefilter ],
	tweeners = {
		"*": [function( prop, value ) {
			var end, unit,
				tween = this.createTween( prop, value ),
				parts = rfxnum.exec( value ),
				target = tween.cur(),
				start = +target || 0,
				scale = 1,
				maxIterations = 20;

			if ( parts ) {
				end = +parts[2];
				unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" );

				// We need to compute starting value
				if ( unit !== "px" && start ) {
					// Iteratively approximate from a nonzero starting point
					// Prefer the current property, because this process will be trivial if it uses the same units
					// Fallback to end or a simple constant
					start = jQuery.css( tween.elem, prop, true ) || end || 1;

					do {
						// If previous iteration zeroed out, double until we get *something*
						// Use a string for doubling factor so we don't accidentally see scale as unchanged below
						scale = scale || ".5";

						// Adjust and apply
						start = start / scale;
						jQuery.style( tween.elem, prop, start + unit );

					// Update scale, tolerating zero or NaN from tween.cur()
					// And breaking the loop if scale is unchanged or perfect, or if we've just had enough
					} while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
				}

				tween.unit = unit;
				tween.start = start;
				// If a +=/-= token was provided, we're doing a relative animation
				tween.end = parts[1] ? start + ( parts[1] + 1 ) * end : end;
			}
			return tween;
		}]
	};

// Animations created synchronously will run synchronously
function createFxNow() {
	setTimeout(function() {
		fxNow = undefined;
	}, 0 );
	return ( fxNow = jQuery.now() );
}

function createTweens( animation, props ) {
	jQuery.each( props, function( prop, value ) {
		var collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
			index = 0,
			length = collection.length;
		for ( ; index < length; index++ ) {
			if ( collection[ index ].call( animation, prop, value ) ) {

				// we're done with this property
				return;
			}
		}
	});
}

function Animation( elem, properties, options ) {
	var result,
		index = 0,
		tweenerIndex = 0,
		length = animationPrefilters.length,
		deferred = jQuery.Deferred().always( function() {
			// don't match elem in the :animated selector
			delete tick.elem;
		}),
		tick = function() {
			var currentTime = fxNow || createFxNow(),
				remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
				// archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
				temp = remaining / animation.duration || 0,
				percent = 1 - temp,
				index = 0,
				length = animation.tweens.length;

			for ( ; index < length ; index++ ) {
				animation.tweens[ index ].run( percent );
			}

			deferred.notifyWith( elem, [ animation, percent, remaining ]);

			if ( percent < 1 && length ) {
				return remaining;
			} else {
				deferred.resolveWith( elem, [ animation ] );
				return false;
			}
		},
		animation = deferred.promise({
			elem: elem,
			props: jQuery.extend( {}, properties ),
			opts: jQuery.extend( true, { specialEasing: {} }, options ),
			originalProperties: properties,
			originalOptions: options,
			startTime: fxNow || createFxNow(),
			duration: options.duration,
			tweens: [],
			createTween: function( prop, end, easing ) {
				var tween = jQuery.Tween( elem, animation.opts, prop, end,
						animation.opts.specialEasing[ prop ] || animation.opts.easing );
				animation.tweens.push( tween );
				return tween;
			},
			stop: function( gotoEnd ) {
				var index = 0,
					// if we are going to the end, we want to run all the tweens
					// otherwise we skip this part
					length = gotoEnd ? animation.tweens.length : 0;

				for ( ; index < length ; index++ ) {
					animation.tweens[ index ].run( 1 );
				}

				// resolve when we played the last frame
				// otherwise, reject
				if ( gotoEnd ) {
					deferred.resolveWith( elem, [ animation, gotoEnd ] );
				} else {
					deferred.rejectWith( elem, [ animation, gotoEnd ] );
				}
				return this;
			}
		}),
		props = animation.props;

	propFilter( props, animation.opts.specialEasing );

	for ( ; index < length ; index++ ) {
		result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
		if ( result ) {
			return result;
		}
	}

	createTweens( animation, props );

	if ( jQuery.isFunction( animation.opts.start ) ) {
		animation.opts.start.call( elem, animation );
	}

	jQuery.fx.timer(
		jQuery.extend( tick, {
			anim: animation,
			queue: animation.opts.queue,
			elem: elem
		})
	);

	// attach callbacks from options
	return animation.progress( animation.opts.progress )
		.done( animation.opts.done, animation.opts.complete )
		.fail( animation.opts.fail )
		.always( animation.opts.always );
}

function propFilter( props, specialEasing ) {
	var index, name, easing, value, hooks;

	// camelCase, specialEasing and expand cssHook pass
	for ( index in props ) {
		name = jQuery.camelCase( index );
		easing = specialEasing[ name ];
		value = props[ index ];
		if ( jQuery.isArray( value ) ) {
			easing = value[ 1 ];
			value = props[ index ] = value[ 0 ];
		}

		if ( index !== name ) {
			props[ name ] = value;
			delete props[ index ];
		}

		hooks = jQuery.cssHooks[ name ];
		if ( hooks && "expand" in hooks ) {
			value = hooks.expand( value );
			delete props[ name ];

			// not quite $.extend, this wont overwrite keys already present.
			// also - reusing 'index' from above because we have the correct "name"
			for ( index in value ) {
				if ( !( index in props ) ) {
					props[ index ] = value[ index ];
					specialEasing[ index ] = easing;
				}
			}
		} else {
			specialEasing[ name ] = easing;
		}
	}
}

jQuery.Animation = jQuery.extend( Animation, {

	tweener: function( props, callback ) {
		if ( jQuery.isFunction( props ) ) {
			callback = props;
			props = [ "*" ];
		} else {
			props = props.split(" ");
		}

		var prop,
			index = 0,
			length = props.length;

		for ( ; index < length ; index++ ) {
			prop = props[ index ];
			tweeners[ prop ] = tweeners[ prop ] || [];
			tweeners[ prop ].unshift( callback );
		}
	},

	prefilter: function( callback, prepend ) {
		if ( prepend ) {
			animationPrefilters.unshift( callback );
		} else {
			animationPrefilters.push( callback );
		}
	}
});

function defaultPrefilter( elem, props, opts ) {
	var index, prop, value, length, dataShow, toggle, tween, hooks, oldfire,
		anim = this,
		style = elem.style,
		orig = {},
		handled = [],
		hidden = elem.nodeType && isHidden( elem );

	// handle queue: false promises
	if ( !opts.queue ) {
		hooks = jQuery._queueHooks( elem, "fx" );
		if ( hooks.unqueued == null ) {
			hooks.unqueued = 0;
			oldfire = hooks.empty.fire;
			hooks.empty.fire = function() {
				if ( !hooks.unqueued ) {
					oldfire();
				}
			};
		}
		hooks.unqueued++;

		anim.always(function() {
			// doing this makes sure that the complete handler will be called
			// before this completes
			anim.always(function() {
				hooks.unqueued--;
				if ( !jQuery.queue( elem, "fx" ).length ) {
					hooks.empty.fire();
				}
			});
		});
	}

	// height/width overflow pass
	if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
		// Make sure that nothing sneaks out
		// Record all 3 overflow attributes because IE does not
		// change the overflow attribute when overflowX and
		// overflowY are set to the same value
		opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];

		// Set display property to inline-block for height/width
		// animations on inline elements that are having width/height animated
		if ( jQuery.css( elem, "display" ) === "inline" &&
				jQuery.css( elem, "float" ) === "none" ) {

			// inline-level elements accept inline-block;
			// block-level elements need to be inline with layout
			if ( !jQuery.support.inlineBlockNeedsLayout || css_defaultDisplay( elem.nodeName ) === "inline" ) {
				style.display = "inline-block";

			} else {
				style.zoom = 1;
			}
		}
	}

	if ( opts.overflow ) {
		style.overflow = "hidden";
		if ( !jQuery.support.shrinkWrapBlocks ) {
			anim.done(function() {
				style.overflow = opts.overflow[ 0 ];
				style.overflowX = opts.overflow[ 1 ];
				style.overflowY = opts.overflow[ 2 ];
			});
		}
	}


	// show/hide pass
	for ( index in props ) {
		value = props[ index ];
		if ( rfxtypes.exec( value ) ) {
			delete props[ index ];
			toggle = toggle || value === "toggle";
			if ( value === ( hidden ? "hide" : "show" ) ) {
				continue;
			}
			handled.push( index );
		}
	}

	length = handled.length;
	if ( length ) {
		dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} );
		if ( "hidden" in dataShow ) {
			hidden = dataShow.hidden;
		}

		// store state if its toggle - enables .stop().toggle() to "reverse"
		if ( toggle ) {
			dataShow.hidden = !hidden;
		}
		if ( hidden ) {
			jQuery( elem ).show();
		} else {
			anim.done(function() {
				jQuery( elem ).hide();
			});
		}
		anim.done(function() {
			var prop;
			jQuery.removeData( elem, "fxshow", true );
			for ( prop in orig ) {
				jQuery.style( elem, prop, orig[ prop ] );
			}
		});
		for ( index = 0 ; index < length ; index++ ) {
			prop = handled[ index ];
			tween = anim.createTween( prop, hidden ? dataShow[ prop ] : 0 );
			orig[ prop ] = dataShow[ prop ] || jQuery.style( elem, prop );

			if ( !( prop in dataShow ) ) {
				dataShow[ prop ] = tween.start;
				if ( hidden ) {
					tween.end = tween.start;
					tween.start = prop === "width" || prop === "height" ? 1 : 0;
				}
			}
		}
	}
}

function Tween( elem, options, prop, end, easing ) {
	return new Tween.prototype.init( elem, options, prop, end, easing );
}
jQuery.Tween = Tween;

Tween.prototype = {
	constructor: Tween,
	init: function( elem, options, prop, end, easing, unit ) {
		this.elem = elem;
		this.prop = prop;
		this.easing = easing || "swing";
		this.options = options;
		this.start = this.now = this.cur();
		this.end = end;
		this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
	},
	cur: function() {
		var hooks = Tween.propHooks[ this.prop ];

		return hooks && hooks.get ?
			hooks.get( this ) :
			Tween.propHooks._default.get( this );
	},
	run: function( percent ) {
		var eased,
			hooks = Tween.propHooks[ this.prop ];

		if ( this.options.duration ) {
			this.pos = eased = jQuery.easing[ this.easing ](
				percent, this.options.duration * percent, 0, 1, this.options.duration
			);
		} else {
			this.pos = eased = percent;
		}
		this.now = ( this.end - this.start ) * eased + this.start;

		if ( this.options.step ) {
			this.options.step.call( this.elem, this.now, this );
		}

		if ( hooks && hooks.set ) {
			hooks.set( this );
		} else {
			Tween.propHooks._default.set( this );
		}
		return this;
	}
};

Tween.prototype.init.prototype = Tween.prototype;

Tween.propHooks = {
	_default: {
		get: function( tween ) {
			var result;

			if ( tween.elem[ tween.prop ] != null &&
				(!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
				return tween.elem[ tween.prop ];
			}

			// passing any value as a 4th parameter to .css will automatically
			// attempt a parseFloat and fallback to a string if the parse fails
			// so, simple values such as "10px" are parsed to Float.
			// complex values such as "rotate(1rad)" are returned as is.
			result = jQuery.css( tween.elem, tween.prop, false, "" );
			// Empty strings, null, undefined and "auto" are converted to 0.
			return !result || result === "auto" ? 0 : result;
		},
		set: function( tween ) {
			// use step hook for back compat - use cssHook if its there - use .style if its
			// available and use plain properties where available
			if ( jQuery.fx.step[ tween.prop ] ) {
				jQuery.fx.step[ tween.prop ]( tween );
			} else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
				jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
			} else {
				tween.elem[ tween.prop ] = tween.now;
			}
		}
	}
};

// Remove in 2.0 - this supports IE8's panic based approach
// to setting things on disconnected nodes

Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
	set: function( tween ) {
		if ( tween.elem.nodeType && tween.elem.parentNode ) {
			tween.elem[ tween.prop ] = tween.now;
		}
	}
};

jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
	var cssFn = jQuery.fn[ name ];
	jQuery.fn[ name ] = function( speed, easing, callback ) {
		return speed == null || typeof speed === "boolean" ||
			// special check for .toggle( handler, handler, ... )
			( !i && jQuery.isFunction( speed ) && jQuery.isFunction( easing ) ) ?
			cssFn.apply( this, arguments ) :
			this.animate( genFx( name, true ), speed, easing, callback );
	};
});

jQuery.fn.extend({
	fadeTo: function( speed, to, easing, callback ) {

		// show any hidden elements after setting opacity to 0
		return this.filter( isHidden ).css( "opacity", 0 ).show()

			// animate to the value specified
			.end().animate({ opacity: to }, speed, easing, callback );
	},
	animate: function( prop, speed, easing, callback ) {
		var empty = jQuery.isEmptyObject( prop ),
			optall = jQuery.speed( speed, easing, callback ),
			doAnimation = function() {
				// Operate on a copy of prop so per-property easing won't be lost
				var anim = Animation( this, jQuery.extend( {}, prop ), optall );

				// Empty animations resolve immediately
				if ( empty ) {
					anim.stop( true );
				}
			};

		return empty || optall.queue === false ?
			this.each( doAnimation ) :
			this.queue( optall.queue, doAnimation );
	},
	stop: function( type, clearQueue, gotoEnd ) {
		var stopQueue = function( hooks ) {
			var stop = hooks.stop;
			delete hooks.stop;
			stop( gotoEnd );
		};

		if ( typeof type !== "string" ) {
			gotoEnd = clearQueue;
			clearQueue = type;
			type = undefined;
		}
		if ( clearQueue && type !== false ) {
			this.queue( type || "fx", [] );
		}

		return this.each(function() {
			var dequeue = true,
				index = type != null && type + "queueHooks",
				timers = jQuery.timers,
				data = jQuery._data( this );

			if ( index ) {
				if ( data[ index ] && data[ index ].stop ) {
					stopQueue( data[ index ] );
				}
			} else {
				for ( index in data ) {
					if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
						stopQueue( data[ index ] );
					}
				}
			}

			for ( index = timers.length; index--; ) {
				if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
					timers[ index ].anim.stop( gotoEnd );
					dequeue = false;
					timers.splice( index, 1 );
				}
			}

			// start the next in the queue if the last step wasn't forced
			// timers currently will call their complete callbacks, which will dequeue
			// but only if they were gotoEnd
			if ( dequeue || !gotoEnd ) {
				jQuery.dequeue( this, type );
			}
		});
	}
});

// Generate parameters to create a standard animation
function genFx( type, includeWidth ) {
	var which,
		attrs = { height: type },
		i = 0;

	// if we include width, step value is 1 to do all cssExpand values,
	// if we don't include width, step value is 2 to skip over Left and Right
	includeWidth = includeWidth? 1 : 0;
	for( ; i < 4 ; i += 2 - includeWidth ) {
		which = cssExpand[ i ];
		attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
	}

	if ( includeWidth ) {
		attrs.opacity = attrs.width = type;
	}

	return attrs;
}

// Generate shortcuts for custom animations
jQuery.each({
	slideDown: genFx("show"),
	slideUp: genFx("hide"),
	slideToggle: genFx("toggle"),
	fadeIn: { opacity: "show" },
	fadeOut: { opacity: "hide" },
	fadeToggle: { opacity: "toggle" }
}, function( name, props ) {
	jQuery.fn[ name ] = function( speed, easing, callback ) {
		return this.animate( props, speed, easing, callback );
	};
});

jQuery.speed = function( speed, easing, fn ) {
	var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
		complete: fn || !fn && easing ||
			jQuery.isFunction( speed ) && speed,
		duration: speed,
		easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
	};

	opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
		opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;

	// normalize opt.queue - true/undefined/null -> "fx"
	if ( opt.queue == null || opt.queue === true ) {
		opt.queue = "fx";
	}

	// Queueing
	opt.old = opt.complete;

	opt.complete = function() {
		if ( jQuery.isFunction( opt.old ) ) {
			opt.old.call( this );
		}

		if ( opt.queue ) {
			jQuery.dequeue( this, opt.queue );
		}
	};

	return opt;
};

jQuery.easing = {
	linear: function( p ) {
		return p;
	},
	swing: function( p ) {
		return 0.5 - Math.cos( p*Math.PI ) / 2;
	}
};

jQuery.timers = [];
jQuery.fx = Tween.prototype.init;
jQuery.fx.tick = function() {
	var timer,
		timers = jQuery.timers,
		i = 0;

	fxNow = jQuery.now();

	for ( ; i < timers.length; i++ ) {
		timer = timers[ i ];
		// Checks the timer has not already been removed
		if ( !timer() && timers[ i ] === timer ) {
			timers.splice( i--, 1 );
		}
	}

	if ( !timers.length ) {
		jQuery.fx.stop();
	}
	fxNow = undefined;
};

jQuery.fx.timer = function( timer ) {
	if ( timer() && jQuery.timers.push( timer ) && !timerId ) {
		timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
	}
};

jQuery.fx.interval = 13;

jQuery.fx.stop = function() {
	clearInterval( timerId );
	timerId = null;
};

jQuery.fx.speeds = {
	slow: 600,
	fast: 200,
	// Default speed
	_default: 400
};

// Back Compat <1.8 extension point
jQuery.fx.step = {};

if ( jQuery.expr && jQuery.expr.filters ) {
	jQuery.expr.filters.animated = function( elem ) {
		return jQuery.grep(jQuery.timers, function( fn ) {
			return elem === fn.elem;
		}).length;
	};
}
var rroot = /^(?:body|html)$/i;

jQuery.fn.offset = function( options ) {
	if ( arguments.length ) {
		return options === undefined ?
			this :
			this.each(function( i ) {
				jQuery.offset.setOffset( this, options, i );
			});
	}

	var docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft,
		box = { top: 0, left: 0 },
		elem = this[ 0 ],
		doc = elem && elem.ownerDocument;

	if ( !doc ) {
		return;
	}

	if ( (body = doc.body) === elem ) {
		return jQuery.offset.bodyOffset( elem );
	}

	docElem = doc.documentElement;

	// Make sure it's not a disconnected DOM node
	if ( !jQuery.contains( docElem, elem ) ) {
		return box;
	}

	// If we don't have gBCR, just use 0,0 rather than error
	// BlackBerry 5, iOS 3 (original iPhone)
	if ( typeof elem.getBoundingClientRect !== "undefined" ) {
		box = elem.getBoundingClientRect();
	}
	win = getWindow( doc );
	clientTop  = docElem.clientTop  || body.clientTop  || 0;
	clientLeft = docElem.clientLeft || body.clientLeft || 0;
	scrollTop  = win.pageYOffset || docElem.scrollTop;
	scrollLeft = win.pageXOffset || docElem.scrollLeft;
	return {
		top: box.top  + scrollTop  - clientTop,
		left: box.left + scrollLeft - clientLeft
	};
};

jQuery.offset = {

	bodyOffset: function( body ) {
		var top = body.offsetTop,
			left = body.offsetLeft;

		if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) {
			top  += parseFloat( jQuery.css(body, "marginTop") ) || 0;
			left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
		}

		return { top: top, left: left };
	},

	setOffset: function( elem, options, i ) {
		var position = jQuery.css( elem, "position" );

		// set position first, in-case top/left are set even on static elem
		if ( position === "static" ) {
			elem.style.position = "relative";
		}

		var curElem = jQuery( elem ),
			curOffset = curElem.offset(),
			curCSSTop = jQuery.css( elem, "top" ),
			curCSSLeft = jQuery.css( elem, "left" ),
			calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
			props = {}, curPosition = {}, curTop, curLeft;

		// need to be able to calculate position if either top or left is auto and position is either absolute or fixed
		if ( calculatePosition ) {
			curPosition = curElem.position();
			curTop = curPosition.top;
			curLeft = curPosition.left;
		} else {
			curTop = parseFloat( curCSSTop ) || 0;
			curLeft = parseFloat( curCSSLeft ) || 0;
		}

		if ( jQuery.isFunction( options ) ) {
			options = options.call( elem, i, curOffset );
		}

		if ( options.top != null ) {
			props.top = ( options.top - curOffset.top ) + curTop;
		}
		if ( options.left != null ) {
			props.left = ( options.left - curOffset.left ) + curLeft;
		}

		if ( "using" in options ) {
			options.using.call( elem, props );
		} else {
			curElem.css( props );
		}
	}
};


jQuery.fn.extend({

	position: function() {
		if ( !this[0] ) {
			return;
		}

		var elem = this[0],

		// Get *real* offsetParent
		offsetParent = this.offsetParent(),

		// Get correct offsets
		offset       = this.offset(),
		parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();

		// Subtract element margins
		// note: when an element has margin: auto the offsetLeft and marginLeft
		// are the same in Safari causing offset.left to incorrectly be 0
		offset.top  -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
		offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;

		// Add offsetParent borders
		parentOffset.top  += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
		parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;

		// Subtract the two offsets
		return {
			top:  offset.top  - parentOffset.top,
			left: offset.left - parentOffset.left
		};
	},

	offsetParent: function() {
		return this.map(function() {
			var offsetParent = this.offsetParent || document.body;
			while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
				offsetParent = offsetParent.offsetParent;
			}
			return offsetParent || document.body;
		});
	}
});


// Create scrollLeft and scrollTop methods
jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
	var top = /Y/.test( prop );

	jQuery.fn[ method ] = function( val ) {
		return jQuery.access( this, function( elem, method, val ) {
			var win = getWindow( elem );

			if ( val === undefined ) {
				return win ? (prop in win) ? win[ prop ] :
					win.document.documentElement[ method ] :
					elem[ method ];
			}

			if ( win ) {
				win.scrollTo(
					!top ? val : jQuery( win ).scrollLeft(),
					 top ? val : jQuery( win ).scrollTop()
				);

			} else {
				elem[ method ] = val;
			}
		}, method, val, arguments.length, null );
	};
});

function getWindow( elem ) {
	return jQuery.isWindow( elem ) ?
		elem :
		elem.nodeType === 9 ?
			elem.defaultView || elem.parentWindow :
			false;
}
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
	jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
		// margin is only for outerHeight, outerWidth
		jQuery.fn[ funcName ] = function( margin, value ) {
			var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
				extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );

			return jQuery.access( this, function( elem, type, value ) {
				var doc;

				if ( jQuery.isWindow( elem ) ) {
					// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
					// isn't a whole lot we can do. See pull request at this URL for discussion:
					// https://github.com/jquery/jquery/pull/764
					return elem.document.documentElement[ "client" + name ];
				}

				// Get document width or height
				if ( elem.nodeType === 9 ) {
					doc = elem.documentElement;

					// Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
					// unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
					return Math.max(
						elem.body[ "scroll" + name ], doc[ "scroll" + name ],
						elem.body[ "offset" + name ], doc[ "offset" + name ],
						doc[ "client" + name ]
					);
				}

				return value === undefined ?
					// Get width or height on the element, requesting but not forcing parseFloat
					jQuery.css( elem, type, value, extra ) :

					// Set width or height on the element
					jQuery.style( elem, type, value, extra );
			}, type, chainable ? margin : undefined, chainable, null );
		};
	});
});
// Expose jQuery to the global object
window.jQuery = window.$ = jQuery;

// Expose jQuery as an AMD module, but only for AMD loaders that
// understand the issues with loading multiple versions of jQuery
// in a page that all might call define(). The loader will indicate
// they have special allowances for multiple jQuery versions by
// specifying define.amd.jQuery = true. Register as a named module,
// since jQuery can be concatenated with other files that may use define,
// but not use a proper concatenation script that understands anonymous
// AMD modules. A named AMD is safest and most robust way to register.
// Lowercase jquery is used because AMD module names are derived from
// file names, and jQuery is normally delivered in a lowercase file name.
// Do this after creating the global so that if an AMD module wants to call
// noConflict to hide this version of jQuery, it will work.
if ( typeof define === "function" && define.amd && define.amd.jQuery ) {
	define( "jquery", [], function () { return jQuery; } );
}

})( window );
var HazmatBuilder = function(_,root) {
  // Actual Hazmat Code
  // top level module
  var Hazmat  = function(config) {
    this.config = config || {};
    if(!_.isObject(this.config)) {
      throw new Error('Hazmat is not initialized properly');
    }
    this.fail = _.isFunction(this.config.fail) ? this.config.fail : Hazmat.fail;
    this.warn = _.isFunction(this.config.warn) ? this.config.warn : Hazmat.warn;
    this.log = _.isFunction(this.config.log) ? this.config.log : Hazmat.log;
  };

  _.extend(Hazmat, {

    // constants
    ID_REGEX : /^[\_\-A-Za-z0-9]+$/,

    // factory
    create : function(config) {
      return new Hazmat(config);
    },

    // noConflict
    noConflict : function() {
      root.Hazmat = Hazmat.original;
      return Hazmat;
    },

    // default log function
    log : function() {
      if(window.console && _.isFunction(window.console.log)) {
        window.console.log.apply(window.console, arguments);
      }
    },

    // default fail function
    fail : function(_reason, _data) {
      var reason = _reason || "", data = _data || {};
      Hazmat.log('Hazmat Failure::', reason, data);
      throw new Error('Hazmat Failure '+reason.toString());
    },

    // default warn function
    warn : function(_reason, _data) {
      var reason = _reason || "", data = _data || {};
      Hazmat.log('Hazmat Warning::', reason, data);
    },

    // global fixers
    fixDomId : function(_value) {
      if(_.isString(_value) && _value.length > 0) {
        return _value.replace(/[^A-Za-z0-9\_]/g,'');
      } else {
        return null;
      }
    },

    // global testers
    isDomId : function(value) {
      return _.isString(value) && value.match(Hazmat.ID_REGEX);
    },


    __placeholder : true
  });

  _.extend(Hazmat.prototype, {
    _safeValue : function(name, value, fallback, type) {
      // make fallback safe and eat exceptions
      var _fallback = fallback;
      if(_.isFunction(fallback)) {
        fallback = _.once(function() {
          try {
            return _fallback.apply(this, arguments);
          } catch(e) {
          }
        });
      }

      if(type.checker(value)) {
        return value;
      } else if(type.evalFallback && _.isFunction(fallback) && type.checker(fallback(value))){
        this.warn('Expected valid '+type.name+' for '+name+' but was able to sanitize it:', [value, fallback(value)]);
        return fallback(value);
      } else if(type.checker(_fallback)){
        this.warn('Expected valid '+type.name+' for '+name+' but was able to fallback to default value:', [value, _fallback]);
        return _fallback;
      } else {
        this.fail('Expected valid '+type.name+' for '+name+' but received:', value);
      }
    },

    safeString : function(name, value, fallback) {
      return this._safeValue(name, value, fallback, {name: 'String', checker: _.isString, evalFallback:true});
    },

    safeStringOrNull : function(name, value, fallback) {
      if(value == null) {
        return value;
      } else {
        return this._safeValue(name, value, fallback, {name: 'String', checker: _.isString, evalFallback:true});
      }
    },

    safeDomId : function(name, value, fallback) {
      return this._safeValue(name, value, fallback, {name: 'DOM ID', checker: Hazmat.isDomId, evalFallback:true});
    },

    safeFunction : function(name, value, fallback) {
      return this._safeValue(name, value, fallback, {name: 'Function', checker: _.isFunction, evalFallback:false});
    },

    safeFunctionOrNull : function(name, value, fallback) {
      if(value == null) {
        return value;
      } else {
        return this._safeValue(name, value, fallback, {name: 'Function', checker: _.isFunction, evalFallback:false});
      }
    },

    safeObject : function(name, value, fallback) {
      return this._safeValue(name, value, fallback, {name: 'Object', checker: _.isObject, evalFallback:false});
    },

    safeObjectOrNull : function(name, value, fallback) {
      if(value == null) {
        return value;
      } else {
        return this._safeValue(name, value, fallback, {name: 'Object', checker: _.isObject, evalFallback:false});
      }
    },
    
    safeArray : function(name, value, fallback) {
      return this._safeValue(name, value, fallback, {name: 'Array', checker: _.isArray, evalFallback:false});
    },
    
    safeArrayOfElements : function(name, value, elementValidator, fallback) {
      var safeArray = this._safeValue(name, value, fallback, {name: 'Array', checker: _.isArray, evalFallback:false});
      return _.map(safeArray, elementValidator);
    },

    __placeholder:true
  });

  return Hazmat;
};

// Integration with Node.js/Browser
if(typeof window !== 'undefined' && typeof window._ !== 'undefined') {
  var hazmat = HazmatBuilder(window._, window);
  hazmat.original = window.Hazmat;
  window.Hazmat = hazmat;
} else {
  var _ = require('underscore');
  var hazmat = HazmatBuilder(_);
  _.extend(exports,hazmat);
}
/*!  SWFObject v2.2 <http://code.google.com/p/swfobject/>
  is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject = function() {
  // NOTE[jigish]: this has been trimmed down significantly. The original version uses onDomLoad to embed an
  // object on the page and test the version that way. the "ua" function below is actually a fallback but it
  // seems to work just fine and is a *lot* smaller so we're using it instead.

  var UNDEF = "undefined",
    OBJECT = "object",
    SHOCKWAVE_FLASH = "Shockwave Flash",
    SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
    FLASH_MIME_TYPE = "application/x-shockwave-flash",

    win = window,
    doc = document,
    nav = navigator,

  /* Centralized function for browser feature detection
    - User agent string detection is only used when no good alternative is possible
    - Is executed directly for optimal performance
  */
  ua = function() {
    var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF &&
                 typeof doc.createElement != UNDEF,
      u = nav.userAgent.toLowerCase(),
      p = nav.platform.toLowerCase(),
      windows = p ? /win/.test(p) : /win/.test(u),
      mac = p ? /mac/.test(p) : /mac/.test(u),
      webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) :
                                  false, // returns either the webkit version or false if not webkit
      ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution:
                    // http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html
      playerVersion = [0,0,0],
      d = null;
    if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
      d = nav.plugins[SHOCKWAVE_FLASH].description;
      // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are
      // enabled or disabled in Safari 3+
      if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] &&
                 !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) {
        ie = false; // cascaded feature detection for Internet Explorer
        d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
        playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
        playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
        playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
      }
    }
    else if (typeof win.ActiveXObject != UNDEF) {
      try {
        var a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
        if (a) { // a will return null when ActiveX is disabled
          d = a.GetVariable("$version");
          if (d) {
            ie = true; // cascaded feature detection for Internet Explorer
            d = d.split(" ")[1].split(",");
            playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
          }
        }
      }
      catch(e) {}
    }
    return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac };
  }();

  function hasPlayerVersion(rv) {
    var pv = ua.pv, v = rv.split(".");
    v[0] = parseInt(v[0], 10);
    v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0"
    v[2] = parseInt(v[2], 10) || 0;
    return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) ||
            (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
  }

  return {
    ua: ua,

    getFlashPlayerVersion: function() {
      return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
    },

    hasFlashPlayerVersion: hasPlayerVersion
  };
}();
/* A JavaScript implementation of the SHA family of hashes, as defined in FIPS
 * PUB 180-2 as well as the corresponding HMAC implementation as defined in
 * FIPS PUB 198a
 *
 * Version 1.31 Copyright Brian Turek 2008-2012
 * Distributed under the BSD License
 * See http://caligatio.github.com/jsSHA/ for more information
 *
 * Several functions taken from Paul Johnson
 */
(function ()
{
	var charSize = 8,
	b64pad = "",
	hexCase = 0,

	str2binb = function (str)
	{
		var bin = [], mask = (1 << charSize) - 1,
			length = str.length * charSize, i;

		for (i = 0; i < length; i += charSize)
		{
			bin[i >> 5] |= (str.charCodeAt(i / charSize) & mask) <<
				(32 - charSize - (i % 32));
		}

		return bin;
	},

	hex2binb = function (str)
	{
		var bin = [], length = str.length, i, num;

		for (i = 0; i < length; i += 2)
		{
			num = parseInt(str.substr(i, 2), 16);
			if (!isNaN(num))
			{
				bin[i >> 3] |= num << (24 - (4 * (i % 8)));
			}
			else
			{
				return "INVALID HEX STRING";
			}
		}

		return bin;
	},

	binb2hex = function (binarray)
	{
		var hex_tab = (hexCase) ? "0123456789ABCDEF" : "0123456789abcdef",
			str = "", length = binarray.length * 4, i, srcByte;

		for (i = 0; i < length; i += 1)
		{
			srcByte = binarray[i >> 2] >> ((3 - (i % 4)) * 8);
			str += hex_tab.charAt((srcByte >> 4) & 0xF) +
				hex_tab.charAt(srcByte & 0xF);
		}

		return str;
	},

	binb2b64 = function (binarray)
	{
		var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" +
			"0123456789+/", str = "", length = binarray.length * 4, i, j,
			triplet;

		for (i = 0; i < length; i += 3)
		{
			triplet = (((binarray[i >> 2] >> 8 * (3 - i % 4)) & 0xFF) << 16) |
				(((binarray[i + 1 >> 2] >> 8 * (3 - (i + 1) % 4)) & 0xFF) << 8) |
				((binarray[i + 2 >> 2] >> 8 * (3 - (i + 2) % 4)) & 0xFF);
			for (j = 0; j < 4; j += 1)
			{
				if (i * 8 + j * 6 <= binarray.length * 32)
				{
					str += tab.charAt((triplet >> 6 * (3 - j)) & 0x3F);
				}
				else
				{
					str += b64pad;
				}
			}
		}
		return str;
	},

	rotr = function (x, n)
	{
		return (x >>> n) | (x << (32 - n));
	},

	shr = function (x, n)
	{
		return x >>> n;
	},

	ch = function (x, y, z)
	{
		return (x & y) ^ (~x & z);
	},

	maj = function (x, y, z)
	{
		return (x & y) ^ (x & z) ^ (y & z);
	},

	sigma0 = function (x)
	{
		return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
	},

	sigma1 = function (x)
	{
		return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
	},

	gamma0 = function (x)
	{
		return rotr(x, 7) ^ rotr(x, 18) ^ shr(x, 3);
	},

	gamma1 = function (x)
	{
		return rotr(x, 17) ^ rotr(x, 19) ^ shr(x, 10);
	},

	safeAdd_2 = function (x, y)
	{
		var lsw = (x & 0xFFFF) + (y & 0xFFFF),
			msw = (x >>> 16) + (y >>> 16) + (lsw >>> 16);

		return ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
	},

	safeAdd_4 = function (a, b, c, d)
	{
		var lsw = (a & 0xFFFF) + (b & 0xFFFF) + (c & 0xFFFF) + (d & 0xFFFF),
			msw = (a >>> 16) + (b >>> 16) + (c >>> 16) + (d >>> 16) +
				(lsw >>> 16);

		return ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
	},

	safeAdd_5 = function (a, b, c, d, e)
	{
		var lsw = (a & 0xFFFF) + (b & 0xFFFF) + (c & 0xFFFF) + (d & 0xFFFF) +
				(e & 0xFFFF),
			msw = (a >>> 16) + (b >>> 16) + (c >>> 16) + (d >>> 16) +
				(e >>> 16) + (lsw >>> 16);

		return ((msw & 0xFFFF) << 16) | (lsw & 0xFFFF);
	},

	coreSHA2 = function (message, messageLen, variant)
	{
		var a, b, c, d, e, f, g, h, T1, T2, H, lengthPosition, i, t, K, W = [],
			appendedMessageLength;

		if (variant === "SHA-224" || variant === "SHA-256")
		{
			lengthPosition = (((messageLen + 65) >> 9) << 4) + 15;
			K = [
					0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
					0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
					0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
					0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
					0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
					0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
					0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
					0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
					0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
					0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
					0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
					0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
					0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
					0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
					0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
					0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2
				];

			if (variant === "SHA-224")
			{
				H = [
						0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
						0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
					];
			}
			else
			{
				H = [
						0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A,
						0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19
					];
			}
		}

		message[messageLen >> 5] |= 0x80 << (24 - messageLen % 32);
		message[lengthPosition] = messageLen;

		appendedMessageLength = message.length;

		for (i = 0; i < appendedMessageLength; i += 16)
		{
			a = H[0];
			b = H[1];
			c = H[2];
			d = H[3];
			e = H[4];
			f = H[5];
			g = H[6];
			h = H[7];

			for (t = 0; t < 64; t += 1)
			{
				if (t < 16)
				{
					W[t] = message[t + i];
				}
				else
				{
					W[t] = safeAdd_4(
							gamma1(W[t - 2]), W[t - 7],
							gamma0(W[t - 15]), W[t - 16]
						);
				}

				T1 = safeAdd_5(h, sigma1(e), ch(e, f, g), K[t], W[t]);
				T2 = safeAdd_2(sigma0(a), maj(a, b, c));
				h = g;
				g = f;
				f = e;
				e = safeAdd_2(d, T1);
				d = c;
				c = b;
				b = a;
				a = safeAdd_2(T1, T2);
			}

			H[0] = safeAdd_2(a, H[0]);
			H[1] = safeAdd_2(b, H[1]);
			H[2] = safeAdd_2(c, H[2]);
			H[3] = safeAdd_2(d, H[3]);
			H[4] = safeAdd_2(e, H[4]);
			H[5] = safeAdd_2(f, H[5]);
			H[6] = safeAdd_2(g, H[6]);
			H[7] = safeAdd_2(h, H[7]);
		}

		switch (variant)
		{
		case "SHA-224":
			return [
				H[0], H[1], H[2], H[3],
				H[4], H[5], H[6]
			];
		case "SHA-256":
			return H;
		default:
			return [];
		}
	},

	jsSHA = function (srcString, inputFormat)
	{

		this.sha224 = null;
		this.sha256 = null;

		this.strBinLen = null;
		this.strToHash = null;

		if ("HEX" === inputFormat)
		{
			if (0 !== (srcString.length % 2))
			{
				return "TEXT MUST BE IN BYTE INCREMENTS";
			}
			this.strBinLen = srcString.length * 4;
			this.strToHash = hex2binb(srcString);
		}
		else if (("ASCII" === inputFormat) ||
			 ('undefined' === typeof(inputFormat)))
		{
			this.strBinLen = srcString.length * charSize;
			this.strToHash = str2binb(srcString);
		}
		else
		{
			return "UNKNOWN TEXT INPUT TYPE";
		}
	};

	jsSHA.prototype = {
		getHash : function (variant, format)
		{
			var formatFunc = null, message = this.strToHash.slice();

			switch (format)
			{
			case "HEX":
				formatFunc = binb2hex;
				break;
			case "B64":
				formatFunc = binb2b64;
				break;
			default:
				return "FORMAT NOT RECOGNIZED";
			}

			switch (variant)
			{
			case "SHA-224":
				if (null === this.sha224)
				{
					this.sha224 = coreSHA2(message, this.strBinLen, variant);
				}
				return formatFunc(this.sha224);
			case "SHA-256":
				if (null === this.sha256)
				{
					this.sha256 = coreSHA2(message, this.strBinLen, variant);
				}
				return formatFunc(this.sha256);
			default:
				return "HASH NOT RECOGNIZED";
			}
		},

		getHMAC : function (key, inputFormat, variant, outputFormat)
		{
			var formatFunc, keyToUse, i, retVal, keyBinLen, hashBitSize,
				keyWithIPad = [], keyWithOPad = [];

			switch (outputFormat)
			{
			case "HEX":
				formatFunc = binb2hex;
				break;
			case "B64":
				formatFunc = binb2b64;
				break;
			default:
				return "FORMAT NOT RECOGNIZED";
			}

			switch (variant)
			{
			case "SHA-224":
				hashBitSize = 224;
				break;
			case "SHA-256":
				hashBitSize = 256;
				break;
			default:
				return "HASH NOT RECOGNIZED";
			}

			if ("HEX" === inputFormat)
			{
				if (0 !== (key.length % 2))
				{
					return "KEY MUST BE IN BYTE INCREMENTS";
				}
				keyToUse = hex2binb(key);
				keyBinLen = key.length * 4;
			}
			else if ("ASCII" === inputFormat)
			{
				keyToUse = str2binb(key);
				keyBinLen = key.length * charSize;
			}
			else
			{
				return "UNKNOWN KEY INPUT TYPE";
			}

			if (64 < (keyBinLen / 8))
			{
				keyToUse = coreSHA2(keyToUse, keyBinLen, variant);
				keyToUse[15] &= 0xFFFFFF00;
			}
			else if (64 > (keyBinLen / 8))
			{
				keyToUse[15] &= 0xFFFFFF00;
			}

			for (i = 0; i <= 15; i += 1)
			{
				keyWithIPad[i] = keyToUse[i] ^ 0x36363636;
				keyWithOPad[i] = keyToUse[i] ^ 0x5C5C5C5C;
			}

			retVal = coreSHA2(
						keyWithIPad.concat(this.strToHash),
						512 + this.strBinLen, variant);
			retVal = coreSHA2(
						keyWithOPad.concat(retVal),
						512 + hashBitSize, variant);

			return (formatFunc(retVal));
		}
	};

	window.jsSHA = jsSHA;
}());
window.LZW = {
  // LZW-compress a string
  encode: function (s) {
      var dict = {};
      var data = (s + "").split("");
      var out = [];
      var currChar;
      var phrase = data[0];
      var code = 256;
      for (var i=1; i<data.length; i++) {
          currChar=data[i];
          if (dict[phrase + currChar] != null) {
              phrase += currChar;
          }
          else {
              out.push(phrase.length > 1 ? dict[phrase] : phrase.charCodeAt(0));
              dict[phrase + currChar] = code;
              code++;
              phrase=currChar;
          }
      }
      out.push(phrase.length > 1 ? dict[phrase] : phrase.charCodeAt(0));
      for (var i=0; i<out.length; i++) {
          out[i] = String.fromCharCode(out[i]);
      }
      return out.join("");
  },

  // Decompress an LZW-encoded string
  decode: function (s) {
      var dict = {};
      var data = (s + "").split("");
      var currChar = data[0];
      var oldPhrase = currChar;
      var out = [currChar];
      var code = 256;
      var phrase;
      for (var i=1; i<data.length; i++) {
          var currCode = data[i].charCodeAt(0);
          if (currCode < 256) {
              phrase = data[i];
          }
          else {
             phrase = dict[currCode] ? dict[currCode] : (oldPhrase + currChar);
          }
          out.push(phrase);
          currChar = phrase.charAt(0);
          dict[code] = oldPhrase + currChar;
          code++;
          oldPhrase = phrase;
      }
      return out.join("");
  }

};  (function(OO) {
    // Resolve all 3rd parties conflicts
    // Beyond this point we can use OO._ for underscore and OO.$ for zepto
    OO._ = window._.noConflict();
    OO.$ = window.$.noConflict(true);

    OO.HM = window.Hazmat.noConflict().create();

    OO.swfobject = swfobject;

    OO.jsSHA = window.jsSHA;

    OO.LZW = window.LZW;

    if(!window.console || !window.console.log) {
      window.console = window.console || {};
      window.console.log = function() {};
    }

  }(OO));
  (function(OO,_,HM) {
    // Ensure playerParams exists
    OO.playerParams = HM.safeObject('environment.playerParams', OO.playerParams,{});
    OO.playerParams.platform = HM.safeString('environment.playerParams.platform', OO.playerParams.platform,'flash');

    // process tweaks
    // tweaks is optional. Hazmat takes care of this but throws an undesirable warning.
    OO.playerParams.tweaks = OO.playerParams.tweaks || '';
    OO.playerParams.tweaks = HM.safeString('environment.playerParams.tweaks', OO.playerParams.tweaks,'');
    OO.playerParams.tweaks = OO.playerParams.tweaks.split(',');

    // explicit list of supported tweaks
    OO.tweaks = {};
    OO.tweaks["android-enable-hls"] = _.contains(OO.playerParams.tweaks, 'android-enable-hls');
    OO.tweaks["html5-force-mp4"] = _.contains(OO.playerParams.tweaks, 'html5-force-mp4');

    // Max timeout for fetching ads metadata, default to 3 seconds.
    OO.playerParams.maxAdsTimeout = OO.playerParams.maxAdsTimeout || 5;
    // max wrapper ads depth we look, we will only look up to 3 level until we get vast inline ads
    OO.playerParams.maxVastWrapperDepth = OO.playerParams.maxVastWrapperDepth || 3;
    OO.playerParams.minLiveSeekWindow = OO.playerParams.minLiveSeekWindow || 10;

    // Ripped from: http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
    OO.guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
      var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
      return v.toString(16);
    });
    OO.playerCount = 0;

    // Check environment to see if this is prod
    OO.isProd = OO.playerParams.environment &&
                OO.playerParams.environment.match(/^prod/i);

    // Environment invariant.
    OO.platform = window.navigator.platform;
    OO.os = window.navigator.appVersion;
    OO.supportsVideo = !!document.createElement('video').canPlayType;
    OO.supportsFlash = OO.swfobject && OO.swfobject.getFlashPlayerVersion && OO.swfobject.getFlashPlayerVersion().major >= 10 && !OO.os.match(/Android/);

    OO.browserSupportsCors = (function() {
      try {
        return _.has(new XMLHttpRequest(), "withCredentials") ||
          _.has(XMLHttpRequest.prototype, "withCredentials");
      } catch(e) {
        return false;
      }
    }());

    OO.isIos = (function() {
      return OO.platform.match(/iPhone/) || OO.platform.match(/iPad/) || OO.platform.match(/iPod/);
    }());

    OO.isIphone = (function() {
      return OO.platform.match(/iPhone/) || OO.platform.match(/iPod/);
    }());

    OO.isIpad = (function() {
      return OO.platform.match(/iPad/);
    }());

    OO.iosMajorVersion = (function() {
      try {
        if (window.navigator.userAgent.match(/(iPad|iPhone|iPod)/)) {
          return parseInt(window.navigator.userAgent.match(/OS (\d+)/)[1], 10);
        } else {
          return null;
        }
      } catch(err) {
        return null;
      }
    }());

    OO.isAndroid = (function() {
      return OO.os.match(/Android/);
    }());

    OO.isAndroid4Plus = (function() {
      return OO.isAndroid && !OO.os.match(/Android [23]/);
    }());

    OO.isRimDevice = (function() {
      return OO.os.match(/BlackBerry/) ||  OO.os.match(/PlayBook/);
    }());

    OO.isFirefox = (function() {
      return !!window.navigator.userAgent.match(/Firefox/);
    }());

    OO.isChrome = (function () {
      return !!window.navigator.userAgent.match(/Chrome/);
    }());

    OO.chromeMajorVersion = (function () {
      try {
        return parseInt(window.navigator.userAgent.match(/Chrome.([0-9]*)/)[1], 10);
      } catch(err) {
        return null;
      }
    }());

    OO.isChromecast = (function() {
      return !!window.navigator.userAgent.match(/CrKey/);
    }());

    OO.isIE = (function(){
      return !!window.navigator.userAgent.match(/MSIE/) || !!window.navigator.userAgent.match(/Trident/);
    }());

    OO.isIE11Plus = (function(){
      // check if IE
      if (!window.navigator.userAgent.match(/Trident/)) {
        return false;
      }

      // extract version number
      var ieVersionMatch = window.navigator.userAgent.match(/rv:(\d*)/);
      var ieVersion = ieVersionMatch && ieVersionMatch[1];
      return ieVersion >= 11;
    }());

    OO.isWinPhone = (function(){
      return !!OO.os.match(/Windows Phone/) || !!OO.os.match(/ZuneWP/) || !!OO.os.match(/XBLWP/);
    }());

    OO.isSmartTV = (function(){
      return (!!window.navigator.userAgent.match(/SmartTV/) ||
             !!window.navigator.userAgent.match(/NetCast/));
    }());

    OO.isMacOs = (function() {
      return !OO.isIos && !!OO.os.match(/Mac/);
    }());

    OO.isMacOsLionOrLater = (function() {
      // TODO: revisit for Firefox when possible/necessary
      var macOs = OO.os.match(/Mac OS X ([0-9]+)_([0-9]+)/);
      if (macOs == null || macOs.length < 3) { return false; }
      return (parseInt(macOs[1],10) >= 10 && parseInt(macOs[2],10) >= 7);
    }());

    OO.isKindleHD = (function(){
      return !!OO.os.match(/Silk\/2/);
    }());

    OO.supportAds = (function() {
      // We are disabling ads for Android 2/3 device, the reason is that main video is not resuming after
      // ads finish. Util we can figure out a work around, we will keep ads disabled.
      return !OO.isWinPhone && !OO.os.match(/Android [23]/);
    }());

    OO.allowGesture = (function() {
      return OO.isIos;
    }());

    OO.allowAutoPlay = (function() {
      return !OO.isIos && !OO.isAndroid;
    }());

    OO.supportTouch = (function() {
      // IE8- doesn't support JS functions on DOM elements
      if (document.documentElement.hasOwnProperty && document.documentElement.hasOwnProperty("ontouchstart")) { return true; }
      return false;
    }());

    OO.docDomain = (function() {
      var domain = null;
      try {
        domain = document.domain;
      } catch(e) {}
      if (!OO._.isEmpty(domain)) { return domain; }
      if (OO.isSmartTV) { return 'SmartTV'; }
      return 'unknown';
    }());

    OO.uiParadigm = (function() {
      var paradigm = 'tablet';

      // The below code attempts to decide whether or not we are running in 'mobile' mode
      // Meaning that no controls are displayed, chrome is minimized and only fullscreen playback is allowed
      // Unfortunately there is no clean way to figure out whether the device is tablet or phone
      // or even to properly detect device screen size http://tripleodeon.com/2011/12/first-understand-your-screen/
      // So there is a bunch of heuristics for doing just that
      // Anything that is not explicitly detected as mobile defaults to desktop
      // so worst case they get ugly chrome instead of unworking player
      if (OO.playerParams.platform === 'html5-nativeui') {
        paradigm = 'mobile-native';
      } else if(OO.isAndroid4Plus && OO.tweaks["android-enable-hls"]) {
        // special case for Android 4+ running HLS
        paradigm = 'tablet';
      } else if(OO.isIphone) {
        paradigm = 'mobile-native';
      } else if(OO.os.match(/BlackBerry/)) {
        paradigm = 'mobile-native';
      } else if(OO.os.match(/iPad/)) {
        paradigm = 'tablet';
      } else if(OO.isKindleHD) {
        // Kindle Fire HD
        paradigm = 'mobile-native';
      } else if(OO.os.match(/Silk/)) {
        // Kindle Fire
        paradigm = 'mobile';
      } else if(OO.os.match(/Android 2/)) {
        // On Android 2+ only window.outerWidth is reliable, so we are using that and window.orientation
        if((window.orientation % 180) == 0 &&  (window.outerWidth / window.devicePixelRatio) <= 480 ) {
          // portrait mode
          paradigm = 'mobile';
        } else if((window.outerWidth / window.devicePixelRatio) <= 560 ) {
          // landscape mode
          paradigm = 'mobile';
        }
      } else if(OO.os.match(/Android/)) {
          paradigm = 'tablet';
      } else if (OO.isWinPhone) {
        // Windows Phone is mobile only for now, tablets not yet released
        paradigm = 'mobile';
      } else if(!!OO.platform.match(/Mac/)    // Macs
                || !!OO.platform.match(/Win/)  // Winboxes
                || !!OO.platform.match(/Linux/)) {    // Linux
        paradigm = 'desktop';
      }

      return paradigm;
    }());

    OO.supportMultiVideo = (function() {
      // short cut for Android non-chrome browser.
      if (OO.isAndroid && !OO.isChrome) { return false; }
      return !OO.isIos && !OO.os.match(/Android [23]/);
    }());

    OO.supportedVideoTypes = (function() {
      // tweak to force MP4 playback
      if (!!OO.tweaks["html5-force-mp4"]) {
        return { mp4:true };
      }

      // Sony OperaTV based supports HLS but doesn't properly report it so we are forcing it here
      if(window.navigator.userAgent.match(/SonyCEBrowser/)) {
        return { m3u8:true };
      }

      // The android is a special case because of it's crappy HLS support
      if(!!OO.isAndroid) {
        if (OO.tweaks["android-enable-hls"] && OO.isAndroid4Plus) {
          return { m3u8:true, mp4:true }; // Allow HLS despite our best intentions (PBK-125)
        }
        return { mp4:true };
      }

      // (PBW-1969) Special case since Windows user-agent includes 'like iPhone'
      if (!!OO.isWinPhone) {
        return { mp4:true };
      }

      // Smart TV hack, neither Samsung/LG plays hls correctly for their 2012 models.
      if (OO.isSmartTV) {
        return { mp4:true };
      }

      if (OO.isChromecast) {
        return { smooth:true };
      }

      var video = document.createElement('video');
      if (typeof video.canPlayType !== "function") {
        return {};
      }
      return {
        m3u8: (!!video.canPlayType("application/vnd.apple.mpegurl") ||
               !!video.canPlayType("application/x-mpegURL")) &&
               !OO.isRimDevice && (!OO.isMacOs || OO.isMacOsLionOrLater),
        mp4: !!video.canPlayType("video/mp4"),
        webm: !!video.canPlayType("video/webm")
      };
    }());

    // TODO(jj): need to make this more comprehensive
    // Note(jj): only applies to mp4 videos for now
    OO.supportedVideoProfiles = (function() {
      // iOS only supports baseline profile
      if (OO.isIos || OO.isAndroid) {
        return "baseline";
      }
      return null;
    }());

    // TODO(bz): add flash for device when we decide to use stream data from sas
    // TODO(jj): add AppleTV and other devices as necessary
    OO.device = (function() {
        var device = 'html5';
        if (OO.isIphone) { device = 'iphone-html5'; }
        else if (OO.isIpad) { device = 'ipad-html5'; }
        else if (OO.isAndroid) { device = 'android-html5'; }
        else if (OO.isRimDevice) { device = 'rim-html5'; }
        else if (OO.isWinPhone) { device = 'winphone-html5'; }
        else if (OO.isSmartTV) { device = 'smarttv-html5'; }
        else if (OO.isChromecast) { device = 'generic'; }
        return device;
    }());

    // list of environment-specific modules needed by the environment or empty to include all
    // Note: should never be empty because of flash/html5
    OO.environmentRequiredFeatures = (function(){
      var features = [];

      // HTML5 video not supported, flash it is
      if (!OO.supportsVideo) {
        features.push('flash-playback');
        features.push('flash-ui');
      // enable flash in 'flash-only' and in 'flash-adset'
      } else if (OO.playerParams.platform === 'flash-only' || OO.playerParams.platform === "flash-adset") {
        features.push('flash-playback');
        features.push('flash-ui');
      // either desktop mode detected or flash supported in 'flash' mode
      } else if ( (OO.supportsFlash || OO.uiParadigm == 'desktop') && OO.playerParams.platform === 'flash' ) {
        features.push('flash-playback');
        features.push('flash-ui');
      // if flash supported and in 'flash-priority' mode
      } else if ( OO.supportsFlash && _.indexOf(['flash-priority', 'html5-fallback'], OO.playerParams.platform) !== -1 ) {
        features.push('flash-playback');
        features.push('flash-ui');
      // if FF detected, and it doesn't support MP4 playback
      } else if ( OO.isFirefox && !OO.supportedVideoTypes.mp4) {
        features.push('flash-playback');
        features.push('flash-ui');
      } else if(OO.os.match(/Android 2/)) {  // safari android
        features.push('android-ui');
        features.push('html5-playback');
      } else if (OO.isChromecast || OO.playerParams.platform == 'html5-cast') {
        features.push('cast-playback');
        features.push('default-ui');
        if (OO.supportAds) { features.push('ads'); }
      } else { // normal html5
        features.push('html5-playback');
        features.push('default-ui');
        if (OO.supportAds) { features.push('ads'); }
      }

      return _.reduce(features, function(memo, feature) {return memo+feature+' ';}, '');
    }());

    OO.supportMidRollAds = (function() {
      return (OO.uiParadigm === "desktop" && !OO.isIos && !OO.isRimDevice);
    }());

    OO.supportCookies = (function() {
      document.cookie = "ooyala_cookie_test=true";
      var cookiesSupported = document.cookie.indexOf("ooyala_cookie_test=true") >= 0;
      document.cookie = "ooyala_cookie_test=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
      return cookiesSupported;
    }());

    OO.isSSL = document.location.protocol == "https:";

    OO.SERVER =
    {
      API: OO.isSSL ? OO.playerParams.api_ssl_server || "https://player-ssl.ooyala.com" :
                      OO.playerParams.api_server || "http://player.ooyala.com",
      AUTH: OO.isSSL ? OO.playerParams.auth_ssl_server || "https://player-ssl.ooyala.com/sas" :
                      OO.playerParams.auth_server || "http://player.ooyala.com/sas",
      ANALYTICS: OO.isSSL ? OO.playerParams.analytics_ssl_server || "https://player-ssl.ooyala.com" :
                            OO.playerParams.analytics_server || "http://player.ooyala.com",
      HASTUR: OO.isSSL ? OO.playerParams.hastur_ssl_server ||
                         (OO.isProd ? "https://l.ooyala.com/player_events" :
                                      "https://l-staging.ooyala.com/player_events") :
                         OO.playerParams.hastur_server ||
                         (OO.isProd ? "http://l.ooyala.com/player_events" :
                                      "http://l-staging.ooyala.com/player_events")
    };

    // returns true iff environment-specific feature is required to run in current environment
    OO.requiredInEnvironment = function(feature) {
      return !!OO.environmentRequiredFeatures.match(new RegExp(feature));
    };

    // Detect Chrome Extension. We will recieve an acknowledgement from the content script, which will prompt us to start sending logs
    OO.chromeExtensionEnabled = document.getElementById('ooyala-extension-installed') ? true : false;

    // Locale Getter and Setter
    OO.locale = "";
    OO.setLocale = function(locale) {
      OO.locale = locale.toUpperCase();
    };
    OO.getLocale = function() {
      return (OO.locale || document.documentElement.lang || navigator.language ||
              navigator.userLanguage || "en").substr(0,2).toUpperCase();
    };
  }(OO, OO._, OO.HM));
(function(OO, $, _){
  /*
   *  extend jquery lib
   */

  // add support for ie8/9 cross domain requests to jquery
  // see more here: http://bugs.jquery.com/ticket/8283
  // and here: https://github.com/jaubourg/ajaxHooks/blob/master/src/xdr.js
  if (window.XDomainRequest) {
    OO.$.ajaxTransport(function(s) {
      if (s.crossDomain && s.async) {
        if (s.timeout) {
          s.xdrTimeout = s.timeout;
          delete s.timeout;
        }
        var xdr;
        return {
          send: function(_, complete) {
            function callback(status, statusText, responses, responseHeaders) {
              xdr.onload = xdr.onerror = xdr.ontimeout = OO.$.noop;
              xdr = undefined;
              complete(status, statusText, responses, responseHeaders);
            }
            xdr = new XDomainRequest();
            xdr.open(s.type, s.url);
            xdr.onload = function() {
              callback(200, "OK", {
                text: xdr.responseText
              }, "Content-Type: " + xdr.contentType);
            };
            xdr.onerror = function() {
              callback(404, "Not Found");
            };
            xdr.onprogress = function() {};
            if (s.xdrTimeout) {
              xdr.ontimeout = function() {
                callback(0, "timeout");
              };
              xdr.timeout = s.xdrTimeout;
            }
            xdr.send((s.hasContent && s.data) || null);
          },
          abort: function() {
            if (xdr) {
              xdr.onerror = OO.$.noop();
              xdr.abort();
            }
          }
        };
      }
    });
  }


  $.getScriptRetry = function (url, callback, options) {
    options = options || {};
    var errorCallBack = options.error;
    var removeOptions = ['error', 'dataType', 'success'];
    _.each(removeOptions, function(k) { delete(options[k]); });

    // default settings; may be overridden by passing options
    var settings = {
      'url': url,
      'type': 'get',
      'dataType': 'script',
      'success': callback,
      'cache': true,
      'timeout': 5000,
      'tryCount': 0,
      'retryLimit': 1,
      'warning': false,
      'warningMessage': 'Can not load URL',
      'error': function () {
        if (this.tryCount < this.retryLimit) {
          this.tryCount++;
          $.ajax(this);
        } else {
          if (this.warning) {
            alert(this.warningMessage);
          }
          if (errorCallBack) { errorCallBack.apply(null, arguments); }
        }
      }
    }

    _.extend(settings, options);

    $.ajax(settings);
  };


}(OO, OO.$, OO._));
  (function(OO,_){

    // External States
    OO.STATE = {
      LOADING : 'loading',
      READY : 'ready',
      PLAYING : 'playing',
      PAUSED : 'paused',
      BUFFERING : 'buffering',
      ERROR : 'error',
      DESTROYED : 'destroyed',

      __end_marker : true
    };

    // All Events Constants
    OO.EVENTS = {
      PLAYER_CREATED : 'playerCreated',
      PLAYER_EMBEDDED: 'playerEmbedded',
      SET_EMBED_CODE : 'setEmbedCode',
      EMBED_CODE_CHANGED : 'embedCodeChanged',
      AUTH_TOKEN_CHANGED: "authTokenChanged",

      GUID_SET : 'guidSet',

      WILL_FETCH_PLAYER_XML: 'willFetchPlayerXml',
      PLAYER_XML_FETCHED: 'playerXmlFetched',

      WILL_FETCH_CONTENT_TREE: 'willFetchContentTree',
      CONTENT_TREE_FETCHED: 'contentTreeFetched',

      WILL_FETCH_METADATA: 'willFetchMetadata',
      METADATA_FETCHED: 'metadataFetched',

      WILL_FETCH_AUTHORIZATION: 'willFetchAuthorization',
      AUTHORIZATION_FETCHED: 'authorizationFetched',

      WILL_FETCH_AD_AUTHORIZATION: 'willFetchAdAuthorization',
      AD_AUTHORIZATION_FETCHED: 'adAuthorizationFetched',

      PRELOAD_STREAM: 'preloadStream',
      RELOAD_STREAM: 'reloadStream',
      WILL_PLAY_STREAM: 'willPlayStream',
      PLAY_STREAM: 'playStream',
      PAUSE_STREAM: 'pauseStream',
      STREAM_PLAYING: 'streamPlaying',
      STREAM_PLAY_FAILED: 'streamPlayFailed',
      STREAM_PAUSED: 'streamPaused',
      STREAM_PLAYED: 'streamPlayed',
      SEEK_STREAM: 'seekStream',
      CAN_SEEK: 'canSeek',

      PLAY_MIDROLL_STREAM: 'playMidrollStream',
      MIDROLL_STREAM_PLAYED: 'midrollStreamPlayed',
      WILL_RESUME_MAIN_VIDEO: 'willResumeMainVideo',

      PLAYBACK_READY: 'playbackReady',
      INITIAL_PLAY: "initialPlay", // when play is called for the very first time ( in start screen )
      WILL_PLAY : 'willPlay',
      PLAYHEAD_TIME_CHANGED: 'playheadTimeChanged',
      BUFFERING: 'buffering', // playing stops because player is buffering
      BUFFERED: 'buffered',
      DOWNLOADING:  'downloading', // player is downloading content (could be playing while downloading)

      BITRATE_INFO_AVAILABLE: 'bitrateInfoAvailable',
      SET_TARGET_BITRATE: 'setTargetBitrate',
      SET_TARGET_BITRATE_QUALITY: 'setTargetBitrateQuality',
      BITRATE_CHANGED: 'bitrateChanged',

      CLOSED_CAPTIONS_INFO_AVAILABLE: 'closedCaptionsInfoAvailable',
      SET_CLOSED_CAPTIONS_LANGUAGE: 'setClosedCaptionsLanguage',

      INSERT_CUE_POINT: 'insertCuePoint',

      SCRUBBING: 'scrubbing',
      SCRUBBED: 'scrubbed',
      SEEK: 'seek',
      SEEKED: 'seeked',
      PLAY: 'play',
      PLAYING: 'playing',
      PLAY_FAILED: 'playFailed',
      PAUSE: 'pause',
      PAUSED: 'paused',
      PLAYED: 'played',

      TOGGLE_SHARE_PANEL: 'toggleSharePanel',
      SHARE_PANEL_CLICKED: 'sharePanelClicked',
      TOGGLE_INFO_PANEL: 'toggleInfoPanel',
      INFO_PANEL_CLICKED: 'infoPanelClicked',

      SHOULD_DISPLAY_CUE_POINTS: 'shouldDisplayCuePoints',

      WILL_CHANGE_FULLSCREEN: 'willChangeFullscreen',
      FULLSCREEN_CHANGED: 'fullscreenChanged',
      SIZE_CHANGED: 'sizeChanged',
      CHANGE_VOLUME: 'changeVolume',
      VOLUME_CHANGED: 'volumeChanged',
      CONTROLS_SHOWN: 'controlsShown',
      CONTROLS_HIDDEN: 'controlsHidden',
      END_SCREEN_SHOWN: 'endScreenShown',

      PLAYER_CLICKED: 'playerClicked',

      ERROR: 'error',

      DESTROY: 'destroy',

      WILL_PLAY_FROM_BEGINNING: 'willPlayFromBeginning',

      DISABLE_PLAYBACK_CONTROLS: 'disablePlaybackControls',
      ENABLE_PLAYBACK_CONTROLS: 'enablePlaybackControls',

      WILL_FETCH_ADS: 'willFetchAds',
      WILL_PLAY_ADS: 'willPlayAds',
      WILL_PLAY_SINGLE_AD: 'willPlaySingleAd',
      WILL_PAUSE_ADS: 'willPauseAds',
      ADS_PLAYED: 'adsPlayed',
      SINGLE_AD_PLAYED: 'singleAdPlayed',
      ADS_ERROR: 'adsError',
      ADS_CLICKED: 'adsClicked',
      FIRST_AD_FETCHED: "firstAdFetched",
      AD_CONFIG_READY: "adConfigReady",
      WILL_SHOW_COMPANION_ADS: "willShowCompanionAds",
      AD_FETCH_FAILED: "adFetchFailed",
      MIDROLL_PLAY_FAILED: "midrollPlayFailed",
      SKIP_AD: "skipAd",
      UPDATE_AD_COUNTDOWN: "updateAdCountdown",
      SHOW_AD_MARQUEE: "showAdMarquee",

      ADOBE_PASS_WAITING_FOR_TOKEN: "adobePassWaitingForToken", // When the flash player is waiting for token
      ADOBE_PASS_TOKEN_FETCHED: "adobePassTokenFetched",
      ADOBE_PASS_AUTH_STATUS: "setAuthenticationStatus",

      // this player is part of these experimental variations
      REPORT_EXPERIMENT_VARIATIONS: "reportExperimentVariations",

      FETCH_STYLE: "fetchStyle",
      STYLE_FETCHED: "styleFetched",
      SET_STYLE: "setStyle",

      USE_SERVER_SIDE_HLS_ADS: "useServerSideHlsAds",

      LOAD_ALL_VAST_ADS: "loadAllVastAds",

      ADS_FILTERED: "adsFiltered",
      ADS_MANAGER_HANDLING_ADS: "adsManagerHandlingAds",
      ADS_MANAGER_FINISHED_ADS: "adsManagerFinishedAds",

      // Window published beforeUnload event. It's still user cancellable.
      PAGE_UNLOAD_REQUESTED: "pageUnloadRequested",
      // Either 1) The page is refreshing (almost certain) or 2) The user tried to refresh
      // the page, the embedding page had an "Are you sure?" prompt, the user clicked
      // on "stay", and a real error was produced due to another reason during the
      // following few seconds. The real error, if any, will be received in some seconds.
      // If we are certain it has unloaded, it's too late to be useful.
      PAGE_PROBABLY_UNLOADING: "pageProbablyUnloading",

      // DiscoveryApi publishes these, OoyalaAnalytics listens for them and propagates to reporter.js
      REPORT_DISCOVERY_IMPRESSION: "reportDiscoveryImpression",
      REPORT_DISCOVERY_CLICK: "reportDiscoveryClick",

      __end_marker : true
    };

    OO.ERROR = {
      API: {
        NETWORK:'network',
        SAS: {
          GENERIC:'sas',
          GEO:'geo',
          DOMAIN:'domain',
          FUTURE:'future',
          PAST:'past',
          DEVICE:'device',
          PROXY:'proxy',
          CONCURRENT_STREAMS:'concurrent_streams',
          INVALID_HEARTBEAT:'invalid_heartbeat',
          ERROR_DEVICE_INVALID_AUTH_TOKEN:'device_invalid_auth_token',
          ERROR_DEVICE_LIMIT_REACHED:'device_limit_reached',
          ERROR_DEVICE_BINDING_FAILED:'device_binding_failed',
          ERROR_DEVICE_ID_TOO_LONG:'device_id_too_long',
          ERROR_DRM_RIGHTS_SERVER_ERROR:'drm_server_error',
          ERROR_DRM_GENERAL_FAILURE:'drm_general_failure'
        },
        CONTENT_TREE:'content_tree',
        METADATA:'metadata'
      },
      PLAYBACK: {
        GENERIC:'playback',
        STREAM:'stream',
        LIVESTREAM:'livestream',
        NETWORK: 'network_error'
      },
      CHROMECAST: {
        MANIFEST:'chromecast_manifest',
        MEDIAKEYS:'chromecast_mediakeys',
        NETWORK:'chromecast_network',
        PLAYBACK:'chromecast_playback'
      },
      UNPLAYABLE_CONTENT:'unplayable_content',
      INVALID_EXTERNAL_ID:'invalid_external_id',
      EMPTY_CHANNEL:'empty_channel',
      EMPTY_CHANNEL_SET:'empty_channel_set',
      CHANNEL_CONTENT:'channel_content'
    };

    // All Server-side URLS
    OO.URLS = {
      ADOBE_AE_URL_STAGING: "https://entitlement.auth-staging.adobe.com/entitlement/AccessEnabler.js",
      ADOBE_AE_URL: "https://entitlement.auth.adobe.com/entitlement/AccessEnabler.js",
      TOKEN_VERIFIER_URL:  _.template('/sas/embed_token/pcode/<%=embedCode%>?auth_type=adobepass&requestor=<%=requestor%>&token=<%=token%>&resource=<%=resource%>&mvpd_id=<%=mvpd_id%>'),
      VAST_PROXY: _.template('http://player.ooyala.com/nuplayer/mobile_vast_ads_proxy?callback=<%=cb%>&embed_code=<%=embedCode%>&expires=<%=expires%>&tag_url=<%=tagUrl%>'),
      EXTERNAL_ID: _.template('<%=server%>/player_api/v1/content_tree/external_id/<%=pcode%>/<%=externalId%>'),
      CONTENT_TREE: _.template('<%=server%>/player_api/v1/content_tree/embed_code/<%=pcode%>/<%=embedCode%>'),
      METADATA: _.template('<%=server%>/player_api/v1/metadata/embed_code/<%=playerBrandingId%>/<%=embedCode%>?videoPcode=<%=pcode%>'),
      SAS: _.template('<%=server%>/player_api/v1/authorization/embed_code/<%=pcode%>/<%=embedCode%>'),
      ANALYTICS: _.template('<%=server%>/reporter.js'),
      PLAYER_XML: _.template('<%=server%>/nuplayer?embedCode=<%=embedCode%>&playerBrandingId=<%=playerBrandingId%>'),
      PLAYER_SWF: _.template('<%=server%>?player=<%=player%>'),
      __end_marker : true
    };

    OO.CSS = {
      VISIBLE_POSITION : "0px",
      INVISIBLE_POSITION : "-100000px",
      SUPER_Z_INDEX: 20000,
      TRANSPARENT_COLOR : "rgba(255, 255, 255, 0)",

      __end_marker : true
    };

    // flash embed attribute: http://helpx.adobe.com/flash/kb/flash-object-embed-tag-attributes.html
    OO.TEMPLATES = {
      RANDOM_PLACE_HOLDER: ['[place_random_number_here]', '<now>', '[timestamp]', '<rand-num>', '[cache_buster]', '[random]'],
      REFERAK_PLACE_HOLDER: ['[referrer_url]', '[LR_URL]'],
      EMBED_CODE_PLACE_HOLDER: ['[oo_embedcode]'],
      FLASH : '\
         <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" \
             id="<%= playerId %>" class="video" width="100%" height="100%">\
          <param name="movie" value="<%= swfUrl %>" />\
          <!--[if !IE]>-->\
          <object type="application/x-shockwave-flash" id="<%= playerId %>_internal" data="<%= swfUrl %>"\
              width="100%" height="100%">\
          <!--<![endif]-->\
          <param name="allowScriptAccess" value="always">\
          <param name="allowFullScreen" value="true">\
          <param name="bgcolor" value="#000000">\
          <param name="wmode" value="<%= wmode %>">\
          <param name="flashvars" value="<%= flashVars %>">\
           <p>Please upgrade your Flash Plugin</p>\
          <!--[if !IE]>-->\
          </object>\
          <!--<![endif]-->\
         </object>\
         ',
         FLASH_IE : '\
            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" \
                id="<%= playerId %>" class="video" width="100%" height="100%">\
             <param name="movie" value="<%= swfUrl %>" />\
             <param name="allowScriptAccess" value="always">\
             <param name="allowFullScreen" value="true">\
             <param name="bgcolor" value="#000000">\
             <param name="wmode" value="<%= wmode %>">\
             <param name="flashvars" value="<%= flashVars %>">\
              <p>Please upgrade your Flash Plugin</p>\
            </object>\
            ',
      MESSAGE : '\
                  <table width="100%" height="100%" bgcolor="black" style="padding-left:55px; padding-right:55px; \
                  background-color:black; color: white;">\
                  <tbody>\
                  <tr valign="middle">\
                  <td align="right"><span style="font-family:Arial; font-size:20px">\
                  <%= message %>\
                  </span></td></tr></tbody></table>\
                  ',

      FLASH_INSTALL : '\
                        <div style="color:white">You need to have the Adobe Flash Player to view this content.</div>\
                        <div style="font-size:16px;"><a href="http://www.adobe.com/go/getflash/" style="color:white">Please click here to continue.</a></div>\
                        ',

      __end_marker : true
    };

    OO.CONSTANTS = {
      STANDALONE_AD_HOLDER: "third_party_standalone_ad_holder",

      // Ad frequency constants
      AD_PLAY_COUNT_KEY: "oo_ad_play_count",
      AD_ID_TO_PLAY_COUNT_DIVIDER: ":",
      AD_PLAY_COUNT_DIVIDER: "|",
      MAX_AD_PLAY_COUNT_HISTORY_LENGTH: 20,

      __end_marker : true
    };

  }(OO,OO._));
(function(OO) {
  // place holder for all text resource key
  OO.TEXT = {
    ADS_COUNTDOWN: 'adsCountdown',
    LIVE: 'LIVE',
    HOOK_PROMPT: 'hookPrompt',
    HOOK_DOWNLOAD: 'hookDownload',
    HOOK_INSTALLED: 'hookInstalled',
    HOOK_IGNORE: 'hookIgnore',

    __end_marker: true
  };

}(OO));
(function(OO) {
  OO.MESSAGES = {
    EN: {},
    ES: {},
    FR: {},
    JA: {}
  };

  var en = OO.MESSAGES.EN;
  var es = OO.MESSAGES.ES;
  var fr = OO.MESSAGES.FR;
  var ja = OO.MESSAGES.JA;

  // ENGLISH
  en[OO.ERROR.API.NETWORK] = "Cannot Contact Server";
  en[OO.ERROR.API.SAS.GENERIC] = "Invalid Authorization Response";
  en[OO.ERROR.API.SAS.GEO] = "This video is not authorized in your location";
  en[OO.ERROR.API.SAS.DOMAIN] = "This video is not authorized for your domain";
  en[OO.ERROR.API.SAS.FUTURE] = "This video will be available soon";
  en[OO.ERROR.API.SAS.PAST] = "This video is no longer available";
  en[OO.ERROR.API.SAS.DEVICE] = "This video is not authorized for playback on this device";
  en[OO.ERROR.API.SAS.PROXY] = "An anonymous proxy was detected. Please disable the proxy and retry.";
  en[OO.ERROR.API.SAS.CONCURRENT_STREAMS] = "You have exceeded the maximum number of concurrent streams";
  en[OO.ERROR.API.SAS.INVALID_HEARTBEAT] = "Invalid heartbeat response";
  en[OO.ERROR.API.CONTENT_TREE] = "Invalid Content";
  en[OO.ERROR.API.METADATA] = "Invalid Metadata";
  en[OO.ERROR.PLAYBACK.GENERIC] = "Could not play the content";
  en[OO.ERROR.PLAYBACK.STREAM] = "This video isn't encoded for your device";
  en[OO.ERROR.PLAYBACK.LIVESTREAM] = "Live stream is off air";
  en[OO.ERROR.PLAYBACK.NETWORK] = "Network connection temporarily lost";
  en[OO.ERROR.UNPLAYABLE_CONTENT] = "This video is not playable on this player";
  en[OO.ERROR.INVALID_EXTERNAL_ID] = "Invalid External ID";
  en[OO.ERROR.EMPTY_CHANNEL] = "This channel is empty";
  en[OO.ERROR.EMPTY_CHANNEL_SET] = "This channel set is empty";
  en[OO.ERROR.CHANNEL_CONTENT] = "This channel is not playable at this time";
  en[OO.ERROR.STREAM_PLAY_FAILED] = "This video is not encoded for your device";
  en[OO.TEXT.ADS_COUNTDOWN] = "Advertisement: Your Video will resume shortly";
  en[OO.TEXT.LIVE] = "LIVE";
  en[OO.TEXT.HOOK_PROMPT] = "The Hook Player is required to watch this video";
  en[OO.TEXT.HOOK_DOWNLOAD] = "Download Hook";
  en[OO.TEXT.HOOK_INSTALLED] = "I Already Have It";
  en[OO.TEXT.HOOK_IGNORE] = "Remind Me Later";

  // SPANISH
  es[OO.ERROR.API.NETWORK] = "No se puede contactar al servidor";
  es[OO.ERROR.API.SAS.GENERIC] = "Respuesta de autorización no válida";
  es[OO.ERROR.API.SAS.GEO] = "El vídeo no está autorizado en su ubicación";
  es[OO.ERROR.API.SAS.DOMAIN] = "El vídeo no está autorizado para su dominio";
  es[OO.ERROR.API.SAS.FUTURE] = "El vídeo estará disponible pronto";
  es[OO.ERROR.API.SAS.PAST] = "El vídeo ya no está disponible";
  es[OO.ERROR.API.SAS.DEVICE] = "El vídeo no está autorizado para reproducirse en este dispositivo";
  es[OO.ERROR.API.SAS.PROXY] = "Se detectó un proxy anónimo. Deshabilite el proxy e intente nuevamente.";
  es[OO.ERROR.API.SAS.CONCURRENT_STREAMS] = "Ha superado la cantidad máxima de transmisiones concurrentes";
  es[OO.ERROR.API.SAS.INVALID_HEARTBEAT] = "Respuesta de pulso no válida";
  es[OO.ERROR.API.CONTENT_TREE] = "Contenido no válido";
  es[OO.ERROR.API.METADATA] = "Metadatos no válidos";
  es[OO.ERROR.PLAYBACK.GENERIC] = "No se pudo reproducir el contenido";
  es[OO.ERROR.PLAYBACK.STREAM] = "El vídeo no está codificado para su dispositivo";
  es[OO.ERROR.PLAYBACK.LIVESTREAM] = "La transmisión en vivo está fuera del aire";
  es[OO.ERROR.PLAYBACK.NETWORK] = "La conexión de red se halla temporalmente perdida";
  es[OO.ERROR.UNPLAYABLE_CONTENT] = "El vídeo no se puede reproducir en este reproductor";
  es[OO.ERROR.INVALID_EXTERNAL_ID] = "ID externo no válido";
  es[OO.ERROR.EMPTY_CHANNEL] = "El canal está vacío";
  es[OO.ERROR.EMPTY_CHANNEL_SET] = "El conjunto de canales está vacío";
  es[OO.ERROR.CHANNEL_CONTENT] = "El canal no se puede reproducir en este momento";
  es[OO.ERROR.STREAM_PLAY_FAILED] = "El vídeo no está codificado para su dispositivo";
  es[OO.TEXT.ADS_COUNTDOWN] = "Anuncio: el vídeo se reanudará en breve";
  es[OO.TEXT.LIVE] = "EN VIVO";
  es[OO.TEXT.HOOK_PROMPT] = "Se requiere Hook Player para ver este vídeo";
  es[OO.TEXT.HOOK_DOWNLOAD] = "Descargar Hook";
  es[OO.TEXT.HOOK_INSTALLED] = "Ya lo tengo";
  es[OO.TEXT.HOOK_IGNORE] = "Recordarme más tarde";

  // FRENCH
  fr[OO.ERROR.API.NETWORK] = "Impossible de contacter le serveur";
  fr[OO.ERROR.API.SAS.GENERIC] = "Réponse d'autorisation non valide";
  fr[OO.ERROR.API.SAS.GEO] = "Cette vidéo n'est pas autorisée dans votre pays";
  fr[OO.ERROR.API.SAS.DOMAIN] = "Cette vidéo n'est pas autorisée pour votre domaine";
  fr[OO.ERROR.API.SAS.FUTURE] = "Cette vidéo sera bientôt disponible";
  fr[OO.ERROR.API.SAS.PAST] = "Cette vidéo n'est plus disponible";
  fr[OO.ERROR.API.SAS.DEVICE] = "La lecture de cette vidéo n'est pas autorisée sur cet appareil";
  fr[OO.ERROR.API.SAS.PROXY] = "Un proxy anonyme a été détecté. Désactivez le proxy, puis réessayez.";
  fr[OO.ERROR.API.SAS.CONCURRENT_STREAMS] = "Vous avez dépassé le nombre maximum de flux simultanés.";
  fr[OO.ERROR.API.SAS.INVALID_HEARTBEAT] = "Réponse du signal de pulsation ('heartbeat') non valide";
  fr[OO.ERROR.API.CONTENT_TREE] = "Contenu non valide";
  fr[OO.ERROR.API.METADATA] = "Métadonnées non valides";
  fr[OO.ERROR.PLAYBACK.GENERIC] = "Impossible de lire le contenu";
  fr[OO.ERROR.PLAYBACK.STREAM] = "Cette vidéo n'est pas encodée pour votre appareil";
  fr[OO.ERROR.PLAYBACK.LIVESTREAM] = "Le flux direct a été interrompu";
  fr[OO.ERROR.PLAYBACK.NETWORK] = "Connexion au réseau temporairement interrompue";
  fr[OO.ERROR.UNPLAYABLE_CONTENT] = "Vous ne pouvez pas lire cette vidéo sur ce lecteur";
  fr[OO.ERROR.INVALID_EXTERNAL_ID] = "Identifiant externe non valide";
  fr[OO.ERROR.EMPTY_CHANNEL] = "Cette chaîne est vide";
  fr[OO.ERROR.EMPTY_CHANNEL_SET] = "Ce groupe de chaînes est vide";
  fr[OO.ERROR.CHANNEL_CONTENT] = "Vous ne pouvez pas lire cette chaîne pour le moment";
  fr[OO.ERROR.STREAM_PLAY_FAILED] = "Cette vidéo n'est pas encodée pour votre appareil";
  fr[OO.TEXT.ADS_COUNTDOWN] = "Publicité : votre vidéo reprendra bientôt";
  fr[OO.TEXT.LIVE] = "EN DIRECT";
  fr[OO.TEXT.HOOK_PROMPT] = "Le lecteur Hook est nécessaire pour visionner cette vidéo";
  fr[OO.TEXT.HOOK_DOWNLOAD] = "Télécharger Hook";
  fr[OO.TEXT.HOOK_INSTALLED] = "Je l'ai déjà";
  fr[OO.TEXT.HOOK_IGNORE] = "Me le rappeler plus tard";

  // JAPANESE
  ja[OO.ERROR.API.NETWORK] = "後でご確認ください。";
  ja[OO.ERROR.API.SAS.GENERIC] = "ビデオを認証できません。";
  ja[OO.ERROR.API.SAS.GEO] = "この地域ではこのビデオは許可されていません。";
  ja[OO.ERROR.API.SAS.DOMAIN] = "お使いのドメインではこのビデオは許可されていません。";
  ja[OO.ERROR.API.SAS.FUTURE] = "このビデオはしばらくすると再生可能になります。";
  ja[OO.ERROR.API.SAS.PAST] = "このビデオは、既に御利用いただけません。";
  ja[OO.ERROR.API.SAS.DEVICE] = "このビデオは、このデバイスでの再生は許可されていません。";
  ja[OO.ERROR.API.SAS.CONCURRENT_STREAMS] = "最大同時接続数を超えています。";
  ja[OO.ERROR.API.SAS.INVALID_HEARTBEAT] = "同時再生ストリームの最大数に達しました。";
  ja[OO.ERROR.API.CONTENT_TREE] = "不正なコンテンツです。";
  ja[OO.ERROR.API.METADATA] = "不正なメタデータです。";
  ja[OO.ERROR.PLAYBACK.GENERIC] = "このコンテンツを再生できませんでした。";
  ja[OO.ERROR.PLAYBACK.STREAM] = "このビデオは、お使いのデバイス向けにエンコードされていません。";
  ja[OO.ERROR.PLAYBACK.LIVESTREAM] = "ライブ配信はされておりません。";
  ja[OO.ERROR.PLAYBACK.NETWORK] = "ネットワークに一時的に接続できません。";
  ja[OO.ERROR.UNPLAYABLE_CONTENT] = "このビデオは、このプレーヤーでは再生できません。";
  ja[OO.ERROR.INVALID_EXTERNAL_ID] = "External IDが不正です。";
  ja[OO.ERROR.EMPTY_CHANNEL] = "このチャンネルは空です。";
  ja[OO.ERROR.EMPTY_CHANNEL_SET] = "このチャンネルセットは空です。";
  ja[OO.ERROR.CHANNEL_CONTENT] = "このチャンネルは、現在再生できません。";
  ja[OO.ERROR.STREAM_PLAY_FAILED] = "このビデオは、お使いのデバイス向けにエンコードされていません。";
  ja[OO.TEXT.ADS_COUNTDOWN] = "広告：";
  ja[OO.TEXT.LIVE] = "ライブ";
  ja[OO.TEXT.HOOK_PROMPT] = "このビデオを視聴するには<br />Hook Video Playerが必要です。";
  ja[OO.TEXT.HOOK_DOWNLOAD] = "Hook Video Playerをダウンロード";
  ja[OO.TEXT.HOOK_INSTALLED] = "既にダウンロード済み";
  ja[OO.TEXT.HOOK_IGNORE] = "あとで通知";
  OO.getLocalizedMessage = function(code) {
    var language = OO.getLocale();
    return (OO.MESSAGES[language] ? OO.MESSAGES[language][code] : undefined) ||
           OO.MESSAGES.EN[code] ||
           "";
  };
}(OO));
  (function(OO) { 
    OO.asset_list = {
      'image/png:discovery_dots' : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAQAAADa613fAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAACYktHRAD/h4/MvwAAAAlwSFlzAAALEwAACxMBAJqcGAAACABJREFUeNrdXAtMllUY/mQCEjjNZSoiCbqV9eOty5yVGpqzzZzKZOqcOtss8xKWa1aozYzIdLnQyktGMwmXa6zbjKm1CIeW0sXNQtvyT8umKIiGKPp0/o/vh//7/3P/LhgPIuw/73nf8/Cdy/u+55zPgNExvkL/XAQSMRRzUIASVOE4atGGWtSQz0pI2Wwik+CqVfeIEAJj8ToOoAlyuIJKFCLbHUKuEEEScrALl6GHSygl9ZPamQgGowh1cI46oiernYhgPMrhLsrxqM9EMBrfwRtUYLRPRDAQZfAWZRjgMRHEYwWZb7zHFeQj3jMiyMJP8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QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAAASUVORK5CYII=',
      'image/png:icon_full_on' : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC0AAAAuCAQAAAAWh1i/AAAAAmJLR0QA/4ePzL8AAAa7SURBVFjDtVdtSJRZFH4afdVRx2+z0b7WSte0cnUzwY8+dMDRndCFVtMC+zIwKIOUkowUhgqMBNcfUSvMSvPHmpwG2sVyYX9IiOxWkL8q6Efs/qh//TKVd597533nw3do3djmcJn73nPO8573nHvPPQdYBROiEYt4JCKJZOEslismcv79F9S2SO3EUG0TFD4mIxPZWEfK5iyFK4pgz2D2EySBhXZKmHayps03xCMVOdiMbe4fPS5lB/Ioko4ExCCKyqQg2EwQVFAUZRIouw55yg7Pz+5hbCNODvHiiUvzk/mur7HLdWdGnVHdD5RqFOMrvj1RfloUySQ/UCfxJFaFIxIpl0v56vEHQtt1B7uIlU3MWMCMDGxWyl13Z9RpEsGnlHrsxBZY+aHCd3G0TdFeIEAVPsfJ2KRQZgt2muvdv82ov0tt1z2lnJZnkE8BKwrd96fJmiIJAdcTcyMqUIiN5GUiLRDaqEDI0rhuJb8QFUqj60motvs+V63EZVTXotg5OLU0KZka+w9LK2pRhiLkea4ii95LkLYL36Yii2t55JWh1tLq/lMHltpLzut00Fri0oIcTus7bk0S3E8C3v3CcgJNsI3+NK3yA7MJaKbFZv5nY/O0OnobNjRZTrhfTFNe15xc6riFeuLlEJdWrMFW1KC92e1b8kkBnwR3vUrtGX4o7EEpwbMobObI4rx0il82/DC1x/VK8H0asG+pxY12Ym0lZoIIYzpjXI7vccZx17voU/00SXDfB78i9mE7N1gKxVP4vx37/C/3fpiShvjJu+i4izPEKSdeOnHpvSQ6fSv2oBU9tnueBV9AWMB6BXQjt1QuQ5fIkct5o//lUzooybNg86CHGHuIZSVmjDgycZotNn7MxaoJz4JXDSe0oYphy6A7MvhfhTb/ui8gMb5QNYE+6tu074sTR0bkADOt2UiP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JNMuYAaxogeY6rGK75ruZfg3Zv4MxRzrKdEvJiGkwitapSNVdWo5aqEPxHeQ23uNKFHWeNKsLFfgkHy+kITOs4aVeyU7330UgqrRI+wRhQ758s6nsMA7iFaZYPElAeYdo6ZyiOWO2pZvZKnfcelUezHY8TpEnSj+rhcriiXz7LlvuGq6D/R/iFewVMUcY+N+WRWr6Is8LsridfwDPzoqzJklEfVClHbs7EU/Mv9Gd7AsxjEg3z+sR/oUVa7Qqe7D+EAhjGE7ZSeumZITxFWm0L/er7CQTyPAHyipBq3JtVhZlZEUA6f7zkmvYUX8SQe4lPBavNUMAJFQnRYQwjO4f+8P0nvIYp9eBhbRROYChagw6yKir5f2z/GqwhhF7x82l1hnnZj0FUFHaoo+U66PsHrCJPF7hctFlSgXD4s6BATyf+3O03P78dubKNBbFniqDDZFs0XZkFWKf8Z92G8SRbbgx2ihZkMsSzLSTN26Gz3N4jjBTyBftFyMgp7WRbBAaZpaNrznfQOXsJestgW6yK4GtaILi/dS+ALPT9KH/B08wjlXsHSPYoI7I5IBbq04SBs0fuD622K9mlKj17RhiOCWmTZJvm+73yZcsJuivaB8jZpkW6x2rBGdHlzR1FupsG7SbS5qx1rRJe3pNSZbnqBZUt6kTbSje3RL9L2/3/I7CSqa6A3LgAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAAASUVORK5CYII=',
      'image/png:icon_playhead' : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADoAAAA6CAYAAADhu0ooAAAABmJLR0QA/wD/AP+gvaeTAAAKMklEQVRo3t1bf2xV5Rm+7NKWcrvWalvwFoSagcttKgZpagTFGjEwaiVt1pbMOEckpZZtkkhFpkzMytiARGMo03UmRv5jmXFKshGy/YHbHwu6GcaS/UXcP25ZsmWoixsld8/TPC95+3HOuef2xyQ0edLTc77zvs/zve/3ft8552smMzc/82LwhQBx7a7ZnygxWWC+UOFQKfhz1i4b0wnXlLisE0UhVcACoBpYCOSAmgA5Xat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awjFwinHzHrcpiPR5RmYNZAhbQcU/a9tL38MiT4/kDuU2tN1RsMxAgdylb1DyrggawTEt/hoN3lcEUqPgjIY2awg6zlDwks6BBjgVpifCo7J+qNitvasd0eIax3UGK3H9qP6e3g131wqem4PwzNs7hM4JnBaE53xwlhtSQLLN3CfLtN0gf8juneqrfD+OExpepQ0NGahzoMamyrAIekkCsl1Dug6fn703+2f5hTLq1NHA625Y4IbR/1t9lP+oZgfGAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAABJRU5ErkJggg==',
      'image/gif:oo_spinner' : 'data:image/gif;base64,R0lGODlhyADIAPECAJmZmczMzP///wAAACH5BAkKAAIAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAyADIAAAC/pSPqcvtD6OctNqLs968+w+G4kiW5omm6sq27gvH8kzX9o3n+s73/g8MCofEovGITCqXzKbzCY1Kp9Sq9YrNarfcrvcLDovH5LL5jE6r1+y2+w2Py+f0uv2Oz+v3/L7/DxgoOEhYaHiImKi4yNjo+AgZKTlJWWl5iZmpucnZ6fkJGio6SlpqeoqaqrrK2ur6ChsrO0tba3uLm6u7y9vr+wscLDxMXGx8jJysvMzc7PwMHS09TV1tfY2drb3N3e39DR4uPk5ebn6Onq6+zt7u/g4fLz8fG2B/bz+Mvx+AZQ8AEEC/MvwKVgmIEODAMAUNSgmQMOJCLw0bSomIcSKXmIoOn0DEGPELR4tPQGakOJKfR5MYUabEt5JlQpcv8zn5KDMgzZoxcwIUWVMjE58KgfKEQhQAw5dTfArdOJIKTpNkOFqZmvApmI5XQ9L7CnYDVq27sCIke8tsVl9qvfIiilZW25Zlk8aFlVTgrrx3X82VWJdoL7i9/upkK7PvrLmKa021GTay5MmUK1u+jDmz5s2cO3v+fKUAACH5BAkKAAIALAAAAADIAMgAAAL+lI+py+0Po5y02ouz3rz7D4biSJbmiabqyrbuC8fyTNf2jef6zvf+DwwKh8Si8YhMKpfMpvMJjUqn1Kr1is1qt9yu9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hYaHiImKi4yNjo+AgZKTlJWWl5iZmpucnZ6fkJGio6SlpqeoqaqrrK2ur6ChsrO0tba3uLm6u7y9vr+wscLDxMXGx8jJysvMzc7Pz8EwAwDRBALE2dbQ2c3T293YvtrR0+Pl5u3g2em36+2+7NC98tP09dbw/AKw6/zm7/a16wdsP4fYOGMKHChQwbOnwIMaLEiRQrWryIMaPGgo0cO3r8CDISvwD+fBnMFuwkPZMAe+UraUulOXwtdeWbRlPgu5v7eOZMBzNmzZ5AJ5E8SnKFzKCKkDpNqmKk0adPTVKlGu5q1V1ar3LtujUX2LC4xjr9ahaq2LRqy7JlOout1bFzu6bUWpBsyL18+/r9Cziw4MGECxs+jDix4sXOCgAAIfkEBQoAAgAsAAAAAMgAyAAAAv6Uj6nL7Q+jnLTai7PevPsPhuJIluaJpurKtu4Lx/JM1/aN5/rO9/4PDAqHxKLxiEwql8ym8wmNSqfUqvWKzWq33K73Cw6Lx+Sy+YxOq9fstvsNj8vn9Lr9js/r9/y+/w8YKDhIWGh4iJiouMjY6PgIGSk5SVlpeYmZqbnJ2en5CRoqOkpaanqKmqq6ytrq+gobKztLW2t7i5uru8vb6/sLHCw8TFxsfIycrLzM3Oz8DB0tPU1dbX2Nna29zd3t/Q0eLj5OLhoAgI4eMHye7g4Q/C4P79s+7+57L7++a6+fzuufvIAC8e0qaFAXQoD9FtI7iJBfw4K/KALz946Yv5MAEst5/AgypMiRJEuaPInSEceVHNmxfBnspcyO/WbKZAHzkU2bKTAyZLRzJgqBNA8FFVrC58BFR2+SUDpPUVOnIxwWHTQ1Z9WFV7FmbTkC6ryugr6S5SA2aiKzJqwynXrC7dujJ9ImnIt0aMGzhXiqsPuwV1p27/jyApsyseLFjBs7fgw5suTJlCtbvow5s+ZlBQAAOw==',
      __end_marker:1 };
  }(OO));  (function(OO) { 
    OO.stylus_css = {
      'adobe_pass.styl' : "#ooyalaMvpdPickerContainer{position:absolute;height:100%;width:100%;top:0;left:0;background:rgba(0,0,0,0.50);}#ooyalaMvpdPickerContainer .innerDiv{width:360px;height:420px;border:1px solid rgba(0,0,0,0.50);text-align:left;position:absolute;top:50%;left:50%;margin:-210px 0 0 -180px;background:#fff;color:#000;outline:none;transition:all .5s ease-in-out;border:0;-webkit-border-radius:15px;-moz-border-radius:15px;-ms-border-radius:15px;-o-border-radius:15px;border-radius:15px;-webkit-box-shadow:0 0 5px #c8c8c8;-moz-box-shadow:0 0 5px #c8c8c8;-ms-box-shadow:0 0 5px #c8c8c8;-o-box-shadow:0 0 5px #c8c8c8;box-shadow:0 0 5px #c8c8c8}#ooyalaMvpdPickerContainer .cancelDiv{margin:10px 10px 20px 10px;width:16px;height:16px;background-image:url('<%= cancelIcon %>');background-size:100%;background-origin:content;cursor:pointer}#ooyalaMvpdPickerContainer .titleBar{align:center;font-size:24 p;font-weight:bold;text-align:center;margin:20px}#ooyalaMvpdPickerContainer .providerList{width:85%;height:280px;padding:0 1em;overflow:auto;overflow-x:hidden;-ms-overflow-x:hidden}#ooyalaMvpdPickerContainer ul{list-style-type:none}#ooyalaMvpdPickerContainer li{width:280px;height:audo;margin:15px;cursor:pointer}#ooyalaMvpdPickerContainer li img{vertical-align:middle;width:120px}#ooyalaMvpdPickerContainer li:hover{background-color:#9a9aef;color:#fff}",
      'basic_ui.styl' : "#<%= elementId %> .oo_promo{position:absolute;width:100%;height:100%;cursor:pointer;background:#1a1a1a;background-position:center center;-webkit-background-size:contain;-moz-background-size:contain;-ms-background-size:contain;-o-background-size:contain;background-size:contain;background-repeat:no-repeat;z-index:10001;}#<%= elementId %> .oo_promo div.oo_start_button{width:60px;height:60px;position:absolute;bottom:24px;left:24px;opacity:.8;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=80);background:#000;border:0;-webkit-border-radius:6px;-moz-border-radius:6px;-ms-border-radius:6px;-o-border-radius:6px;border-radius:6px;background-position:center;-webkit-background-size:54% auto;-moz-background-size:54% auto;-ms-background-size:54% auto;-o-background-size:54% auto;background-size:54% auto;background-origin:content;background-repeat:no-repeat}#<%= elementId %> .plugins{position:absolute;width:100%;height:100%;z-index:10003}#<%= elementId %> .plugins.video{width:100%;height:100%}#<%= elementId %> .oo_start_spinner{width:50px;height:50px;margin:5px;-webkit-animation:spin 3.6s infinite linear;-moz-animation:spin 3.6s infinite linear;-ms-animation:spin 3.6s infinite linear;-o-animation:spin 3.6s infinite linear;animation:spin 3.6s infinite linear}#<%= elementId %> .oo_spinner{position:absolute}#<%= elementId %> .oo_tap_panel{position:absolute;z-index:10004;opacity:0;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=0);height:100%;width:100%}#<%= elementId %> .oo_mini_controls{height:40px;left:15px;right:15px;}#<%= elementId %> .oo_mini_controls .oo_scrubber{left:-5px;right:-5px;top:4px;bottom:24px}#<%= elementId %> .oo_mini_controls .oo_scrubber_track{left:45px;right:45px}#<%= elementId %> .oo_mini_controls .oo_toolbar_item{width:16px;height:16px;top:22px}#<%= elementId %> .oo_mini_controls .oo_glow{display:none;position:absolute;left:50%;top:50%;width:0;height:0;-webkit-box-shadow:0 0 30px 13.333333333333334px #fff;-moz-box-shadow:0 0 30px 13.333333333333334px #fff;-ms-box-shadow:0 0 30px 13.333333333333334px #fff;-o-box-shadow:0 0 30px 13.333333333333334px #fff;box-shadow:0 0 30px 13.333333333333334px #fff}#<%= elementId %> .oo_mini_controls .oo_currentTime,#<%= elementId %> .oo_mini_controls .oo_timeToLive{position:absolute;left:2px;text-align:center}#<%= elementId %> .oo_mini_controls .oo_duration{right:2px;position:absolute;text-align:right}#<%= elementId %> .oo_mini_controls .oo_duration,#<%= elementId %> .oo_mini_controls .oo_currentTime,#<%= elementId %> .oo_mini_controls .oo_timeToLive{top:1px;font-size:10px;width:40px}#<%= elementId %> .oo_mini_controls .oo_playhead{height:8px;width:8px;margin:-8px;padding:8px;top:-1px}#<%= elementId %> .oo_full_controls{height:40px;left:15px;right:15px;}#<%= elementId %> .oo_full_controls .vod .oo_scrubber{left:85px;right:45px;top:9px;bottom:10px}#<%= elementId %> .oo_full_controls .live .oo_scrubber{left:165px;right:45px;top:10px;bottom:10px}#<%= elementId %> .oo_full_controls .vod .oo_scrubber_track{left:45px;right:45px}#<%= elementId %> .oo_full_controls .live .oo_scrubber_track{left:5px;right:5px}#<%= elementId %> .oo_full_controls .oo_currentTime,#<%= elementId %> .oo_full_controls .oo_timeToLive{left:5px;text-align:left;position:absolute}#<%= elementId %> .oo_full_controls .oo_duration{right:5px;text-align:right;position:absolute}#<%= elementId %> .oo_full_controls .oo_toolbar_item{width:40px;height:24px;top:8px}#<%= elementId %> .oo_full_controls .oo_button_highlight{display:none;position:absolute;left:50%;top:50%;width:0;height:0;-webkit-box-shadow:0 0 30px 13.333333333333334px #fff;-moz-box-shadow:0 0 30px 13.333333333333334px #fff;-ms-box-shadow:0 0 30px 13.333333333333334px #fff;-o-box-shadow:0 0 30px 13.333333333333334px #fff;box-shadow:0 0 30px 13.333333333333334px #fff}#<%= elementId %> .oo_full_controls .oo_duration,#<%= elementId %> .oo_full_controls .oo_currentTime{top:5px;font-size:12px;width:40px}#<%= elementId %> .oo_full_controls .oo_playhead{height:24px;width:24px;margin:-4px;padding:4px;top:-4px}#<%= elementId %> .oo_controls{position:absolute;padding:0;background:rgba(0,0,0,0.65);-webkit-border-radius:6px;-moz-border-radius:6px;-ms-border-radius:6px;-o-border-radius:6px;border-radius:6px;z-index:10004;-webkit-transition:.5s all ease;-moz-transition:.5s all ease;-ms-transition:.5s all ease;-o-transition:.5s all ease;transition:.5s all ease;}#<%= elementId %> .oo_controls .live{display:none}#<%= elementId %> .oo_controls .oo_controls_inner{position:absolute;top:0;bottom:0;left:10px;right:10px}#<%= elementId %> .oo_controls .oo_label{font-family:sans-serif;line-height:10px;color:#fff;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;cursor:default;text-align:center}#<%= elementId %> .oo_controls .oo_scrubber{position:absolute;background:#000;-webkit-border-radius:12px;-moz-border-radius:12px;-ms-border-radius:12px;-o-border-radius:12px;border-radius:12px}#<%= elementId %> .oo_controls .oo_playhead{background-image:url('<%= playheadIcon %>');background-position:border;-webkit-background-size:100% auto;-moz-background-size:100% auto;-ms-background-size:100% auto;-o-background-size:100% auto;background-size:100% auto;background-origin:content;background-repeat:no-repeat;position:absolute}#<%= elementId %> .oo_controls .oo_scrubber_track{top:4px;bottom:4px;-webkit-border-radius:12px;-moz-border-radius:12px;-ms-border-radius:12px;-o-border-radius:12px;border-radius:12px;position:absolute}#<%= elementId %> .oo_controls .vod .oo_scrubber_track{left:45px}#<%= elementId %> .oo_controls .live .oo_scrubber_track{left:5px}#<%= elementId %> .oo_controls .oo_progress{height:100%;-webkit-border-radius:12px;-moz-border-radius:12px;-ms-border-radius:12px;-o-border-radius:12px;border-radius:12px;position:absolute}#<%= elementId %> .oo_controls .oo_buffer_progress{width:0}#<%= elementId %> .oo_controls .oo_playhead_progress{width:16px}#<%= elementId %> .oo_controls .oo_button{background-position:center;-webkit-background-size:contain;-moz-background-size:contain;-ms-background-size:contain;-o-background-size:contain;background-size:contain;background-repeat:no-repeat}#<%= elementId %> .oo_controls .oo_rewind{background-image:url('<%= rewindIcon %>');position:absolute;left:0}#<%= elementId %> .oo_controls .oo_play{background-image:url('<%= playIcon %>');position:absolute;left:40px}#<%= elementId %> .oo_controls .oo_pause{background-image:url('<%= pauseIcon %>');position:absolute;left:40px}#<%= elementId %> .oo_controls .oo_fullscreen{position:absolute;right:0}#<%= elementId %> .oo_controls .oo_fullscreen_on{background-image:url('<%= fullscreenOnIcon %>')}#<%= elementId %> .oo_controls .oo_fullscreen_off{background-image:url('<%= fullscreenOffIcon %>')}#<%= elementId %> .oo_controls .oo_live_indicator{background-image:url('<%= liveIcon %>');position:absolute;left:80px}#<%= elementId %> .oo_controls .oo_live_message{color:#fff;line-height:1.6em;font-size:16px;position:absolute;left:120px}#<%= elementId %> .oo_controls .oo_timer{color:#fff;font-size:13px;padding:7px}#<%= elementId %> .oo_ads_countdown{position:absolute;padding:2px 5px;opacity:.6;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=60);width:100%;height:25px;color:#fff;background-color:#000;display:none;overflow:hidden;z-index:10005;font-size:16px;font-weight:bold}#<%= elementId %> .oo_end_screen{position:absolute;width:100%;height:100%;background:#1a1a1a;background-position:center center;-webkit-background-size:contain;-moz-background-size:contain;-ms-background-size:contain;-o-background-size:contain;background-size:contain;background-repeat:no-repeat;display:none;left:0;top:0;overflow:hidden;text-align:center;z-index:10005;}#<%= elementId %> .oo_end_screen .oo_fullscreen{width:28px;height:28px;position:absolute;display:none;top:15px;left:81px;padding:11px 16px;opacity:.65;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=65);background:#000;border:0;-webkit-border-radius:6px;-moz-border-radius:6px;-ms-border-radius:6px;-o-border-radius:6px;border-radius:6px;background-position:center;-webkit-background-size:auto;-moz-background-size:auto;-ms-background-size:auto;-o-background-size:auto;background-size:auto;background-origin:content;background-repeat:no-repeat}#<%= elementId %> .oo_replay{width:61px;height:50px;position:absolute;top:15px;left:15px;opacity:.65;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=65);background:#000;border:0;-webkit-border-radius:6px;-moz-border-radius:6px;-ms-border-radius:6px;-o-border-radius:6px;border-radius:6px;background-position:center;-webkit-background-size:auto;-moz-background-size:auto;-ms-background-size:auto;-o-background-size:auto;background-size:auto;background-origin:content;background-repeat:no-repeat}#<%= elementId %> .oo_spinner{top:0;z-index:10006}@-moz-keyframes spin{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);-o-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);-o-transform:rotate(360deg);transform:rotate(360deg)}}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);-o-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);-o-transform:rotate(360deg);transform:rotate(360deg)}}@-o-keyframes spin{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);-o-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);-o-transform:rotate(360deg);transform:rotate(360deg)}}@-ms-keyframes spin{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);-o-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);-o-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes spin{0%{-webkit-transform:rotate(0);-moz-transform:rotate(0);-ms-transform:rotate(0);-o-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);-moz-transform:rotate(360deg);-ms-transform:rotate(360deg);-o-transform:rotate(360deg);transform:rotate(360deg)}}",
      'discovery_toaster.styl' : "#<%= elementId %> .discovery_toaster{transition:.5s all ease;-moz-transition:.5s all ease;-webkit-transition:.5s all ease;-o-transition:.5s all ease;position:absolute;height:40%;bottom:60px;opacity:0;left:15px;right:15px;border:0;-webkit-border-radius:6px;-moz-border-radius:6px;-ms-border-radius:6px;-o-border-radius:6px;border-radius:6px;z-index:10008;background:rgba(0,0,0,0.65);}#<%= elementId %> .discovery_toaster .discovery_copy{font-family:sans-serif;font-weight:normal;color:#fff;position:absolute;top:13px;margin-left:35px}#<%= elementId %> .discovery_toaster .discovery_image_holder{width:45px;position:absolute;left:0;top:12px}#<%= elementId %> .discovery_toaster .discovery_image{background-position:center center;background-size:contain;background-repeat:no-repeat;background-image:url('<%= discoveryIcon %>');position:absolute;left:12px;top:0;width:20px;height:20px}#<%= elementId %> .discovery_toaster .discovery_outer{left:12px;right:12px;position:absolute;bottom:0;}#<%= elementId %> .discovery_toaster .discovery_outer .discovery_left_scroll{position:absolute;width:10%;height:100%;left:0;top:0;z-index:10009}#<%= elementId %> .discovery_toaster .discovery_outer .discovery_left_gradient{transition:.5s all ease;-moz-transition:.5s all ease;-webkit-transition:.5s all ease;-o-transition:.5s all ease;position:absolute;width:10%;height:100%;left:0;top:0;z-index:10008;background-image:-ms-linear-gradient(left,rgba(0,0,0,0.90) 0%,rgba(0,0,0,0.00) 100%);background-image:-moz-linear-gradient(left,rgba(0,0,0,0.90) 0%,rgba(0,0,0,0.00) 100%);background-image:-o-linear-gradient(left,rgba(0,0,0,0.90) 0%,rgba(0,0,0,0.00) 100%);background-image:-webkit-gradient(linear,left center,right center,color-stop(0,rgba(0,0,0,0.90)),color-stop(1,rgba(0,0,0,0.00)));background-image:-webkit-linear-gradient(left,rgba(0,0,0,0.90) 0%,rgba(0,0,0,0.00) 100%);background-image:linear-gradient(to right,rgba(0,0,0,0.90) 0%,rgba(0,0,0,0.00) 100%)}#<%= elementId %> .discovery_toaster .discovery_outer .discovery_right_gradient{transition:.5s all ease;-moz-transition:.5s all ease;-webkit-transition:.5s all ease;-o-transition:.5s all ease;position:absolute;width:10%;height:100%;right:0;top:0;z-index:10008;background-image:-ms-linear-gradient(right,rgba(0,0,0,0.90) 0%,rgba(0,0,0,0.00) 100%);background-image:-moz-linear-gradient(right,rgba(0,0,0,0.90) 0%,rgba(0,0,0,0.00) 100%);background-image:-o-linear-gradient(right,rgba(0,0,0,0.90) 0%,rgba(0,0,0,0.00) 100%);background-image:-webkit-gradient(linear,right center,left center,color-stop(0,rgba(0,0,0,0.90)),color-stop(1,rgba(0,0,0,0.00)));background-image:-webkit-linear-gradient(right,rgba(0,0,0,0.90) 0%,rgba(0,0,0,0.00) 100%);background-image:linear-gradient(to left,rgba(0,0,0,0.90) 0%,rgba(0,0,0,0.00) 100%)}#<%= elementId %> .discovery_toaster .discovery_outer .discovery_right_scroll{position:absolute;width:10%;height:100%;right:0;top:0;z-index:10009}#<%= elementId %> .discovery_toaster .discovery_outer .discovery_holder{overflow:hidden;width:100%;height:100%;}#<%= elementId %> .discovery_toaster .discovery_outer .discovery_holder .discovery_slider{-webkit-transform:translateX(0);-webkit-backface-visibility:hidden;-moz-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0);height:100%;}#<%= elementId %> .discovery_toaster .discovery_outer .discovery_holder .discovery_slider .discovery_video{float:left;height:100%;}#<%= elementId %> .discovery_toaster .discovery_outer .discovery_holder .discovery_slider .discovery_video .discovery_video_image{background:rgba(0,0,0,0.90);background-position:center;background-size:contain;background-repeat:no-repeat;top:10%;width:90%;height:80%;position:relative;}#<%= elementId %> .discovery_toaster .discovery_outer .discovery_holder .discovery_slider .discovery_video .discovery_video_image .discovery_video_name{font-family:sans-serif;background:rgba(0,0,0,0.65);font-weight:normal;color:#fff;position:absolute;bottom:0;left:0;right:0;text-wrap:unrestricted;padding:5px}#<%= elementId %> .discovery-countdown-container{width:38px;height:38px;position:absolute;-webkit-border-radius:25px;-moz-border-radius:25px;-ms-border-radius:25px;-o-border-radius:25px;border-radius:25px;border:6px solid;top:5px;right:5px;border-color:#000}#<%= elementId %> .discovery-countdown{-webkit-mask-box-image:-webkit-radial-gradient(center,ellipse cover,#000 66%,rgba(0,0,0,0.00) 69.5%);background:#eee;width:40px;height:40px;position:absolute;top:-1px;right:-1px}#<%= elementId %> .countdown-play{background-image:url('<%= playIcon %>');background-position:center;background-size:contain;background-repeat:no-repeat;width:20px;height:20px;position:absolute;top:10px;right:10px;z-index:10013}#<%= elementId %> .countdown-inner{position:absolute;top:0;left:0;background:transparent;border-width:20px;width:0;height:0;border-style:solid;border-color:transparent;border-top-color:#5c5c5c;-webkit-transform:rotate(-45deg);-webkit-animation:inner 15s linear 1}#<%= elementId %> .countdown-mask{position:absolute;top:0;left:0;background:transparent;border-width:20px;width:0;height:0;border-style:solid;border-color:transparent;border-top-color:#eee;-webkit-transform:rotate(-45deg);-webkit-animation:mask 15s linear 1}#<%= elementId %> .countdown-mask:after,#<%= elementId %> .countdown-mask-two{display:block;content:'';opacity:1;position:absolute;top:0;left:0;background:transparent;border-width:20px;width:0;height:0;border-style:solid;border-color:transparent;border-top-color:rgba(92,92,92,0.00);-webkit-transform:rotate(45deg);-webkit-animation:masktwo 15s linear 1}@-webkit-keyframes inner{0%{-webkit-transform:rotate(-45deg)}25%{border-left-color:transparent}26%{border-left-color:#5c5c5c}50%{border-bottom-color:transparent}51%{border-bottom-color:#5c5c5c}75%{border-right-color:transparent}76%{border-right-color:#5c5c5c}100%{-webkit-transform:rotate(315deg);border-left-color:#5c5c5c;border-bottom-color:#5c5c5c;border-right-color:#5c5c5c}}@-webkit-keyframes mask{0%{-webkit-transform:rotate(-45deg)}75%{-webkit-transform:rotate(-45deg)}100%{-webkit-transform:rotate(45deg)}}@-webkit-keyframes masktwo{0%{border-top-color:rgba(92,92,92,0.00)}25%{border-top-color:rgba(92,92,92,0.00)}26%{border-top-color:#5c5c5c}100%{border-top-color:#5c5c5c}}@-webkit-keyframes whee{0%{-webkit-transform:rotate(0);-webkit-filter:sepia() hue-rotate(0) contrast(95%)}100%{-webkit-transform:rotate(360deg);-webkit-filter:sepia() hue-rotate(360deg) contrast(95%)}}",
      'hook.styl' : "div#hookDiv{font-family:sans-serif;background-color:rgba(0,0,0,0.50);z-index:10002;height:100%;width:100%;top:0;left:0;position:fixed;text-align:center;}div#hookDiv #hookCenterDiv{display:inline-block;height:100%;vertical-align:middle;margin-right:-.25em;}div#hookDiv #hookInnerDiv{border:6px solid rgba(200,200,200,0.50);max-width:360px;text-align:center;margin:auto auto;background:#0b3147;color:#fff;outline:none;-webkit-transition:all .5s ease-in-out;-moz-transition:all .5s ease-in-out;-ms-transition:all .5s ease-in-out;-o-transition:all .5s ease-in-out;transition:all .5s ease-in-out;display:inline-block;vertical-align:middle}div#hookDiv .hookTitleText{padding:10px 20px 0 20px;font-size:22px;line-height:1.5em}div#hookDiv #hookLaunchLink{margin:0 10px 0 10px;float:left;text-align:left}div#hookDiv #hookIgnoreLink{margin:0 10px 0 10px;float:right;text-align:right}div#hookDiv .singleLinkDiv{display:table-cell;width:50%;margin:10px}div#hookDiv #hookLinkDiv{width:100%;display:table;margin:0 0 30px 0}div#hookDiv a.hookLinks:link,div#hookDiv a.hookLinks:hover,div#hookDiv a.hookLinks:visited{color:#7bbade;font-size:12px;float:left;display:inline}div#hookDiv #hookDownloadLink{color:#fff;font-weight:bold;text-align:center}div#hookDiv #hookDownloadDiv{margin:0 auto 30px auto;display:block;max-width:200px;text-align:center;color:#fff;border-top:1px solid #0e5d8b;border-bottom:1px solid #042c3a;font-size:18px;padding:10px 10px;text-decoration:none;background:-moz-linear-gradient(top,#1e7aaf 0%,#185f89 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#1e7aaf),color-stop(100%,#185f89));background:-webkit-linear-gradient(top,#1e7aaf 0%,#185f89 100%);background:-o-linear-gradient(top,#1e7aaf 0%,#185f89 100%);background:-ms-linear-gradient(top,#1e7aaf 0%,#185f89 100%);}",
      'playback.styl' : "#<%= elementId %> .video,#<%= elementId %> .midroll{position:absolute;width:100%;height:100%;z-index:10000;left:-10000px}",
      'root.styl' : "#<%= elementId %>>div{width:0;height:0;position:relative;z-index:10000;overflow:hidden}#<%= elementId %> .innerWrapper{background:#000}#<%= elementId %> .innerWrapper:-webkit-full-screen{width:100%;height:100%}#<%= elementId %> .innerWrapper:-webkit-full-screen video{width:100%}#<%= elementId %> .innerWrapper.fullscreen{position:fixed;top:0;left:0;width:100%;height:100%;background:#fff}#<%= elementId %> .oo_playhead{-ms-touch-action:none}#<%= elementId %> .oo_error{position:absolute;width:100%;height:100%;cursor:pointer;background:#1a1a1a;background-position:center center;background-size:contain;background-repeat:no-repeat;z-index:10002;}#<%= elementId %> .oo_error .oo_error_image{position:absolute;width:100%;height:30%;top:20%;background-image:url('<%= errorIcon %>');background-position:center;background-size:contain;background-origin:content;background-repeat:no-repeat}#<%= elementId %> .oo_error .oo_error_message{position:absolute;width:100%;top:70%;text-align:center;}#<%= elementId %> .oo_error .oo_error_message .oo_error_message_text{color:#d0d0d0;font-size:18px;font-family:Helvetica,sans-serif;font-weight:bold;line-height:100%;text-shadow:1px 3px 4px #000}",
      __end_marker:1 };
  }(OO));    OO.publicApi.REV='09996aa4c2283151d32c217ca3ce3e276d7bf1dd';

  (function(OO) {
    OO.get_img_base64 = function(imgName) {
      if (!OO.asset_list || !imgName) { return null; }
      return OO.asset_list["image/png:" + imgName] || OO.asset_list["image/gif:" + imgName];
    };

    OO.get_css = function(cssName) {
      if (!OO.stylus_css || !cssName) { return null; }
      return OO.stylus_css[cssName + ".styl"];
    };

  }(OO));  (function(OO,_,$) {
    OO.getRandomString = function() { return Math.random().toString(36).substring(7); };

    OO.safeClone = function(source) {
      if (_.isNumber(source) || _.isString(source) || _.isBoolean(source) || _.isFunction(source) ||
          _.isNull(source) || _.isUndefined(source)) {
        return source;
      }
      var result = (source instanceof Array) ? [] : {};
      try {
        $.extend(true, result, source);
      } catch(e) { OO.log("deep clone error", e); }
      return result;
    };

    OO.d = function() {
      if (OO.isDebug) { OO.log.apply(OO, arguments); }
      OO.$("#OOYALA_DEBUG_CONSOLE").append(JSON.stringify(OO.safeClone(arguments))+'<br>');
    };

    // Note: This inherit only for simple inheritance simulation, the Parennt class still has a this binding
    // to the parent class. so any variable initiated in the Parent Constructor, will not be available to the
    // Child Class, you need to copy paste constructor to Child Class to make it work.
    // coffeescript is doing a better job here by binding the this context to child in the constructor.
    // Until we switch to CoffeeScript, we need to be careful using this simplified inherit lib.
    OO.inherit = function(ParentClass, myConstructor) {
      if (typeof(ParentClass) !== "function") {
        OO.log("invalid inherit, ParentClass need to be a class", ParentClass);
        return null;
      }
      var SubClass = function() {
        ParentClass.apply(this, arguments);
        if (typeof(myConstructor) === "function") { myConstructor.apply(this, arguments); }
      };
      var parentClass = new ParentClass();
      OO._.extend(SubClass.prototype, parentClass);
      SubClass.prototype.parentClass = parentClass;
      return SubClass;
    };

    var styles = {}; // keep track of all styles added so we can remove them later if destroy is called

    OO.attachStyle = function(styleContent, playerId) {
      var s = $('<style type="text/css">' + styleContent + '</style>').appendTo("head");
      styles[playerId] = styles[playerId] || [];
      styles[playerId].push(s);
    };

    OO.removeStyles = function(playerId) {
      OO._.each(styles[playerId], function(style) {
        style.remove();
      });
    };

    OO.formatSeconds = function(timeInSeconds) {
      var seconds = parseInt(timeInSeconds,10) % 60;
      var hours = parseInt(timeInSeconds / 3600, 10);
      var minutes = parseInt((timeInSeconds - hours * 3600) / 60, 10);


      if (hours < 10) {
        hours = '0' + hours;
      }

      if (minutes < 10) {
        minutes = '0' + minutes;
      }

      if (seconds < 10) {
        seconds = '0' + seconds;
      }

      return (parseInt(hours,10) > 0) ? (hours + ":" + minutes + ":" + seconds) : (minutes + ":" + seconds);
    };

    OO.timeStringToSeconds = function(timeString) {
      var timeArray = (timeString || '').split(":");
      return _.reduce(timeArray, function(m, s) { return m * 60 + parseInt(s, 10); }, 0);
    };

    OO.leftPadding = function(num, totalChars) {
      var pad = '0';
      var numString = num ? num.toString() : '';
      while (numString.length < totalChars) {
        numString = pad + numString;
      }
      return numString;
    };

    OO.getColorString = function(color) {
      return '#' + (OO.leftPadding(color.toString(16), 6)).toUpperCase();
    };

    OO.hexToRgb = function(hex) {
      var r = (hex & 0xFF0000) >> 16;
      var g = (hex & 0xFF00) >> 8;
      var b = (hex & 0xFF);
      return [r, g, b];
    };

    OO.changeColor = function(color, ratio, darker) {
      var minmax     = darker ? Math.max : Math.min;
      var boundary = darker ? 0 : 255;
      var difference = Math.round(ratio * 255) * (darker ? -1 : 1);
      var rgb = OO.hexToRgb(color);
      return [
        OO.leftPadding(minmax(rgb[0] + difference, boundary).toString(16), 2),
        OO.leftPadding(minmax(rgb[1] + difference, boundary).toString(16), 2),
        OO.leftPadding(minmax(rgb[2] + difference, boundary).toString(16), 2)
      ].join('');
    };

    OO.decode64 = function(s) {
      s = s.replace(/\n/g,"");
      var results = "";
      var j, i = 0;
      var enc = [];
      var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

      //shortcut for browsers with atob
      if (window.atob) {
        return atob(s);
      }

      do {
        for (j = 0; j < 4; j++) {
          enc[j] = b64.indexOf(s.charAt(i++));
        }
        results += String.fromCharCode((enc[0] << 2) | (enc[1] >> 4),
                                        enc[2] == 64 ? 0 : ((enc[1] & 15) << 4) | (enc[2] >> 2),
                                        enc[3] == 64 ? 0 : ((enc[2] & 3) << 6) | enc[3]);
      } while (i < s.length);

      //trim tailing null characters
      return results.replace(/\0/g, "");
    };

    OO.pixelPing = function (url) {
      var img = new Image();
      img.onerror = img.onabort = function() { OO.d("onerror:", url); };
      img.src = OO.getNormalizedTagUrl(url);
    };

    // ping array of urls.
    OO.pixelPings = function (urls) {
        if (_.isEmpty(urls)) { return; }
        _.each(urls, function(url) {
          OO.pixelPing(url);
        }, this);
    };


    OO.regexEscape = function(value) {
      var specials = /[<>()\[\]{}]/g;
      return value.replace(specials, "\\$&");
    };

    OO.getNormalizedTagUrl = function (url, embedCode) {
      var ts = new Date().getTime();
      var pageUrl = escape(document.URL);

      var placeHolderReplace = function (template, replaceValue) {
        _.each(template, function (placeHolder) {
          var regexSearchVal = new RegExp("(" +
                                    OO.regexEscape(placeHolder) + ")", 'gi');
          url = url.replace(regexSearchVal, replaceValue);
        }, this);
      }

      // replace the timestamp and referrer_url placeholders
      placeHolderReplace(OO.TEMPLATES.RANDOM_PLACE_HOLDER, ts);
      placeHolderReplace(OO.TEMPLATES.REFERAK_PLACE_HOLDER, pageUrl);

      // first make sure that the embedCode exists, then replace the
      // oo_embedcode placeholder
      if (embedCode) {
        placeHolderReplace(OO.TEMPLATES.EMBED_CODE_PLACE_HOLDER, embedCode);
      }
      return url;
    };

    OO.safeSeekRange = function(seekRange) {
      return {
        start : seekRange.length > 0 ? seekRange.start(0) : 0,
        end : seekRange.length > 0 ? seekRange.end(0) : 0
      };
    };

    OO.loadedJS = OO.loadedJS || {};

    OO.jsOnSuccessList = OO.jsOnSuccessList || {};

    OO.safeFuncCall = function(fn) {
      if (typeof fn !== "function") { return; }
      try {
        fn.apply();
      } catch (e) {
        OO.log("Can not invoke function!", e);
      }
    };

    OO.loadScriptOnce = function(jsSrc, successCallBack, errorCallBack, timeoutInMillis) {
      OO.jsOnSuccessList[jsSrc] = OO.jsOnSuccessList[jsSrc] || [];
      if (OO.loadedJS[jsSrc]) {
        // invoke call back directly if loaded.
        if (OO.loadedJS[jsSrc] === "loaded") {
          OO.safeFuncCall(successCallBack);
        } else if (OO.loadedJS[jsSrc] === "loading") {
          OO.jsOnSuccessList[jsSrc].unshift(successCallBack);
        }
        return false;
      }
      OO.loadedJS[jsSrc] = "loading";
      $.ajax({
        url: jsSrc,
        type: 'GET',
        cache: true,
        dataType: 'script',
        timeout: timeoutInMillis || 15000,
        success: function() {
          OO.loadedJS[jsSrc] = "loaded";
          OO.jsOnSuccessList[jsSrc].unshift(successCallBack);
          OO._.each(OO.jsOnSuccessList[jsSrc], function(fn) {
            OO.safeFuncCall(fn);
          }, this);
          OO.jsOnSuccessList[jsSrc] = [];
        },
        error: function() {
          OO.safeFuncCall(errorCallBack);
        }
      });
      return true;
    };

    OO.localStorage = window.localStorage;
    if (!OO.localStorage) {
      OO.localStorage = {
        getItem: function (sKey) {
          if (!sKey || !this.hasOwnProperty(sKey)) { return null; }
          return unescape(document.cookie.replace(new RegExp("(?:^|.*;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"), "$1"));
        },
        key: function (nKeyId) {
          return unescape(document.cookie.replace(/\s*\=(?:.(?!;))*$/, "").split(/\s*\=(?:[^;](?!;))*[^;]?;\s*/)[nKeyId]);
        },
        setItem: function (sKey, sValue) {
          if(!sKey) { return; }
          document.cookie = escape(sKey) + "=" + escape(sValue) + "; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/";
          this.length = document.cookie.match(/\=/g).length;
        },
        length: 0,
        removeItem: function (sKey) {
          if (!sKey || !this.hasOwnProperty(sKey)) { return; }
          document.cookie = escape(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
          this.length--;
        },
        hasOwnProperty: function (sKey) {
          return (new RegExp("(?:^|;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie);
        }
      };
      OO.localStorage.length = (document.cookie.match(/\=/g) || OO.localStorage).length;
    }

    OO.JSON = window.JSON;

  }(OO, OO._, OO.$));
  (function(OO,_) {

    OO.Emitter  = function(messageBus){
      this.mb = messageBus;
      this._subscribers = {};
    };

    _.extend(OO.Emitter.prototype,  {
      on  : function(eventName, subscriber, callback){
        this._subscribers[eventName] = this._subscribers[eventName]  || [];
        this._subscribers[eventName].push({callback: callback, subscriber: subscriber});
      },

      off  : function(eventName, subscriber, callback){
        this._subscribers[eventName] = _.reject(this._subscribers[eventName] || [], function(elem) {
          return (elem.callback == callback || callback === undefined) && elem.subscriber === subscriber;
        });
      },

      trigger  : function(eventName /* , args... */){
        _.each(this._subscribers[eventName] || [], _.bind(this._triggerSubscriber, this, eventName, arguments));
        _.each(this._subscribers['*'] || [], _.bind(this._triggerSubscriber, this, eventName, arguments));
      },

      _triggerSubscriber : function(eventName, params, subscriber) {
        try {
          subscriber.callback.apply(this,params);
        } catch (e) {
          var stack = e.stack || "unavailable";
          OO.log('Uncaught exception', e, 'Stack', stack,'triggering subscriber', subscriber,
            'with event',eventName, 'Parameters: ', params);
        }
      },

      __placeholder:true
    });

  }(OO, OO._));
  (function(OO,_) {
    OO.MessageBus = function() {
      this._emitter = new OO.Emitter(this);
      this._dependentEmitter = new OO.Emitter(this);
      this._interceptEmitter = new OO.Emitter(this);
      this._interceptArgs = {};
      this._dependentList = {};
      this._blockList = {};
      this._readyEventList = {};
      this._queuedArgs = {};
      this._dispatching = false;   // whether message bus is currently dispatching published events
      this._publishingQueue = [];
      this.blockedEvent = {};
      this.blockedParams = {};

      // public properties
      this._messageHistory = [];
      this._tracer = _.bind(this._internalTracer, this);   // default internal tracer

      // add a random ID for debug
      this.MbId = OO.getRandomString();
    };

    _.extend(OO.MessageBus.prototype,  {
      // Adds a tracer function, which will be fired for each published/executed event
      addTracer: function(newTracer) {
        if(newTracer && _.isFunction(newTracer)) {
          if(this._tracer) {
            this._tracer = _.wrap(this._tracer, function(f) { newTracer.apply(this, _.rest(arguments)); });
          } else {
            this._tracer = newTracer;
          }
        }
      },

      _internalTracer: function() {
        this._messageHistory.push(_.toArray(arguments));
      },

      messageTraceSnapshot: function() {
        return _.toArray(this._messageHistory);
      },

      /*
       * addDependent blocks eventName until dependentEvent fires, at which point onMergeParams will be
       * called.  This means that eventName MUST be fired before dependentEvent.
       */
      addDependent: function(eventName, dependentEvent, subscriber, onMergeParams){
        // TODO, add a circular detectecion here.
        this._dependentList[eventName] = this._dependentList[eventName] || [];
        this._dependentList[eventName].push(dependentEvent);
        this._blockList[dependentEvent] = this._blockList[dependentEvent] || [];
        this._blockList[dependentEvent].push(eventName);
        this.blockedParams[eventName] = [];

        var onSourceReady = OO._.bind(function(e) {
          if (this.blockedEvent[e] != 1) {
            delete this._queuedArgs[e];
            return;
          }
          var args = OO.safeClone(_.flatten(arguments));
          var origParams = OO.safeClone(this.blockedParams[eventName]);
          args.shift(); origParams.shift();

          var newArgs = onMergeParams.apply(this, [eventName, dependentEvent, origParams, args]) || args;
          delete this.blockedEvent[e];
          this.blockedParams[e] = [];
          this._emitter.trigger.apply(this._emitter, [e].concat(newArgs));
        }, this);

        this._dependentEmitter.on(eventName, subscriber, onSourceReady);
      },

      publish: function() {
        var args = OO.safeClone(_.flatten(arguments));
        this._publishingQueue.push(args);

        if(!this._dispatching) {
          this._dispatching = true;
          var ev = this._publishingQueue.shift();
          while(ev) {
            this._publish.apply(this, ev);
            ev = this._publishingQueue.shift();
          }
          this._dispatching = false;
        }
      },


      _publish: function(eventName) {
        // queue event here untill all dependency is cleared.
        // also trigger queued event if there are blocked by this event.
        this._readyEventList[eventName] = 1;
        var args = OO.safeClone(_.flatten(arguments));

        this._interceptEmitter.trigger.apply(this._interceptEmitter, args);
        if (this._interceptArgs[eventName] === false) { this._interceptArgs[eventName] = true; return; }
        if (this._interceptArgs[eventName]) {
          args = _.flatten([eventName, this._interceptArgs[eventName]]);
        }

        if(this._tracer && _.isFunction(this._tracer)) {
          var params = _.flatten(['publish'].concat(args));
          this._tracer.apply(this._tracer, params);
        }

        if (this._noDependency(eventName)) {
          this._emitter.trigger.apply(this._emitter, this._queuedArgs[eventName] || args);
          delete this._queuedArgs[eventName];
          _.each(this._blockList[eventName], function(e) {
            this._clearDependent(e, eventName);
            args[0] = e;
            this._queuedArgs[e] = args;
            this._dependentEmitter.trigger.apply(this._dependentEmitter, args);
          }, this);
        } else {
           this.blockedEvent[eventName] = 1;
           this.blockedParams[eventName] = args;
        }
      },

      /*
       * eventName is the event to intercept
       * subscriber is the subscriber
       * callback returns a list of arguments, not including the eventName
       */
      intercept: function(eventName, subscriber, callback) {
        this._interceptEmitter.on(eventName, subscriber, _.bind(function(e) {
          var args = OO.safeClone(_.flatten(arguments));
          if (this._interceptArgs[eventName] != false) {
            this._interceptArgs[eventName] = callback.apply(this, args);
          }
        }, this));
        this._interceptArgs[eventName] = [eventName];
      },

      subscribe: function(eventName, subscriber, callback) {
        // TODO check if it is on the dependent queue, should not allow this action if a event is blocking
        // other event.
        this._emitter.on(eventName, subscriber, callback);
      },

      unsubscribe: function(eventName, subscriber, callback) {
        this._emitter.off(eventName, subscriber, callback);
      },

      /** Start of the private member function, all internal used func will prefix with _ **/

      _noDependency: function(eventName) {
        if (!this._dependentList[eventName]) { return true; }
        return (this._dependentList[eventName].length === 0);

      },

      _clearDependent: function(source, target) {
        var depEvents = this._dependentList[source];
        this._dependentList[source] = OO._.filter(depEvents, function(e){ return e !== target; }, this);
      }

    });

  }(OO,OO._));

(function (OO, _) {
  OO.StateMachine = {
    //Based on https://github.com/jakesgordon/javascript-state-machine
    create: function(_cfg) {
      // validate parameters
      var cfg = OO.HM.safeObject('statemachine.create.cfg', _cfg);
      var initial = OO.HM.safeDomId('statemachine.create.cfg.initial', cfg.initial);
      var fsm = OO.HM.safeObject('statemachine.create.cfg.target', cfg.target, {});
      var events = OO.HM.safeArrayOfElements('statemachine.create.cfg.events', cfg.events, function(element){ return OO.HM.safeObject('statemachine.create.cfg.events[]', element); }, []);
      var moduleName = OO.HM.safeString('statemachine.create.cfg.moduleName', cfg.moduleName,"");
      var mb = OO.HM.safeObject('statemachine.create.cfg.messageBus', cfg.messageBus);

      var map        = {};
      var n;

      var doCallback = function(name) {
        var f = null;
        var shortEventName = name.replace(/[^\/]*\//,'').match(/^(.)(.*)/);   // transform xxx/abc into ['abc','a','bc']
        var shortMethodName = 'on'+shortEventName[1].toUpperCase() + shortEventName[2];
        if(fsm[shortMethodName]) {
          f = fsm[shortMethodName];
        } else {
          var fullEventName = name.replace(/\/.*/, '').match(/^(.)(.*)/);    // transform xyz/abc into ['xyz','x','yz']
          var fullMethodName = 'on'+fullEventName[1].toUpperCase() + fullEventName[2] + shortEventName[1].toUpperCase() + shortEventName[2];
          if(fsm[fullMethodName]) {
            f = fsm[fullMethodName];
          }
        }

        if (f) {
          try {
            var result = f.apply(fsm, arguments);
            return (result !== false ? 'ok' : 'fail');
          }
          catch(e) {
            OO.log(e);
            if(OO.TEST_TEST_TEST) {
              throw e;  // rethrow in test environment
            }
            return 'fail';
          }
        }

        // callback not found
        return 'not_found';
      };

      var add = function(e) {
        var from = (e.from instanceof Array) ? e.from : (e.from ? [e.from] : ['*']); // allow 'wildcard' transition if 'from' is not specified
        var n;
        map[e.name] = map[e.name] || {};
        for (n = 0 ; n < from.length ; n++) {
          map[e.name][from[n]] = e.to || from[n]; // allow no-op transition if 'to' is not specified
        }
      };

      var updateState = function(fsm, state) {
        if (state === "*") { return; } // no op  for * state
        fsm.currentState = state;
      };

      fsm.canReceive = function(event) { return map[event] && (map[event].hasOwnProperty(fsm.currentState) || map[event].hasOwnProperty('*')); };

      fsm.receive = function(event/*....arguments*/) {
        //drop events not valid in current state
        if (!fsm.canReceive(event)) {
          OO.log('dropped event', arguments, 'for', moduleName, 'while in state',fsm.currentState, 'with map',map);
          return;
        }

        var from  = fsm.currentState;
        var to    = map[event][from] || map[event]['*'] || from;
        var n;

        //handle transition to same state
        if (from === to) {
          doCallback.apply(fsm, arguments);
          return;
        }

        updateState(fsm, to);

        var callbackResult = 'not_found';
        if(to !== "*") { callbackResult = doCallback.apply(fsm, _.union([to], _.rest(arguments))); }
        if(callbackResult==='not_found') { callbackResult = doCallback.apply(fsm, arguments); }

        switch ( callbackResult )  {
          case 'not_found':
            OO.log('Module ' + moduleName + ' does not handle state ' + to + ' or event ', arguments);
            updateState(fsm, from);
            break;
          case 'fail':
            updateState(fsm, from);
            break;
          case 'ok':
            break;
        }
      };

      for(n = 0 ; n < events.length ; n++) {
        if(typeof(events[n]) == 'object') {
          add(events[n]);
        }
      }

      updateState(fsm, initial);
      if (mb !== undefined) {
        for(n in map) {
          mb.subscribe(n.toString(), moduleName, fsm.receive);
        }
      }

      return fsm;
    },

    __end_marker : true
  };
}(OO, OO._));  (function(OO,_, $) {
    // Module registration facility
    OO.players  = {};
    OO.modules = [];
    OO.registerModule = function(_moduleName, _moduleFactoryMethod) {
      // validate params
      var moduleName = OO.HM.safeDomId('moduleName', _moduleName, OO.HM.fixDomId),
        moduleFactoryMethod = OO.HM.safeFunction('moduleFactoryMethod', _moduleFactoryMethod);

      OO.modules.push({ name: moduleName, factory: moduleFactoryMethod});
    };

    OO.plugin = function(moduleName, moduleClassFactory) {
      OO.log("Registered optional plugin: ", moduleName);
      OO.registerModule(moduleName, function(messageBus, id) {
        // TODO, check if we need to catch any exception here.
        var moduleClass = moduleClassFactory.apply({}, [OO, OO._, OO.$, window]);
        var plugin = new moduleClass(messageBus, id);
        return plugin;
      });
    };

    // API registration facility
    OO.exposeStaticApi = function(_apiModule, _apiObject) {
      // validate params
      var apiModule = OO.HM.safeDomId('apiModule', _apiModule),
        apiObject = OO.HM.safeObject('apiObject', _apiObject);

      OO.publicApi[apiModule] = OO.publicApi[apiModule] || {};
      OO._.extend(OO.publicApi[apiModule], apiObject);
    };

    // Player class
    OO.Player = function(_elementId, _embedCode, _parameters) {
      // validate params
      // _parameters is optional. Hazmat takes care of this but throws an undesirable warning.
      _parameters = _parameters || {};

      var elementId = OO.HM.safeDomId('Player.create.elementId', _elementId),
        embedCode = OO.HM.safeStringOrNull('Player.create.embedCode', _embedCode),
        parameters = OO.HM.safeObject('Player.create.parameters', _parameters, {});

      parameters.onCreate = OO.HM.safeFunctionOrNull('Player.create.parameters.onCreate', parameters.onCreate);

      // copy parameters
      this.elementId = elementId;
      this.embedCode = embedCode;
      this.parameters = parameters;
      this.playbackReady = false;
      this.adPlaying = false;
      this.isPlaying = false;

      $("#" + this.elementId).html(''); // clear the container for player rendering.

      var mb = this.mb = new OO.MessageBus();

      // initialize modules
      this.modules = OO._.map(OO.modules, function(moduleDefinition) {
        var id = moduleDefinition.name + '-' + OO.getRandomString();
        var module = {
          name: moduleDefinition.name,
          moduleId: id, // a random id to help debug
          instance: moduleDefinition.factory(mb, id, parameters)   // Modules Only See MB directly, not the player
        };
        OO.log("Loaded plugin", module.moduleId, module);
        return module;
      });

      // keep state
      this.state = OO.STATE.LOADING;
      this.mb.subscribe(OO.EVENTS.PLAYBACK_READY, 'player', _.bind(function() {
        this.state = OO.STATE.READY;
        this.playbackReady = true;
        if (this._playQueued) { this.play(); }
      }, this));
      this.mb.subscribe(OO.EVENTS.PLAYING, 'player', _.bind(function() {
        // initial time:
        // TODO, w3c has introduced a new attribute for HTML 5 tag: initialTime
        // http://www.w3.org/TR/2011/WD-html5-20110113/video.html#dom-media-initialtime
        // Once it is widely supported, we can directly set this attribute instead.

        this.state = OO.STATE.PLAYING;
        this._playedOnce = true;
        this.isPlaying = true;
      }, this));
      this.mb.subscribe(OO.EVENTS.PAUSED, 'player', _.bind(function() {
        this.state = OO.STATE.PAUSED;
        this.isPlaying = false;
      }, this));
      this.mb.subscribe(OO.EVENTS.BUFFERING, 'player', _.bind(function() {
        this.state = OO.STATE.BUFFERING;
      }, this));
      this.mb.subscribe(OO.EVENTS.BUFFERED, 'player', _.bind(function() {
        // If the video is still in a buffering state after we've finished buffering,
        // Change it to either a playing or paused state
        if (this.state === OO.STATE.BUFFERING) {
          this.state = (this.isPlaying) ? OO.STATE.PLAYING : OO.STATE.PAUSED;
        }
      }, this));
      this.mb.subscribe(OO.EVENTS.PLAYED, 'player', _.bind(function() {
        this.state = OO.STATE.READY;
      }, this));
      this.mb.subscribe(OO.EVENTS.WILL_PLAY_ADS, 'player', _.bind(function(event, adDuration) {
        this.adDuration = adDuration;
        this._playedOnce = true;
        this.adPlaying = true;
      }, this));
      this.mb.subscribe(OO.EVENTS.ADS_PLAYED, 'player', _.bind(function() {
        this.adDuration = -1;
        this.adPlaying = false;
      }, this));

      // listen for some events to keep a copy of metadata for APIs
      this.playheadTime = -1;
      this.duration = -1;
      this.adDuration = -1;
      this.bufferLength = -1;
      this.currentItem = this.item = null;
      this.clockOffset = 0;
      this.mb.subscribe(OO.EVENTS.CONTENT_TREE_FETCHED, 'player', _.bind(function(event, tree) {
        // NOTE[jigish]: we do not support channels yet, so currentItem *is* the root item
        this.currentItem = this.item = tree;
        if (!tree) { return; }
        // preset duration to what contentTree thinks it is. we'll change it later
        this.duration = tree.duration;
      }, this));
      this.mb.subscribe(OO.EVENTS.WILL_FETCH_AUTHORIZATION, 'player', _.bind(function(event) {
        this.authStartTime = new Date().getTime();
      }, this));
      this.mb.subscribe(OO.EVENTS.AUTHORIZATION_FETCHED, 'player', _.bind(function(event, tree) {
        if (!tree.debug_data || !tree.debug_data.user_info) { return; }
        var currentTime = new Date().getTime();
        var latency = (currentTime - this.authStartTime - tree.debug_data.server_latency) / 2;
        this.clockOffset = (tree.debug_data.user_info.request_timestamp * 1000) + latency - currentTime;
      }, this));

      this.mb.subscribe(OO.EVENTS.CAN_SEEK, 'player', _.bind(function(event) {
        var initialTime = parseInt(this.parameters.initialTime, 10);
        if (!isNaN(initialTime) && initialTime > 0 && !this.adPlaying) {
          this.seek(initialTime);
          this.parameters.initialTime = null; // unset initial time to avoid double seek.
        }
      }, this));

      this.mb.subscribe(OO.EVENTS.PLAYHEAD_TIME_CHANGED, 'player', _.bind(function(event, time, duration, buffer) {
        this.playheadTime = time;
        this.duration = duration;
        this.bufferLength = buffer;
        if (!this.startTime) { this.startTime = new Date().getTime(); }

        // initialTime is used for X-Device Resume. After it's triggered once, it should go away.
        // However it isn't possible to do an initialTime seek if we're in the loading state
        if (!this.adPlaying && this.parameters.initialTime &&
              time && this.state != OO.STATE.LOADING) {
          OO.log("Trying to do initialTime seek", this.parameters.initialTime);
          this.mb.publish(OO.EVENTS.CAN_SEEK);
        }
      }, this));
      this.mb.subscribe(OO.EVENTS.DOWNLOADING, 'player', _.bind(function(event, time, duration, buffer) {
        this.playheadTime = time;
        this.duration = duration;
        this.bufferLength = buffer;
      }, this));

      // keep track of fullscreen state
      this.fullscreen = false;
      this.mb.subscribe(OO.EVENTS.FULLSCREEN_CHANGED, 'player', _.bind(function(event, state) {
        this.fullscreen = state;
      }, this));

      // keep track of errors
      this.error = null;
      this.mb.subscribe(OO.EVENTS.ERROR, 'player', _.bind(function(event, err) {
        this.error = err;
        this.state = OO.STATE.ERROR;
      }, this));

      // keep track of volume
      // NOTE[jigish]: this may or may not work on some browsers.
      this.volume = 1;
      this.mb.subscribe(OO.EVENTS.VOLUME_CHANGED, 'player', _.bind(function(event, volume) {
        this.volume = volume;
      }, this));

      // reset shit on setEmbedCode
      this.mb.subscribe(OO.EVENTS.SET_EMBED_CODE, 'player', _.bind(function(event, embedCode, options) {
        this.error = null;
        this.playheadTime = -1;
        this.duration = -1;
        this.bufferLength = -1;
        this.currentItem = this.item = null;
        this.playbackReady = false;
        this.state = OO.STATE.LOADING;
        this.parameters = _.extend(this.parameters, options)
        if (this.parameters.locale !== undefined) {
          OO.setLocale(this.parameters.locale);
        }
      }, this));

      // listen for destroy
      this.mb.subscribe(OO.EVENTS.DESTROY, 'player', _.bind(function(event, embedCode) {
        $("#" + this.elementId).empty();
        delete OO.players[this.elementId];
        OO.removeStyles(this.elementId);
        this.state = OO.STATE.DESTROYED;

        // [PBW-459] Call optional destory() callback after DESTROY is complete.
        if (this.destroyCallback) {
          this.destroyCallback();
          this.destroyCallback = null;
        }
      }, this));

      // keep track of bitrates
      this.bitratesInfo = {};
      this.mb.subscribe(OO.EVENTS.BITRATE_INFO_AVAILABLE, 'player', _.bind(function(event, info) {
        this.bitratesInfo = info;
      }, this));

      // keep track of closedCaptionsLanguages
      this.closedCaptionsLanguages = {};
      this.mb.subscribe(OO.EVENTS.CLOSED_CAPTIONS_INFO_AVAILABLE, 'player', _.bind(function(event, info) {
        this.closedCaptionsLanguages = info;
      }, this));

      /*
       * Public Player API Instance Methods
       *
       * NOTE[jigish]: Some functions are aliased to maintain compatibility with the flash player. Others are
       * aliased because they are Channel APIs and Channels are not supported yet.
       *
       * TODO[jigish]:
       * setQueryStringParameters
       */

      /* Actions */
      this._playedOnce = false;
      this._playQueued = false;

      this.setEmbedCode = this.setCurrentItemEmbedCode = function(embedCode, options) {
        this._playedOnce = false;
        this.mb.publish(OO.EVENTS.SET_EMBED_CODE, embedCode, options || {});
      };

      this.play = this.playMovie = function() {
        if (!this.playbackReady) {
          this._playQueued = true;
          return;
        }
        this.mb.publish(this._playedOnce ? OO.EVENTS.PLAY : OO.EVENTS.INITIAL_PLAY);
        this._playedOnce = true;
        this._playQueued = false;
      };

      this.pause = this.pauseMovie = function() {
        this.mb.publish(OO.EVENTS.PAUSE);
      };

      this.seek = this.setPlayheadTime = function(seconds) {
        this.mb.publish(OO.EVENTS.SEEK, seconds);
      };

      this.setVolume = function(volume) {
        this.mb.publish(OO.EVENTS.CHANGE_VOLUME, volume);
      };

      this.destroy = function(callback) {
        // [PBW-459] Save optional callback to be called after DESTROY event is unblocked.
        if (callback && typeof callback === "function") {
          this.destroyCallback = callback;
        }
        this.mb.publish(OO.EVENTS.DESTROY);
      };

      this.toggleSharePanel = function() {
        this.mb.publish(OO.EVENTS.TOGGLE_SHARE_PANEL);
      };

      this.toggleInfoPanel = function() {
        this.mb.publish(OO.EVENTS.TOGGLE_INFO_PANEL);
      };

      this.shouldDisplayCuePointMarkers = function(visible) {
        this.mb.publish(OO.EVENTS.SHOULD_DISPLAY_CUE_POINTS, visible);
      }

      /* Getters */

      this.getPlayheadTime = function() {
        return this.playheadTime;
      };

      this.getLiveTime = function() {
        return new Date(this.startTime + (this.playheadTime * 1000) + this.clockOffset);
      };

      this.getDuration = this.getTotalTime = function() {
        if (this.embedCode === OO.CONSTANTS.STANDALONE_AD_HOLDER) {
          return this.adDuration;
        }
        return this.duration;
      };

      this.getBufferLength = function() {
        return this.bufferLength;
      };

      this.getItem = this.getCurrentItem = function() {
        return this.item;
      };

      this.getDescription = this.getCurrentItemDescription = function() {
        if (!this.item) { return null; }
        return this.item.description;
      };

      this.getEmbedCode = this.getCurrentItemEmbedCode = function() {
        if (!this.item) { return null; }
        return this.item.embedCode || this.item.embed_code; // it could be one or the other
      };

      this.getTitle = this.getCurrentItemTitle = function() {
        if (!this.item) { return null; }
        return this.item.title;
      };

      this.isFullscreen = this.getFullscreen = function() {
        return this.fullscreen;
      };

      this.getError = this.getErrorCode = function() {
        return this.error != null ? this.error.code : null;
      };

      this.getErrorText = function() {
        // TODO[jigish]: figure out what to do here
        // TODO[gregm]: and hook up flash player as well
        return null;
      };

      this.getState = function() {
        return this.state;
      };

      this.getVolume = function() {
        return this.volume;
      };

      this.skipAd = function() {
        this.mb.publish(OO.EVENTS.SKIP_AD);
      };

      this.getBitrateInfo = function() {
        return this.bitratesInfo;
      };

      this.getBitrateQualitiesAvailable = function() {
        return this.bitratesInfo['bitrateQualities'];
      };

      this.getBitratesAvailable = function() {
        return this.bitratesInfo['bitrates'];
      };

      this.getTargetBitrateQuality = function() {
        return this.bitratesInfo['targetBitrateQuality'];
      };

      this.getTargetBitrate = function() {
        return this.bitratesInfo['targetBitrate'];
      };

      this.setTargetBitrate = function(bitrate) {
        this.mb.publish(OO.EVENTS.SET_TARGET_BITRATE, bitrate);
      };

      this.setTargetBitrateQuality = function(bitrateQuality) {
        this.mb.publish(OO.EVENTS.SET_TARGET_BITRATE_QUALITY, bitrateQuality);
      };

      this.getCurrentItemClosedCaptionsLanguages = function() {
        // TODO[gregm]: why not working???
        return this.closedCaptionsLanguages;
      };

      this.setClosedCaptionsLanguage = function(language) {
        this.mb.publish(OO.EVENTS.SET_CLOSED_CAPTIONS_LANGUAGE, language);
      };

      this.insertCuePoint = function(type, preloadTime, duration) {
        this.mb.publish(OO.EVENTS.INSERT_CUE_POINT, type, preloadTime, duration);
      };

      this.subscribe = function(eventName, subscriber, callback) {
        this.mb.subscribe(eventName, subscriber, function() {
          var argsArray = _.toArray(arguments);
          argsArray.unshift(callback);
          _.defer.apply(this, argsArray);
        } );
      };

      // give the creator a chance to initalize itself
      if(_.isFunction(this.parameters.onCreate)) {
        this.parameters.onCreate(this);
      }

      // announce player instance was created
      this.mb.publish(OO.EVENTS.PLAYER_CREATED, this.elementId, this.parameters);

      // initiate content loading
      if (this.embedCode) {
        this.setEmbedCode(embedCode, this.parameters);
      }
    };

    // Public Player API Class Methods
    OO.exposeStaticApi('Player', {
      // Creates player object and attaches it to the provided element.
      // If embed code is specified, the player will load that embed code video (only single video is supported)
      create: function(elementId, embedCode, parameters) {
        if (OO.playerParams.platform === "flash-adset") {
          embedCode = OO.CONSTANTS.STANDALONE_AD_HOLDER;
        }

        if (typeof(window.console) != "undefined" && typeof(window.console.log) == "function") {
          console.log("V3 version: " + OO.playerParams['v3_version']);
          console.log("V3 version source: " + OO.playerParams['v3_version_source']);
        }
        // will not allow OO.players create twice for the same embedding element.
        if (!OO.players[elementId]) {
          OO.playerCount++;
          OO.players[elementId] = new OO.Player(elementId, embedCode, parameters);
        }
        return OO.players[elementId];
      },

      // Log to the Ooyala Debug Panel
      flashDebugCallback: function(msg) {
        window.postMessage({ type: "OO_LOG", text: msg }, "*");
      },

      isolate:function(targetPlayer) {
        var url = "http://debug.ooyala.com/?";

        var pbid = OO.playerParams.playerBrandingId;
        var p = null;

        if (pbid) {
          url += "pbid=" + pbid + "&";
        }

        // find the player
        var player;
        if (targetPlayer) {
          player = OO.players[targetPlayer];
        } else if (OO.playerCount > 1) {
          console.log("More than one player to choose.  Please specify the target div of the intended player as a parameter");
          console.log("Available players are: ", _.keys(OO.players));
          return _.keys(OO.players);
        } else if (OO.playerCount < 1) {
          console.log("There are no players on the page to isolate");
          return "";
        } else {
          // Get the only player available in the list
          player = _.values(OO.players)[0];
        }

        var params = JSON.stringify(player.parameters);
        var ec = player.embedCode;

        if (params) {
          url += "options=" + encodeURIComponent(params) + "&";
        }

        if (ec) {
          url += "ec=" + ec + "&";
        }

        // If this isn't local development or default, then there is a version specified
        if (OO.playerParams.environment !== "local-dev" && OO.playerParams.v3_version_source !== "default") {
          url += "version=" + OO.playerParams.v3_version + "&";
        }
        //We need to check if it is suppose to play a html5 player or not, so we check if the platform doesn't have flash in the string
        // and that if it doesn't then it is also not html5-fallback which would need to play the flash player.
        var environmentRF = OO.environmentRequiredFeatures;
        if (environmentRF.indexOf("html5-playback") > -1) {
          url += "useHtml5=true" + "&";
        }

        console.log("If you are copying this link, do not highlight. right click and press 'copy link address'");
        return url;
      },

      __placeholder : 0
    });

  }(OO, OO._, OO.$));
(function(OO, _, $){
  /*
   *  Defines a module for simulating old style callbacks
   */
  var OldCallbacksModule = function(messageBus, id) {
    this.id = id;
    this.mb = messageBus;

    this.mb.subscribe(OO.EVENTS.PLAYER_CREATED, 'old_callbacks', _.bind(this._playerWasCreated,this));

    this.mb.subscribe(OO.EVENTS.PLAYING, 'old_callbacks', _.bind(this._playing,this));

  };

  _.extend(OldCallbacksModule.prototype, {
    _playerWasCreated: function(event, elementId, params) {
      if(params.oldStyleCallbackHandler) {
        this.playerId = elementId;
      }
    },

    _fireCustomerCallback: function(playerId, eventName, params) {
      var i;

      if (!window.OOYALA_PLAYER_JS.customerCallbackName) {return;}
      try {
        var args = [playerId, eventName, params];
        var namespaces = window.OOYALA_PLAYER_JS.customerCallbackName.split(".");
        var func = namespaces.pop();
        var context = window;
        for (i = 0; i < namespaces.length; i++) {
          context = context[namespaces[i]];
        }
        if (context && typeof(context[func]) === 'function') {
          context[func].apply(this, args);
        }
      } catch (error) {
        var errorMsg = "Severe, cannot invoke function:" + error.toString();
        if (window.console && typeof window.console.log == 'function') { console.log(errorMsg); }
      }
    },

    _playing: function() {
      if(this.playerId) {
        this._fireCustomerCallback(this.playerId, 'stateChanged', {state:'playing'});
      }
    },

    __end_marker : true

  });

  OO.registerModule('old_callbacks', function(messageBus, id) {
    return new OldCallbacksModule(messageBus, id);
  });
}(OO, OO._, OO.$));
(function(OO,_,$) {
  //local constants
  var IFRAME_URL = _.template('<%=server%>/ooyala_storage.html')({ server: OO.SERVER.API });
  var DOMAIN = OO.SERVER.API;
  var IFRAME_LOAD_MESSAGE = "LOADED";
  var IFRAME_LOAD_TIMEOUT = 3000;
  var IFRAME_STATE_INIT = 0;
  var IFRAME_STATE_ERROR = 1;
  var IFRAME_STATE_READY = 2;

  var iframeState = IFRAME_STATE_INIT; //state of iframe
  var postMessageQueue = []; //messages waiting until iframe ready
  var callbacks = {}; //Store Callback functions
  var errorTimeout = null;

  //add iframe
  var iframe = document.createElement('iframe');
  iframe.style.display = "none";
  iframe.src = IFRAME_URL;

  $(document).ready(function() {
    document.body.appendChild(iframe);
    errorTimeout = setTimeout(function() {
      onIframeLoaded(IFRAME_STATE_ERROR);
    }, IFRAME_LOAD_TIMEOUT);
  });

  //add event listener
  if (window.addEventListener) {
    window.addEventListener("message", onMessage, false);
  } else if (window.attachEvent) {
    window.attachEvent("onmessage", onMessage);
  }

  function onMessage(event) {
    if (event.origin !== DOMAIN) { return; }

    //listen for loaded message
    if (event.data === IFRAME_LOAD_MESSAGE) {
      clearTimeout(errorTimeout);
      onIframeLoaded(IFRAME_STATE_READY);
      return;
    }
    var msg = null;
    try { msg = OO.JSON.parse(event.data); } catch(e) {} //do nothing, will be caught by next line

    if (!msg || !msg.callback) { return; } //result can be null

    if (callbacks[msg.callback]) {
      callbacks[msg.callback](msg.result);
      delete callbacks[msg.callback];
    }
  }

  function onIframeLoaded(state) {
    var a;
    iframeState = state;
    while((a = postMessageQueue.pop()) != undefined) {
      callPostMessage(a[0], a[1], a[2]);
    }
  }

  function callPostMessage(method, args, callback) {
    if (iframeState === IFRAME_STATE_INIT) {
      postMessageQueue.push(arguments);
      return;
    }

    if (iframeState === IFRAME_STATE_ERROR || !iframe.contentWindow.postMessage) {
      var result = OO.localStorage[method].apply(OO.localStorage, args);
      if(!!callback) {
        callback(result);
      }
    } else {
      var msg = {
        method: method,
        arguments: args,
        callback: Math.random().toString(36).substring(7) //random id
      };
      callbacks[msg.callback] = callback;
      iframe.contentWindow.postMessage(JSON.stringify(msg), DOMAIN);
    }
  }

  OO.ooyalaStorage = {
    getItem: function(key, callback) {
      callPostMessage("getItem", [key], callback);
    },
    key: function(keyId, callback) {
      callPostMessage("key", [keyId], callback);
    },
    setItem: function(key, value, callback) {
      callPostMessage("setItem", [key, value], callback);
    },
    removeItem: function(key, callback) {
      callPostMessage("removeItem", [key], callback);
    },
    hasOwnProperty: function(key, callback) {
      callPostMessage("hasOwnProperty", [key], callback);
    }
  };
  if (!!OO.TEST_TEST_TEST) {
    OO.ooyalaStorage._getIframeState = function() {
      return iframeState;
    };
  }
}(OO, OO._, OO.$));
(function(OO,_,$) {
  callbackQueue = [];
  OO.GUID = undefined;

  OO.ooyalaStorage.getItem("ooyala_guid", _.bind(function(value) {
    if (value) {
      OO.GUID = value;
    } else {
      OO.GUID = generateDeviceId();
      OO.ooyalaStorage.setItem("ooyala_guid", OO.GUID);
    }
    while((callback = callbackQueue.pop()) != undefined) {
      callback(OO.GUID);
    }
  }), this);

  OO.publicApi.getGuid = OO.getGuid = function(callback) {
    if (OO.GUID) {
      if (typeof callback === "function") {
        try {
          callback(OO.GUID);
        } catch (e) {
          //do nothing on error
        }
      }
    } else {
      callbackQueue.push(callback);
    }
  };

  generateDeviceId = function() {
    var randomString = (new Date().getTime()) + window.navigator.userAgent + Math.random().toString(16).split(".")[1];
    return new OO.jsSHA(randomString, 'ASCII').getHash('SHA-256', 'B64');
  };

  OO.plugin("DeviceId", function(OO, _, $, W) {
    return function(mb, id) {
      mb.subscribe(OO.EVENTS.PLAYER_CREATED, "DeviceId", function() {
        OO.publicApi.getGuid(function(guid) {
          mb.publish(OO.EVENTS.GUID_SET, guid);
        });
      });
    };
  });

}(OO, OO._, OO.$));
(function(OO, $, _){
  /*
   *  Defines a basic chromeless UI
   */
  var ChromelessUi = function(messageBus, id) {
    this.id = id;
    this.mb = messageBus;
    this.resizeTimer = null;
    this.width = 0;
    this.height = 0;
    this.useCustomControls = !OO.uiParadigm.match(/mobile/);
    this.useNativeControls = !!OO.uiParadigm.match(/native/);

    OO.StateMachine.create({
      initial:'Init',
      messageBus:this.mb,
      moduleName:'ChromelessUi',
      target:this,
      events:[
        {name:OO.EVENTS.PLAYER_CREATED,         from:'Init',        to:'PlayerCreated'},
        {name:OO.EVENTS.EMBED_CODE_CHANGED,     from:'*'},
        {name:OO.EVENTS.ERROR,                  from:'*'},
        {name:OO.EVENTS.PLAY,                   from:'*'},
        {name:OO.EVENTS.WILL_CHANGE_FULLSCREEN, from:'*'},
        {name:OO.EVENTS.FULLSCREEN_CHANGED,     from:'*'},
        {name:OO.EVENTS.STREAM_PLAYING,         from:'*'},
        {name:OO.EVENTS.INITIAL_PLAY,           from:'*'},
        {name:OO.EVENTS.WILL_PLAY_ADS,          from:'*'},
        {name:OO.EVENTS.PLAY_MIDROLL_STREAM,    from:'*'},
        {name:OO.EVENTS.PLAYING,                from:'*'},
        ]
    });
  };

  _.extend(ChromelessUi.prototype, {
    onPlayerCreated: function(event, elementId, params) {
      this.elementId = elementId;
      this.topMostElement = $('#'+this.elementId);
      this.topMostElement.append('<div class="innerWrapper"></div>');
      this.rootElement = this.topMostElement.find("div.innerWrapper");
      this.params = params;

      var topMostWidth = this.topMostElement.width();
      var topMostHeight = this.topMostElement.height();

      if (topMostWidth == 0 || topMostHeight == 0) {
        this.topMostElement.css({width: '100%', height: '100%'});
      }

      // add root container css:
      var width = params.width || '100%';
      var height = params.height || '100%';

      if(_.isNumber(width)) {
        width = width + 'px';
      }

      if(_.isNumber(height)) {
        height = height + 'px';
      }

      var rootCss = _.template(OO.get_css("root"))({

        errorIcon : OO.get_img_base64('icon_error'),
        elementId : this.elementId
      }).replace("width:0;", "width:" + width + ';').replace("height:0;", "height:" + height + ';');

      OO.attachStyle(rootCss,this.elementId);


      //error screen UI
      this.rootElement.append('<div class="oo_error" style="display:none"></div>');
      this.errorUi = new _ErrorUi(this.rootElement.find('div.oo_error'));

      // plugins placeholder, don't create it for Flash playback
      if (!OO.requiredInEnvironment("flash-playback")) {
        this.rootElement.append("<div class='plugins' style='display:none'></div>");
      }

      // bind UI events.
      var fullscreenEvents = ["fullscreenchange", "webkitfullscreenchange"];
      var onBrowserOriginatedFullscreenChange = _.bind(this._onBrowserOriginatedFullscreenChange, this);
      var rootElement = this.rootElement;
      _.each(fullscreenEvents, function(e) { rootElement.on(e, onBrowserOriginatedFullscreenChange); });
      // https://developer.mozilla.org/en/DOM/Using_full-screen_mode
      // Mozilla is dispatching the fullscreen event to the document object instead of the dom object that
      // change to full screen.
      // TODO, keep an eye on the doc if they change the notification to the dom element instead.
      $(document).on("mozfullscreenchange", onBrowserOriginatedFullscreenChange);
      document.onwebkitfullscreenchange = onBrowserOriginatedFullscreenChange;
      //$(document).on("webkitfullscreenchange", onBrowserOriginatedFullscreenChange);
      rootElement.resize(_.bind(this._onResize, this));
      $(document).resize(_.bind(this._onResize, this));
      $(window).resize(_.bind(this._onResize, this));

      // BeforeUnload Event
      $(window).on("beforeunload", _.bind(this._onBeforeUnload, this));
    },

    onEmbedCodeChanged: function(event, embedCode) {
      this.errorUi.hide();
      if (!OO.isIos && !this.useNativeControls) {
        this.rootElement.find('div.plugins').hide();
      }
    },

    onError: function(event, error) {
      if(error && error.source != 'flash') {  // don't show empty errors or flash errors
        this.mb.publish(OO.EVENTS.PAUSE);
        this.errorUi.show(error);
      }
    },

    onStreamPlaying: function(event) {
      if (this.errorUi) { this.errorUi.hide(); }
      this._updatePlayingUi();
    },

    _isFullscreen: function() {
      if (this.rootElement.hasClass("fullscreen")) { return true; }
      var isFullscreen = document.fullscreen || document.mozFullScreen || document.webkitIsFullScreen || document.webkitDisplayingFullscreen;
      return !!isFullscreen;
    },

    _onBrowserOriginatedFullscreenChange: function() {
      OO.d('Fullscreen Changed',this._isFullscreen());
      this.mb.publish(OO.EVENTS.SIZE_CHANGED, this.rootElement.width(), this.rootElement.height());
      this.mb.publish(OO.EVENTS.FULLSCREEN_CHANGED, this._isFullscreen());
    },

    onFullscreenChanged: function(event, isFullscreen) {
      if(isFullscreen) {
        // increase the z-index of the player before going to fullscreen, to make sure it won't be behind other players
        // some browsers unfortunately show through elements with higher z-index even when in fullscreen mode
        this.originalZ = this.rootElement.css('z-index');
        this.rootElement.css('z-index', this.originalZ + 1000);
        this.rootElement.css('overflow','visible');
      } else {
        // reset the z-index of the player before exiting fullscreen, to make sure it is back to same level as other players
        // some browsers unfortunately show through elements with higher z-index even when in fullscreen mode
        this.rootElement.css('z-index', "");

        if (!OO.isIos && !!OO.uiParadigm.match(/native/) && !OO.uiParadigm.match(/mobile/)) {
          this.rootElement.find('div.plugins').hide();
        }
      }
    },

    _onResize: function() {
      if(this.resizeTimer) {
        clearTimeout(this.resizeTimer);
      }
      this.resizeTimer = _.delay(_.bind(function() {
        if (this.width != this.rootElement.width() && this.height != this.rootElement.height()) {
          this.width = this.rootElement.width();
          this.height = this.rootElement.height();
          this.mb.publish(OO.EVENTS.SIZE_CHANGED, this.width, this.height);
        }
      }, this), 100);
    },

    onPlay: function() {
      if(!this.useCustomControls && !this.useNativeControls) {
        this.mb.publish(OO.EVENTS.WILL_CHANGE_FULLSCREEN, true);
      }
    },

    onWillChangeFullscreen: function(event, shouldEnterFullscreen) {
      if (!this.useNativeControls && !this.useCustomControls) { return; }
      if (shouldEnterFullscreen) {
        this._showFullscreen();
      } else {
        this._hideFullscreen();
      }
    },

    onInitialPlay: function() {
      if (!OO.isIos && !this.useNativeControls) {
        this.rootElement.find('div.plugins').show();
      }
    },

    onWillPlayAds: function() {
      this._updatePlayingUi();
    },

    onPlayMidrollStream: function() {
      this._updatePlayingUi();
    },

    onPlaying: function() {
      this._updatePlayingUi();
    },

    _getActiveVideo: function() {
      var mainVideo = this.rootElement.find("video.video");
      var midrollVideo = this.rootElement.find("video.midroll");
      var activeVideo = mainVideo.get(0);
      var pluginVideo = this.rootElement.find("div.plugins video").get(0);
      if ( this._isVideoDomVisible("video.midroll") ) {
         activeVideo = midrollVideo.get(0);
      } else if ( pluginVideo && !this._isVideoDomVisible("video.video") ) {
         activeVideo = pluginVideo;
      }
      return activeVideo;
    },

    _showFullscreen: function() {
      var el = this.rootElement[0];
      var activeVideo = this._getActiveVideo();
      var fullscreenApi = el.requestFullScreen || el.requestFullscreen || el.mozRequestFullScreen ||
            el.webkitRequestFullScreen || el.msRequestFullScreen;
      if ((!fullscreenApi || (OO.isAndroid && !OO.isChrome)) && activeVideo && activeVideo.webkitEnterFullscreen) {
        // this uglyness is cause mobile chrome on android claims to support full screen on divs (next method), but doesn't actually work
        // however we still prefer to use div fullscreen on anything else so we only try this if android is detected
        // update: Chrome on Android looks to properly support the fullscreen API for divs, so now we check
        // specifically for the native browser which still does not.
        activeVideo.isFullScreenMode = true;
        activeVideo.webkitEnterFullscreen();
      } else if (fullscreenApi) {
        $(activeVideo).css("background-color","black");
        fullscreenApi.call(el);
      } else {
        this.rootElement.addClass("fullscreen");
      }
      this.mb.publish(OO.EVENTS.FULLSCREEN_CHANGED, true);
    },

    _hideFullscreen: function() {
      var activeVideo = this._getActiveVideo();
      if (document.cancelFullScreen) {
        document.cancelFullScreen();
      } else if (document.mozCancelFullScreen) {
        document.mozCancelFullScreen();
      } else if (document.webkitCancelFullScreen) {
        document.webkitCancelFullScreen();
      } else if (activeVideo && activeVideo.webkitExitFullscreen) {
        activeVideo.isFullScreenMode = false;
        activeVideo.webkitExitFullscreen();
      } else {
        this.rootElement.removeClass("fullscreen");
      }

      $(activeVideo).css("background-color","");
      this.mb.publish(OO.EVENTS.FULLSCREEN_CHANGED, false);
    },

    _isVideoDomVisible: function(domSelector) {
       return (this.rootElement.find(domSelector).css("left") == OO.CSS.VISIBLE_POSITION);
    },

    _onBeforeUnload: function(event) {
      // A still user-cancellable page unload request has been made.
      this.mb.publish(OO.EVENTS.PAGE_UNLOAD_REQUESTED, true);
    },

    _updatePlayingUi: function() {
      if (!OO.isIos) {
        this.rootElement.find('div.plugins').show();
      }
    },

    __placeholder: true
  });

    var _ErrorUi = function(container) {
      this.container = container;
      this.container.append('<div class="oo_error_image"></div>');
      this.container.append('<div class="oo_error_message"><h1 class="oo_error_message_text"></h1></div>');
    };

    _.extend(_ErrorUi.prototype, {
      show: function(error) {
        this.container.find('h1.oo_error_message_text').html(OO.getLocalizedMessage(error.code));
        this.container.show();
      },
      hide: function() {
        this.container.hide();
      }
    });
  OO.registerModule('chromeless_ui', function(messageBus, id) {
    return new ChromelessUi(messageBus, id);
  });
}(OO, OO.$, OO._));
  (function(OO, _, $) {
    /*
     *  Defines the wrapper of video element on the page, reduce the different state introduced by different browser
     *  to a finate state that our PlayBack module cares about.
     * Reference page:
     * http://www.w3.org/TR/html5/the-iframe-element.html#the-video-element
     * http://www.w3schools.com/html5/html5_ref_av_dom.asp
     * http://www.chipwreck.de/blog/2010/03/01/html-5-video-dom-attributes-and-events/
     * http://developer.apple.com/library/safari/#documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Introduction/Introduction.html
     */
    OO.VideoElementWrapper = OO.inherit(OO.Emitter, function(video) {
      this._video = video; // video is the dom object of video tag on the page.
      this._readyToPlay = true;
      this._playQueued = false;
      this.canAccessBufferAttribute = true;
      this.Id = OO.getRandomString();
      this.isM3u8 = false;
      this.videoEnded = false;
      this.isPlaying = false;
      this._currentUrl = '';
      this._emitErrors = true;
      this._emitErrorsTimer = null;
      this._unemittedErrors = [];
    });

    _.extend(OO.VideoElementWrapper, {
      FULL_SCREEN_CHANGED: 'fullScreenChanged',
      WILL_PLAY: 'willPlay',
      PLAYING: 'playing',
      PAUSED: 'paused',
      SEEKING: 'seeking',
      SEEKED: 'seeked',
      BUFFERING: 'buffering',
      BUFFERED: 'buffered',
      ERROR: 'error',
      PLAYHEAD_TIME_CHANGED: 'playheadTimeChanged',
      PLAYED: 'played',
      VOLUME_CHANGED: 'volumeChanged',
      DURACTION_CHANGED: 'durationChanged',
      PLAY_NEXT: 'playNext',
      DOWNLOADING: 'downloading',
      __placeholder:true
    });

    _.extend(OO.VideoElementWrapper.prototype, {
      setup: function() {
        var events = {
          "loadstart": _.bind(this.onLoadStart, this), // Browser starts loading data
          "progress": _.bind(this.onProgress, this), // Browser loads data
          "suspend": _.bind(this.onSuspend, this), // Browser does not load data, waiting
          "abort": _.bind(this.onAbort, this), // Data loading was aborted
          "error": _.bind(this.onError, this), // An error occured
          "emptied": _.bind(this.onEmptied, this), // Data not present unexpectedly
          "stalled": _.bind(this.onStalled, this), // Data transfer stalled
          "play": _.bind(this.onPlay, this), // Video started playing (fired with play())
          "pause": _.bind(this.onPause, this), // Video has paused (fired with pause())
          "loadedmetadata": _.bind(this.onLoadedMetaData, this), // Metadata loaded
          "loadeddata": _.bind(this.onLoadedData, this), // Data loaded
          "waiting": _.bind(this.onWaiting, this), // Waiting for more data
          "playing": _.bind(this.onPlaying, this), // Playback started
          "canplay": _.bind(this.onCanPlay, this), // Video can be played, but possibly must stop to buffer content
          "canplaythrough": _.bind(this.onCanPlayThrough, this), // Enough data to play the whole video
          "seeking": _.bind(this.onSeeking, this), // seeking is true (browser seeks a position)
          "seeked": _.bind(this.onSeeked, this), // seeking is now false (position found)
          "timeupdate": _.bind(this.onTimeUpdate, this), // currentTime was changed
          "ended": _.bind(this.onEnded, this), // Video has ended
          "ratechange": _.bind(this.onRateChange, this), // Playback rate has changed
          "durationchange": _.bind(this.onDurationChange, this), // Duration has changed (for streams)
          "volumechange": _.bind(this.onVolumeChange, this), // Volume has changed
          "volumechangeNew": _.bind(this.onVolumeChange, this), // Volume has changed
          "webkitbeginfullscreen": _.bind(this.onFullScreenBegin, this), // ios webkit browser fullscreen event
          "webkitendfullscreen": _.bind(this.onFullScreenEnd, this), // ios webkit browser fullscreen event
          "webkitfullscreenchange": _.bind(this.onFullScreenChange, this) // webkit browser fullscreen event
        };
        _.each(events, function(v, i) { $(this._video).on(i, v); }, this);
      },

      /*   Public getter function */

      setEmbedCode: function(embedCode) {}, // no-op for html 5 video

      getIsActive: function() {
        return $(this._video).css("left") == "0px";
      },

      getStreamUrl: function() {
        return this._currentUrl;
      },

      getVolume: function() {
        return this._video.volume;
      },

      getCurrentTime: function() {
        return this._video.currentTime;
      },

      getSeekableRange: function() {
        return OO.safeSeekRange(this._video.seekable); // in seconds;
      },

      getDuration: function() {
        if (this._video.duration === Infinity || isNaN(this._video.duration)) {
          // TODO, if we can not extract duration, we should use the value from the movie table
          // for vast ads, use the value in the duration field.
          return 0;
        }
        return this._video.duration; // in seconds;
      },

      getBuffer: function() {
        if (this._video.buffered && this._video.buffered.length > 0) {
          return this._video.buffered.end(0); // in sec;
        }
        return  0;
      },

      getOriginVideoWidth: function() {
        return this._video.videoWidth;
      },

      getOriginVideoHeight: function() {
        return this._video.videoHeight;
      },

      hasBrowserDefaultControl: function() {
        return this._video.controls;
      },

      /******* Start public method ******/

      setPosterUrl: function(url) {
        this._video.poster = url; // thumbnail image on start screen.
      },

      // Allow for the video src to be changed without loading the video
      // @param url: the new url to insert into the video element's src attribute
      setVideoUrl: function(url) {
        // check if we actually need to change the URL on video tag
        // compare URLs but make sure to strip out the trailing cache buster
        var urlChanged = false;
        if (this._currentUrl.replace(/[\?\&]_=[^&]+$/,'') != url) {
          this._currentUrl = url || "";

          // bust the chrome stupid caching bug
          if(this._currentUrl.length > 0 && OO.isChrome) {
            this._currentUrl = this._currentUrl + (/\?/.test(this._currentUrl) ? "&" : "?") +"_="+OO.getRandomString();
          }

          this.isM3u8 = (this._currentUrl.toLowerCase().indexOf("m3u8") > 0);
          this._readyToPlay = false;
          urlChanged = true;
          this._video.src = this._currentUrl;
        }

        if(_.isEmpty(url)) {
          this.trigger(OO.VideoElementWrapper.ERROR, 0); //0 -> no stream
        }
        return urlChanged;
      },

      load: function(rewind) {
        if(!!rewind) {
          try {
            this._video.currentTime = 0;
            this._video.pause();
          } catch (ex) {
            // error because currentTime does not exist because stream hasn't been retrieved yet
            OO.log('Failed to rewind video, probably ok');
          }
        }
        this._video.load();
      },

      reload: function() {
        this._video.load();
      },

      play: function() {
        this._video.play();
        this.isPlaying = true;
      },

      pause: function() {
        this._playQueued = false;
        this._video.pause();
        this.isPlaying = false;
      },

      safeSeekTime: function(time) {
        var safeTime = time >= this._video.duration ? this._video.duration - 0.01 : (time < 0 ? 0 : time);
        // iPad with 6.1 has an intersting bug that causes the video to break if seeking exactly to zero
        if(OO.isIpad && safeTime < 0.1) { safeTime = 0.1; }
        return safeTime;
      },

      canSeekToTime: function(time) {
        var range = this.getSeekableRange();
        if (range.start === 0 && range.end === 0) { return false; }
        var safeTime = this.safeSeekTime(time);
        if (range.start <= safeTime && range.end >= safeTime) { return true; }
        return false;
      },

      seek: function(time) {
        if (this.canSeekToTime(time)) {
          this._video.currentTime = this.safeSeekTime(time);
          return true;
        }
        this.queueSeek(time);
        return false;
      },

      queueSeek: function(time) {
        this.queuedSeekTime = time;
      },

      dequeueSeek: function() {
        if (this.queuedSeekTime === undefined) { return; }
        if (this.seek(this.queuedSeekTime)) { this.queuedSeekTime = undefined; }
      },

      setVolume: function(value) {
        if (typeof(value) !== "number" || value < 0 || value > 1) {
          OO.d("can not assign volume with invalid value", value);
          return;
        }
        //  TODO check if we need to capture any exception here. ios device will not allow volume set.
        this._video.volume = value;
      },

      delayErrorPublishing: function(e) {
        OO.d(e);
        // User-cancellable event beforeUnload has been dispatched to window.
        // Prevent errors to be dispatched due to the video element being destroyed.
        this._emitErrors = false;
        // Clear previous timeout in case the user selected "stay" and then
        // navigated away again, otherwise the error may get emitted on low bandwidth.
        clearTimeout(this._emitErrorsTimer);
        this._emitErrorsTimer = null;
        // Restore error dispatching after a timeout.
        _.delay(_.bind(function() {
          // This will happen after the user clicks on "leave" or "stay" in case
          // the embedding webpage adds another listener which gives the option.
          this._emitErrorsTimer = _.delay(_.bind(function() {
            // After 5 seconds it is assumed the user stayed on the page.
            // Any errors that occurred after selecting to "stay" and before
            // the time limit are dispatched.
            this._emitErrors = true;
            _.each(this._unemittedErrors, function(e) {
              this._emitError(e.error , e.code);
            });
            this._unemittedErrors.length = 0;
          }, this), 5000);
        }, this), 1);
      },

      onLoadStart: function(e) {
        OO.d(e.type, this._video.src);
        this._currentUrl = this._video.src;
      },

      onProgress: function(e) {
        OO.d(e.type);
        this.trigger(OO.VideoElementWrapper.DOWNLOADING);
      },

      onSuspend: function(e) {
        OO.d(e.type);
      },

      onAbort: function(e) {
        OO.d(e.type, this._currentUrl);
      },

      // HTML5 Media Error Constants:
      // MediaError.MEDIA_ERR_ABORTED = 1
      // MediaError.MEDIA_ERR_NETWORK = 2
      // MediaError.MEDIA_ERR_DECODE = 3
      // MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED = 4
      // MediaError.MEDIA_ERR_ENCRYPTED = 5 (Chrome only)
      // Ooyala Extensions:
      // NO_STREAM = 0
      // UNKNOWN = -1
      onError: function(e) {
        var code = this._video.error ? this._video.error.code : -1;
        if (this._emitErrors) {
          this._emitError(e, code);
        } else {
          // The error occurred when the page was probably unloading.
          // Happens more often on low bandwith.
          OO.d("Error not emitted: " + e.type);
          this._unemittedErrors.push({error : e, code : code});
          this.mb.publish(OO.EVENTS.PAGE_PROBABLY_UNLOADING);
        }
      },

      onEmptied: function(e) {
        OO.d(e.type);
      },

      onStalled: function(e) {
        OO.d(e.type);
        // Fix multiple video tag error in iPad
        if (OO.isIpad && this._video.currentTime === 0) {
          this._video.pause();
        }
      },

      onPlay: function(e) {
        OO.d(e.type);
        this.trigger(OO.VideoElementWrapper.WILL_PLAY);
      },

      onPause: function(e) {
        OO.d(e.type, {paused: this._video.paused, ended: this._video.ended});
        this.trigger(OO.VideoElementWrapper.PAUSED);
        this.isPlaying = true;
      },

      onLoadedMetaData: function(e) {
        OO.d(e.type);
      },

      onLoadedData: function(e) {
        OO.d(e.type);
      },

      onWaiting: function(e) {
        OO.d(e.type);
        this.trigger(OO.VideoElementWrapper.BUFFERING);
      },

      onPlaying: function(e) {
        OO.d(e.type);
        this._playQueued = false;
        this.videoEnded = false;
        this.isPlaying = true;
        this.trigger(OO.VideoElementWrapper.PLAYING);
      },

      onCanPlay: function(e) {
        OO.d(e.type, this._video.readyState);
      },

      onCanPlayThrough: function(e) {
        this.trigger(OO.VideoElementWrapper.BUFFERED);
        OO.d(e.type, this._video.readyState);
      },

      onSeeking: function(e) {
        OO.d(e.type);
        this.trigger(OO.VideoElementWrapper.SEEKING);
      },

      onSeeked: function(e) {
        OO.d(e.type);
        this.trigger(OO.VideoElementWrapper.SEEKED);
      },

      onTimeUpdate: function(e) {
        this.trigger(OO.VideoElementWrapper.PLAYHEAD_TIME_CHANGED);
        // NOTE[jigish]: iOS has issues seeking so if we queue a seek handle it here
        this.dequeueSeek();
        // This is a hack fix for m3u8, current iOS has a bug that if the m3u8 EXTINF indication a different
        // duration, the ended event never got dispatched. Monkey patch here to manual trigger a onEnded event
        // need to wait OTS to fix their end.
        var duration = this.getDuration();
        var durationInt = Math.floor(duration);
        if (this.isM3u8 && this.getCurrentTime() == duration && duration > durationInt) {
          OO.log("manually triggering end", this._currentUrl, duration, this.getCurrentTime());
          _.delay(_.bind(this.onEnded, this), 0, e);
        }
      },

      onEnded: function(e) {
        OO.d(e.type);
        if (this.videoEnded) { return; } // no double firing ended event.
        this.videoEnded = true;

        this.trigger(OO.VideoElementWrapper.PLAYED);
        this.trigger(OO.VideoElementWrapper.PLAY_NEXT);
      },

      onRateChange: function(e) {
        OO.d(e.type);
      },

      onDurationChange: function(e) {
        OO.d(e.type);
        this.trigger(OO.VideoElementWrapper.DURATION_CHANGED);
      },

      onVolumeChange: function(e) {
        OO.d(e.type);
        this.trigger(OO.VideoElementWrapper.VOLUME_CHANGED);
      },

      onFullScreenChange: function(e) {
        OO.d(e.type);
      },

      onFullScreenBegin: function(e) {
        OO.d(e.type);
        this.trigger(OO.VideoElementWrapper.FULL_SCREEN_CHANGED, true);
      },
      onFullScreenEnd: function(e) {
        OO.d(e.type);
        this.trigger(OO.VideoElementWrapper.FULL_SCREEN_CHANGED, false, this._video.paused);
      },

      show: function(visible) {
        $(this._video).css('left', visible ? OO.CSS.VISIBLE_POSITION : OO.CSS.INVISIBLE_POSITION);
      },

      _emitError: function(error, errorCode) {
          OO.d(error.type);
          this.trigger(OO.VideoElementWrapper.ERROR, errorCode);
      },

      _asyncTriggerEvent: function(eventName) {
        _.delay(_.bind(function(){ this.trigger(eventName); }, this), 0);
      },

      kill: function() {
        this.pause();
        this._video.src = '';
      },

      __placeholder: true
    });


  }(OO, OO._, OO.$));
  (function(OO, _, $){
    OO.createVideoElementWrapper = function(parentContainer, className, params) {
      var wrapper = null;
      OO.d("Using HTML5 Playback");
      var v = $("<video>");
      v.attr("class", className);

      // NOTE(neeraj): add preload=none to video dom element to prevent automatic fetching of video stream
      // we manually force a preload in _preloadStream
      v.attr("preload", "none");

      // enable airplay for ios.
      // http://developer.apple.com/library/safari/#documentation/AudioVideo/Conceptual/AirPlayGuide/OptingInorOutofAirPlay/OptingInorOutofAirPlay.html
      if (OO.isIos) {
        v.attr("x-webkit-airplay", "allow");
      }
      parentContainer.append(v);
      wrapper = new OO.VideoElementWrapper(v[0]);
      wrapper.setup();
      return wrapper;
    };


  }(OO, OO._, OO.$));
  (function(OO,_,$){
    /*
     *  Defines the playback controller
     */
    var PlaybackControlModule = function(messageBus, id) {
      if (!OO.requiredInEnvironment('html5-playback') && !OO.requiredInEnvironment('cast-playback')) { return; }

      this.mb = messageBus;
      this.id = id;
      this.inlineAds = [];
      this.waitForPlaybackReady = true;
      this.isInlineAdsPlaying = false;
      this.currentMainVideoPlayhead = 0;
      this.skipPrerollAdsCheck = false;
      this.userRequest = '';
      this.playedAtLeastOnce = false;
      this.adsManagerHandlingAds = false;
      this.playInFlight = false;

      OO.StateMachine.create({
        initial:'Init',
        messageBus:this.mb,
        moduleName:'PlaybackControl',
        target:this,
        events:[
          {name:OO.EVENTS.PLAYER_CREATED,                     from:'*'},
          {name:OO.EVENTS.EMBED_CODE_CHANGED,                 from:'*',                                                                to:'WaitingForApiResponse'},
          {name:OO.EVENTS.CONTENT_TREE_FETCHED,               from:'WaitingForApiResponse'},
          {name:OO.EVENTS.METADATA_FETCHED,                   from:'WaitingForApiResponse'},
          {name:OO.EVENTS.AUTHORIZATION_FETCHED,              from:['WaitingForApiResponse', 'PlaybackReady']},
          {name:OO.EVENTS.AD_AUTHORIZATION_FETCHED,           from:'*'},
          {name:OO.EVENTS.PLAYBACK_READY,                     from:'WaitingForApiResponse',                                            to:'PlaybackReady'},
          {name:OO.EVENTS.INITIAL_PLAY,                       from:'*',                                                                to:'*'},
          {name:OO.EVENTS.PLAY,                               from:'*',                                                                to:'PlayRequested'},
          {name:OO.EVENTS.PLAY_STREAM,                        from:['PlaybackReady', 'Paused', 'SwitchingStreams', 'PauseRequested'],  to:'PlayingState'},
          {name:OO.EVENTS.PAUSE,                              from:['PlayingState', 'PlayRequested', 'PlaybackReady'],                      to:'PauseRequested'},
          {name:OO.EVENTS.PAUSE_STREAM,                       from:['PlayingState', 'PlayRequested'],                                       to:'Paused'},
          {name:OO.EVENTS.PAUSED,                             from:['PlayingState', 'PlayRequested', 'PauseRequested'],                     to:'Paused'},
          {name:OO.EVENTS.STREAM_PAUSED,                      from:['PlayingState', 'PlayRequested', 'PauseRequested'],                     to:'Paused'},
          {name:OO.EVENTS.PLAYING,                            from:['Paused', 'PlayRequested', 'PauseRequested'],                      to:'PlayingState'},
          {name:OO.EVENTS.STREAM_PLAYING,                     from:['Paused', 'PlayRequested', 'PauseRequested', 'PlayingState','SwitchingStreams'],           to:'PlayingState'},
          {name:OO.EVENTS.STREAM_PLAYED,                      from:['PlayingState','Paused'],                                               to:'SwitchingStreams'},
          {name:OO.EVENTS.PLAYED,                             from:'SwitchingStreams',                                                 to:'PlaybackReady'},
          {name:OO.EVENTS.STREAM_PLAY_FAILED,                 from:'*'},
          {name:OO.EVENTS.WILL_PLAY_STREAM,                   from:['PlaybackReady', 'Paused', 'PlayRequested']},
          {name:OO.EVENTS.SEEK,                               from:['PlaybackReady', 'Paused', 'PlayingState', 'PlayRequested']},
          {name:OO.EVENTS.PLAYHEAD_TIME_CHANGED,              from:'*'},

          // TODO, following events are ads related, we need to determine if we need to introduce new state for those events.
          {name:OO.EVENTS.WILL_FETCH_ADS,                     from:"*"},
          {name:OO.EVENTS.AD_CONFIG_READY,                    from:"*"},
          {name:OO.EVENTS.WILL_PLAY_ADS,                      from:"*"},
          {name:OO.EVENTS.ADS_PLAYED,                         from:"*"},
          {name:OO.EVENTS.ADS_ERROR,                          from:"*"},
          {name:OO.EVENTS.PLAY_MIDROLL_STREAM,                from:"*"},
          {name:OO.EVENTS.MIDROLL_PLAY_FAILED,                from:"*"},
          {name:OO.EVENTS.MIDROLL_STREAM_PLAYED,              from:"*"},
          {name:OO.EVENTS.USE_SERVER_SIDE_HLS_ADS,            from:"*"},
          {name:OO.EVENTS.ADS_MANAGER_HANDLING_ADS,           from:"*"},
          {name:OO.EVENTS.ADS_MANAGER_FINISHED_ADS,           from:"*"}
        ]
      });
    };

    _.extend(PlaybackControlModule.prototype, {
      onPlayerCreated: function(event, elementId, params) {
        this.parameters = params;
      },

      onPlayed: function(event) {
        this.onPlaybackReady(); // re-initiate the playback ready for replay.
      },

      onWillPlayAds: function(event) {
        this.isInlineAdsPlaying = true;
      },

      onAdsPlayed: function(event) {
        this.isInlineAdsPlaying = false;
      },

      onAdsError: function(event) {
        this.isInlineAdsPlaying = false;
      },

      onPlayMidrollStream: function(event) {
        this.isInlineAdsPlaying = true;
      },

      onMidrollStreamPlayed: function(event, mainVideoPlayhead) {
        this.isInlineAdsPlaying = false;
        var previousMidroll = this.currentMidrollAdItem;
        var hadMidroll = this._checkAndPlayReadyMidrolls(mainVideoPlayhead);
        // resume
        if (!hadMidroll) {
          this.mb.publish(OO.EVENTS.ADS_PLAYED, previousMidroll.item);
          this.mb.publish(OO.EVENTS.WILL_RESUME_MAIN_VIDEO);
        }
      },

      onEmbedCodeChanged: function(event, embedCode) {
        //reset data
        this.contentTree = null;
        this.metadata = null;
        this.authorization = null;
        this.currentItem = null;
        this.inlineAds = [];
        this.prerolls = [];
        this.midrolls = [];
        this.postrolls = [];
        this.inlineAdsItems = [];
        this.mainVideoItem = null;
        this.waitForPlaybackReady = true;
        this.movieIndex = -1; // offset to the prerolls.
        this.currentMidrollAdItem = null;
        this.skipPrerollAdsCheck = false;
        this.userRequest = '';
        this.playedAtLeastOnce = false;
        this.useStitchedAds = false;
        this.playInFlight = false;
        this.lastMidrollPlayhead = -1;
      },

      onContentTreeFetched:function(event, response) {
        this.contentTree = response;
        if (this.parameters && this.parameters.vastAds) {
          this.contentTree.ads = this.parameters.vastAds;
        }
        // TODO, filter out non-linear ads here.
        // need to make non-linear ads into a seperate array.
        if (OO.requiredInEnvironment('ads') && !this.useStitchedAds && this.contentTree.ads) {
          this.inlineAds = this.contentTree.ads;
        }
        else {
          this.inlineAds = [];
        }

        this.inlineAdsItems = _.map(this.inlineAds, function(ad, index) {
          return { type: 'ad', index: index, item: ad };
        }, this);
        this.prerolls = _.select(this.inlineAdsItems, _.bind(this._isPreRollAd, this), this);
        if (OO.supportMidRollAds) {
          this.midrolls = _.select(this.inlineAdsItems, _.bind(this._isMidRollAd, this), this);
        } else { this.midrolls = []; }
        this.postrolls = _.select(this.inlineAdsItems, _.bind(this._isPostRollAd, this), this);

        this.movieIndex = (_.size(this.postrolls) > 0) ? this.postrolls[0].index - 1 : _.size(this.inlineAds);

        this.mainVideoItem = {type: 'movie', index: this.movieIndex, item: this.authorization};

        // assign index for each ads.
        if (_.size(this.inlineAds) > 0) {
          // TODO, add a time out here to make sure we are not blocked by a failed ads fetch.
          OO.d("start a timer to fetch initial ads", OO.playerParams.maxAdsTimeout);
          _.delay(_.bind(this._onFetchPrerollTimeOut, this), OO.playerParams.maxAdsTimeout * 1000);
        }
        this._checkPlaybackReady();
        // AdsManager will intercept this event to fetch ads config.
        this.mb.publish(OO.EVENTS.WILL_FETCH_ADS, null);
      },

      _onFetchPrerollTimeOut: function() {
        // false playbackready here:
        OO.d("Timeout of fetching pre-roll ads.");
        this.skipPrerollAdsCheck = true;
        if (this.waitForPlaybackReady) { this._checkPlaybackReady(); }

        this.mb.publish(OO.EVENTS.AD_FETCH_FAILED, null);
      },

      onAdConfigReady: function(event, inlineAd) {
        if (inlineAd && inlineAd.vastAdUnit) {
          _.each(this.inlineAds, function(ad, index) {
            if (ad.type == "vast" && !_.isEmpty(ad.url) && ad.url === inlineAd.vastUrl) {
              _.extend(ad, inlineAd.vastAdUnit);
            }
          }, this);
        }
        this._checkPlaybackReady();
      },

      onWillFetchAds: function(event) {
        // if on one intercept 'willFetchAds', will instantanly fire playback ready.
        this.skipPrerollAdsCheck = true;
        this._checkPlaybackReady();
      },

      onMetadataFetched:function(event, response) {
        this.metadata = response;
        this._checkPlaybackReady();
      },

      onUseServerSideHlsAds: function(event, useStitchedAds) {
        this.useStitchedAds = useStitchedAds;
        if (this.useStitchedAds) {
          this.inlineAds = this.prerolls = this.midrolls = this.postrolls = [];
        }
      },

      onAuthorizationFetched:function(event, response) {
        this.authorization = response;
        this.mainVideoItem = {type: 'movie', index: this.movieIndex, item: this.authorization};
        this._checkPlaybackReady();
      },

      onAdAuthorizationFetched: function(event, response) {
        _.each(this.inlineAds, function(ad, index) {
          var authForEmbed = (ad.ad_embed_code) ? response[ad.ad_embed_code] : null;
          if (authForEmbed) {
            _.extend(ad, authForEmbed);
          }
        }, this);
        this._checkPlaybackReady();
      },

      onAdsManagerHandlingAds: function(event, response) {
        this.adsManagerHandlingAds = true;
      },

      onAdsManagerFinishedAds: function(event, response) {
        this.adsManagerHandlingAds = false;
      },

      _findFirstReadyPreRolls: function() {
        return _.find(this.prerolls, function(adItem, index) {
          return adItem && this._isAdReady(adItem.item);
        }, this);
      },

      _checkWaitForAds: function() {
        // check if any required ads were checked
        var waitForAds = true;

        if(_.size(this.prerolls) > 0) {
          var ad = this._findFirstReadyPreRolls();
          if (ad) {
            waitForAds = false;
          }
        } else { // no pre rolls ad
          waitForAds = false;
        }
        return waitForAds;
      },

      _checkPlaybackReady:function() {
        if (!this.waitForPlaybackReady) {
          if (this.currentState == "PlaybackReady" && !this.playInFlight) { this.onPlaybackReady(); }
          return;
        }
        // if all basic metadata has returned
        if (this.contentTree != null && this.metadata != null && this.authorization != null) {
          // we are ready if no longer waiting for ads
          if(this.skipPrerollAdsCheck || !this._checkWaitForAds()) {
            this.mb.publish(OO.EVENTS.PLAYBACK_READY);
          }
        }
      },

      onPlaybackReady: function() {
        // preload the next stream
        var ad = this._findFirstReadyPreRolls();
        this.currentItem = ad || this.mainVideoItem;
        this.stream_url = this._streamForItem(this.currentItem.item);

        this.mb.publish(OO.EVENTS.PRELOAD_STREAM, this.stream_url);
        this.waitForPlaybackReady = false;
        // check autoplay
        var autoPlay = this.parameters.autoPlay === 'true' || this.parameters.autoPlay === true ||
                       this.parameters.autoplay === 'true' || this.parameters.autoplay === true;
        if (this.playedAtLeastOnce == false && autoPlay && OO.allowAutoPlay) {
          this.playInFlight = true;
          this.mb.publish(OO.EVENTS.INITIAL_PLAY);    // initial play is special since it allows for pre-rolls
        }

        // check loop
        var loop = this.parameters.loop === 'true' || this.parameters.loop === true;
        if (this.playedAtLeastOnce && loop)
        {
          this.mb.publish(OO.EVENTS.PLAY);
        }
      },

      _isAdReady: function(ad) {
        return (ad && this._streamForItem(ad));
      },

      _isMidRollAd: function(adItem) {
        return (adItem && !this._isPreRollAd(adItem) && !this._isPostRollAd(adItem));
      },

      _isPreRollAd: function(adItem) {
        var ad = adItem ? adItem.item : null;
        return (ad && ad.time < 250);
      },

      _isPostRollAd: function(adItem) {
        var ad = adItem ? adItem.item : null;
        return (ad && ad.time == 1000000000);
      },

      _lookupNextPlaybackItem: function(type, index) {
        // Just finish prerolls, return movie item directly
        if(type == "ad" && index == _.size(this.prerolls)) { return this.mainVideoItem; }
        // still play
        if(index < _.size(this.prerolls) || index > this.mainVideoItem.index) {
          // see if any ads to play
          var nextAd = _.find(this.inlineAdsItems, _.bind(function(adItem, adIndex){
            // If we're still in preroll territory, then any non-preroll ads should be invalid
            if (index < _.size(this.prerolls) && adIndex >= _.size(this.prerolls)) { return false; }
            if (adIndex < index) { return false; }
            if (this._isAdReady(adItem.item)) {
              return true;
            }
            return false;
          },this));

          // if remaining ad is not ready, skip and play mainVideo. For postroll case, return null if no ad.
          if (index > this.mainVideoItem.index && !nextAd) { return null; }
          return nextAd || this.mainVideoItem;
        }
        // Handle mid roll here, need to find first ready ads match curent main video playhead time
        return null;
      },

      _streamForItem: function(playbackItem) {
        if (playbackItem.streamUrl) { return playbackItem.streamUrl; }
        if (_.isEmpty(playbackItem.streams)) { return null; }
        if (_.isEmpty(playbackItem.streams[0])) { return null; }
        return OO.decode64(playbackItem.streams[0].url.data);
      },

      _publishPlayItemEvent: function(playItem, streamUrl, eventName) {
        this._checkCompanionAds(playItem);
        this.mb.publish(eventName, streamUrl, playItem);
      },

      onInitialPlay:function() {
        this.playInFlight = true;
        this.mb.publish(OO.EVENTS.PLAY, this.currentItem.item);
      },

      onPlay:function() {
        this.userRequest = 'play';

        if (this.currentItem.type == "ad" || this.currentMidrollAdItem) {
          this.mb.publish(OO.EVENTS.WILL_PLAY_ADS, this.currentItem.item);
        }
        if (this.currentMidrollAdItem) {
          var midrollUrl = this._streamForItem(this.currentMidrollAdItem.item);
          this._publishPlayItemEvent(this.currentMidrollAdItem, midrollUrl, OO.EVENTS.PLAY_MIDROLL_STREAM);
        } else {
          this.playInFlight = false;
          this._publishPlayItemEvent(this.currentItem, this.stream_url, OO.EVENTS.PLAY_STREAM);
        }
      },

      onPause:function() {
        this.userRequest = 'pause';
        this.mb.publish(OO.EVENTS.PAUSE_STREAM);
      },

      _checkAndPlayReadyMidrolls: function(playhead) {
        if (this.midrolls.length == 0 || this.isInlineAdsPlaying) { return false; }
        // [pbw-1196] IE is double firing the same playhead time when the VAST ad completes,
        // so we need to dedupe it to prevent looped midrolls
        if (!this.currentMidrollAdItem && this.lastMidrollPlayhead == playhead) { return false; }
        this.lastMidrollPlayhead = playhead;
        // startIndex for next Midroll.
        var startIndex = (this.currentMidrollAdItem) ? this.currentMidrollAdItem.index : -1;

        this.currentMidrollAdItem = _.find(this.midrolls, function(adItem) {
          // map ad time to each 250 milliseconds slot.
          var adTimeSlot = Math.floor(adItem.item.time / 250);
          return (adTimeSlot == Math.floor(playhead * 1000 / 250) && adItem.index > startIndex);
        }, this);
        if (this.currentMidrollAdItem) {
          var midrollUrl = this._streamForItem(this.currentMidrollAdItem.item);
          if (midrollUrl) {
            if (startIndex == -1) { this.mb.publish(OO.EVENTS.WILL_PLAY_ADS, this.currentItem.item); }
            this._publishPlayItemEvent(this.currentMidrollAdItem, midrollUrl, OO.EVENTS.PLAY_MIDROLL_STREAM);
            return true;
          }
        }
        this.currentMidrollAdItem = null;
        return false;
      },

      _checkCompanionAds: function(playItem) {
        //WILL_SHOW_COMPANION_ADS

        if (playItem.type != "ad" || _.isNull(playItem.item) || _.isNull(playItem.item.data) ||
            playItem.item.type != "vast" || _.isEmpty(playItem.item.data.companion)) {
          return;
        }
        // Defer so that external JS exception will not hang our player.
        _.defer(_.bind(function() {
            this.mb.publish(OO.EVENTS.WILL_SHOW_COMPANION_ADS, {ads: playItem.item.data.companion});
          }, this));
      },

      onPlayheadTimeChanged: function(event, time, duration) {
        if (this.currentState != 'PlayingState'  || this.currentMidrollAdItem) { return; }
        this.currentItemActualDuration = duration;
        // TODO, this is for MO-514, using a small delta here, the reason is that for IE 9, when pause and resume
        // a video, the next playhead is fired after around 100 ms, then it will resume to fire at 250ms
        // every time. We will need to figure out a more predict way of getting the delta or find some doc
        // to prove this observation.
        if (this.currentMainVideoPlayhead < time - 0.1) { this._checkAndPlayReadyMidrolls(time); }
        this.currentMainVideoPlayhead = time;
      },

      onStreamPlayed: function() {
        if (this.adsManagerHandlingAds) {
          return;
        }

        this.playedAtLeastOnce = true;

        if(this.currentItem.type === 'movie' && _.size(this.postrolls) == 0 && !this.isInlineAdsPlaying) {
          this.mb.publish(OO.EVENTS.PLAYED);
          return;
        }
        // play the next stream
        var previousItem = this.currentItem;
        this.currentItem = this._lookupNextPlaybackItem(this.currentItem.type, this.currentItem.index+1);
        if (!this.currentItem) {
          // PostRoll Ads finsihed:
          if (previousItem.type == "ad") { this.mb.publish(OO.EVENTS.ADS_PLAYED, previousItem.item); }
          this.mb.publish(OO.EVENTS.PLAYED);
          return;
        }
        this.stream_url = this._streamForItem(this.currentItem.item);

        if (this.currentItem.type == "movie" && previousItem.type == "ad") {
          this.mb.publish(OO.EVENTS.ADS_PLAYED, this.currentItem.item);
        } else if (this.currentItem.type == "ad" && previousItem.type == "movie") {
          this.mb.publish(OO.EVENTS.WILL_PLAY_ADS, this.currentItem.item);
        }
        this._publishPlayItemEvent(this.currentItem, this.stream_url, OO.EVENTS.PLAY_STREAM);
      },

      onStreamPlaying: function() {
        if (this.userRequest === 'play') {
          this.mb.publish(OO.EVENTS.PLAYING);
        }
        this.userRequest = '';
      },

      onStreamPaused: function() {
        if (this.userRequest === 'pause') {
          this.mb.publish(OO.EVENTS.PAUSED);
        }
        this.userRequest = '';
      },

      onSeek: function(event, seconds) {
        // this will only be triggered if we were playing, paused, playback is ready, or play was requested
        // because of the state machine
        this.mb.publish(OO.EVENTS.SEEK_STREAM, seconds);
      },

      onStreamPlayFailed: function(event, mediaErrorCode) {
        if (this.adsManagerHandlingAds) {
          // When Ads Manager are handling the ads playback don't publish more play error events as
          // they are meant for the main video and not ad
          return;
        }

        if (this.currentItem && this.currentItem.type == "ad") {
          OO.d("PreRoll failed, fallback to next stream");
          // For PreRoll/PostRoll, continue to next.
          this.currentItem.item.streams = [];
          this.currentItem.item.streamUrl = null;
          if (this.currentState === 'PlayingState') { this.onStreamPlayed(); }
          else { this._checkPlaybackReady(); }
        } else {
          this.mb.publish(OO.EVENTS.PLAY_FAILED, mediaErrorCode);

          var mediaErrorAborted = !!window.MediaError ? window.MediaError.MEDIA_ERR_ABORTED : 1;
          var mediaErrorNetwork = !!window.MediaError ? window.MediaError.MEDIA_ERR_NETWORK : 2;
          if (mediaErrorCode==mediaErrorAborted || mediaErrorCode==mediaErrorNetwork) {
            this.mb.publish(OO.EVENTS.ERROR, { code: OO.ERROR.PLAYBACK.NETWORK });
          } else {
            switch(this.contentTree.content_type) {
            case "Video":
              this.mb.publish(OO.EVENTS.ERROR, { code: OO.ERROR.PLAYBACK.STREAM });
              break;
            case "LiveStream":
              this.mb.publish(OO.EVENTS.ERROR, { code: OO.ERROR.PLAYBACK.LIVESTREAM });
              break;
            default:
              this.mb.publish(OO.EVENTS.ERROR, { code: OO.ERROR.PLAYBACK.GENERIC });
            }
          }
        }
        this.userRequest = '';
      },

      onMidrollPlayFailed: function() {
        OO.d("MidRoll failed, fall back to main video");
        // TODO, use ads played event for now to indicate ad is done, use a different event to nofity
        var item = this.currentMidrollAdItem.item;
        this.currentMidrollAdItem = null;
        this.mb.publish(OO.EVENTS.ADS_PLAYED, item);
        this.mb.publish(OO.EVENTS.WILL_RESUME_MAIN_VIDEO);
      },

      onWillPlayStream: function() {
        this.mb.publish(OO.EVENTS.WILL_PLAY);
      },

      __placeholder: true
    });

    OO.registerModule('playbackControl', function(messageBus, id) {
      return new PlaybackControlModule(messageBus, id);
    });
  }(OO, OO._, OO.$));
  (function(OO, _, $){
    /*
     *  Defines a simple debug mode
     */
    var PlaybackModule = function(messageBus, id) {
      // short circuit here if the page does not need playback
      if (!OO.requiredInEnvironment('html5-playback')) { return; }
      this.toString = function() {return 'html5-playback';};

      this.mb = messageBus;
      this.id = id;
      this.willPlayFromBeginning = true;
      this.playedAtLeastOnce = false;
      this.loadedAtLeastOnce = false;
      this.replayVideo = false;
      this._setDefaultPreloadValue();

      this.mb.subscribe(OO.EVENTS.PLAYER_CREATED, 'playback', _.bind(this._playerWasCreated,this));
      this.mb.subscribe(OO.EVENTS.PRELOAD_STREAM, 'playback', _.bind(this._preloadStream,this));
      this.mb.subscribe(OO.EVENTS.RELOAD_STREAM, 'playback', _.bind(this._reloadStream,this));
      this.mb.subscribe(OO.EVENTS.PLAY_STREAM, 'playback', _.bind(this._playStream,this));
      this.mb.subscribe(OO.EVENTS.PAUSE_STREAM, 'playback', _.bind(this._pauseStream,this));
      this.mb.subscribe(OO.EVENTS.SEEK_STREAM, 'playback', _.bind(this._seek,this));
      this.mb.subscribe(OO.EVENTS.EMBED_CODE_CHANGED, 'playback', _.bind(this._embedCodeChanged,this));
      this.mb.subscribe(OO.EVENTS.CHANGE_VOLUME, 'playback', _.bind(this._changeVolume,this));
      this.mb.subscribe(OO.EVENTS.DESTROY, 'playback', _.bind(this._destroy, this));
      this.mb.subscribe(OO.EVENTS.END_SCREEN_SHOWN, 'playback', _.bind(this._endScreenShown, this));

      this.mb.subscribe(OO.EVENTS.PLAY_MIDROLL_STREAM, 'playback', _.bind(this._playMidRoll,this));
      this.mb.subscribe(OO.EVENTS.WILL_RESUME_MAIN_VIDEO, 'playback', _.bind(this._resumeMainVideo,this));

      this.mb.subscribe(OO.EVENTS.PAGE_UNLOAD_REQUESTED, 'playback', _.bind(this._pageUnloadRequested, this));
    };

    _.extend(PlaybackModule.prototype, {
      _toggleMidrollAndMainVideo: function(showMainVideo) {
        if (this.videoWrapper) { this.videoWrapper.show(showMainVideo); }
        if (this.midrollWrapper) { this.midrollWrapper.show(!showMainVideo); }
      },

      _playMidRoll: function(event, url) {
        this.videoWrapper.pause();
        this._toggleMidrollAndMainVideo(false);
        // Only call load and rewind if we've swapped elements, otherwise we'll restart
        // the ad on pause->play
        var urlChanged = this.midrollWrapper.setVideoUrl(url);
        // Dispatch load event earlier, so we can preload midroll
        if (urlChanged) { this.midrollWrapper.load(true); }
        this.midrollWrapper.play();
      },

      _midrollPlayed: function() {
        this.mb.publish(OO.EVENTS.MIDROLL_STREAM_PLAYED, this.videoWrapper.getCurrentTime());
      },

      _midrollPaused: function() {
        if (this.videoWrapper.isPlaying) { return; }
        this.mb.publish(OO.EVENTS.STREAM_PAUSED, this.midrollWrapper.getCurrentTime());
      },

      _midrollPlayheadChanged: function() {
        this.mb.publish(OO.EVENTS.PLAYHEAD_TIME_CHANGED, this.midrollWrapper.getCurrentTime(),
            this.midrollWrapper.getDuration(), this.midrollWrapper.getBuffer());
      },

      _resumeMainVideo: function(event) {
        this._toggleMidrollAndMainVideo(true);
        this.videoWrapper.play();
        this.midrollWrapper.pause();
      },

      _embedCodeChanged: function(event, embedCode) {
        if (this.videoWrapper) { this.videoWrapper.setEmbedCode(embedCode); }
        this.willPlayFromBeginning = true;
        this.loadedAtLeastOnce = false;
      },

      _playerWasCreated: function(event, elementId, params) {
        this.elementId = elementId;
        this.rootElement = $('#'+this.elementId+' > div');
        this.params = params;

        // Set HTML5 locale
        if (this.params.locale !== undefined) {
          OO.setLocale(this.params.locale);
        }

        // load the css
        OO.attachStyle(_.template(OO.get_css("playback"))({
          elementId: this.elementId
        }), this.elementId);

        // display initial ui
        this.videoWrapper = OO.createVideoElementWrapper(this.rootElement, "video", this.params);
        this.videoWrapper.on(OO.VideoElementWrapper.WILL_PLAY, 'playback', _.bind(this._videoWillPlay, this));
        this.videoWrapper.on(OO.VideoElementWrapper.PLAYING, 'playback', _.bind(this._videoPlaying, this));
        this.videoWrapper.on(OO.VideoElementWrapper.PAUSED, 'playback', _.bind(this._videoPaused, this));
        this.videoWrapper.on(OO.VideoElementWrapper.ERROR, 'playback', _.bind(this._videoError, this));
        this.videoWrapper.on(OO.VideoElementWrapper.PLAYHEAD_TIME_CHANGED, 'playback',
                             _.bind(this._videoPlayheadTimeChanged, this));
        this.videoWrapper.on(OO.VideoElementWrapper.DURATION_CHANGED, 'playback',
                            _.bind(this._videoDurationChanged, this));
        this.videoWrapper.on(OO.VideoElementWrapper.BUFFERING, 'playback',
                             _.bind(this._videoBuffering, this));
        this.videoWrapper.on(OO.VideoElementWrapper.BUFFERED, 'playback', _.bind(this._videoBuffered, this));
        this.videoWrapper.on(OO.VideoElementWrapper.SEEKED, 'playback', _.bind(this._videoSeeked, this));
        this.videoWrapper.on(OO.VideoElementWrapper.DOWNLOADING, 'playback',
                             _.bind(this._videoDownloading, this));
        this.videoWrapper.on(OO.VideoElementWrapper.VOLUME_CHANGED, 'playback',
                             _.bind(this._videoVolumeChanged, this));
        this.videoWrapper.on(OO.VideoElementWrapper.PLAYED, 'playback',
                            _.bind(this._videoPlayed, this));
        this.videoWrapper.on(OO.VideoElementWrapper.FULL_SCREEN_CHANGED, 'playback',
                            _.bind(this._fullScreenChanged, this));

        //let page-level parameters override our default value for shouldPreload from true to false only
        if (this.params && this.params.preload == false) {
          this.shouldPreload = false;
        }

        // midroll:
        if (OO.supportMidRollAds) {
          this.midrollWrapper = OO.createVideoElementWrapper(this.rootElement, "midroll", this.params);
          this.midrollWrapper.on(OO.VideoElementWrapper.PLAYED, 'playback',
                            _.bind(this._midrollPlayed, this));

          this.midrollWrapper.on(OO.VideoElementWrapper.PAUSED, 'playback', _.bind(this._midrollPaused, this));
          this.midrollWrapper.on(OO.VideoElementWrapper.PLAYHEAD_TIME_CHANGED, 'playback',
                             _.bind(this._midrollPlayheadChanged, this));
          this.midrollWrapper.on(OO.VideoElementWrapper.ERROR, 'playback', _.bind(this._midRollVideoError, this));
        }

        // NOTE[jigish]: Throw initial volumeChanged
        this._videoVolumeChanged();
      },

      _playVideoWithReport: function() {
         this._toggleMidrollAndMainVideo(true);
         this.videoWrapper.play();
         if (this.willPlayFromBeginning) {
           this.mb.publish(OO.EVENTS.WILL_PLAY_FROM_BEGINNING);
         }
         this.willPlayFromBeginning = false;
      },

      _setDefaultPreloadValue: function() {
        // TODO (neeraj): do we only need to default false on specific versions?
        if (OO.isChrome || OO.isIos || OO.isAndroid) {
          this.shouldPreload = false;
        } else {
          this.shouldPreload = true;
        }
      },

      _preloadStream: function(event, streamUrl) {
        var urlChanged = this.videoWrapper.setVideoUrl(streamUrl);
        if (this.shouldPreload && urlChanged) {
          this.loadedAtLeastOnce = true;
          this.videoWrapper.load(true);
        }
      },

      _reloadStream: function(event) {
        if (!this.loadedAtLeastOnce) {
          this.videoWrapper.reload();
          this.loadedAtLeastOnce = true;
        }
      },

      _playStream: function(event, streamUrl) {
        var urlChanged = this.videoWrapper.setVideoUrl(streamUrl);
        //on subsequent video plays we can allow _preloadStream to load the video
        this.shouldPreload = true;
        if (urlChanged) {
          this.videoWrapper.load(false);
          this.loadedAtLeastOnce = true;
        }
        this._playVideoWithReport();
      },

      _pauseStream: function(event) {
        // TODO, only need to call one pause based on if current video playing is midroll.
        this.videoWrapper.pause();
        if (this.midrollWrapper) { this.midrollWrapper.pause(); }
      },

      _seek: function(event, seconds) {
        if (this.videoWrapper.getIsActive()) {
          this.videoWrapper.seek(seconds);
        } else if (this.midrollWrapper && this.midrollWrapper.getIsActive()) {
          this.midrollWrapper.seek(seconds);
        } else {
          OO.log("Trying to seek while video element is not active");
        }
      },

      _changeVolume: function(event, volume) {
        this.videoWrapper.setVolume(volume);
      },

      _videoWillPlay:function() {
        this.mb.publish(OO.EVENTS.WILL_PLAY_STREAM, this.videoWrapper.getStreamUrl());
        //[pbw-1734] iOS fullscreen blocks the replay button, so mimic functionality here
        if (OO.isIos && this.replayVideo) {
          this.replayVideo = false;
          this.mb.publish(OO.EVENTS.SEEK, 0);
          this.mb.publish(OO.EVENTS.PLAY);
        }
      },

      _endScreenShown:function() {
        this.replayVideo = true;
      },

      _videoPlaying: function() {
        this.mb.publish(OO.EVENTS.STREAM_PLAYING, this.videoWrapper.getStreamUrl());
      },

      _videoPaused: function() {
        if (this.midrollWrapper && this.midrollWrapper.isPlaying) { return; }
        this.mb.publish(OO.EVENTS.STREAM_PAUSED, this.videoWrapper.getStreamUrl());
      },

      _videoPlayed: function() {
        this.willPlayFromBeginning = true;
        this.playedAtLeastOnce = true;
        this.mb.publish(OO.EVENTS.STREAM_PLAYED, this.videoWrapper.getStreamUrl());
      },

      _videoError: function(event, code) {
        this.mb.publish(OO.EVENTS.STREAM_PLAY_FAILED, code);
      },

      _videoBuffering: function() {
        this.mb.publish(OO.EVENTS.BUFFERING, this.videoWrapper.getStreamUrl());
      },

      _videoBuffered: function() {
        this.mb.publish(OO.EVENTS.BUFFERED, this.videoWrapper.getStreamUrl());
      },

      _videoSeeked: function() {
        this.mb.publish(OO.EVENTS.SEEKED);
      },

      _videoDownloading: function() {
        var currentTime, duration, buffer, seekRange, streamUrl;
        if (this.videoWrapper.getIsActive()) {
          currentTime = this.videoWrapper.getCurrentTime();
          duration = this.videoWrapper.getDuration();
          buffer = this.videoWrapper.getBuffer();
          seekRange = this.videoWrapper.getSeekableRange();
          streamUrl = this.videoWrapper.getStreamUrl();
        } else if (this.midrollWrapper && this.midrollWrapper.getIsActive()) {
          currentTime = this.midrollWrapper.getCurrentTime();
          duration = this.midrollWrapper.getDuration();
          buffer = this.midrollWrapper.getBuffer();
          seekRange = this.midrollWrapper.getSeekableRange();
          streamUrl = this.midrollWrapper.getStreamUrl();
        }
        this.mb.publish(OO.EVENTS.DOWNLOADING, currentTime, duration,
          buffer, seekRange, streamUrl);
      },

      _fullScreenChanged: function(e, isFullScreen, paused) {
        this.mb.publish(OO.EVENTS.FULLSCREEN_CHANGED, isFullScreen, paused);
      },

      _videoVolumeChanged: function() {
        this.mb.publish(OO.EVENTS.VOLUME_CHANGED, this.videoWrapper.getVolume());
      },

      _videoPlayheadTimeChanged: function() {
        var ts = this.videoWrapper.getCurrentTime();
        var dur = this.videoWrapper.getDuration();
        var buffer = this.videoWrapper.getBuffer();
        var seekRange = this.videoWrapper.getSeekableRange();
        this.mb.publish(OO.EVENTS.PLAYHEAD_TIME_CHANGED, ts, dur, buffer, seekRange);
      },

      _videoDurationChanged: function() {
        var ts = this.videoWrapper.getCurrentTime();
        var dur = this.videoWrapper.getDuration();
        var buffer = this.videoWrapper.getBuffer();
        var seekRange = this.videoWrapper.getSeekableRange();
        this.mb.publish(OO.EVENTS.PLAYHEAD_TIME_CHANGED, ts, dur, buffer, seekRange);
      },

      _midRollVideoError: function() {
        this.mb.publish(OO.EVENTS.MIDROLL_PLAY_FAILED, arguments);
      },

      _destroy: function() {
        this.videoWrapper.kill();
        if (this.midrollWrapper) { this.midrollWrapper.kill(); }
      },

      _pageUnloadRequested: function() {
        this.videoWrapper.delayErrorPublishing();
        if (this.midrollWrapper) {
          this.midrollWrapper.delayErrorPublishing();
        }
      },

      __placeholder:true
    });

    OO.registerModule('playback', function(messageBus, id) {
      return new PlaybackModule(messageBus, id);
    });

  }(OO, OO._, OO.$));
(function(OO, _, $) {
  /*
   *  Defines an HTML5 wrapper around Google's Media Player Library to support EME
   *
   *  Google Media Player Library
   *  https://developers.google.com/cast/docs/player
   */
  var CastPlaybackModule = function(messageBus, id) {
    // short circuit if the page does not need cast playback
    if (!OO.requiredInEnvironment('cast-playback')) { return; }
    this.toString = function() {return 'cast-playback';};

    OO.log("CastPlaybackModule loaded!");

    this.mb = messageBus;
    this.id = id;
    this.willPlayFromBeginning = true;
    this.playedAtLeastOnce = false;
    this.streamUrl = null;
    this.mediaPlayerSrcReady = false;
    this.currentEmbedCode = null;
    this.mediaPlayerCreated = false;
    this.authToken = null;

    this.mediaPlayerJS = "//www.gstatic.com/cast/sdk/libs/mediaplayer/1.0.0/media_player.js";
    this.protocol = OO.isSSL ? "https:" : "http:";
    this.mediaPlayerSrc = this.protocol + this.mediaPlayerJS;

    // TODO(jdlew): Subscribe to all necessary events here.
    this.mb.subscribe(OO.EVENTS.PLAYER_CREATED, 'cast_playback', _.bind(this._playerWasCreated, this));
    this.mb.subscribe(OO.EVENTS.PRELOAD_STREAM, 'cast_playback', _.bind(this._preloadStream, this));
    this.mb.subscribe(OO.EVENTS.RELOAD_STREAM, 'cast_playback', _.bind(this._reloadStream, this));
    this.mb.subscribe(OO.EVENTS.PLAY_STREAM, 'cast_playback', _.bind(this._playStream, this));
    this.mb.subscribe(OO.EVENTS.PAUSE_STREAM, 'cast_playback', _.bind(this._pauseStream, this));
    this.mb.subscribe(OO.EVENTS.SEEK_STREAM, 'cast_playback', _.bind(this._seek, this));
    this.mb.subscribe(OO.EVENTS.EMBED_CODE_CHANGED, 'cast_playback', _.bind(this._embedCodeChanged, this));
    this.mb.subscribe(OO.EVENTS.CHANGE_VOLUME, 'cast_playback', _.bind(this._changeVolume, this));
    this.mb.intercept(OO.EVENTS.DESTROY, 'cast_playback', _.bind(this._destroy, this));

    this.mb.subscribe(OO.EVENTS.PLAY_MIDROLL_STREAM, 'cast_playback', _.bind(this._playMidRoll, this));
    this.mb.subscribe(OO.EVENTS.WILL_RESUME_MAIN_VIDEO, 'cast_playback', _.bind(this._resumeMainVideo, this));

    this.mb.subscribe(OO.EVENTS.PAGE_UNLOAD_REQUESTED, 'cast_playback', _.bind(this._pageUnloadRequested, this));

    this.mb.subscribe(OO.EVENTS.AUTHORIZATION_FETCHED, 'cast_playback', _.bind(this._onAuthorizationFetched, this));

    // Do we need to _.defer() in case there are multiple players on the page?
    // Load Google's Media Player Library
    // Note: this call will both fetch and execute the code, and success shouldn't run until
    // the loaded script has executed.
    $.ajax({
      url: this.mediaPlayerSrc,
      type: 'GET',
      cache: true,
      dataType: 'script',
      success: _.bind(this._onMediaPlayerSrcReady, this)
    });
  };

  _.extend(CastPlaybackModule.prototype, {

    _toggleMidrollAndMainVideo: function(showMainVideo) {
      if (this.videoWrapper) { this.videoWrapper.show(showMainVideo); }
      if (this.midrollWrapper) { this.midrollWrapper.show(!showMainVideo); }
    },

    _playMidRoll: function(event, url) {
      this.videoWrapper.pause();
      this._toggleMidrollAndMainVideo(false);
      // Dispatch load event earlier, so we can preload midroll
      this.midrollWrapper.setVideoUrl(url);
      this.midrollWrapper.load(true);
      this.midrollWrapper.play();
    },

    _midrollPlayed: function() {
      this.mb.publish(OO.EVENTS.MIDROLL_STREAM_PLAYED, this.videoWrapper.getCurrentTime());
    },

    _midrollPaused: function() {
      if (this.videoWrapper.isPlaying) { return; }
      this.mb.publish(OO.EVENTS.STREAM_PAUSED, this.midrollWrapper.getCurrentTime());
    },

    _midrollPlayheadChanged: function() {
      this.mb.publish(OO.EVENTS.PLAYHEAD_TIME_CHANGED, this.midrollWrapper.getCurrentTime(),
          this.midrollWrapper.getDuration(), this.midrollWrapper.getBuffer());
    },

    _resumeMainVideo: function(event) {
      this._toggleMidrollAndMainVideo(true);
      this.videoWrapper.play();
      this.midrollWrapper.pause();
    },

    _embedCodeChanged: function(event, embedCode) {
      this.currentEmbedCode = embedCode;
      if (this.videoWrapper) {
        this.videoWrapper.setEmbedCode(embedCode);
        this.videoWrapper.pause();
      }

      if (this.castPlayer) {
        this.castPlayer.unload();
      }

      //Flag to re-initialize the media host w/ new stream url
      this.mediaPlayerCreated = false;

      this.willPlayFromBeginning = true;
      this.playedAtLeastOnce = false;
    },

    _playerWasCreated: function(event, elementId, params) {
      this.elementId = elementId;
      this.rootElement = $('#'+this.elementId+' > div');
      this.params = params;

      OO.log("CastPlaybackModule: _playerWasCreated");

      // load the css
      OO.attachStyle(_.template(OO.get_css("playback"))({
        elementId: this.elementId
      }), this.elementId);

      // display initial ui
      this.videoWrapper = OO.createVideoElementWrapper(this.rootElement, "video", this.params);

      this.videoWrapper.on(OO.VideoElementWrapper.WILL_PLAY, 'cast_playback', _.bind(this._videoWillPlay, this));
      this.videoWrapper.on(OO.VideoElementWrapper.PLAYING, 'cast_playback', _.bind(this._videoPlaying, this));
      this.videoWrapper.on(OO.VideoElementWrapper.PAUSED, 'cast_playback', _.bind(this._videoPaused, this));
      this.videoWrapper.on(OO.VideoElementWrapper.ERROR, 'cast_playback', _.bind(this._videoError, this));
      this.videoWrapper.on(OO.VideoElementWrapper.PLAYHEAD_TIME_CHANGED, 'cast_playback',
                           _.bind(this._videoPlayheadTimeChanged, this));
      this.videoWrapper.on(OO.VideoElementWrapper.DURATION_CHANGED, 'cast_playback',
                          _.bind(this._videoDurationChanged, this));
      this.videoWrapper.on(OO.VideoElementWrapper.BUFFERING, 'cast_playback',
                           _.bind(this._videoBuffering, this));
      this.videoWrapper.on(OO.VideoElementWrapper.BUFFERED, 'cast_playback', _.bind(this._videoBuffered, this));
      this.videoWrapper.on(OO.VideoElementWrapper.SEEKED, 'cast_playback', _.bind(this._videoSeeked, this));
      this.videoWrapper.on(OO.VideoElementWrapper.DOWNLOADING, 'playback',
                           _.bind(this._videoDownloading, this));
      this.videoWrapper.on(OO.VideoElementWrapper.VOLUME_CHANGED, 'cast_playback',
                           _.bind(this._videoVolumeChanged, this));
      this.videoWrapper.on(OO.VideoElementWrapper.PLAYED, 'cast_playback',
                          _.bind(this._videoPlayed, this));
      this.videoWrapper.on(OO.VideoElementWrapper.FULL_SCREEN_CHANGED, 'cast_playback',
                          _.bind(this._fullScreenChanged, this));

      // midroll:
      if (OO.supportMidRollAds) {
        this.midrollWrapper = OO.createVideoElementWrapper(this.rootElement, "midroll", this.params);

        this.midrollWrapper.on(OO.VideoElementWrapper.PLAYED, 'cast_playback',
                          _.bind(this._midrollPlayed, this));
        this.midrollWrapper.on(OO.VideoElementWrapper.PAUSED, 'cast_playback', _.bind(this._midrollPaused, this));
        this.midrollWrapper.on(OO.VideoElementWrapper.PLAYHEAD_TIME_CHANGED, 'cast_playback',
                           _.bind(this._midrollPlayheadChanged, this));
        this.midrollWrapper.on(OO.VideoElementWrapper.ERROR, 'cast_playback', _.bind(this._midRollVideoError, this));
      }

      this._videoVolumeChanged();
    },

    _playVideoWithReport: function() {
      OO.log("playVideoWithReport");
      this._toggleMidrollAndMainVideo(true);

      if (this.mediaPlayerSrcReady && !this.mediaPlayerCreated) {
        this._initMediaPlayer();
      }
      if (this.mediaPlayerCreated) {
        //only need to set the auth token and create the player on first play
        if (this.willPlayFromBeginning && !this.playedAtLeastOnce) {
          if (this.authToken) {
            this.mediaHost.licenseCustomData = "auth_token=" + this.authToken;
          }
          var initialTimeIndexSeconds = 0;
          this.castPlayer.load(this.streamingProtocol, initialTimeIndexSeconds);

          this.mb.publish(OO.EVENTS.WILL_PLAY_FROM_BEGINNING);
          this.willPlayFromBeginning = false;
        }
        this.videoWrapper.play();
      }
    },

    _preloadStream: function(event, streamUrl) {
      this.streamUrl = streamUrl;
      OO.log("preloadStream");
      OO.log("StreamURL: " + this.streamUrl);

      if (this.mediaPlayerSrcReady && !this.mediaPlayerCreated) {
        this._initMediaPlayer();
      }
      // TODO(jdlew): Probably should move player loading here, instead of on play.
    },

    _initMediaPlayer: function() {
      OO.log("Chromecast initMediaPlayer");
      this.mediaPlayerCreated = true;

      this.videoWrapper._video.autoplay = true;
      this.mediaHost = new cast.player.api.Host({
        'mediaElement': this.videoWrapper._video,
        'url': this.streamUrl
      });

      this.mediaHost.onError = _.bind(function(errorCode) {
        var errorMessage = "Unknown Chromecast error: code " + errorCode;
        if (errorCode === cast.player.api.ErrorCode.MANIFEST) {
          errorMessage = "Error loading or parsing the manifest";
          this.mb.publish(OO.EVENTS.ERROR, { code: OO.ERROR.CHROMECAST.MANIFEST });
        } else if (errorCode === cast.player.api.ErrorCode.MEDIAKEYS) {
          errorMessage = "Error fetching the keys or decrypting the content";
          this.mb.publish(OO.EVENTS.ERROR, { code: OO.ERROR.CHROMECAST.MEDIAKEYS });
          if (this.authToken) {
            $.ajax({
              url: "http://player.ooyala.com/sas/api/v1/device_management/auth_token/" + this.authToken +
                "/last_result",
              type: 'GET',
              dataType: 'json',
              success: _.bind(function(responseData) {
                if (responseData.result == "invalid token") {
                  this.mb.publish(OO.EVENTS.ERROR, { code: OO.ERROR.API.SAS.ERROR_DEVICE_INVALID_AUTH_TOKEN });
                } else if (responseData.result == "device limit reached") {
                  this.mb.publish(OO.EVENTS.ERROR, { code: OO.ERROR.API.SAS.ERROR_DEVICE_LIMIT_REACHED });
                } else if (responseData.result == "device binding failed") {
                  this.mb.publish(OO.EVENTS.ERROR, { code: OO.ERROR.API.SAS.ERROR_DEVICE_BINDING_FAILED });
                } else if (responseData.result == "device id too long") {
                  this.mb.publish(OO.EVENTS.ERROR, { code: OO.ERROR.API.SAS.ERROR_DEVICE_ID_TOO_LONG });
                } else {
                  this.mb.publish(OO.EVENTS.ERROR, { code: OO.ERROR.API.SAS.ERROR_DRM_RIGHTS_SERVER_ERROR });
                }
              }, this),
              error: _.bind(function(jqXHR, status) {
                OO.log("Failed to retrieve DRM failure reason: " + status);
              }, this)
            });
          }
        } else if (errorCode === cast.player.api.ErrorCode.NETWORK) {
          errorMessage = "Network error";
          this.mb.publish(OO.EVENTS.ERROR, { code: OO.ERROR.CHROMECAST.NETWORK });
        } else if (errorCode === cast.player.api.ErrorCode.PLAYBACK) {
          errorMessage = "Error related to media playback";
          this.mb.publish(OO.EVENTS.ERROR, { code: OO.ERROR.CHROMECAST.PLAYBACK });
        }
        OO.log('Chromecast Host error: ' + errorMessage);
      }, this);

      this.castPlayer = new cast.player.api.Player(this.mediaHost);
      //This will need to be dynamic once we support more than Smooth playback
      this.streamingProtocol = cast.player.api.CreateSmoothStreamingProtocol(this.mediaHost);
    },

    _reloadStream: function(event) {
      this.videoWrapper.reload();
    },

    _playStream: function(event, streamUrl) {
      OO.log("playStream");
      this._playVideoWithReport();
    },

    _pauseStream: function(event) {
      if (this.mediaPlayerCreated) {
        OO.log("pauseStream");
        this.videoWrapper.pause();
        if (this.midrollWrapper) { this.midrollWrapper.pause(); }
      }
    },

    _seek: function(event, seconds) {
      if (this.videoWrapper.getIsActive()) {
        this.videoWrapper.seek(seconds);
      } else if (this.midrollWrapper && this.midrollWrapper.getIsActive()) {
        this.midrollWrapper.seek(seconds);
      } else {
        OO.log("Trying to seek while video element is not active");
      }
    },

    _changeVolume: function(event, volume) {
      this.videoWrapper.setVolume(volume);
    },

    _videoWillPlay:function() {
      this.mb.publish(OO.EVENTS.WILL_PLAY_STREAM, this.videoWrapper.getStreamUrl());
    },

    _videoPlaying: function() {
      this.mb.publish(OO.EVENTS.STREAM_PLAYING, this.videoWrapper.getStreamUrl());
    },

    _videoPaused: function() {
      if (this.midrollWrapper && this.midrollWrapper.isPlaying) { return; }
      this.mb.publish(OO.EVENTS.STREAM_PAUSED, this.videoWrapper.getStreamUrl());
    },

    _videoPlayed: function() {
      this.willPlayFromBeginning = true;
      this.playedAtLeastOnce = true;
      this.mb.publish(OO.EVENTS.STREAM_PLAYED, this.videoWrapper.getStreamUrl());
    },

    _videoError: function(event, code) {
      this.mb.publish(OO.EVENTS.STREAM_PLAY_FAILED, code);
    },

    _videoBuffering: function() {
      this.mb.publish(OO.EVENTS.BUFFERING, this.videoWrapper.getStreamUrl());
    },

    _videoBuffered: function() {
      this.mb.publish(OO.EVENTS.BUFFERED, this.videoWrapper.getStreamUrl());
    },

    _videoSeeked: function() {
      this.mb.publish(OO.EVENTS.SEEKED);
    },

    _videoDownloading: function() {
      this.mb.publish(OO.EVENTS.DOWNLOADING, this.videoWrapper.getCurrentTime(),
        this.videoWrapper.getDuration(), this.videoWrapper.getBuffer(),
        this.videoWrapper.getSeekableRange(), this.videoWrapper.getStreamUrl());
    },

    _fullScreenChanged: function(e, isFullScreen, paused) {
      this.mb.publish(OO.EVENTS.FULLSCREEN_CHANGED, isFullScreen, paused);
    },

    _videoVolumeChanged: function() {
      this.mb.publish(OO.EVENTS.VOLUME_CHANGED, this.videoWrapper.getVolume());
    },

    _videoPlayheadTimeChanged: function() {
      var ts = this.videoWrapper.getCurrentTime();
      var dur = this.videoWrapper.getDuration();
      var buffer = this.videoWrapper.getBuffer();
      var seekRange = this.videoWrapper.getSeekableRange();
      this.mb.publish(OO.EVENTS.PLAYHEAD_TIME_CHANGED, ts, dur, buffer, seekRange);
    },

    _videoDurationChanged: function() {
      var ts = this.videoWrapper.getCurrentTime();
      var dur = this.videoWrapper.getDuration();
      var buffer = this.videoWrapper.getBuffer();
      var seekRange = this.videoWrapper.getSeekableRange();
      this.mb.publish(OO.EVENTS.PLAYHEAD_TIME_CHANGED, ts, dur, buffer, seekRange);
    },

    _midRollVideoError: function() {
      this.mb.publish(OO.EVENTS.MIDROLL_PLAY_FAILED, arguments);
    },

    _destroy: function() {
      this.videoWrapper.kill();
      if (this.midrollWrapper) { this.midrollWrapper.kill(); }
    },

    _pageUnloadRequested: function() {
      this.videoWrapper.delayErrorPublishing();
      if (this.midrollWrapper) {
        this.midrollWrapper.delayErrorPublishing();
      }
    },

    _onAuthorizationFetched: function(evt, response) {
      if (response["auth_token"]) {
        this.authToken = response["auth_token"];
      }
      var code;
      var safe_response = OO.HM.safeObject("playbackControl.sasResponse", response, {});
      OO.log("authFetched: " + JSON.stringify(safe_response));
      var embed_code = this.currentEmbedCode;
    },

    _onMediaPlayerSrcReady: function() {
      OO.log("CastPlaybackModule loaded Media Player Library!");
      this.mediaPlayerSrcReady = true;
      cast.player.api.setLoggerLevel(cast.player.api.LoggerLevel.DEBUG);
      // TODO(jdlew): Anything else to put here? Can we move any of the MPL logic here?
    },

    __placeholder: true
  });

  OO.registerModule('cast_playback', function(messageBus, id) {
    return new CastPlaybackModule(messageBus, id);
  });
}(OO, OO._, OO.$));
(function(OO, _, $){
  /*
   *  Defines a flashback wrapper
   */
  var FlashPlaybackModule = function(messageBus, id) {
    // short circuit here if the page does not need playback
    if (!OO.requiredInEnvironment('flash-playback')) { return; }
    OO.d("Using Flash Playback");

    this.mb = messageBus;
    this.id = id;
    this.adobeToken = null;
    this.playerEmbedded = false;
    this.playbackReady = false;
    this.queuedPlaybackReady = false;
    this.embedCodeChanged = false;
    this.sasResponse = {};
    this.playerXml = {};
    this.playerXmlRequest = null;
    this.areFlashParamsSet = false;
    this.enableChannels = false;
    this.debugHost = "";
    this.o0jsdebug = "";
    this.isTwitter = "";
    this._playingAd = false;
    this.QUERY_STRING_PARAM_WHITELIST = ['embedCode', 'adSetCode', 'autoplay', 'loop', 'playerBrandingId',
      'devModuleCategory', 'devModuleURL', 'devModuleData', 'preload', 'showInAdControlBar', 'showAdMarquee',
      'tvRatingsPosition', 'tvRatingsTimer', 'shouldDisplayCuePointMarkers', 'adRequestTimeout'];
    this.mb.subscribe(OO.EVENTS.PLAYER_CREATED, 'flash_playback', _.bind(this._playerWasCreated,this));
    this.mb.subscribe(OO.EVENTS.SET_EMBED_CODE, 'flash_playback', _.bind(this._setEmbedCode,this));
    this.mb.subscribe(OO.EVENTS.AUTHORIZATION_FETCHED, 'flash_playback', _.bind(this._onAuthorizationFetched,this));
    this.mb.subscribe(OO.EVENTS.WILL_FETCH_PLAYER_XML, 'flash_playback', _.bind(this._onWillFetchPlayerXml,this));
    this.mb.subscribe(OO.EVENTS.PLAY, 'flash_playback', _.bind(this._play,this));
    this.mb.subscribe(OO.EVENTS.INITIAL_PLAY, 'flash_playback', _.bind(this._play,this));
    this.mb.subscribe(OO.EVENTS.PAUSE, 'flash_playback', _.bind(this._pause,this));
    this.mb.subscribe(OO.EVENTS.SEEK, 'flash_playback', _.bind(this._seek,this));
    this.mb.subscribe(OO.EVENTS.CHANGE_VOLUME, 'flash_playback', _.bind(this._changeVolume,this));
    this.mb.subscribe(OO.EVENTS.ADOBE_PASS_WAITING_FOR_TOKEN, 'flash_playback', _.bind(this._adobeWaitingForToken, this));
    this.mb.subscribe(OO.EVENTS.ADOBE_PASS_TOKEN_FETCHED, 'flash_playback', _.bind(this._adobeTokenFetched, this));
    this.mb.subscribe(OO.EVENTS.ADOBE_PASS_AUTH_STATUS, 'flash_playback', _.bind(this._adobeAuthStatus, this));
    this.mb.subscribe(OO.EVENTS.ERROR, 'flash_playback', _.bind(this._onError, this));
    this.mb.subscribe(OO.EVENTS.SKIP_AD, 'flash_playback', _.bind(this._skipAd, this));
    this.mb.subscribe(OO.EVENTS.SET_TARGET_BITRATE, 'flash_playback', _.bind(this._setTargetBitrate, this));
    this.mb.subscribe(OO.EVENTS.SET_TARGET_BITRATE_QUALITY, 'flash_playback', _.bind(this._setTargetBitrateQuality, this));
    this.mb.subscribe(OO.EVENTS.SET_CLOSED_CAPTIONS_LANGUAGE, 'flash_playback', _.bind(this._setClosedCaptionsLanguage, this));
    this.mb.subscribe(OO.EVENTS.FETCH_STYLE, "flash_playback", _.bind(this._fetchStyle, this));
    this.mb.subscribe(OO.EVENTS.SET_STYLE, "flash_playback", _.bind(this._setStyle, this));
    this.mb.subscribe(OO.EVENTS.INSERT_CUE_POINT, "flash_playback", _.bind(this._insertCuePoint, this));
    this.mb.subscribe(OO.EVENTS.TOGGLE_SHARE_PANEL, 'flash_playback', _.bind(this._toggleSharePanel,this));
    this.mb.subscribe(OO.EVENTS.TOGGLE_INFO_PANEL, 'flash_playback', _.bind(this._toggleInfoPanel,this));
    this.mb.subscribe(OO.EVENTS.SHOULD_DISPLAY_CUE_POINTS, 'flash_playback', _.bind(this._shouldDisplayCuePointMarkers,this));

    //clear the Ooyala Debug Panel
    if (OO.chromeExtensionEnabled) {
      window.postMessage({ type: "OO_CLEAR_LOGS", text: "" }, "*");
    }
  };

  _.extend(FlashPlaybackModule.prototype, {

    _getDuration: function() {
      if (this._isStandaloneAd || this._playingAd) { return this._adDuration; }
      return this._duration;
    },

    _onAuthorizationFetched: function(event, response) {
      if (OO.playerParams.flash_performance) {
        // Note(bz): keep a copy of the sas response for flash playback in case the player isn't embedded yet
        // and we need to retry setting the sas response when the player is embedded
        this.sasResponse[this.embedCode] = response;
        this._setFlashParams();
      }
    },

    _onWillFetchPlayerXml: function(event, request) {
      if (OO.playerParams.flash_performance) {
        this.playerXmlRequest = $.ajax({
          url: OO.URLS.PLAYER_XML(request),
          type: 'GET',
          dataType: 'text',
          cache:false,
          success: _.bind(this._onPlayerXmlFetched, this)
        });
      }
    },

    _onPlayerXmlFetched: function(response) {
      if (OO.playerParams.flash_performance) {
        this.mb.publish(OO.EVENTS.PLAYER_XML_FETCHED);
        this.playerXml[this.embedCode] = response;
        this._setFlashParams();
      }
    },

    _createFlashElement: function(parentContainer) {
      this.flashId = 'OoFlash' + OO.getRandomString();
      OO.publicApi[this.flashId] = _.bind(this._onFlashCallBack, this);

      var params = '';
      this.params['flashParams'] = this.params['flashParams'] || {};

      // Note(jdlew): We are ignoring autoplay in the flashParams hash.
      // We only respect the top-level 'autoplay'.
      delete this.params['flashParams']['autoplay'];

      // check autoplay
      if (OO.allowAutoPlay && (this.params.autoPlay === 'true' || this.params.autoPlay === true ||
          this.params.autoplay === 'true' || this.params.autoplay === true)) {
        this.params['flashParams']['autoplay'] = '1';
      }

      delete this.params['flashParams']['loop'];

      // check loop
      if (OO.allowLoop && (this.params.loop === 'true' || this.params.loop === true)) {
        this.params['flashParams']['loop'] = '1';
      }

      var swfUrl = OO.URLS.PLAYER_SWF({
        server: OO.playerParams.flash_player_url || OO.SERVER.API + '/player.swf',
        player: OO.playerParams.playerBrandingId
      });

      if (OO.playerParams.flash_version) {
        swfUrl += "&flash_version=" + OO.playerParams.flash_version;
      }

      if (OO.playerParams.use_asp_flash_route) {
        swfUrl = swfUrl.replace("player.swf", "asp/player.swf");
      }

      var callback = (OO.playerParams.namespace || 'OO') + '.' + this.flashId;
      var flashVars = {
        playerBrandingId: OO.playerParams.playerBrandingId,
        version: 2,
        embedType: OO.playerParams.flash_performance && this.enableChannels === false ? 'mjolnir' : 'nuplayer',
        embedStyle: 'mjolnir',
        me: this.flashId,
        callback: callback,
        width: '100%',
        height: '100%'
      };

      _.extend(flashVars, this.params['flashParams']);  // take any overrides
      if(!!this.params['layout']) {       // check for top-level layout
        flashVars['layout'] = this.params['layout'];
      }
      if (this.enableDiagnostics) {
        flashVars.diagnosticCallback = callback;
      }
      if (this.debugHost) {
        flashVars.debugHost = this.debugHost;
      }
      if (this.isTwitter) {
        flashVars.isTwitter = this.isTwitter;
      }
      if (this.adSetCode) {
        flashVars.adSetCode = this.adSetCode;
      }
      if (this.params.preload !== undefined) {
        flashVars.preload = this.params.preload;
      }
      if (this.params.shouldDisplayCuePointMarkers !== undefined) {
        flashVars.shouldDisplayCuePointMarkers = this.params.shouldDisplayCuePointMarkers;
      }
      if (this.showInAdControlBar) {
        flashVars.showInAdControlBar = this.showInAdControlBar;
      }
      if (this.showAdMarquee) {
        flashVars.showAdMarquee = this.showAdMarquee;
      }
      if (this.params.tpmOverrides) {
        flashVars.tpmOverrides = this.params.tpmOverrides;
      }

      if (this.params.adRequestTimeout !== undefined) {
        flashVars.adRequestTimeout = this.params.adRequestTimeout;
      }

      if (this.params.locale !== undefined) {
        flashVars.locale = this.params.locale;
      }

      flashVars['flash_version'] = OO.playerParams.flash_version || "";
      flashVars['v3_version'] = OO.playerParams.v3_version || "";

      //Prioritize flashvars from options hash over default o0jsDebug
      flashVars.o0jsdebug = flashVars.o0jsdebug || this.o0jsdebug;

      this.flashVars = flashVars; // save those for later so we can pass them again in setQueryStringParams

      var flashEmbed = (OO.isIE && !OO.isIE11Plus) ? OO.TEMPLATES.FLASH_IE : OO.TEMPLATES.FLASH;
      var template = OO.supportsFlash ? flashEmbed : OO.TEMPLATES.MESSAGE;
      var flash_html = _.template(template)({
        playerId: this.flashId,
        swfUrl: swfUrl,
        flashVars: $.param(flashVars),
        wmode: this.params.wmode || 'direct',
        message: OO.TEMPLATES.FLASH_INSTALL,

        __end_marker:true
      });

      parentContainer.append(flash_html);
      $("#" + this.flashId).css({ left: '0px' });
      var dom = parentContainer.find("object.video")[0];
      // for non-IE, the nested dom are the actural flash object
      var nestedDom = parentContainer.find("object.video object")[0];
      return nestedDom || dom;
    },

    _onFlashCallBack: function(playerId, eventName, params) {
      if (playerId !== this.flashId) { return; }
      switch (eventName) {
        case "playerEmbedded":
          this.mb.publish(OO.EVENTS.PLAYER_EMBEDDED);
          this.playerEmbedded = true;
          this._setFlashParams();
          break;
        case "totalTimeChanged":
          this._duration = params.totalTime;
          this.mb.publish(OO.EVENTS.PLAYHEAD_TIME_CHANGED, this._playheadTime, this._getDuration(), this.videoWrapper.getBufferLength());
          break;
        case "playheadTimeChanged":
          this._playheadTime = params.playheadTime;
          this.mb.publish(OO.EVENTS.PLAYHEAD_TIME_CHANGED, this._playheadTime, this._getDuration(), this.videoWrapper.getBufferLength());
          break;
        case "embedCodeChanged":
        case "currentItemEmbedCodeChanged":
          this.mb.publish(OO.EVENTS.EMBED_CODE_CHANGED, params);
          this.mb.publish(OO.EVENTS.CONTENT_TREE_FETCHED, params);
          this.embedCodeChanged = true;
          if (this.queuedPlaybackReady) {
            this.mb.publish(OO.EVENTS.PLAYBACK_READY);
            this.queuedPlaybackReady = false;
          }
          break;
        case "fullscreenChanged":
          this.mb.publish(OO.EVENTS.FULLSCREEN_CHANGED, params.state == 'fullScreen');
          break;
        case "closedCaptionsTextReady":
          this._reportClosedCaptions();
          break;
        case "stateChanged":
          switch (params.state) {
            case "error":
              this.mb.publish(OO.EVENTS.ERROR, { code : params.errorCode, source : 'flash' });
              break;
            case "playing":
              this.mb.publish(OO.EVENTS.PLAYING);
              this._reportBitrates();
              break;
            case "paused":
              this.mb.publish(OO.EVENTS.PAUSED);
              break;
            case "buffering":
              this.mb.publish(OO.EVENTS.BUFFERING);
              break;
            default:
              OO.log('CALLBACK', arguments);
          }
          break;
        case "apiReady":
          if (((this.embedCode && this.embedCode === this.videoWrapper.getEmbedCode()) ||
              OO.CONSTANTS.STANDALONE_AD_HOLDER === this.videoWrapper.getEmbedCode()) &&
              !this.playbackReady) {
            if (!this.embedCodeChanged) {
              // PB-702 - sometimes flash player is stupid and sends apiReady before embedCodeChanged.
              this.queuedPlaybackReady = true;
            } else {
              this.mb.publish(OO.EVENTS.PLAYBACK_READY);
            }
            this.playbackReady = true;
          }
          break;
        case "playComplete":
          this.mb.publish(OO.EVENTS.PLAYED);
          break;
        case "volumeChanged":
          this.mb.publish(OO.EVENTS.VOLUME_CHANGED, params.volume);
          break;
        case 'companionAdsReady':
          this.mb.publish(OO.EVENTS.WILL_SHOW_COMPANION_ADS, {ads: params.companionAds});
          break;
        case 'adStarted':
          this._adDuration = params.adDuration / 1000;
          this._playingAd = true;
          var adItem = { duration: this._adDuration, type: 'flashad', format: params.format,
                source: params.source };
          this.mb.publish(OO.EVENTS.WILL_PLAY_ADS, adItem);
          break;
        case 'adCompleted':
          this._playingAd = false;
          this.mb.publish(OO.EVENTS.ADS_PLAYED);
          break;
        case 'singleAdStarted':
          var singleAdItem = { duration: params.adDuration / 1000, adId: params.adId,
            creativeId: params.creativeId, type: 'flashad', format: params.format,
            source: params.source };
          this.mb.publish(OO.EVENTS.WILL_PLAY_SINGLE_AD, singleAdItem);
          break;
        case 'singleAdCompleted':
          this.mb.publish(OO.EVENTS.SINGLE_AD_PLAYED);
          break;
        case 'adError':
          this._playingAd = false;
          this.mb.publish(OO.EVENTS.ADS_ERROR);
          break;
        case "seeked":
          this.mb.publish(OO.EVENTS.SCRUBBED);
          break;
        case "targetBitrateChanged":
          this._reportBitrates();
          break;
        case "adClicked":
          this.mb.publish(OO.EVENTS.ADS_CLICKED);
          break;
        case "getOoyalaStorageItem":
          OO.ooyalaStorage.getItem(params.key, _.bind(function(value) {
            this._fire("getOoyalaStorageItemResponse", [params.key, value]);
          }, this));
          break;
        case "setOoyalaStorageItem":
          OO.ooyalaStorage.setItem(params.key, params.value, _.bind(function(value) {
            this._fire("setOoyalaStorageItemResponse", [params.key, value]);
          }, this));
          break;
        case "removeOoyalaStorageItem":
          OO.ooyalaStorage.removeItem(params.key, _.bind(function(value) {
            this._fire("removeOoyalaStorageItemResponse", [params.key, value]);
          }, this));
          break;
        case "sharePanelClicked":
          this.mb.publish(OO.EVENTS.SHARE_PANEL_CLICKED);
          break;
        case "infoPanelClicked":
          this.mb.publish(OO.EVENTS.INFO_PANEL_CLICKED);
          break;
        case "authTokenChanged":
          this.mb.publish(OO.EVENTS.AUTH_TOKEN_CHANGED, params);
          break;
        case "startContentDownload":
          this.mb.publish(OO.EVENTS.DOWNLOADING, this._playheadTime,
            this._getDuration(), this.videoWrapper.getBufferLength(),
            null, params.streamURL);
          break;
        case "bitrateChanged":
          var bitrateItem = { videoBitrate : params.videoBitrate };
          this.mb.publish(OO.EVENTS.BITRATE_CHANGED, bitrateItem);
          break;
        case "subscribeToMessage":
          this.mb.subscribe(params.messageName, "flash_playback", _.bind(function(){this.videoWrapper[params.callback]();}, this));
          break;
        // We need to explicitly catch all known flash events that we do NOT want to propagate to V3 clients
        // Feel free to add to this list if you find something missing
        case "loadComplete":
        case "activePanelChanged":
        case "metadataReady":
        case "recommendedContentReady":
        case "relatedMediaReady":
        case "playerResize":
        case "attemptFullScreenChange":
        case "videoShared":
          OO.log('Ignoring flash callback', eventName, params);
          break;
        // Any event that drops through here is custom event, so should be pushed into message bus
        default:
          OO.log('Propagating flash callback', eventName, params);
          this.mb.publish(eventName, params);
      }
      if (this.enableDiagnostics) {
        this.mb.publish('ASP' + eventName, params);
      }
    },

    _fire: function(type, params) {
      if (this.playerEmbedded) { this.videoWrapper.fire({type: type, params: params}); }
    },

    _notifyTokenReadyForPlayer: function() {
      if (this.waitingForToken && this.adobeToken) {
          this.waitingForToken = false;
          this._fire('setEmbedToken', [this.adobeToken]);
      }
    },

    _adobeWaitingForToken: function(event) {
      this.waitingForToken = true;
      this._notifyTokenReadyForPlayer();
    },

    _adobeTokenFetched: function(event, token) {
      OO.log("setEmbedToken", token);
      this.adobeToken = token;
      this._notifyTokenReadyForPlayer();
    },

    _adobeAuthStatus: function(event, isAuthenticated, errorCode) {
      if (!isAuthenticated) { this.adobeToken = null; }
      this._fire('setAuthenticationStatus', [isAuthenticated, errorCode]);
      //TODO (mlen): this actually isn't handled in Flash.  Should it be?
    },

    _onError: function(event, errorType, errorCode) {
      if (errorType == OO.ERROR.ADOBE_PASS_TOKEN) {
        this.adobeToken = null;
        this._fire('tokenRequestFailed', [this.embedCode, errorCode]);
      }
    },

    _setFlashParams: function() {
      if (this.videoWrapper && this.playerEmbedded && !this.areFlashParamsSet) {

        // check if we need to wait for playerXml or sasResponse
        if (OO.playerParams.flash_performance) {
          if(!this.playerXml[this.embedCode] || !this.sasResponse[this.embedCode]) {
            return;
          }
        }

        var moduleParam = this.params || {};

        if (this.adobeToken) {
          moduleParam.authorization = { "embedToken" : this.adobeToken };
        } else if (!_.isEmpty(this.embedToken)) {
          moduleParam.authorization = { "embedToken": this.embedToken };
        }

        // apply flash params to module params
        _.extend(moduleParam, moduleParam['flashParams']);
        delete moduleParam['flashParams'];
        this.videoWrapper.setModuleParams(moduleParam);

        var params = _.extend({playerBrandingId: OO.playerParams.playerBrandingId}, this.options);
        this.queryStringParams = _.pick(params, this.QUERY_STRING_PARAM_WHITELIST);
        this.videoWrapper.setQueryStringParameters(_.extend(this.queryStringParams, this.flashVars || {}));

        if (OO.playerParams.flash_performance) {
          // TODO(pb-team): When run with flash-performance mode, SAS authorization happens in JS code and the
          // response is given to the flash player here. When that happens, the account_id parameter from the
          // SAS response does not get propagated to the flash analytics module. This should be fixed before
          // we enable flash performance mode by default.

          // SAS response needs to be set before player XML is set
          this.videoWrapper.setSasResponse({
            embedCode: this.embedCode,
            response: this.sasResponse[this.embedCode]
          });
          this.videoWrapper.setPlayerXml(this.playerXml[this.embedCode]);
        }

        // don't reset params until embedCode changes.
        this.areFlashParamsSet = true;
      }
    },

    _setEmbedCode: function(event, embedCode, options) {
      // adset players do not set embed codes
      if (embedCode === OO.CONSTANTS.STANDALONE_AD_HOLDER) {
        this._isStandaloneAd = true;
        return;
      }
      this._isStandaloneAd = false;

      this.playbackReady = false;
      this.queuedPlaybackReady = false;
      this.embedCodeChanged = false;

      if (OO.playerParams.flash_performance) {
        if (this.playerXmlRequest) {
          this.playerXmlRequest.abort();
          this.playerXmlRequest = null;
        }
      }

      this.areFlashParamsSet = false;
      this.embedCode = embedCode;
      this.options = options || {};
      this.options.embedCode = embedCode;
      this.embedToken = this.options.embedToken || this.embedToken || this.adobeToken;
      // Prevent crash by not accessing and setting this.flashVars in the case it is undefined
      if (this.flashVars) {
        this.flashVars.adSetCode = this.options.adSetCode || this.flashVars.adSetCode || "";
      }
      this._setFlashParams();
    },

    _playerWasCreated: function(event, elementId, params) {
      this.elementId = elementId;
      this.rootElement = $('#'+this.elementId + '>div');

      this.params = params;
      this.params.playerBrandingId = OO.playerParams.playerBrandingId;
      this.enableDiagnostics = params.enableDiagnostics || false;
      this.enableChannels = (OO.playerParams.enableChannels === "true" ? true : false) ||
                            (this.params.enableChannels === "true" ? true : false);
      this.debugHost = OO.playerParams.debugHost || this.params.debugHost || this.debugHost;

      //if extension enabled, hit static API for player.log. if namespaced, use that
      var defaultJsDebug = OO.chromeExtensionEnabled ? (OO.playerParams.namespace || "OO") + ".Player.flashDebugCallback" : null;
      this.o0jsdebug = OO.playerParams.o0jsdebug || this.params.o0jsdebug || defaultJsDebug;

      this.isTwitter = OO.playerParams.isTwitter || this.params.isTwitter || this.isTwitter;
      this.embedToken = params ? params.embedToken : undefined;
      this.adSetCode = params ? params.adSetCode : undefined;
      this.showInAdControlBar = params ? params.showInAdControlBar : undefined;
      this.adRequestTimeout = params ? params.adRequestTimeout : undefined;
      this.showAdMarquee = params ? params.showAdMarquee : undefined;

      // display initial ui
      this.videoWrapper = this._createFlashElement(this.rootElement);

      if (!OO.supportsFlash) {
        this.mb.publish(OO.EVENTS.ERROR, { source: "flash", code: OO.ERROR.UNPLAYABLE_CONTENT });
      }
    },

    _play: function(event, streamUrl) {
      this.videoWrapper.playMovie();
      // send out volume (flash don't have it before play)
      this.mb.publish(OO.EVENTS.VOLUME_CHANGED, this.videoWrapper.getVolume());
    },

    _pause: function(event) {
      this.videoWrapper.pauseMovie();
    },

    _toggleSharePanel: function(event) {
      this.videoWrapper.toggleSharePanel();
    },

    _toggleInfoPanel: function(event) {
      this.videoWrapper.toggleInfoPanel();
    },

    _shouldDisplayCuePointMarkers: function(event, visible) {
      this.videoWrapper.shouldDisplayCuePointMarkers(visible);
    },

    _seek: function(event, seconds) {
      this.videoWrapper.seek(seconds);
    },

    _changeVolume: function(event, volume) {
      this.videoWrapper.setVolume(volume);
    },

    _skipAd: function() {
      this.videoWrapper.skipAd();
    },

    _reportBitrates: function() {
      this.mb.publish(OO.EVENTS.BITRATE_INFO_AVAILABLE, {
        bitrateQualities: this.videoWrapper.getBitrateQualitiesAvailable(),
        bitrates: this.videoWrapper.getBitratesAvailable(),
        targetBitrateQuality: this.videoWrapper.getTargetBitrateQuality(),
        targetBitrate: this.videoWrapper.getTargetBitrate()
      });
    },

    _setTargetBitrate: function(event, bitrate) {
      this.videoWrapper.setTargetBitrate(bitrate);
    },

    _setTargetBitrateQuality: function(event, bitrateQuality) {
      this.videoWrapper.setTargetBitrateQuality(bitrateQuality);
    },

    _setClosedCaptionsLanguage: function(event, language) {
      this.videoWrapper.setClosedCaptionsLanguage(language);
    },

    _reportClosedCaptions: function() {
      try {
        this.mb.publish(OO.EVENTS.CLOSED_CAPTIONS_INFO_AVAILABLE, this.videoWrapper.getCurrentItemClosedCaptionsLanguages());
      } catch(e) {
      }
    },

    _fetchStyle: function() {
      this.mb.publish(OO.EVENTS.STYLE_FETCHED, this.videoWrapper.getStyles());
    },

    _setStyle: function(event, style) {
      this.videoWrapper.setStyles(style);
    },

    _insertCuePoint: function(event, type, preloadTime, duration) {
      this.videoWrapper.insertCuePoint(type, preloadTime || 0, duration || 0);
    },


    __placeholder:true
  });

  OO.registerModule('flash_playback', function(messageBus, id) {
    return new FlashPlaybackModule(messageBus, id);
  });

}(OO, OO._, OO.$));
(function(OO,_,$){
  /*
   *  Defines the playback controller
   */

  var ApiModule = function(messageBus, id, params) {
    if (OO.playerParams.platform === "flash-adset") { return; }
    this.mb = messageBus;
    this.id = id;
    this.params = params || {};

    this.contentTree = {};
    this.metadata = {};
    this.sasResponse = {};
    this.authToken = OO.localStorage.getItem("oo_auth_token");

    this._aborting = false;
    this._contentAjax = null;
    this._metadataAjax = null;
    this._sasAjax = null;

    OO.StateMachine.create({
      initial:'Init',
      messageBus:this.mb,
      moduleName:'Api',
      target:this,
      events:[
        {name:OO.EVENTS.SET_EMBED_CODE,                     from:'*',                                          to:'Init'},
        {name:OO.EVENTS.EMBED_CODE_CHANGED,                 from:'Init',                                       to:'WaitingForAPIResponse'},

        {name:OO.EVENTS.WILL_FETCH_CONTENT_TREE,            from:'WaitingForAPIResponse'},
        {name:OO.EVENTS.WILL_FETCH_METADATA,                from:'WaitingForAPIResponse'},
        {name:OO.EVENTS.WILL_FETCH_AUTHORIZATION,           from:'WaitingForAPIResponse'},
        {name:OO.EVENTS.WILL_FETCH_AD_AUTHORIZATION,        from:['WaitingForAPIResponse', "Init"]},

        {name:OO.EVENTS.PLAYBACK_READY,                     from:'WaitingForAPIResponse',                      to:'Init'},
      ]
    });
  };

  _.extend(ApiModule.prototype, {

    onSetEmbedCode: function(event, embedCode, options) {
      // store parameters
      this.rootEmbedCode = embedCode;
      this.adSetCode = options ? options.adSetCode : undefined;
      this.embedToken = (options && options.embedToken) || this.embedToken;
      this.mb.publish(OO.EVENTS.EMBED_CODE_CHANGED, embedCode, options);
    },

    onEmbedCodeChanged: function(event, embedCode) {
      // store parameters
      this.currentEmbedCode = embedCode;

      this._abort(this._contentAjax);
      this._abort(this._metadataAjax);
      this._abort(this._sasAjax);

      // start server request
      var request = {
        embedCode: this.currentEmbedCode,
        pcode: OO.playerParams.pcode || "unknown",
        playerBrandingId : OO.playerParams.playerBrandingId || "unknown",
        params: {}
      };

      if (!_.isEmpty(this.adSetCode)) {
        _.extend(request.params, { adSetCode: this.adSetCode });
      }
      if (!_.isEmpty(this.embedToken)) {
        _.extend(request.params, { embedToken: this.embedToken });
      }

      // Note(bz): Temporary call to fetch player xml until we move to player api
      var apiRequest = _.extend({}, request, { server: OO.SERVER.API });
      var authRequest = _.extend({}, request, { server: OO.SERVER.AUTH });

      //always publish the metadata event, but only html5 should publish the others.
      this.mb.publish(OO.EVENTS.WILL_FETCH_METADATA, apiRequest);
      if (OO.requiredInEnvironment('html5-playback') ||
        OO.requiredInEnvironment('cast-playback') || OO.playerParams.flash_performance) {
        this.mb.publish(OO.EVENTS.WILL_FETCH_PLAYER_XML, apiRequest);
        this.mb.publish(OO.EVENTS.WILL_FETCH_CONTENT_TREE, apiRequest);
        this.mb.publish(OO.EVENTS.WILL_FETCH_AUTHORIZATION, authRequest);
      }
    },

    // Ooyala API Calls

    /*
     *  Content Tree
     */
    onWillFetchContentTree: function(event, request) {
      if (typeof this.contentTree[this.currentEmbedCode] != "undefined") {
        this.mb.publish(OO.EVENTS.CONTENT_TREE_FETCHED, this.contentTree[this.currentEmbedCode]);
      } else {
        this._contentAjax = $.ajax({
          url: OO.URLS.CONTENT_TREE(request) + "?" + $.param(request.params),
          type: 'GET',
          dataType: 'json',
          crossDomain: true,
          success: _.bind(this._onContentTreeFetched, this),
          error: _.bind(this._onApiError, this)
        });
      }
    },

    _onContentTreeFetched: function(response) {
      var embed_code;
      var safe_response = OO.HM.safeObject("playbackControl.contentTree", response, {});

      this._contentAjax = null;

      if (safe_response.errors && safe_response.errors.code == 0) {
        _.each(safe_response.content_tree, _.bind(function(value, embed_code){
          this.contentTree[embed_code] = safe_response.content_tree[embed_code];

        }, this));
      }

      var supportedContentType = ["Video", "VideoAd", "LiveStream", "Channel", "MultiChannel"];
      if (this.contentTree[this.currentEmbedCode]) {
        var hostedAtURL = safe_response.content_tree[this.currentEmbedCode].hostedAtURL;
        if (hostedAtURL == "" || hostedAtURL == null) {
          safe_response.content_tree[this.currentEmbedCode].hostedAtURL = document.URL;
        }

        var contentIsSupportedInHtml5 = supportedContentType.indexOf(this.contentTree[this.currentEmbedCode].content_type) >= 0;
        if (contentIsSupportedInHtml5 || OO.playerParams.flash_performance) {
          this.mb.publish(OO.EVENTS.CONTENT_TREE_FETCHED, this.contentTree[this.currentEmbedCode], this.currentEmbedCode);
        } else {
          this.mb.publish(OO.EVENTS.ERROR, { code : OO.ERROR.API.CONTENT_TREE });
        }
      } else {
        this.mb.publish(OO.EVENTS.ERROR, { code : OO.ERROR.UNPLAYABLE_CONTENT });
      }
    },


    /*
     *  Metadata
     */
    onWillFetchMetadata: function(event, request) {
      // send the metadata request
      if (typeof this.metadata[this.currentEmbedCode] != "undefined") {
        this.mb.publish(OO.EVENTS.METADATA_FETCHED, this.metadata[this.currentEmbedCode]);
      } else {
        this._metadataAjax = $.ajax({
          url: OO.URLS.METADATA(request) + "&" + $.param(request.params),
          type: 'GET',
          dataType: 'json',
          crossDomain: true,
          success: _.bind(this._onMetadataFetched, this),
          error: _.bind(this._onApiError, this)
        });
      }
    },

    _onMetadataFetched: function(response) {
      this.metadata = this.metadata || {};
      var safeResponse = OO.HM.safeObject("api.metadata", response, {});
      this._metadataAjax = null;

      if (safeResponse.errors && safeResponse.errors.code == 0) {
        _.each(safeResponse.metadata, _.bind(function(value, embedCode){
          this.metadata[embedCode] = safeResponse.metadata[embedCode];

          // allow to override module params from player params
          this.metadata[embedCode].modules = this.metadata[embedCode].modules || {};
          this.metadata[embedCode].modules = _.extend(this.metadata[embedCode].modules, this.params.modules || {});
        }, this));
      }
      this.mb.publish(OO.EVENTS.METADATA_FETCHED, this.metadata[this.currentEmbedCode] || {});

      if (safeResponse.errors && safeResponse.errors.player_movie_mismatch &&
        typeof(window.console) != "undefined" && typeof(window.console.log) == "function") {
          console.log("WARNING: Player and movie providers do not match");
      }
    },

    /*
     *  SAS
     */
    onWillFetchAuthorization: function(event, request) {
      if (this.sasResponse[this.currentEmbedCode] && this.sasResponse[this.currentEmbedCode].code == 0) {
        this.mb.publish(OO.EVENTS.AUTHORIZATION_FETCHED, this.sasResponse[this.currentEmbedCode]);
      } else {
        //add additional params for SAS
        this._sendSasRequest(request, _.bind(this._onAuthorizationFetched, this), _.bind(this._onApiError, this));
      }
    },

    _onAuthorizationFetched: function(response) {
      var code, codes;
      this._sasAjax = null;

      if (OO.requiredInEnvironment('flash-playback')) {
        // Flash needs the entire response and will handle individual embed code authorization_data
        this.sasResponse[this.currentEmbedCode] = response;
        code = response.authorization_data[this.currentEmbedCode].code;
      } else {
        var safe_response = OO.HM.safeObject("playbackControl.sasResponse", response, {});

        //save auth token
        if (safe_response.auth_token) {
          OO.localStorage.setItem("oo_auth_token", safe_response.auth_token);
          this.authToken = safe_response.auth_token;
        } else {
          OO.localStorage.removeItem("oo_auth_token");
          this.authToken = null;
        }

        _.each(safe_response.authorization_data, _.bind(function(value, embed_code){
          this.sasResponse[embed_code] = safe_response.authorization_data[embed_code];
          if (safe_response.debug_data) {
            this.sasResponse[embed_code].debug_data = safe_response.debug_data;
          }
          if (safe_response.user_info) {
            this.sasResponse[embed_code].user_info = safe_response.user_info;
          }
          if (safe_response.auth_token) {
            this.sasResponse[embed_code].auth_token = safe_response.auth_token;
          }
          if (safe_response.heartbeat_data) {
            this.sasResponse[embed_code].heartbeat_data = safe_response.heartbeat_data;
          }
        }, this));
        code = this.sasResponse[this.currentEmbedCode].code;
      }

      // Always publish the Authorization Response for Flash and only publish this on success for HTML5
      if ((code == 0) || OO.requiredInEnvironment('flash-playback')) {
        this.mb.publish(OO.EVENTS.AUTHORIZATION_FETCHED, this.sasResponse[this.currentEmbedCode]);
        return;
      }
      if (!_.isString(code)) {
        this.mb.publish(OO.EVENTS.ERROR, { code : OO.ERROR.API.SAS.GENERIC });
        return;
      }
      codes = code.split(',');
      if (_.contains(codes, '2')) {
        this.mb.publish(OO.EVENTS.ERROR, { code : OO.ERROR.API.SAS.DOMAIN });
      } else if (_.contains(codes, '3')) {
        this.mb.publish(OO.EVENTS.ERROR, { code : OO.ERROR.API.SAS.GEO });
      } else if (_.contains(codes, '4')) {
        this.mb.publish(OO.EVENTS.ERROR, { code : OO.ERROR.API.SAS.FUTURE });
      } else if (_.contains(codes, '5')) {
        this.mb.publish(OO.EVENTS.ERROR, { code : OO.ERROR.API.SAS.PAST });
      } else if (_.contains(codes, '13')) {
        this.mb.publish(OO.EVENTS.ERROR, { code : OO.ERROR.API.SAS.DEVICE });
      } else if (_.contains(codes, '18')) {
        this.mb.publish(OO.EVENTS.ERROR, { code : OO.ERROR.API.SAS.CONCURRENT_STREAMS });
      } else if (_.contains(codes, '24')) {
        this.mb.publish(OO.EVENTS.ERROR, { code : OO.ERROR.API.SAS.PROXY });
      } else {
        this.mb.publish(OO.EVENTS.ERROR, { code : OO.ERROR.API.SAS.GENERIC });
      }
    },

    onWillFetchAdAuthorization: function(event, request) {
      this._sendSasRequest(request, _.bind(this._onAdAuthorizationFetched, this));
    },

    _onAdAuthorizationFetched: function(response) {
      var safe_response = OO.HM.safeObject("playbackControl.sasResponse", response, {});

      var ooyalaAds = {};
      _.each(safe_response.authorization_data, _.bind(function(value, embed_code){
        ooyalaAds[embed_code] = safe_response.authorization_data[embed_code];
      }, this));

      this.mb.publish(OO.EVENTS.AD_AUTHORIZATION_FETCHED, ooyalaAds);
    },

    _sendSasRequest: function(request, callback, errorback) {
      var formats = _.reduce(OO.supportedVideoTypes, function(s, supported, type) {
        if (supported) { s.push(type); }
        return s;
      }, []),
      profiles = OO.supportedVideoProfiles,
      device = OO.device;

      $.extend(request.params, { device: device, domain:OO.docDomain, supportedFormats:formats.join(',')});
      if (profiles) {
       $.extend(request.params, {profiles:profiles}); // set profiles if any
      }
      if (this.authToken) {
        $.extend(request.params, { auth_token: this.authToken });
      }

      this._sasAjax = $.ajax({
        url: OO.URLS.SAS(request) + "?" + $.param(request.params),
        type: 'GET',
        dataType: 'json',
        crossDomain: true,
        success: callback,
        error: errorback
      });
    },

    _abort: function(ajax) {
      if (!ajax) { return; }
      this._aborting = true;
      ajax.abort();
      this._aborting = false;
    },

    _onApiError: function(xhr, status, error) {
      if (this._aborting) { return; }

      OO.d(error, status, xhr);
      this.mb.publish(OO.EVENTS.ERROR, { code : OO.ERROR.API.NETWORK, xhrStatus : status });
    },

    __placeholder: true
  });

  OO.registerModule('api', function(messageBus, id, params) {
    return new ApiModule(messageBus, id, params);
  });
}(OO, OO._, OO.$));
  OO.plugin("Channels", function(OO, _, $, W) {

    /*
     * Channel Module:  Intercept all CONTENT_TREE_FETCHED events.
     *   If the player is a flash player, and channels are enabled, play the flash player v2 style
     *   If the player is a flash player, and channels are disabled, publish an error
     *   If the player is html5 and channels are enabled, play the first video of the channel
     *   If the player is html5 and channels are disabled, publish an error
     */
    var Channels = function(mb, id) {
      this.id = id;
      this.mb = mb;
      this.channel_tree = null;
      this.channel_pos = -1;
      this.replay = false;

      OO.StateMachine.create({
        initial:'Init',
        messageBus:this.mb,
        moduleName:'Channels',
        target:this,
        events:[
          {name:OO.EVENTS.PLAYER_CREATED, from:'*'}
        ]
      });
    };

    _.extend(Channels.prototype, {
      onPlayerCreated: function(event, elementId, params) {
        this.enableChannels = params.enableChannels || OO.playerParams.enableChannels || false;
        this.mb.intercept(OO.EVENTS.CONTENT_TREE_FETCHED, "channels",
          _.bind(this._checkTreeForChannel, this));
      },

      _checkTreeForChannel: function(eventName, tree) {
        var supportedContentType = ["Channel", "MultiChannel"];

        //if i get a tree from V3, it will have contenttype
        if (tree && (supportedContentType.indexOf(tree.content_type) >= 0 || tree.lineup)) {
          if (this.enableChannels) {
            //if this is a html5 player, take first child's embed code
            if (OO.requiredInEnvironment('html5-playback') || OO.requiredInEnvironment('cast-playback')) {
              if(!tree.children) {
                if(tree.content_type == 'Channel') {
                  this.mb.publish(OO.EVENTS.ERROR, { code : OO.ERROR.EMPTY_CHANNEL });
                } else {
                  this.mb.publish(OO.EVENTS.ERROR, { code : OO.ERROR.EMPTY_CHANNEL_SET });
                }
                return false;
              }
              this.channel_tree = tree;
              this.channel_pos = 0;
              this.mb.subscribe(OO.EVENTS.PLAYED, 'channels', _.bind(this.onPlayed, this));
              this.mb.subscribe(OO.EVENTS.PLAYBACK_READY, 'channels', _.bind(this.onPlaybackReady, this));
              this.mb.publish(OO.EVENTS.SET_EMBED_CODE, tree.children[0].embed_code);
            }
            return false;
          }

          //If this is a channel, and channels are not enabled, error out
          this.mb.publish(OO.EVENTS.ERROR, { code : OO.ERROR.CHANNEL_CONTENT });
          return false;
        }

        return [tree];
      },


      onPlayed: function(event) {
        this.channel_pos++;

        //Every time a video is played, set the embed code to the next video.
        if(this.channel_tree.children[this.channel_pos]) {
          this.mb.publish(OO.EVENTS.SET_EMBED_CODE, this.channel_tree.children[this.channel_pos].embed_code);
        }

        //If we played the last video, reset to the first video
        else {
          this.channel_pos = 0;
          this.mb.publish(OO.EVENTS.SET_EMBED_CODE, this.channel_tree.children[0].embed_code);
        }
      },

      //Every time the video is loaded (other than first), autoplay
      onPlaybackReady: function(event) {
        if(this.channel_pos > 0) {
          this.mb.publish(OO.EVENTS.PLAY);
        }
      }
    });

    // Return class definition.
    return Channels;
  });
OO.plugin("ExternalId", function(OO, _, $, W) {

  /*
   * Channel Module:  Intercept all CONTENT_TREE_FETCHED events.
   *   If the player is a flash player, and ExternalId are enabled, play the flash player v2 style
   *   If the player is a flash player, and ExternalId are disabled, publish an error
   *   If the player is html5 and ExternalId are enabled, play the first video of the channel
   *   If the player is html5 and ExternalId are disabled, publish an error
   */
  var ExternalId = function(mb, id) {
    this.id = id;
    this.mb = mb;

    this.mb.intercept(OO.EVENTS.SET_EMBED_CODE, "ExternalId", _.bind(this._checkExternalId, this));
  };

  _.extend(ExternalId.prototype, {
    /*
     *  External ID lookup
     */
     _checkExternalId: function(event, embedCode, options) {
       var externalId = embedCode.match("^extId:(.*)");
       if (externalId && externalId[1]) {
         this.externalId = externalId[1];
         this.options = options;
         this._fetchExternalId({
           externalId: this.externalId,
           pcode: OO.playerParams.pcode || "1kNG061cgaoolOncv54OAO1ceO-I",
           server: OO.SERVER.API
         });
         return false;
       }
       return [embedCode, options];
     },

    _fetchExternalId: function(request) {
      this._contentAjax = $.ajax({
        url: OO.URLS.EXTERNAL_ID(request),
        type: 'GET',
        dataType: 'json',
        crossDomain: true,
        cache:false,
        success: _.bind(this._onExternalIdFetched, this),
        error: _.bind(this._onExternalIdError, this)
      });
    },

    _onExternalIdFetched: function(response) {
      var embedCode = null;
      var safe_response = OO.HM.safeObject("playbackControl.contentTree", response, {});

      if (safe_response.errors && safe_response.errors.code == 0) {
        _.each(safe_response.content_tree, _.bind(function(value, ec){
          if (value["external_id"] === this.externalId) {
            embedCode = ec;
          }
        }, this));
      }

      // save the external Id in the option hash (in case it's needed for analytics and such)
      _.extend(this.options, {originalId : this.externalId});

      if (embedCode) {
        this.mb.publish(OO.EVENTS.SET_EMBED_CODE, embedCode, this.options);
      } else {
        this.mb.publish(OO.EVENTS.ERROR, { code: OO.ERROR.INVALID_EXTERNAL_ID });
      }
    },

    _onExternalIdError: function(response) {
      this.mb.publish(OO.EVENTS.ERROR, { code: OO.ERROR.INVALID_EXTERNAL_ID });
    }
  });

  // Return class definition.
  return ExternalId;
});
(function(OO, _, $){

  var AuthHeartbeat = function(messageBus, id) {
    if (!OO.requiredInEnvironment('html5-playback') && !OO.requiredInEnvironment('cast-playback')) { return; }
    this.mb = messageBus;
    this.id = id;

    this.authToken = null;
    this.heartbeatInterval = 300;  // in sec
    this.timer = null;
    this.retries = 3;

    //internal constants
    this.AUTH_HEARTBEAT_URL = _.template('<%=server%>/player_api/v1/auth_heartbeat/pcode/<%=pcode%>/auth_token/<%=authToken%>');

    //listeners
    this.mb.subscribe(OO.EVENTS.EMBED_CODE_CHANGED, 'auth_heartbeat', _.bind(this._onEmbedCodeChanged, this));
    this.mb.subscribe(OO.EVENTS.AUTHORIZATION_FETCHED, 'auth_heartbeat', _.bind(this._onAuthorizationFetched, this));
  };

  _.extend(AuthHeartbeat.prototype, {
    _onEmbedCodeChanged: function(event, embedCode) {
      if (this.timer) {
        clearInterval(this.timer);
      }
      if (this.ajax) {
        this.ajax.error = null;
        this.ajax.abort();
        this.ajax = null;
      }
      this.retries = 3;
    },

    _onAuthorizationFetched: function(event, authResponse) {
      if (authResponse.heartbeat_data && authResponse.heartbeat_data.heartbeat_interval) {
        this.heartbeatInterval = authResponse.heartbeat_data.heartbeat_interval;
      }
      if (authResponse.auth_token) {
        this.authToken = authResponse.auth_token;
      }
      if (authResponse.require_heartbeat === true) {
        this.timer = setInterval(_.bind(this._onTimerTick, this), this.heartbeatInterval * 1000);
        this._onTimerTick(); //Fire first heartbeat NOW.
      }
    },

    _onTimerTick: function() {
      //send heartbeat
      this.ajax = $.ajax({
        url: this.AUTH_HEARTBEAT_URL({
          server: OO.SERVER.AUTH,
          pcode: OO.playerParams.pcode || "unknown",
          authToken: this.authToken || ""
        }),
        type: 'GET',
        dataType: 'json',
        crossDomain: true,
        cache: false,
        success: _.bind(this._onHeartbeatResponse, this),
        error: _.bind(this._onHeartbeatError, this, OO.ERROR.API.SAS.CONCURRENT_STREAMS)
      });
    },

    _onHeartbeatResponse: function(response) {
      this.ajax = null;
      if (!response.message || response.message != "OK" || !response.signature) {
        this._onHeartbeatError(OO.ERROR.API.SAS.INVALID_HEARTBEAT);
      }
      else if (!response.expires || response.expires < new Date().getTime()/1000) {
        this._onHeartbeatError(OO.ERROR.API.SAS.INVALID_HEARTBEAT);
      }
      else {
        this.retries = 3;
        if (response.auth_token != null) {
          this.authToken = response.auth_token;
          OO.localStorage.setItem("oo_auth_token", response.auth_token);
        }
      }
    },

    _onHeartbeatError: function(errorMessage) {
      this.ajax = null;
      this.retries--;

      if (this.retries > 0) {
        this._onTimerTick();
        return;
      }

      if (this.timer) {
        clearInterval(this.timer);
      }
      this.mb.publish(OO.EVENTS.ERROR, { code: errorMessage });
    }
  });

  OO.registerModule('auth_heartbeat', function(messageBus, id) {
    return new AuthHeartbeat(messageBus, id);
  });

}(OO, OO._, OO.$));
(function(OO, _, $){
  /*
   *  Defines a util function to parse the vast inline xml response to json object
   */
  var isValidVastXML = function(vastXML) {
    var rootTagName = (vastXML && vastXML.firstChild) ? vastXML.firstChild.tagName || '' : '';
    if (rootTagName.toUpperCase() != "VAST") {
      OO.log("Invalid VAST XML for tag name: " + rootTagName);
      return false;
    }
    // TODO, when 3.0 is supported, update this check.
    if ($(vastXML.firstChild).attr('version') !== '2.0') { return false; }
    return true;
  };

  var TrackingEvents = ['creativeView', 'start', 'midpoint', 'firstQuartile', 'thirdQuartile', 'complete',
      'mute', 'unmute', 'pause', 'rewind', 'resume', 'fullscreen', 'expand', 'collapse', 'acceptInvitation',
      'close' ];

  var getVastTemplate = function() {
    return {
      error: [],
      impression: [],
      // Note: This means we only support at most 1 linear and 1 non-linear ad
      linear: {},
      nonLinear: {},
      companion: []
    };
  };

  var filterEmpty = function(array) {
    return _.reject(array, function(x){
             return x === null || x === "";
           }, {});
  };

  var parseTrackingEvents = function(tracking, xml, trackingEvents) {
    var events = trackingEvents || TrackingEvents;
    _.each(events, function(item) {
      var sel = "Tracking[event=" + item + "]";
      tracking[item] = filterEmpty(xml.find(sel).map(function(i, v) { return $(v).text(); }));
    }, {});
  };

  var parseLinearAd = function(linearXml) {
    var result = {
      tracking: {},
      // ClickTracking needs to be remembered because it can exist in wrapper ads
      ClickTracking: filterEmpty($(linearXml).find("ClickTracking").map(function() { return $(this).text(); })),
      ClickThrough: filterEmpty($(linearXml).find("ClickThrough").map(function() { return $(this).text(); })),
      CustomClick: filterEmpty($(linearXml).find("CustomClick").map(function() { return $(this).text(); }))
    };
    var mediaFile = linearXml.find("MediaFile");

    parseTrackingEvents(result.tracking, linearXml);
    if (mediaFile.size() > 0) {
      result.mediaFiles = filterEmpty(mediaFile.map(function(i,v) {
        return {
          type: $(v).attr("type").toLowerCase(),
          url: $.trim($(v).text()),
          bitrate: $(v).attr("bitrate"),
          width: $(v).attr("width"),
          height: $(v).attr("height")
        };
      }));
      result.Duration = linearXml.find("Duration").text();
    }

    return result;
  };

  var parseNonLinearAds = function(nonLinearAdsXml) {
    var result = { tracking: {} };
    var nonLinear = nonLinearAdsXml.find("NonLinear").eq(0);

    parseTrackingEvents(result.tracking, nonLinearAdsXml);

    if (nonLinear.size() > 0) {
      var staticResource = nonLinear.find("StaticResource");
      var iframeResource = nonLinear.find("IFrameResource");
      var htmlResource = nonLinear.find("HTMLResource");
      result.width = nonLinear.attr("width");
      result.height = nonLinear.attr("height");
      result.expandedWidth = nonLinear.attr("expandedWidth");
      result.expandedHeight = nonLinear.attr("expandedHeight");
      result.scalable = nonLinear.attr("scalable");
      result.maintainAspectRatio = nonLinear.attr("maintainAspectRatio");
      result.minSuggestedDuration = nonLinear.attr("minSuggestedDuration");
      result.NonLinearClickThrough = nonLinear.find("NonLinearClickThrough").text();

      if (staticResource.size() > 0) {
        _.extend(result, { type: "static", data: staticResource.text(), url: staticResource.text() });
      } else if (iframeResource.size() > 0) {
        _.extend(result, { type: "iframe", data: iframeResource.text(), url: iframeResource.text() });
      } else if (htmlResource.size() > 0) {
        _.extend(result, { type: "html", data: htmlResource.text(), htmlCode: htmlResource.text() });
      }
    }

    return result;
  };

  var parseCompanionAd = function(companionAdXml) {
    var result = { tracking: {} };
    var staticResource = companionAdXml.find("StaticResource");
    var iframeResource = companionAdXml.find("IFrameResource");
    var htmlResource = companionAdXml.find("HTMLResource");

    parseTrackingEvents(result.tracking, companionAdXml, ["creativeView"]);

    result.width = companionAdXml.attr("width");
    result.height = companionAdXml.attr("height");
    result.expandedWidth = companionAdXml.attr("expandedWidth");
    result.expandedHeight = companionAdXml.attr("expandedHeight");
    result.CompanionClickThrough = companionAdXml.find("CompanionClickThrough").text();

    if (staticResource.size() > 0) {
      _.extend(result, { type: "static", data: staticResource.text(), url: staticResource.text() });
    } else if (iframeResource.size() > 0) {
      _.extend(result, { type: "iframe", data: iframeResource.text(), url: iframeResource.text() });
    } else if (htmlResource.size() > 0) {
      _.extend(result, { type: "html", data: htmlResource.text(), htmlCode: htmlResource.text() });
    }

    return result;
  };

  var VastAdSingleParser = function(xml, type) {
    var result = getVastTemplate();
    var linear = $(xml).find("Linear").eq(0);
    var nonLinearAds = $(xml).find("NonLinearAds");

    if (type === "wrapper") { result.VASTAdTagURI = $(xml).find("VASTAdTagURI").text(); }
    result.error = filterEmpty($(xml).find("Error").map(function() { return $(this).text(); }));
    result.impression = filterEmpty($(xml).find("Impression").map(function() { return $(this).text(); }));

    if (linear.size() > 0) { result.linear = parseLinearAd(linear); }
    if (nonLinearAds.size() > 0) { result.nonLinear = parseNonLinearAds(nonLinearAds); }
    $(xml).find("Companion").map(function(i, v){
      result.companion.push(parseCompanionAd($(v)));
      return 1;
    });

    return result;
  };

  OO.VastParser = function(vastXML) {
    if (!isValidVastXML(vastXML)) { return null; }

    var inline = $(vastXML).find("InLine");
    var wrapper = $(vastXML).find("Wrapper");
    var result = { ads: [] };

    if (inline.size() > 0) {
      result.type = "inline";
    } else if (wrapper.size() > 0) {
      result.type = "wrapper";
    } else {
      return null;
    }
    $(vastXML).find("Ad").each(function() {
      result.ads.push(VastAdSingleParser(this, result.type));
    });

    return result;
  };

}(OO, OO._, OO.$));
  (function(OO, _, $){
    OO.VastAdLoader = OO.inherit(OO.Emitter, function(embedCode) {
      this.inlineAd = null;
      this.currentDepth = 0;
      this.vastAdUnit = null;
      this.loaded = false;
      this.errorType = '';
      this.embedCode = embedCode || 'unknown';
      this.loaderId = 'OoVastAdsLoader' + OO.getRandomString();
      this.wrapperAds = { error: [],
                          impression: [],
                          companion: [],
                          linear: { tracking: {}, ClickTracking: [] },
                          nonLinear: { tracking: {} } };
    });

    _.extend(OO.VastAdLoader, {
      ERROR: 'vastError',
      READY: 'vastReady',

      __placeholder:true
    });

    _.extend(OO.VastAdLoader.prototype, {
      loadUrl: function(url, errorCallback) {
        this.vastUrl = url;
        this._ajax(url, errorCallback || this._onVastError, 'xml');
      },

      _ajax: function(url, errorCallback, dataType) {
        var done = (dataType == "script") ? function() {} : null;
        $.ajax({
          url: OO.getNormalizedTagUrl(url, this.embedCode),
          type: 'GET',
          beforeSend: function(xhr) {
            xhr.withCredentials = true;
          },
          dataType: dataType,
          crossDomain: true,
          cache:false,
          success: done || _.bind(this._onVastResponse, this),
          error: _.bind(errorCallback, this)
        });
      },

      getVastAdUnit: function() {
        return OO.safeClone(this.vastAdUnit);
      },

      _getProxyUrl: function() {
        OO.publicApi[this.loaderId] = _.bind(this._onVastProxyResult, this);
        if (OO.playerParams.vast_proxy_url) {
          return [OO.playerParams.vast_proxy_url, "?callback=OO.", this.loaderId, "&tag_url=",
              escape(this.vastUrl), "&embed_code=", this.embedCode].join("");
        }
        return OO.URLS.VAST_PROXY({
            cb: "OO." + this.loaderId,
            embedCode: this.embedCode,
            expires: (new Date()).getTime() + 1000,
            tagUrl: escape(this.vastUrl)
        });
      },

      _onVastError: function(event) {
        this.errorType = 'directAjaxFailed';
        this._ajax(this._getProxyUrl(), this._onFinalError, 'script');
        this.trigger(OO.VastAdLoader.ERROR, this);
      },

      _onFinalError: function() {
        this.errorType = "proxyAjaxFailed";
        this.trigger(OO.VastAdLoader.ERROR, this);
      },

      _extractStreamForType: function(streams, type) {
        // TODO, also cap on bitrate and width/height if there is any device restriction.
        var filter = [];
        switch (type) {
          case "webm":
            filter.push("video/webm");
             break;
          case "mp4":
            filter.push("video/mp4");
            if (OO.isIos) { filter.push("video/quicktime"); }
            break;
        }
        var stream = _.find(streams, function(v) { return (filter.indexOf(v.type) >= 0); }, this);
        return stream ? stream.url : null;
      },

      _handleLinearAd: function() {
        // filter our playable stream:
        var firstLinearAd = _.find(this.inlineAd.ads, function(v){ return !_.isEmpty(v.linear.mediaFiles); }, this);
        if (!firstLinearAd) { return false; }
        var streams = firstLinearAd.linear.mediaFiles;
        var maxMedia = _.max(streams, function(v) { return parseInt(v.bitrate, 10); });
        this.vastAdUnit.maxBitrateStream = maxMedia && maxMedia.url;
        this.vastAdUnit.durationInMilliseconds = OO.timeStringToSeconds(firstLinearAd.linear.Duration) * 1000;
        if (OO.supportedVideoTypes.webm) {
          this.vastAdUnit.streamUrl = this._extractStreamForType(streams, "webm");
        }

        if (this.vastAdUnit.streamUrl == null && OO.supportedVideoTypes.mp4) {
          this.vastAdUnit.streamUrl = this._extractStreamForType(streams, "mp4");
        }
        // TODO, check if any ads network will return m3u8.
        if (this.vastAdUnit.streamUrl == null && OO.supportedVideoTypes.m3u8) {
          OO.log("extrac m3u8 stream here");
        }
        // TODO, need to merge field here for any array object;
        _.extend(this.vastAdUnit.data, firstLinearAd);
        // TODO: Come up with a smarter method for being linear/non-linear agnostic re: tracking
        this.vastAdUnit.data.tracking = firstLinearAd.linear.tracking;

        if (this.vastAdUnit.streamUrl == null) {
          // No Playable stream, report error.
          OO.log("Can not find playable stream in vast result", this.inlineAd);
          return false;
        }
        return true;

      },

      _mergeVastAdResult: function() {
        this.vastAdUnit = { data: {}, vastUrl: this.vastUrl, maxBitrateStream: null };
        // TODO: merge all wrapper ads here. this.wrapperAds
        _.each(this.inlineAd.ads, function(ad) {
          ad.error = this.wrapperAds.error.concat(ad.error);
          ad.impression = this.wrapperAds.impression.concat(ad.impression);
          ad.companion = this.wrapperAds.companion.concat(ad.companion);
          if (this.wrapperAds.linear.ClickTracking) {
            ad.linear.ClickTracking = this.wrapperAds.linear.ClickTracking.concat(ad.linear.ClickTracking || []);
          }
          if (this.wrapperAds.linear.tracking) {
            if (!ad.linear.tracking) { ad.linear.tracking  = {}; }
            _.each(this.wrapperAds.linear.tracking, function(value, key) {
              ad.linear.tracking[key] = ad.linear.tracking[key] ? value.concat(ad.linear.tracking[key]) : value;
            });
          }
          if (this.wrapperAds.nonLinear.tracking) {
            if (!ad.nonLinear.tracking) { ad.nonLinear.tracking = {}; }
            _.each(this.wrapperAds.nonLinear.tracking, function(value, key) {
              ad.nonLinear.tracking[key] = ad.nonLinear.tracking[key] ? value.concat(ad.nonLinear.tracking[key]) : value;
            });
          }
        }, this);
      },


      _onVastProxyResult: function(value) {
        var xml = $.parseXML(value);
        this._onVastResponse(xml);
      },

      _onVastResponse: function(xml) {
        var vastAd = OO.VastParser(xml);
        if (!vastAd) {
          this.errorType = "parseError";
          this.trigger(OO.VastAdLoader.ERROR, this);
        }
        else if (vastAd.type == "wrapper") {
          this.currentDepth++;
          if (this.currentDepth < OO.playerParams.maxVastWrapperDepth) {
            var firstWrapperAd = vastAd.ads[0];
            var _wrapperAds = this.wrapperAds;
            OO.log("vast tag url is", firstWrapperAd.VASTAdTagURI, this.currentDepth);

            if (firstWrapperAd) {
              this.wrapperAds.error = this.wrapperAds.error.concat(firstWrapperAd.error);
              this.wrapperAds.impression = this.wrapperAds.impression.concat(firstWrapperAd.impression);
              this.wrapperAds.companion = this.wrapperAds.companion.concat(firstWrapperAd.companion);
              this.wrapperAds.linear.ClickTracking = this.wrapperAds.linear.ClickTracking
                  .concat(firstWrapperAd.linear.ClickTracking);
              _.each(firstWrapperAd.linear.tracking, function(value, key) {
                _wrapperAds.linear.tracking[key] = _wrapperAds.linear.tracking[key] ?
                                                   value.concat(_wrapperAds.linear.tracking[key]) :
                                                   value;
              });
              _.each(firstWrapperAd.nonLinear.tracking, function(value, key) {
                _wrapperAds.nonLinear.tracking[key] = _wrapperAds.nonLinear.tracking[key] ?
                                                      value.concat(_wrapperAds.nonLinear.tracking[key]) :
                                                      value;
              });
              this._ajax(firstWrapperAd.VASTAdTagURI, this._onFinalError, 'xml');
            }
            else {
              this.errorType = "wrapperParseError";
              this.trigger(OO.VastAdLoader.ERROR, this);
            }
          } else {
            OO.log("Max wrapper depth reached.", this.currentDepth, OO.playerParams.maxVastWrapperDepth);
            this.errorType = "tooManyWrapper";
            this.trigger(OO.VastAdLoader.ERROR, this);
          }
        } else if (vastAd.type == "inline") {
          this.inlineAd = vastAd;
          this._mergeVastAdResult();

          // TODO: add logic for non-linear ads here:
          if (this._handleLinearAd()) {
            this.loaded = true;
            this.trigger(OO.VastAdLoader.READY, this);
          } else {
            this.errorType = "noLinearAd";
            this.trigger(OO.VastAdLoader.ERROR, this);
          }
        }
      },

      __placeholder: true
    });

  }(OO, OO._, OO.$));
  (function(OO, _, $){
    /*
     *  AdsManager will manage the Ads config load and notify playback controller when they are ready.
     *  It will intercept willFetchAds event, and send adFetched event to notify playbck to continue.
     *  PlaybackController will timeout if willFetchAds does not return in OO.playerParams.maxAdsTimeout
     *  seconds.
     */

    var VastPings = function(messageBus, id) {
      if (!OO.requiredInEnvironment('ads')) {return;}
      this.Id = id;
      this.mb = messageBus;

      this.currentVastAd = null;
      this.pingedKey = {};
      this.pauseClicked = false;
      this.isMuted = false;
      // TODO, handle error: when valid vast comes back, but no stream can be played:
      OO.StateMachine.create({
        initial:'Init',
        messageBus:this.mb,
        moduleName:'vastPings',
        target:this,
        events:[
          {name:OO.EVENTS.PLAY_STREAM,                  from:'*'},
          {name:OO.EVENTS.PLAY_MIDROLL_STREAM,          from:'*'},
          {name:OO.EVENTS.STREAM_PLAYED,                from:'*'},
          {name:OO.EVENTS.MIDROLL_STREAM_PLAYED,        from:'*'},

          {name:OO.EVENTS.FULLSCREEN_CHANGED,           from:'*'},
          {name:OO.EVENTS.VOLUME_CHANGED,               from:'*'},

          {name:OO.EVENTS.PAUSED,                       from:'*'},
          {name:OO.EVENTS.PLAYHEAD_TIME_CHANGED,        from:'*'},
          {name:OO.EVENTS.ADS_CLICKED,                  from:'*'}
        ]
      });

    };

    _.extend(VastPings.prototype, {
      onFullscreenChanged: function(event, isFullScreen) {
        if (this.currentVastAd == null) { return; }
        this._vastTrackings(isFullScreen ? 'fullscreen' : 'collapse');
      },

      onVolumeChanged: function(event, volume) {
        if (this.currentVastAd == null) { return; }
        var isMuted = (volume == 0);
        this._vastTrackings( (isMuted && !this.isMuted) ? 'mute' : 'unmute');
        this.isMuted = isMuted;
      },

      onAdsClicked: function() {
        if (this.currentVastAd) {
          var clickTracking = this.currentVastAd.data && this.currentVastAd.data.linear &&
             this.currentVastAd.data.linear.ClickTracking;
          OO.log("Click Tracking:", clickTracking);
          if (clickTracking) { OO.pixelPings(clickTracking); }
        }
      },

      onPaused: function() {
        this.pauseClicked = true;
        if (this.currentVastAd) {
          this._vastTrackings('pause');
        }
      },

      onPlayStream: function(event, url, item) {
        if (this.pauseClicked) {
          this._itemResumePlay(item);
        } else {
          this._itemStartPlay(item);
        }
      },

      onPlayMidrollStream: function(event, url, item) {
        if (this.pauseClicked) {
          this._itemResumePlay(item);
        } else {
          this._itemStartPlay(item);
        }
      },

      onStreamPlayed: function(event) {
        this._itemPlayed();
      },

      onMidrollStreamPlayed: function(event, mainVideoPlayhead) {
        this._itemPlayed();
      },

      onPlayheadTimeChanged: function(event, time, duration) {
        if (this.currentVastAd == null || duration == 0) { return; }
        // send percentile pings.
        if (time > duration * 0.75) {
          this._vastTrackings('thirdQuartile');
        } else if (time > duration * 0.50) {
          this._vastTrackings('midpoint');
        } else if (time > duration * 0.25) {
          this._vastTrackings('firstQuartile');
        }
      },

      _itemStartPlay: function(item) {
        if (item.type != "ad" || !item.item) { return; }
        this.currentVastAd = item.item;
        // ping urls, this will make sure Ooyala tracking_url is also pinged.
        OO.pixelPings(this.currentVastAd.tracking_url);

        if (item.item.type != "vast") { return; }
        if (this.currentVastAd.data) {
          this.pingedKey = {};
          OO.pixelPings(this.currentVastAd.data.impression);
          this._vastTrackings('start');
          this._vastTrackings('creativeView');
        }
        this.pauseClicked = false;
      },

      _itemResumePlay: function(item) {
        if (this.currentVastAd) {
          this._vastTrackings('resume');
        }
        this.pauseClicked = false;
      },

      _itemPlayed: function() {
        if (this.currentVastAd && this.currentVastAd.data && this.currentVastAd.data.tracking) {
          OO.pixelPings(this.currentVastAd.data.tracking.complete);
        }
        this._vastTrackings('complete');
        this.currentVastAd = null;
      },

      _vastTrackings: function(key) {
        // make sure we only send each ping once for each vast ads.
        if (this.pingedKey[key] == 1) { return; }
        this.pingedKey[key] = 1;
        if (this.currentVastAd && this.currentVastAd.data && this.currentVastAd.data.tracking) {
          OO.pixelPings(this.currentVastAd.data.tracking[key]);
        }
      },

      __placeholder: true
    });

    OO.registerModule('vastPings', function(messageBus, id) {
      return new VastPings(messageBus, id);
    });

  }(OO, OO._, OO.$));
  (function(OO, $, _) {
    OO.AnalyticsBase = function(messageBus, id) { };

    _.extend(OO.AnalyticsBase.prototype, {
      loadSucceed: function() {}, // Override this function to do additional setup.

      reportEvent: function() {
        throw "Please override this function";
      },

      // Private funciton:

      setup: function(messageBus, id, analyticsType) {
        this.mb = messageBus;
        this.elementId = id;

        this._loaded = false;
        this._bufferedEvents = [];
        this.mb.subscribe('*', analyticsType, _.bind(this._onAnalyticsEvent,this));
      },

      loadExternalAnalyticsJs: function(url) {
        $.getScriptRetry(url, _.bind(this._onLoaded, this), {
          error: function() {
            // TODO: report error to some log server.
            OO.log("can not load url", url);
          }
        });
      },

      _onLoaded: function() {
        this._loaded = true;
        this.loadSucceed();
        if (!this._bufferedEvents) { return; }
        _.each(this._bufferedEvents, function(e){
          this._safeReportEvent.apply(this, e);
        }, this);
      },

      _onAnalyticsEvent: function() {
        // TODO: white labeling here.
        if (this._loaded) {
          this._safeReportEvent.apply(this, arguments);
        } else {
          this._bufferedEvents.push(arguments);
        }
      },

      _safeReportEvent: function() {
        try {
          this.reportEvent.apply(this, arguments);
        } catch (e) {
            OO.log("can not log event");
        }
      },

      __place_holder: true
    });

  }(OO, OO.$, OO._));  (function(OO, $, _) {
    var OOYALA_ANALYTICS = "ooyala_analytics";

    var OoyalaAnalytics = OO.inherit(OO.AnalyticsBase, function(messageBus, id) {
      if (!OO.requiredInEnvironment('html5-playback') && !OO.requiredInEnvironment('cast-playback')) { return; }

      this.setup(messageBus, id, OOYALA_ANALYTICS);

      this.lastEmbedCode = '';
      this.currentEmbedcode = '';
      this.playingInstreamAd = false;
      this.guid = undefined;
      this.accountId = undefined;
      this.accountIdSet = false;
      this.guidSet = false;

      // Note: we load the external JS analytics after the SAS response comes back, so we can propagate the
      // accountId parameter into Reporter if there is one. However, we also need to listen for error events,
      // in case the SAS Authorization fails. If that happens, we also load external JS analytics and
      // instantiate Reporter without an accountId. In either case, we unsubscribe from future authorization
      // fetched or error events.
      // TODO(playback-team): are you guys sure there's no race with SAS authorization request here?
      messageBus.subscribe(OO.EVENTS.AUTHORIZATION_FETCHED, OOYALA_ANALYTICS,
        _.bind(this._onAuthorizationFetched, this));
      messageBus.subscribe(OO.EVENTS.ERROR, OOYALA_ANALYTICS, _.bind(this._onErrorEvent, this));
      messageBus.subscribe(OO.EVENTS.GUID_SET, OOYALA_ANALYTICS, _.bind(this._onGuidSet, this));
      messageBus.subscribe(OO.EVENTS.REPORT_DISCOVERY_IMPRESSION, OOYALA_ANALYTICS,
        _.bind(this._onReportDiscoveryImpression, this));
      messageBus.subscribe(OO.EVENTS.REPORT_DISCOVERY_CLICK, OOYALA_ANALYTICS,
        _.bind(this._onReportDiscoveryClick, this));
    });

    _.extend(OoyalaAnalytics.prototype, {
      _onGuidSet: function(event, guid) {
        this.guid = guid;
        this.guidSet = true;
        this._onGuidAndAccountIdSet();
      },

      _onAuthorizationFetched: function(event, tree) {
        if (tree.user_info && tree.user_info.account_id) {
          this.accountId = tree.user_info.account_id;
        } else if (tree.debug_data && tree.debug_data.user_info && tree.debug_data.user_info.account_id) {
          this.accountId = tree.debug_data.user_info.account_id;
        }
        this.mb.unsubscribe(OO.EVENTS.ERROR, OOYALA_ANALYTICS);
        this.mb.unsubscribe(OO.EVENTS.AUTHORIZATION_FETCHED, OOYALA_ANALYTICS);
        if (_.isNumber(this.accountId)) {
          // Convert numeric id to a string, since reporter.js does a strict type check for strings
          this.accountId = this.accountId.toString();
        }
        if (!_.isString(this.accountId)) {
          this.accountId = undefined;
          OO.d("OO.OoyalaAnalytics: SAS authorization fetched without an accountId");
        } else {
          OO.d("OO.OoyalaAnalytics: SAS authorization fetched with accountId == " + this.accountId);
        }
        this.accountIdSet = true;
        this._onGuidAndAccountIdSet();
      },

      _onGuidAndAccountIdSet: function() {
        if (!this.guidSet || !this.accountIdSet) { return; }
        OO.d("Loading Analtics Module...");
        this.loadExternalAnalyticsJs(OO.URLS.ANALYTICS({ server: OO.SERVER.ANALYTICS }));
      },

      _onErrorEvent: function(event, params) {
        if (!params || !params["code"]) { return; }
        var code = params["code"];
        var isAuthError = false;
        // Check if it's a SAS API error. If yes, call _onAuthorizationError, otherwise ignore.
        _.each(OO.ERROR.API.SAS, function(value, key) {
          if (value === code) { isAuthError = true; }
        });
        if (isAuthError) { this._onAuthorizationError(event, code); }
      },

      _onAuthorizationError: function(event, errorCode) {
        this.mb.unsubscribe(OO.EVENTS.ERROR, OOYALA_ANALYTICS);
        this.mb.unsubscribe(OO.EVENTS.AUTHORIZATION_FETCHED, OOYALA_ANALYTICS);
        OO.d("OO.OoyalaAnalytics: SAS authorization failed, loading external analytics module ...");
        this.loadExternalAnalyticsJs(OO.URLS.ANALYTICS({ server: OO.SERVER.ANALYTICS }));
      },

      _onReportDiscoveryImpression: function(event, params) {
        if (!this.reporter) { return; }
        try {
          this.reporter.reportDiscoveryImpression(params.relatedVideos, params.custom);
        } catch (e) {
          OO.log("Failed to report a discovery impression event with params " + JSON.stringify(params) +
            ": " + e);
        }
      },

      _onReportDiscoveryClick: function(event, params) {
        if (!this.reporter) { return; }
        try {
          this.reporter.reportDiscoveryClick(params.clickedVideo, params.custom);
        } catch (e) {
          OO.log("Failed to report a discovery click event with params " + JSON.stringify(params) +
            ": " + e);
        }
      },

      loadSucceed: function() {
        //todo this should not be possible
        if (!window.Ooyala || !window.Ooyala.Reporter) { return; }
        OoyalaAnalytics.Reporter = Ooyala.Reporter;
        OoyalaAnalytics.Pinger = Ooyala.Pinger;
        //this.guid = OoyalaAnalytics.Pinger.getOrCreateGuid();
        //this.mb.publish(OO.EVENTS.GUID_SET, this.guid);
        this.reporter = null;
        // TODO: if pcode is not set, we may have an error.
        if (!OO.playerParams.pcode) { return; }
        this.reporter = new OoyalaAnalytics.Reporter(OO.playerParams.pcode, {
          accountId: this.accountId,
          guid: this.guid,
          playerBrandingId: OO.playerParams.playerBrandingId
        });
      },

      reportEvent: function(eventName, arg1, arg2) {
        if (!this.reporter) { return; } // TODO report error here. should never happend
        switch (eventName) {
          case OO.EVENTS.PLAYER_CREATED :
            this.reporter.reportPlayerLoad();
            break;
          case OO.EVENTS.EMBED_CODE_CHANGED :
            // TODO: get the right duration for the video.
            // When setEmbedCode is called on the same asset it is NOT treated as a replay
            if (arg1 != this.currentEmbedcode) {
              this.lastEmbedCode = this.currentEmbedcode;
            } else {
              this.lastEmbedCode = '';
            }
            this.currentEmbedcode = arg1;
            break;
          case OO.EVENTS.CONTENT_TREE_FETCHED :
            // TODO: get the right duration for the video.
            this.reporter.initializeVideo(this.currentEmbedcode, arg1.duration);
            break;
          case OO.EVENTS.WILL_PLAY_FROM_BEGINNING:
            if (this.lastEmbedCode === this.currentEmbedcode) {
              this.reporter.reportReplay();
            } else {
              this.reporter.reportVideoStarted();
              this.lastEmbedCode = this.currentEmbedcode;
            }
            break;
          // TODO: reportAdRequest, reportAdClickToSite, reportAdPlayFailure
          // TODO: Add ad metadata
          case OO.EVENTS.WILL_PLAY_ADS :
            this.playingInstreamAd = true;
            var adSource = Ooyala.Reporter.AdSource.UNKNOWN;
            if (arg1 && arg1.type && typeof(arg1.type) == "string") {
              adSource = Ooyala.Reporter.AdSource[arg1.type.toUpperCase()];
            }
            this.reporter.setAdSource(adSource, this.currentEmbedcode, arg1 && arg1.click_url);
            this.reporter.reportAdImpression();
            break;
          case OO.EVENTS.ADS_PLAYED :
            this.playingInstreamAd = false;
            // TODO, report ads end.
            break;
          case OO.EVENTS.ADS_CLICKED :
            this.reporter.reportAdClickToVideo();
            break;
          case OO.EVENTS.PLAYHEAD_TIME_CHANGED:
            if (this.playingInstreamAd) {
              this.reporter.reportAdPlaythrough(arg1, arg2);
            } else {
              if (arg1 > 0) {
                this.reporter.reportPlayheadUpdate(Math.floor(arg1 * 1000));
              }
            }
            break;
          case OO.EVENTS.REPORT_EXPERIMENT_VARIATIONS:
            this.reporter.reportExperimentVariation(arg1.variationIds);
            break;
          case OO.EVENTS.INITIAL_PLAY:
            this.reporter.reportPlayRequested();
            break;
        }

      },

      __place_holder: true
    });

    OO.registerModule(OOYALA_ANALYTICS, function(messageBus, id) {
      return new OoyalaAnalytics(messageBus, id);
    });

  }(OO, OO.$, OO._));
  (function(OO, $, _){
    /*
     *  Defines a simple UI
     */

    var BasicUi = function(messageBus, id, params) {
      // short circuit here if the page does not need default ui
      if (!OO.requiredInEnvironment('default-ui')) { return; }
      if (!!params['layout'] && params['layout']==='chromeless') { return; }

      this.useCustomControls = !OO.uiParadigm.match(/mobile/);
      this.useNativeControls = !!OO.uiParadigm.match(/native/);

      this.Id = id;
      this.mb = messageBus;
      this.isFullscreen = false;
      this.bufferTime = 0;
      this.isSeeking = false;
      this.controlsVisible = false;
      this.buffering = false;
      this.isLivePlaying = false;
      this.seekRange = null;
      this.isVideoAdPlaying = false;
      this.liveSeekWindow = 0;
      this.playbackReady = false;
      this.showAdMarquee = true;

      //Internal Constants
      this.CONTROLS_TIMEOUT = 2000;
      this.SHOW_CONTROLS_DELAY = 100;

      //set flag if has been overriden already.
      this.mb.subscribe(OO.EVENTS.SHOW_AD_MARQUEE, "basic_ui", _.bind(function(event, marquee) {
        this.showAdMarquee = marquee;
      }, this));

      OO.StateMachine.create({
        initial:'Init',
        messageBus:this.mb,
        moduleName:'BasicUi',
        target:this,
        events:[
          {name:OO.EVENTS.PLAYER_CREATED,                           from:'Init',                                       to:'PlayerCreated'},
          {name:OO.EVENTS.EMBED_CODE_CHANGED,                       from:'*',                                          to:'WaitingPlaybackReady'},
          {name:OO.EVENTS.METADATA_FETCHED,                         from:'*',                                          to:'*'},
          {name:OO.EVENTS.AUTHORIZATION_FETCHED,                    from:'*'},
          {name:OO.EVENTS.PLAYBACK_READY,                           from:'WaitingPlaybackReady',                       to:'Ready'},
          {name:OO.EVENTS.WILL_PLAY,                                from:['Ready','Paused'],                           to:'StartingToPlay'},
          {name:OO.EVENTS.PLAYING,                                  from:['StartingToPlay', 'Paused'],                 to:'Playing'},
          {name:OO.EVENTS.STREAM_PLAYING,                           from:'*'},
          {name:OO.EVENTS.PLAYHEAD_TIME_CHANGED,                    from:['Playing', 'StartingToPlay'],                to:'Playing'},
          {name:OO.EVENTS.PLAYHEAD_TIME_CHANGED,                    from:'Paused',                                     to:'Paused'},
          {name:OO.EVENTS.PLAYHEAD_TIME_CHANGED,                    from:'PlayingMidroll',                             to:'PlayingMidroll'},
          {name:OO.EVENTS.PLAYHEAD_TIME_CHANGED,                    from:'Ready',                                      to:'Ready'},
          {name:OO.EVENTS.WILL_PAUSE_ADS,                           from:'*',                                          to:'Paused'},
          {name:OO.EVENTS.PAUSED,                                   from:'*',                                          to:'Paused'},
          {name:OO.EVENTS.PLAYED,                                   from:['Playing', 'Paused'],                        to:'Ready'},
          {name:OO.EVENTS.STREAM_PAUSED,                            from:'*'},
          {name:OO.EVENTS.BUFFERING,                                from:'*'},
          {name:OO.EVENTS.BUFFERED,                                 from:'*'},
          {name:OO.EVENTS.SEEKED,                                   from:'*'},
          {name:OO.EVENTS.FULLSCREEN_CHANGED,                       from:'*'},
          {name:OO.EVENTS.SIZE_CHANGED,                             from:'*'},
          {name:OO.EVENTS.DOWNLOADING,                              from:'*'},
          {name:OO.EVENTS.CONTENT_TREE_FETCHED,                     from:'*'},
          {name:OO.EVENTS.PLAY_MIDROLL_STREAM,                      from:['Playing', 'Paused'],                         to:"PlayingMidroll"},
          {name:OO.EVENTS.WILL_RESUME_MAIN_VIDEO,                   from:'PlayingMidroll',                              to:"Playing"},

          {name:OO.EVENTS.DISABLE_PLAYBACK_CONTROLS,                          from:"*"},
          {name:OO.EVENTS.ENABLE_PLAYBACK_CONTROLS,                           from:"*"},

          {name:OO.EVENTS.WILL_PLAY_ADS,                            from:"*"},
          {name:OO.EVENTS.INITIAL_PLAY,                             from:"*"},
          {name:OO.EVENTS.ADS_ERROR,                                from:"*"},
          {name:OO.EVENTS.ADS_PLAYED,                               from:"*"},
          {name:OO.EVENTS.UPDATE_AD_COUNTDOWN,                      from:"*"}

        ]
      });
    };

    _.extend(BasicUi.prototype, {
      onInitialPlay: function() {
        if (!this.playbackReady) { return; }
        this.rootElement.find('div.oo_promo').hide();
        this._prepareControl();
      },

      onWillPlayAds: function(event, params) {
        if (this.showAdMarquee) {
          this.rootElement.find('div.oo_ads_countdown').html((params && params["useCustomCountdown"] ? "" :
            OO.getLocalizedMessage(OO.TEXT.ADS_COUNTDOWN)));
          this.rootElement.find('div.oo_ads_countdown').show();
        }
        this.rootElement.find('div.oo_scrubber').css('pointer-events', 'none');
        this.rootElement.find('div.oo_tap_panel').css('display', 'none');
        this.rootElement.find('div.oo_duration').html(OO.formatSeconds(0));
        this.isVideoAdPlaying = true;
        if (typeof this.params.showInAdControlBar != 'undefined') {
          this._toggleControls(this.params.showInAdControlBar);
        }
        this._updatePlayingUi();
      },

      onUpdateAdCountdown: function(event, message) {
        if (message) {
          this.rootElement.find(".oo_ads_countdown").html(message);
        }
      },

      onAuthorizationFetched:function(event, response) {
        this.authorization = response;
        this.isLivePlaying = (this.isLivePlaying || this.authorization.streams[0].is_live_stream);
      },

      onAdsError: function() {
        OO.log("Ads Error, hiding ads countdown.");
        this.onAdsPlayed();
      },

      onAdsPlayed: function() {
        this.rootElement.find('div.oo_ads_countdown').hide();
        this.rootElement.find('div.oo_scrubber').css('pointer-events', 'auto');
        this.isVideoAdPlaying = false;
      },

      _showDomObject: function(domSelector, show) {
        var value = show ? OO.CSS.VISIBLE_POSITION : OO.CSS.INVISIBLE_POSITION;
        this.rootElement.find(domSelector).css("left", value);
      },

      onPlayMidrollStream: function(event, streamUrl, adItem) {
        this._showDomObject('video.video', false);
        this._showDomObject('video.midroll', true);

        // Vast midrolls require the tap_panel to be visible for clickthroughs
        if (adItem && adItem.item && adItem.item.type &&
          (adItem.item.type == "vast" || adItem.item.type == "ooyala")) {
          this.rootElement.find('div.oo_tap_panel').css('display', '');
        }

        this._updatePlayingUi();
      },

      onWillResumeMainVideo: function(event) {
        this._showDomObject('video.video', true);
        this._showDomObject('video.midroll', false);
      },

      onPlayerCreated: function(event, elementId, params) {
        this.elementId = elementId;
        this.topMostElement = $('#'+this.elementId);
        this.rootElement =  this.topMostElement.find("div.innerWrapper");
        this.params = params;
        this.accentColor = params.accentColor || 0x5D8ADD;

        // do not display any UI elements unless directly specified in CSS.
        OO.attachStyle(this.elementId + ".oo_ui_element { display: none; }", this.elementId);

        //load default CSS
        OO.attachStyle(_.template(OO.get_css("basic_ui"))({
          elementId : this.elementId,
          liveIcon : OO.get_img_base64('icon_live'),
          rewindIcon : OO.get_img_base64('icon_rewind'),
          playIcon : OO.get_img_base64('icon_play'),
          pauseIcon : OO.get_img_base64('icon_pause'),
          playheadIcon : OO.get_img_base64('icon_playhead'),
          fullscreenOnIcon : OO.get_img_base64('icon_full_off'),
          fullscreenOffIcon : OO.get_img_base64('icon_full_on')
        }), this.elementId);

        if (params.css) {
          // if css is not a string, assume that the customer has already embedded it and don't load ours
          // else, load their css URL
          if (typeof params.css === "string") {
            if (params.css.match(/\.css$/)) { // if it ends with .css try to load it
              // load specified CSS - If we don't use a timeout, this will break layout measurements and
              // result in improper resizing of controls.  We need to ensure this is async from the thread
              setTimeout(function() {
                $('head').append('<link href="' + params.css + '" rel="stylesheet" type="text/css">');
              }, 0);
            } else {
              OO.attachStyle(params.css, this.elementId);
            }
          }
        }

        // ad count down:
        this.rootElement.append('<div class="oo_ads_countdown" style="display:none"></div>');

        // display initial ui
        this.rootElement.append('<div class="oo_promo"></div>');
        this.promoUi = new _PromoUi(this.rootElement.find('div.oo_promo'));

        if(this.useCustomControls) {
          // display controls
          this._createControls();
        } else {
          this.controlsRoot = this.rootElement.find('div.oo_controls');
        }
        this.spinner = new OO.Spinner(this.mb, this.rootElement.find('div.oo_spinner'), this.rootElement);

        if(this.useNativeControls) {
          this.rootElement.find('video.video').attr('controls','true');
        }
        // append endscreen:
        this.rootElement.append('<div class="oo_end_screen" style="display:none"><img class="oo_replay" src="' +
            OO.get_img_base64('icon_replay') + '"><img class="oo_fullscreen" src="' + OO.get_img_base64('icon_full_on') + '"></div>');

        this.rootElement.find('div.oo_end_screen img.oo_replay').bind('click', _.bind(this._replayClicked, this));
        this.rootElement.find('div.oo_end_screen img.oo_fullscreen').bind('click', _.bind(this._fullscreenClick, this));
      },

      _onClickOnPlayer: function(e) {
        if (this.rootElement.find("div.oo_end_screen").is(":visible") ||
            this.rootElement.find("div.oo_promo").is(":visible")) { return; }
        this.mb.publish(OO.EVENTS.PLAYER_CLICKED);
      },

      _createControls: function() {
        this.rootElement.append('<div class="oo_tap_panel" style="display:none"></div>');
        this.rootElement.append('<div class="oo_controls_wrap" style="display: none; position: relative; overflow: hidden; height: 100%; width: 100%;"></div>');
        this.rootElement.bind("mousemove.showcontrols touchstart.showcontrols MSPointerDown.showcontrols", _.bind(this._onMouseMove, this));
        var tapElement = OO.isIos ? "video.video" : "div.oo_tap_panel";
        // We don't fire both click and touchstart events because some touch-supported devices
        // will also fire the click event a few hundred ms later and we will therefore fire the
        // PLAYER_CLICKED event twice
        // We can't call preventDefault on the touchstart event because that breaks scrolling, although if we
        // cared about that we would probably use the touchend event instead...
        this.rootElement.find(tapElement).bind(OO.supportTouch ? "touchstart" : "click",
            _.bind(this._onClickOnPlayer, this));

        this.controlsWrap = this.rootElement.find('div.oo_controls_wrap');
        this.controlsWrap.append('<div class="oo_controls" style="display: none; bottom:-1000px;"></div>');
        this.controlsRoot = this.controlsWrap.find('div.oo_controls');
        this.controlsRoot.append('<div class="oo_controls_inner vod"></div><div class="oo_controls_inner live"></div>');

        this.vodControl = new _VodControlBar(this.controlsRoot.find("div.vod"), this);
        this.liveControl = new _LiveControlBar(this.controlsRoot.find("div.live"), this);

        var buttons = this.controlsRoot.find('div.oo_button');
        buttons.append('<div class="oo_button_highlight" />');
        buttons.bind('touchstart MSPointerDown mousedown', function(event) {
          $(event.target).find('div.oo_button_highlight').show();
        });
        buttons.bind('touchend MSPointerUp mouseup', function(event) {
          $(event.target).find('div.oo_button_highlight').hide();
        });

        this.controlsRoot.find('div.oo_play').bind('click', _.bind(this._playClick, this));
        this.controlsRoot.find('div.oo_pause').bind('click', _.bind(this._pauseClick, this));
        this.controlsRoot.find('div.oo_rewind').bind('click', _.bind(this._rewindClick, this));

        this.controlsRoot.find('div.oo_fullscreen').bind('click', _.bind(this._fullscreenClick, this));
        // [pbw-1155][pbw-1723] android isn't always firing a click event
        // after touchstart-touchend, so use touchend to ensure consistent behavior of the buttons.
        if (OO.isAndroid) {
          this.controlsRoot.find('div.oo_play').bind('touchend', _.bind(this._playClick, this));
          this.controlsRoot.find('div.oo_pause').bind('touchend', _.bind(this._pauseClick, this));
          this.controlsRoot.find('div.oo_rewind').bind('touchend', _.bind(this._rewindClick, this));
          this.controlsRoot.find('div.oo_fullscreen').bind('touchend', _.bind(this._fullscreenClick, this));
        }

        this.controlsRoot.find('div.oo_playhead_progress').css('background-color', OO.getColorString(this.accentColor));
        var bufferColor = 0x5C5C5C;
        this.controlsRoot.find('div.oo_buffer_progress').css('background-color', OO.getColorString(bufferColor));

        _.each([$(this.vodControl.scrubber), $(this.liveControl.scrubber)], _.bind(function(scrubber) {
          scrubber.bind('scrubStart', _.bind(this._scrubStart, this));
          scrubber.bind('scrub', _.bind(this._scrub, this));
          scrubber.bind('scrubEnd', _.bind(this._scrubEnd, this));
        }, this));

        // append spinner
        this.rootElement.append('<div class="oo_spinner" style="display:none"></div>');
        this._resizeControls();
      },

      onEmbedCodeChanged: function(event, embedCode, params) {
        if (this.isVideoAdPlaying) {
          this.onAdsPlayed();
        }

        this.params.promoUrl = null;    // some params must be reset before switching to new embed code
        this.params = _.extend(this.params, params);

        this.rootEmbedCode = embedCode;
        this.currentTime = 0;
        this.duration = 0;
        this.isLivePlaying = false;
        this.seekRange = null;
        this.liveSeekWindow = 0;
        this.controlsEnabled = true;
        this.promoImageUrl = null;

        // restore Promo UI
        this.rootElement.find('div.oo_end_screen').hide();
        this.rootElement.find('div.oo_promo').show();

        this.rootElement.find('video.video').css("left", OO.CSS.INVISIBLE_POSITION);
        this.rootElement.find('div.oo_promo').unbind('click');
        this.rootElement.find('div.oo_tap_panel').css('display','none');
        this.promoUi.disallowPlayback();
        this._toggleControls(false);
        this.playbackReady = false;
      },

      _setPromoImage: function() {
        if(_.isString(this.promoImageUrl)) {   // some providers don't use promo images.
          this.promoUi.setBackground(this.promoImageUrl);
          var endScreen = this.rootElement.find('div.oo_end_screen');
          endScreen.css('background-image', 'url('+this.promoImageUrl+')');
        }
      },

      onContentTreeFetched: function(event, contentTree) {
        this.contentTree = contentTree;

        // reset promo image if it's empty (so metadata can win)
        if(_.isString(this.promoImageUrl) && this.promoImageUrl.length == 0) {
          this.promoImageUrl = undefined;
        }

        // promo can be overriden from player params > metadata > content tree
        this.promoImageUrl = this.params.promoUrl || this.promoImageUrl || this.contentTree.promo_image ||
          this.contentTree.thumbnail_image || "";
        this._setPromoImage();

        if (this.rootEmbedCode === this.contentTree.embed_code) {
          // Note(jdlew): This means that archived live streams will still use Live UI..
          this.isLivePlaying = (this.isLivePlaying || this.contentTree.content_type === "LiveStream");
        }
      },

      onMetadataFetched: function(event, metadata) {
        // reset promo image if it's empty (so metadata can win)
        if(_.isString(this.promoImageUrl) && this.promoImageUrl.length == 0) {
          this.promoImageUrl = undefined;
        }

        this.promoImageUrl = this.promoImageUrl || (metadata && metadata.base && metadata.base.thumbnail) || "";
        this._setPromoImage();
      },

      onPlaybackReady: function(event, playbackPackage) {
        // allow playback
        this.rootElement.find('div.oo_promo').bind('click', _.bind(this._promoClick, this));
        this.promoUi.allowPlayback();
        this.playbackReady = true;
      },

      _prepareControl:function() {
        if(this.useCustomControls) {
          this.controlsWrap.css('display','');
          this.controlsRoot.css('display','');
          if (!OO.isIos) { this.rootElement.find('div.oo_tap_panel').css('display',''); }
          this._toggleControls(false);
        }
      },

      onWillPlay: function(event, streamUrl) {
        this._prepareControl();

        this._showDomObject('video.video', true);
        this._showDomObject('video.midroll', false);

        this.rootElement.find('div.oo_end_screen').hide();
      },

      onPlayed: function(event) {
        if(this.useCustomControls) {
          this.rootElement.find('div.oo_pause').hide();
          this.rootElement.find('div.oo_play').show();
        }
        this._showDomObject('video.video', false);
        this._showDomObject('video.midroll', false);

        var endScreen = this.rootElement.find('div.oo_end_screen');
        var replayButton = this.rootElement.find('div.oo_end_screen img.oo_replay');

        endScreen.show();
        this.mb.publish(OO.EVENTS.END_SCREEN_SHOWN);
      },

      onWillPauseAds: function(e) {
        this.onPaused(e);
      },

      onPaused: function(event) {
        if(this.useCustomControls) {
          this.rootElement.find('div.oo_pause').hide();
          this.rootElement.find('div.oo_play').show();
          this._onMouseMove();
        }
      },

      onStreamPaused: function(event) {
        if(this.useCustomControls) {
          this.rootElement.find('div.oo_pause').hide();
          this.rootElement.find('div.oo_play').show();
        }
      },

      onPlaying: function(event, streamUrl) {
        this._updatePlayingUi();
      },

      onStreamPlaying: function(event, streamUrl) {
        this._updatePlayingUi();
      },

      _updatePlayingUi: function() {
        if (this.useNativeControls) { return; }
        this.rootElement.find('div.oo_end_screen').hide();
        this.rootElement.find('div.oo_promo').hide();
        if(this.useCustomControls) {
          this.rootElement.find('div.oo_play').hide();
          this.controlsRoot.show();
          this.rootElement.find('div.oo_pause').show();
        }
      },

      onBuffering: function(event, streamUrl) {
        if(this.useCustomControls) {
          this.spinner.play();
        }
        this.buffering = true;
      },

      onBuffered: function(event, streamUrl) {
        if (this.useNativeControls) { return; }
        if(this.useCustomControls) {
          this.spinner.pause();
        }
        this.buffering = false;
        this._updateScrubberProgressBar();
      },

      // (PB-1635): IE10 fires an extra 'waiting' event when seeking. We need to hide
      // the spinner after we finish seeking. This function is identical to onBuffered.
      onSeeked: function(event) {
        if (this.useNativeControls) { return; }
        if (this.useCustomControls) {
          this.spinner.pause();
        }
        this.buffering = false;
        this._updateScrubberProgressBar();
      },

      onPlayheadTimeChanged: function(event, currentTime, duration, buffer, seekRange) {
        if (this.useNativeControls) { return; }
        this.bufferTime = buffer;
        this.currentTime = currentTime;
        this.duration = duration;
        this.seekRange = seekRange;

        if(this.useCustomControls && (OO.isIE || !this.buffering) ) {
          this._updateScrubberProgressBar();
        }
      },

      onFullscreenChanged: function(event, isFullscreen, paused) {
        if(isFullscreen) {
          this.controlsRoot.find('div.oo_fullscreen').removeClass("oo_fullscreen_on");
          this.controlsRoot.find('div.oo_fullscreen').addClass("oo_fullscreen_off");
          this.isFullscreen = true;

          this.rootElement.find('div.oo_end_screen img.oo_fullscreen').show();
        } else {
          // FULLSCREEN EXIT
          // check if UI state is out of sync with video state
          if (this.currentState === 'Playing' && paused) {
            this.mb.publish(OO.EVENTS.PAUSED);
          }
          this.isFullscreen = false;
          this.rootElement.css('overflow','hidden');

          this.rootElement.find('div.oo_end_screen img.oo_fullscreen').hide();

          if(this.useCustomControls) {
            // switch buttons
            this.controlsRoot.find('div.oo_fullscreen').removeClass("oo_fullscreen_off");
            this.controlsRoot.find('div.oo_fullscreen').addClass("oo_fullscreen_on");
            // try to restore controls
            this.controlsCanHide = false;
            this._toggleControls();

            if (OO.isIos && OO.iosMajorVersion < 8) {
              // Switching the src of a video tag while in fullscreen mode causes it to completely
              // ignore the "controls" attribute. You have to manually add and remove it in order to
              // to hide it again after the src swap. Of course, doing it right on fullscreen exit is
              // too early so I've added a delay because it doesn't stick otherwise.
              setTimeout(_.bind(function(){
                this.rootElement.find('video.video').attr("controls", "");
                this.rootElement.find('video.video').removeAttr("controls");
              }, this), 300);
            }
          } else if(!OO.useNativeControls) {
            OO.d('Getting promo back');
            // return promo slide
            this.rootElement.find('div.oo_promo').show();

            this.rootElement.find('video.video').css("left", OO.CSS.INVISIBLE_POSITION);
          }

        }
      },

      onSizeChanged: function(event) {
        this._resizeControls();
        this._updateScrubberProgressBar();
      },

      onDownloading: function(event, currentTime, duration, buffer, seekRange) {
        if (this.useNativeControls) { return; }
        this.bufferTime = buffer;
        this.currentTime = currentTime;
        this.duration = duration;
        this.seekRange = seekRange;
        this._updateScrubberProgressBar();
      },

      onDisablePlaybackControls: function(event) {
        this._toggleControls(false);
        this.controlsEnabled = false;
      },

      onEnablePlaybackControls: function(event) {
        this.controlsEnabled = true;
      },

      _onMouseMove: function(e) {
        if (this.rootElement.find("div.oo_end_screen").is(":visible") ||
            this.rootElement.find("div.oo_promo").is(":visible")) { return; }

        this._toggleControls(true);
      },

      _showControls: function() {
        if (!this.useCustomControls || (this.isVideoAdPlaying && this.params.showInAdControlBar == false)) {
          return;
        }
        this.controlsRoot.css('bottom', '10px');
        if (this.isLivePlaying) {
          this.vodControl.hide();
          this.liveControl.show();
        } else {
          this.vodControl.show();
          this.liveControl.hide();
        }
      },

      _toggleControls: function(force) {
        //if force is undefined, switch controls state
        var visible = false;
        if (this.isVideoAdPlaying && (typeof this.params.showInAdControlBar != 'undefined')
          && (typeof force != 'undefined')) {
          visible = this.params.showInAdControlBar;
        } else if (force === undefined) {
          visible = this.useCustomControls && !this.controlsVisible && this.controlsEnabled;
        } else {
          visible = this.useCustomControls && force && this.controlsEnabled;
        }

        //reset timer
        if(this.controlsTimer) {
          clearTimeout(this.controlsTimer);
          this.controlsTimer = null;
        }

        if (visible) {
          if(this.currentState !== "Paused" && !this.isSeeking) {
            this.controlsTimer = _.delay(_.bind(this._toggleControls, this), this.CONTROLS_TIMEOUT);
          }
          // [PBW-1698] Moved from '_toggleControls'. Need to delay styling in
          // order to show custom controls after exiting fullscreen on iOS 8.
          _.delay(_.bind(this._showControls, this), this.SHOW_CONTROLS_DELAY);
          if (!this.controlsVisible) {
            this.controlsVisible = true;
            this.mb.publish(OO.EVENTS.CONTROLS_SHOWN);
          }
        } else {
          var controlsHeight = '-' + this.controlsRoot.height() + 'px';
          this.controlsRoot.css('bottom', controlsHeight);
          if (this.controlsVisible) {
            this.controlsVisible = false;
            this.mb.publish(OO.EVENTS.CONTROLS_HIDDEN);
          }
        }
      },

      _updateScrubberProgressBar: function() {
        if (this.isSeeking || this.useNativeControls) { return; }
        var live = (this.isLivePlaying && !this.isVideoAdPlaying);
        var scrubber = live ? this.liveControl.scrubber : this.vodControl.scrubber;
        var start = (live && this.seekRange) ? this.seekRange.start : 0;
        var end = (live && this.seekRange) ? this.seekRange.end : this.duration;
        var currentTime = (live && (end - this.currentTime < 10)) ? end - 10 : this.currentTime;
        scrubber.setValue(currentTime, Math.min(this.bufferTime, end), start, end);
      },

      _resizeControls: function() {
        if(this.useCustomControls) {
          if(this.rootElement.width() < 400) {
            this.controlsRoot.addClass('oo_mini_controls').removeClass('oo_full_controls');
          } else {
            this.controlsRoot.removeClass('oo_mini_controls').addClass('oo_full_controls');
          }
        }
      },

      _promoClick: function() {
        this.mb.publish(OO.EVENTS.INITIAL_PLAY);
        return false;
      },

      _playClick: function(e) {
        this.mb.publish(OO.EVENTS.PLAY);
        return false;
      },

      _replayClicked: function(e) {
        this.rootElement.find('div.oo_end_screen').hide();
        this.mb.publish(OO.EVENTS.SEEK, 0);
        this.mb.publish(OO.EVENTS.PLAY);
        return false;
      },

      _pauseClick: function() {
        this.mb.publish(OO.EVENTS.PAUSE);
        return false;
      },

      _fullscreenClick: function() {
        this.mb.publish(OO.EVENTS.WILL_CHANGE_FULLSCREEN, !this.isFullscreen);
        return false;
      },

      _rewindClick: function() {
        this.mb.publish(OO.EVENTS.SEEK, this.currentTime - 30 < 0 ? 0 : this.currentTime - 30);
        return false;
      },

      _scrubStart: function(e) {
        this.wasPlaying = this.currentState == "Playing";
        this.mb.publish(OO.EVENTS.SCRUBBING);
        this.mb.publish(OO.EVENTS.PAUSE);
        this.isSeeking = true;
      },

      _scrub: function(e, time) {
        this.mb.publish(OO.EVENTS.SEEK, time);
      },

      _scrubEnd: function(e, time) {
        this.isSeeking = false;

        this.mb.publish(OO.EVENTS.SCRUBBED);
        if (this.wasPlaying) {
          this.mb.publish(OO.EVENTS.PLAY);
        }

        this._onMouseMove();
      },

      __placeholder: true
    });

    var _PromoUi = function(promo) {
      this.promo = promo;
      this.init();
    };

    _.extend(_PromoUi.prototype, {
      init: function() {
        this.promo.append("<div class='oo_start_button'><img class='oo_start_spinner'></div>");
        var button = this.promo.find("img.oo_start_spinner");
        button.attr({ src: OO.get_img_base64('icon_spinner') });
      },

      setBackground: function(url) {
        this.promo.css('background-image','url('+url+')');
      },

      allowPlayback: function() {
        this.promo.find("div.oo_start_button").html('');
        this.promo.find("div.oo_start_button").css({'background-image': 'url('+OO.get_img_base64('icon_play')+')' });
      },

      disallowPlayback: function() {
        this.promo.find("div.oo_start_button").html("<img class='oo_start_spinner'>");
        this.promo.find("div.oo_start_button").css({'background-image': '' });
        var button = this.promo.find("img.oo_start_spinner");
        button.attr({ src: OO.get_img_base64('icon_spinner') });
      }
    });

    var _Scrubber = function(controlsRoot, min, max) {
      this.scrubber = controlsRoot.find('div.oo_scrubber');
      this.handle = this.scrubber.find('div.oo_playhead');
      this.trackContainer = this.scrubber.find('div.oo_scrubber_track');
      this.playedTrack = this.scrubber.find('div.oo_playhead_progress');
      this.bufferTrack = this.scrubber.find('div.oo_buffer_progress');
      this.currentTime = this.scrubber.find('div.oo_currentTime');
      this.duration = this.scrubber.find('div.oo_duration');
      this.min = min || 0;
      this.max = max || 0;
      this.init();
    };

    _.extend(_Scrubber.prototype, {
      init: function() {
        this.handle.bind('mousedown.scrubber touchstart.scrubber MSPointerDown.scrubber', _.bind(this._onScrubStart, this));
        this.handle.bind('touchmove.scrubber', _.bind(this._onScrub, this));
        this.handle.bind('touchend.scrubber', _.bind(this._onScrubEnd, this));

        $(".oo_progress").each(function() {
          this.onselectstart = function() { return false; };
        });

        $(".oo_playhead").each(function() {
          this.onselectstart = function() { return false; };
        });

        this.setValue(0, 0, 0, 0);
      },

      setValue: function(played, buffered, minTime, maxTime) {
        //allow updates of played and buffered only
        this.min = minTime || this.min;
        this.max = maxTime || this.max;

        //handle and playedTrack
        var playedPercent = (played - minTime) / (maxTime - minTime);
        playedPercent = Math.min(Math.max(0, playedPercent), 1);
        var playedX = playedPercent * (this.trackContainer.width() - this.handle.width());
        this.handle.css('left', playedX);
        this.playedTrack.css('width', playedX + this.handle.width() / 2);

        //buffer precent
        var bufferedPercent = (buffered - minTime) / (maxTime - minTime);
        this.bufferTrack.css('width', (bufferedPercent * this.trackContainer.width()) + 'px');

        //labels
        this.currentTime.html(OO.formatSeconds(played || 0));
        this.duration.html(OO.formatSeconds(maxTime || 0));
      },

      _update: function(x) {
        var scrubberWidth = this.trackContainer.width() - this.handle.width();
        var mouseOffsetX = this.scrubberStartX + x - this.seekStartX;
        var effectiveX = Math.max(Math.min(mouseOffsetX, scrubberWidth), 0);
        var played = ((effectiveX / scrubberWidth) * (this.max - this.min)) + this.min;

        //handle and playedTrack
        this.handle.css('left', effectiveX);
        this.playedTrack.css('width', effectiveX + this.handle.width() / 2);

        //labels
        this.currentTime.html(OO.formatSeconds(played || 0));
        this.duration.html(OO.formatSeconds(this.max || 0));
        return played;
      },

      _onScrubStart: function(e) {
        this.seekStartX = 0;
        if (e.type === "mousedown") {
          $(document).bind('mouseup.scrubber', _.bind(this._onScrubEnd, this));
          $(document).bind('mousemove.scrubber', _.bind(this._onScrub, this));
          this.seekStartX = e.screenX;
        } else if (e.type === "touchstart") {
          this.seekStartX = e.originalEvent.touches[0].screenX;
        } else if (e.type === "MSPointerDown") {
          $(document).bind('MSPointerUp.scrubber', _.bind(this._onScrubEnd, this));
          $(document).bind('MSPointerMove.scrubber', _.bind(this._onScrub, this));
          e.originalEvent.preventDefault();
          this.seekStartX = e.originalEvent.screenX;
        }
        this.scrubberStartX = parseInt(this.handle.css("left"), 10);
        $(this).trigger("scrubStart");
      },

      _onScrub: function(e) {
        var x = 0;
        if (e.type === "mousemove") {
          x = e.screenX;
        } else if (e.type === "touchmove") {
          e.originalEvent.preventDefault();
          this.lastTouchX = e.originalEvent.touches[0].screenX;
          x = this.lastTouchX;
        } else if (e.type === "MSPointerMove") {
          e.originalEvent.preventDefault();
          x = e.originalEvent.screenX;
        }
        $(this).trigger("scrub", this._update(x));
      },

      _onScrubEnd: function(e) {
        var x = 0;
        if (e.type === "mouseup") {
          $(document).unbind('mouseup.scrubber');
          $(document).unbind('mousemove.scrubber');
          x = e.screenX;
        } else if (e.type === "touchend") {
          e.originalEvent.preventDefault();
          x = this.lastTouchX;
        } else if (e.type === "MSPointerUp") {
          $(document).unbind('MSPointerUp.scrubber');
          $(document).unbind('MSPointerMove.scrubber');
          e.originalEvent.preventDefault();
          x = e.originalEvent.screenX;
        }
        $(this).trigger("scrubEnd", this._update(x));
      },

      __end_marker: true
    });

    var _BaseControlBar = function(controlsRoot, basicUi) {
      this.controlsRoot = controlsRoot;
      this.basicUi = basicUi;
    };

    _.extend(_BaseControlBar.prototype, {
      init: function() {},
      show: function() {
        this.controlsRoot.show();
      },
      hide: function() {
        this.controlsRoot.hide();
      },
      __end_marker: true
    });

    var _VodControlBar =  OO.inherit(_BaseControlBar, function(controlsRoot, basicUi) {
      this.controlsRoot = controlsRoot;
      this.basicUi = basicUi;
      this.init();
    });

    _.extend(_VodControlBar.prototype, {
      init: function() {
        this.controlsRoot.append("<div class='oo_scrubber'>\
            <div class='oo_label oo_currentTime'></div>\
            <div class='oo_scrubber_track'>\
              <div class='oo_progress oo_buffer_progress'></div>\
              <div class='oo_progress oo_playhead_progress'></div>\
              <div class='oo_playhead'></div>\
            </div>\
            <div class='oo_label oo_duration'></div>\
          </div>");
        this.controlsRoot.append('<div class="oo_button oo_toolbar_item oo_rewind"></div>');
        this.controlsRoot.append('<div class="oo_button oo_toolbar_item oo_pause" style="display:none;"></div>');
        this.controlsRoot.append('<div class="oo_button oo_toolbar_item oo_play"></div>');
        this.controlsRoot.append('<div class="oo_button oo_toolbar_item oo_fullscreen oo_fullscreen_on"></div>');
        this.scrubber = new _Scrubber(this.controlsRoot);
      }
    });

    var _LiveControlBar = OO.inherit(_BaseControlBar, function(controlsRoot, basicUi) {
      this.controlsRoot = controlsRoot;
      this.basicUi = basicUi;
      this.init();
    });

    _.extend(_LiveControlBar.prototype, {
      init: function() {
        this.controlsRoot.append("<div class='oo_scrubber'>\
        <div class='oo_scrubber_track'>\
          <div class='oo_progress oo_buffer_progress'></div>\
          <div class='oo_progress oo_playhead_progress'></div>\
          <div class='oo_playhead'></div>\
        </div>\
          </div>");
        this.controlsRoot.append('<div class="oo_button oo_toolbar_item oo_rewind"></div>');
        this.controlsRoot.append('<div class="oo_button oo_toolbar_item oo_pause" style="display:none;"></div>');
        this.controlsRoot.append('<div class="oo_button oo_toolbar_item oo_play"></div>');
        this.controlsRoot.append('<div class="oo_live_indicator oo_button oo_toolbar_item"></div>');
        this.controlsRoot.append('<div class="oo_live_message oo_label oo_button oo_toolbar_item"></div>');
        this.controlsRoot.append('<div class="oo_button oo_toolbar_item oo_fullscreen oo_fullscreen_on"></div>');
        this.controlsRoot.find("div.oo_live_message").html(OO.getLocalizedMessage(OO.TEXT.LIVE));
        this.scrubber = new _Scrubber(this.controlsRoot);
      }
    });

    OO.registerModule('basic_ui', function(messageBus, id, params) {
      return new BasicUi(messageBus, id, params);
    });
  }(OO, OO.$, OO._));
  OO.plugin("DiscoveryApi", function(OO, _, $, W) {
    var MAX_VIDEOS = 20;
    OO.EVENTS.DISCOVERY_API = {
      RELATED_VIDEOS_FETCHED : "relatedVideosFetched",
      SEND_DISPLAY_EVENT: "sendDisplayEvent",
      DISPLAY_EVENT_SUCCESS: "displayEventSuccess",
      SEND_CLICK_EVENT: "sendClickEvent",
      CLICK_EVENT_SUCCESS: "clickEventSuccess",
      // If sending a display or click event results in an error, an error event will be published to the
      // message bus. The event will have a DISPLAY_EVENT_ERROR or CLICK_EVENT_ERROR type and a data object
      // with 3 keys: xhr, status, error.
      // The values for these keys are the 3 parameters that are given to the error callback by
      // $.ajax(...) in case of a failure.
      DISPLAY_EVENT_ERROR: "displayEventError",
      CLICK_EVENT_ERROR: "clickEventError"
    };
    var DiscoveryApi = function(mb, id) {
      if (!OO.requiredInEnvironment('html5-playback') && !OO.requiredInEnvironment('cast-playback')) { return; }
      this.id = id;
      this.mb = mb;
      this.error = false;
      this.relatedVideos = [];
      this.guid = "";
      this.apiHost = OO.playerParams.backlot_api_write_server || 'api.ooyala.com';

      OO.StateMachine.create({
        initial:'Init',
        messageBus:this.mb,
        moduleName:'DiscoveryApi',
        target:this,
        events:[
          {name:OO.EVENTS.EMBED_CODE_CHANGED, from:'*'},
          {name:OO.EVENTS.DISCOVERY_API.SEND_DISPLAY_EVENT, from:'*'},
          {name:OO.EVENTS.DISCOVERY_API.SEND_CLICK_EVENT, from:'*'},
          {name:OO.EVENTS.GUID_SET, from:'*'}
        ]
      });
    };

    _.extend(DiscoveryApi.prototype, {
      onEmbedCodeChanged: function(event, embedCode) {
        if (this.guid === "") {
          // wait a little bit before calling fetch related videos to give a little bit of time for the guid
          // to be set. Its possible that even after 500 milliseconds, it won't be set but such is life.
          var fetchRelatedDelayed = _.bind(function() { this._fetchRelatedVideos(embedCode); }, this);
          setTimeout(fetchRelatedDelayed, 500);
        } else {
          this._fetchRelatedVideos(embedCode);
        }
      },

      onGuidSet: function(event, guid) {
        this.guid = guid;
      },

      /**
        * Sends an impression feedback event to the backend discovery APIs. An impression is when
        * recommendations are shown to the user.
        *
        * Params:
        * event - is always OO.EVENTS.DISCOVERY_API.SEND_DISPLAY_EVENT.
        * eventData - should have the fields "bucket_info" and "custom".
        * eventData.bucket_info - should be the discovery bucket info object that was returned as part of
        *    the response to fetch recommendations.
        * eventData.custom.source - should be one of "endScreen" or "pauseScreen".
        */
      onSendDisplayEvent: function(event, eventData) {
        if (!eventData) { return; }
        var relatedVideos = eventData.relatedVideos;
        if (!relatedVideos || !_.isArray(relatedVideos) || _.size(relatedVideos) < 1) {
          return;
        }
        var bucketInfo = relatedVideos[0].bucket_info;
        if (!bucketInfo) { return; }
        if (bucketInfo.charAt(0) == "2") {  // Version 2 bucket info can be handled by reporter.js
          this.mb.publish(OO.EVENTS.REPORT_DISCOVERY_IMPRESSION, eventData);
          return;
        }
        // Version 1 bucket info can't be handled by reporter.js (no zlib to decompress the encoded string)
        // and must go through the discovery feedback APIs.
        eventData = { "bucket_info" : bucketInfo, "custom" : eventData.custom };
        var url = "http://" + this.apiHost + "/v2/discover/feedback/impression";
        eventData["device_id"] = this.guid;
        eventData["discovery_profile_id"] = OO.playerParams.playerBrandingId;
        // Note: "system" must be set to "OOYALA" for all feedback originating from Ooyala players.
        eventData["system"] = "OOYALA";
        $.ajax({
          url: url,
          data: JSON.stringify(eventData),
          type: 'POST',
          dataType: 'json',
          crossDomain: true,
          cache: true,
          success: _.bind(this._displayEventSuccess, this),
          error: _.bind(this._displayEventError, this)
        });
      },

      _displayEventSuccess: function() {
        this.mb.publish(OO.EVENTS.DISCOVERY_API.DISPLAY_EVENT_SUCCESS);
      },

      _displayEventError: function(xhr, status, error) {
        this.mb.publish(OO.EVENTS.DISCOVERY_API.DISPLAY_EVENT_ERROR, { xhr: xhr, status: status, error: error });
      },

      /**
        * Sends an click feedback event to the backend discovery APIs. A click is when a displayed
        * recommendations is clicked by the user. If the countdown timer expires and the first recommendation
        * plays automatically, this event should still be sent, but the value of the countdown timer
        * should be set to 0.
        *
        * Params:
        * event - is always OO.EVENTS.DISCOVERY_API.SEND_CLICK_EVENT.
        * eventData - should have the fields "bucket_info" and "custom".
        * eventData.bucket_info - should be the discovery bucket info object that was returned as part of
        *     the response to fetch recommendations.
        * eventData.custom.source - should be one of "endScreen" or "pauseScreen".
        * eventData.custom.countdown - should have the remaining value of the countdown timer, in seconds
        *     ('endScreen' source only).
        * eventData.custom.autoplay - should be true if the video played automatically because the countdown
        *     timer expired ('endScreen' source only).
        */
      onSendClickEvent: function(event, eventData) {
        if (!eventData) { return; }
        var clickedVideo = eventData.clickedVideo;
        if (!clickedVideo) { return; }
        var bucketInfo = clickedVideo.bucket_info;
        if (!bucketInfo) { return; }
        if (bucketInfo.charAt(0) == "2") {  // Version 2 bucket info can be handled by reporter.js
          this.mb.publish(OO.EVENTS.REPORT_DISCOVERY_CLICK, eventData);
          return;
        }
        // Version 1 bucket info can't be handled by reporter.js (no zlib to decompress the encoded string)
        // and must go through the discovery feedback APIs.
        eventData = { "bucket_info" : bucketInfo, "custom" : eventData.custom };
        var url = "http://" + this.apiHost + "/v2/discover/feedback/play";
        eventData["device_id"] = this.guid;
        eventData["discovery_profile_id"] = OO.playerParams.playerBrandingId;
        // Note: "system" must be set to "OOYALA" for all feedback originating from Ooyala players.
        eventData["system"] = "OOYALA";
        $.ajax({
          url: url,
          data: JSON.stringify(eventData),
          type: 'POST',
          dataType: 'json',
          crossDomain: true,
          cache: true,
          success: _.bind(this._clickEventSuccess, this),
          error: _.bind(this._clickEventError, this)
        });
      },

      _clickEventSuccess: function() {
        this.mb.publish(OO.EVENTS.DISCOVERY_API.CLICK_EVENT_SUCCESS);
      },

      _clickEventError: function(xhr, status, error) {
        this.mb.publish(OO.EVENTS.DISCOVERY_API.CLICK_EVENT_ERROR, { xhr: xhr, status: status, error: error });
      },

      _fetchRelatedVideos: function(embedCode) {
        this.error = false;
        this.relatedVideos = [];
        var params = {
          sign_version : 'player',
          pcode : OO.playerParams.pcode,
          discovery_profile_id : OO.playerParams.playerBrandingId,
          video_pcode : OO.playerParams.pcode,
          limit : MAX_VIDEOS,
          device_id: this.guid,
          expected_bucket_info_version: 2,
          expires : Math.floor((new Date().getTime() / 1000)+3600)
        };
        var signature = encodeURIComponent(this._generateSignature(params));
        // Note(manish) nov-14, 2012: encode the device_id which may have special characters (+,?) etc that
        // may need to be uri-encoded. its important that this is done *after* the signature is calculated.
        params.device_id = encodeURIComponent(params.device_id);
        var url = "//" + this.apiHost + "/v2/discover/similar/assets/" + embedCode + "?" +
                  this._generateParamString(params, signature);
        $.ajax({
          url: url,
          type: 'GET',
          dataType: 'json',
          crossDomain: true,
          cache: true,
          success: _.bind(this._onRelatedVideosFetched, this),
          error: _.bind(this._onApiError, this)
        });
      },

      _onRelatedVideosFetched: function(response) {
        var safe_response = OO.HM.safeObject("discovery.relatedVideos", response, {});
        if (safe_response.errors === undefined || (safe_response.errors && safe_response.errors.code === 0)) {
          this.relatedVideos = safe_response.results || [];
          this.variationIds = safe_response.variation_ids;
        } else {
          this.relatedVideos = [];
          this.variationIds = [];
        }
        this.mb.publish(OO.EVENTS.REPORT_EXPERIMENT_VARIATIONS, { variationIds: this.variationIds });
        this.mb.publish(OO.EVENTS.DISCOVERY_API.RELATED_VIDEOS_FETCHED, { videos : this.relatedVideos });
      },

      _onApiError: function(xhr, status, error) {
        this.error = true;
        this.mb.publish(OO.EVENTS.DISCOVERY_API.RELATED_VIDEOS_FETCHED, { error : true });
      },

      _generateSignature: function(params) {
        // signature format:
        // pcodeparamName=paramValue...
        var pcode = params.pcode;
        var shaParams = _.reject(_.keys(params), function(key) { return key === 'pcode'; });
        var sha = new jsSHA(pcode+this._hashToString(params, '', shaParams), 'ASCII');
        return sha.getHash('SHA-256', 'B64').substring(0, 43);
      },

      _hashToString: function(hash, delimiter, keys) {
        var string = "";
        var myKeys = keys || _.keys(hash);
        _.each(_.sortBy(myKeys,function(val) { return val; }), function(key) {
          string += delimiter+key+"="+hash[key];
        });
        return string;
      },

      _generateParamString: function(params, signature) {
        var string = "signature="+signature+this._hashToString(params,'&');
        return string;
      }
    });

    // Return class definition
    return DiscoveryApi;
  });
(function(OO, _, $){
  var Tween = function(velocity, deceleration, callback, interval) {
    this.initialVelocity = velocity;
    this.deceleration = velocity > 0 ? -Math.abs(deceleration) : Math.abs(deceleration);
    this.callback = callback;
    this.initialTime = new Date().getTime();
    this._tweenInterval = null;
    this.interval = interval || 1;
  };

  _.extend(Tween.prototype, {
    isDone: function() { return this._tweenInterval === null; },
    start : function() {
      this.initialTime = new Date().getTime();
      var velocityDelta = -this.initialVelocity;
      this.stopTime = velocityDelta/this.deceleration;
      this.travelledDistance = 0;
      this._tweenInterval = setInterval(_.bind(this._decelerate, this), this.interval);
    },
    stop : function() {
      if (this._tweenInterval === null) { return; }
      clearInterval(this._tweenInterval);
    },
    _decelerate : function() {
      var elapsedTime = new Date().getTime() - this.initialTime;
      if (elapsedTime > this.stopTime) {
        clearInterval(this._tweenInterval);
        this._tweenInterval = null;
        return;
      }
      var distance = this.initialVelocity*elapsedTime + 0.5*this.deceleration*elapsedTime*elapsedTime;
      var distanceDelta = distance - this.travelledDistance;
      this.travelledDistance = distance;
      this.callback(distanceDelta);
    }
  });

  OO.Tween = Tween;
}(OO, OO._, OO.$));
  OO.plugin("DiscoveryToaster", function(OO, _, $, W) {
    var DISCOVERY_ICON_HEIGHT = 43;
    var SCROLL_DISTANCE = 3;
    var SCROLL_SPEED = 5;
    var SWIPE_DECELERATION = 0.005;
    var HIDDEN_ZINDEX = -1;
    var SHOWN_ZINDEX = 10008;
    var DISCOVERY_MODULE_TYPE = "discovery-ui";

    var DiscoveryToaster = function(mb, id) {
      if (!OO.requiredInEnvironment('html5-playback') && !OO.requiredInEnvironment('cast-playback')) { return; }
      this.id = id;
      this.mb = mb;
      this.relatedVideos = [];
      this.countdownTimerStartedAt = 0;
      this.hideTitle = null;
      this._tween = null;
      this.enableToasterPause = true;
      this.relatedVideoHTML = [];
      this.htmlIndex = -1;
      this.numLoadedImageHTML = 0;

      OO.StateMachine.create({
        initial:'Init',
        messageBus:this.mb,
        moduleName:'DiscoveryToaster',
        target:this,
        events:[
          {name:OO.EVENTS.PLAYER_CREATED,                       from:'*'},
          {name:OO.EVENTS.EMBED_CODE_CHANGED,                   from:'*'},
          {name:OO.EVENTS.METADATA_FETCHED,                     from:'*'},
          {name:OO.EVENTS.DISCOVERY_API.RELATED_VIDEOS_FETCHED, from:'*'},
          {name:OO.EVENTS.WILL_PLAY_ADS,                        from:'*'},
          {name:OO.EVENTS.ADS_PLAYED,                           from:'*'},
          {name:OO.EVENTS.PAUSED,                               from:'*'},
          {name:OO.EVENTS.PLAYED,                               from:'*'},
          {name:OO.EVENTS.PLAYING,                              from:'*'},
          //{name:OO.EVENTS.PLAYHEAD_TIME_CHANGED,                from:'*'}, TODO[jigish] uncomment when last n seconds is turned on
          {name:OO.EVENTS.CONTROLS_SHOWN,                       from:'*'},
          {name:OO.EVENTS.CONTROLS_HIDDEN,                      from:'*'},
          {name:OO.EVENTS.PLAYBACK_READY,                       from:'*'},
          {name:OO.EVENTS.FULLSCREEN_CHANGED,                   from:'*'},
          {name:OO.EVENTS.SCRUBBING,                            from:'*'},
          {name:OO.EVENTS.SCRUBBED,                             from:'*'}
        ]
      });
    };

    _.extend(DiscoveryToaster.prototype, {
      onPlayerCreated: function(event, elementId, params) {
        this.elementId = elementId;
        this.topMostElement = $('#'+this.elementId);
        this.rootElement =  this.topMostElement.find("div.innerWrapper");
        this.params = params;
        this.accentColor = params.accentColor || 0x5D8ADD;
        this.showingToaster = false;
        this._isScrubbing = false;
        this._isPlayingAds = false;
        // toaster div:
        OO.attachStyle(_.template(OO.get_css("discovery_toaster"))({
          elementId : this.elementId,
          discoveryIcon : OO.get_img_base64('discovery_dots'),
          playIcon : OO.get_img_base64('icon_play')
        }), this.elementId);
        this.rootElement.append("<div class='discovery_toaster'>\
            <div class='discovery_copy'>Discover</div>\
            <div class='discovery_image_holder'>\
              <div class='discovery_image'></div>\
            </div>\
            <div class='discovery_outer'>\
              <div class='discovery_left_gradient'></div>\
              <div class='discovery_left_scroll'></div>\
              <div class='discovery_holder'></div>\
              <div class='discovery_right_scroll'></div>\
              <div class='discovery_right_gradient'></div>\
            </div>\
          </div>");
        if (this.params[DISCOVERY_MODULE_TYPE] && this.params[DISCOVERY_MODULE_TYPE].hideTitle != null) {
          if (this.params[DISCOVERY_MODULE_TYPE].hideTitle.toString() === "true") {
            this.hideTitle = true;
          } else if (this.params[DISCOVERY_MODULE_TYPE].hideTitle.toString() === "false") {
            this.hideTitle = false;
          }
        }

        if (this.params[DISCOVERY_MODULE_TYPE] && this.params[DISCOVERY_MODULE_TYPE].enableToasterPause != null) {
          if (this.params[DISCOVERY_MODULE_TYPE].enableToasterPause.toString() === "true") {
            this.enableToasterPause = true;
          } else if (this.params[DISCOVERY_MODULE_TYPE].enableToasterPause.toString() === "false") {
            this.enableToasterPause = false;
          }
        } else if (OO.playerParams.attributes && OO.playerParams.attributes.enable_toaster_pause !== undefined) {
          if (OO.playerParams.attributes.enable_toaster_pause.toString() === "true") {
            this.enableToasterPause = true;
          } else if (OO.playerParams.attributes.enable_toaster_pause.toString() === "false") {
            this.enableToasterPause = false;
          }
        }
      },

      onEmbedCodeChanged: function(event, embedCode) {
        this._resetToaster();
        this._isScrubbing = false;
      },

      onMetadataFetched: function(event, response) {
        if (response && response['modules'] && response['modules'][DISCOVERY_MODULE_TYPE] && response['modules'][DISCOVERY_MODULE_TYPE]['metadata']) {
          var meta = response['modules'][DISCOVERY_MODULE_TYPE]['metadata'];
          // Page level has precedence over meta-data, so we ignore hideTitle meta-data if it was already specified
          if (this.hideTitle == null && meta.hideTitle != null && meta.hideTitle.toString() === "true") {
            this.hideTitle = true;
          } else if (this.hideTitle == null && meta.hideTitle != null && meta.hideTitle.toString() === "false") {
            this.hideTitle = false;
          }
          //If this wasn't set by page level params, check metadata setting
          if (this.params[DISCOVERY_MODULE_TYPE] === undefined || this.params[DISCOVERY_MODULE_TYPE].enableToasterPause === undefined) {
            if (meta.enableToasterPause !== undefined && meta.enableToasterPause.toString() === "true") {
              this.enableToasterPause = true;
            }
            else if (meta.enableToasterPause !== undefined && meta.enableToasterPause.toString() === "false") {
              this.enableToasterPause = false;
            }
          }
        }
      },

      onRelatedVideosFetched: function(event, relatedVideos) {
        this._resetToaster();
        this.relatedVideos = relatedVideos.error ? [] : (relatedVideos.videos || []);

        if (!this._hasRelatedVideos()) { return; }
        // add divs and such in the toaster
        this.toasterRoot = this.rootElement.find('div.discovery_toaster');
        this.holder = this.rootElement.find('div.discovery_holder');
        this.holder.append("<div class='discovery_slider'></div>");
        this.slider = this.holder.find('div.discovery_slider');
        this.discoveryOuter = this.rootElement.find('div.discovery_outer');
        this._resize();
        var first = true;
        _.each(this.relatedVideos, _.bind(function(videoInfo, videoId) {
          var firstClass = first ? ' discovery_first_video_image' : '';
          first = false;
          this.relatedVideoHTML[++this.htmlIndex] = "<div class='discovery_video' style='width: "+this.tileWidth+"px;'>\
            <div data-id='"+videoId+"' data-embed='"+videoInfo.embed_code+"' class='discovery_video_image"+firstClass+"' style='background-image: url("+videoInfo.preview_image_url+");'>";
          if (!this.hideTitle) {
            this.relatedVideoHTML[this.htmlIndex] += "<div data-id='"+videoId+"' data-embed='"+videoInfo.embed_code+"' class='discovery_video_name' style='font-size: "+this.smallFontSize+"px'>"+videoInfo.name+"</div>";
          }
          this.relatedVideoHTML[++this.htmlIndex] = "</div></div>";
        }, this));
        //load the first four promo images here; load the others when user hits pause and starts to scroll right
        this.slider.append(this.relatedVideoHTML.slice(0, 8).join(''));
        this.numLoadedImageHTML = 8;
        this.leftGradient = this.rootElement.find('div.discovery_left_gradient');
        this.rightGradient = this.rootElement.find('div.discovery_right_gradient');
        this.scrollLeft = this.rootElement.find('div.discovery_left_scroll');
        this.scrollRight = this.rootElement.find('div.discovery_right_scroll');

        this._bindListeners();
        this.countdownTimerStartedAt = 0;

        // show toaster if need be
        if (this.showingToaster) {
          this._showToaster();
        }
      },

      onWillPlayAds: function(event, params) {
        this._isPlayingAds = true;
      },

      onAdsPlayed: function() {
        this._isPlayingAds = false;
      },

      onScrubbing: function(event) {
        this._isScrubbing = true;
      },

      onScrubbed: function(event) {
        this._isScrubbing = false;
      },

      onPaused: function(event) {
        if (this._isScrubbing || !this.enableToasterPause) { return; }
        this._showToaster();
      },

      onPlayed: function(event) {
        this._ended = true;
        this._showToaster(true);
        this._showingControls = false;
        this._startContinuousPlayback();
      },

      onPlaybackReady: function(event) {
        if (this.shouldPlay) {
          this.mb.publish(OO.EVENTS.INITIAL_PLAY);
          this.mb.publish(OO.EVENTS.PLAY);
          this.shouldPlay = false;
        }
      },

      onPlayheadTimeChanged: function(event, time, duration) {
        if (!OO.playerParams.attributes ||
             OO.playerParams.attributes.enable_toaster_last_n !== 'true' ||
            !OO.playerParams.attributes.countdown_seconds) { return; }
        var remaining = parseInt(OO.playerParams.attributes.countdown_seconds, 10);
        this.currRemaining = duration - time;
        if (duration - time > remaining || duration === 0) { return; }
        this._showToaster();
      },

      onPlaying: function(event) {
        if (OO.playerParams.attributes && OO.playerParams.attributes.enable_toaster_last_n &&
            OO.playerParams.attributes.enable_toaster_last_n === 'true' &&
            OO.playerParams.attributes.countdown_seconds) {
          var remaining = parseInt(OO.playerParams.attributes.countdown_seconds, 10);
          if (this.currRemaining && this.currRemaining <= remaining) { return; }
        }
        this._hideToaster();
        this._ended = false;
        this.rootElement.find('div.discovery_toaster').css('z-index', SHOWN_ZINDEX);
      },

      onControlsShown: function(event) {
        this._showingControls = true;
        this.rootElement.find('div.discovery_toaster').css('bottom', '60px');
      },

      onControlsHidden: function(event) {
        this._showingControls = false;
        this.rootElement.find('div.discovery_toaster').css('bottom', '15px');
      },

      onFullscreenChanged: function(event) {
        this._resize();
      },

      _bindListeners: function() {
        this._unbindListeners();

        // scroll areas for desktop
        var leftInterval = null;
        var rightInterval = null;
        this.scrollLeft.mouseenter(_.bind(function(event) {
          leftInterval = setInterval(_.bind(this._scrollLeft, this), SCROLL_SPEED);
        }, this)).mouseleave(function() {
          clearInterval(leftInterval);
          leftInterval = null;
        });
        this.scrollRight.mouseenter(_.bind(function() {
          rightInterval = setInterval(_.bind(this._scrollRight, this), SCROLL_SPEED);
        }, this)).mouseleave(function() {
          clearInterval(rightInterval);
          rightInterval = null;
        });

        // touch swipe for mobile
        this.swiping = false;
        this.scrollRight.bind("touchstart", _.bind(this._swipeStart, this));
        this.scrollRight.bind("touchend", _.bind(this._swipeEnd, this));
        this.scrollRight.bind("touchmove", _.bind(this._swipeMove, this));
        this.scrollLeft.bind("touchstart", _.bind(this._swipeStart, this));
        this.scrollLeft.bind("touchend", _.bind(this._swipeEnd, this));
        this.scrollLeft.bind("touchmove", _.bind(this._swipeMove, this));
        this.holder.bind("touchstart", _.bind(this._swipeStart, this));
        this.holder.bind("touchend", _.bind(this._swipeEnd, this));
        this.holder.bind("touchmove", _.bind(this._swipeMove, this));

        // click listeners
        this.holder.click(_.bind(function(event) {
          if (this.showingToaster && event.target && event.target.dataset.id && event.target.dataset.embed &&
              (!this._tween || this._tween.isDone())) {
            this._sendClickEvent(event.target.dataset.id);
            this.shouldPlay = true;
            this.mb.publish(OO.EVENTS.SET_EMBED_CODE, event.target.dataset.embed);
          }
        }, this));
      },

      _unbindListeners: function() {
        if (this.scrollLeft) {
          this.scrollLeft.unbind('mouseenter');
          this.scrollLeft.unbind('mouseleave');
          this.scrollLeft.unbind("touchstart");
          this.scrollLeft.unbind("touchend");
          this.scrollLeft.unbind("touchmove");
        }
        if (this.scrollRight) {
          this.scrollRight.unbind('mouseenter');
          this.scrollRight.unbind('mouseleave');
          this.scrollRight.unbind("touchstart");
          this.scrollRight.unbind("touchend");
          this.scrollRight.unbind("touchmove");
        }
        if (this.holder) {
          this.holder.unbind("touchstart");
          this.holder.unbind("touchend");
          this.holder.unbind("touchmove");
          this.holder.unbind("click");
        }
      },

      _sendDisplayEvent: function() {
        if (!this._hasRelatedVideos()) { return; }
        var eventData = {
          "relatedVideos" : this.relatedVideos.slice(0),
          "custom" : { "source" : this._ended ? "endScreen" : "pauseScreen" }
        };
        this.mb.publish(OO.EVENTS.DISCOVERY_API.SEND_DISPLAY_EVENT, eventData);
      },

      _sendClickEvent: function(id) {
        if (!this._hasRelatedVideos()) { return; }
        var eventData = {
          "clickedVideo" : this.relatedVideos[id],
          "custom" : { "source" : this._ended ? "endScreen" : "pauseScreen" }
        };
        // TODO(ilyam): The countdown timer should not be hard-coded to 15s.
        if (this.playVideoTimer) {
          var countdownTimerRemaining = this.countdownTimerStartedAt + 15000 - new Date().getTime();
          if (countdownTimerRemaining > 0) {
            eventData.custom["countdown"] = countdownTimerRemaining / 1000;
          } else {
            eventData.custom["countdown"] = 0;
          }
        }
        this.mb.publish(OO.EVENTS.DISCOVERY_API.SEND_CLICK_EVENT, eventData);
      },

      _sendAutoplayEvent: function() {
        if (!this._hasRelatedVideos()) { return; }
        var eventData = {
          "clickedVideo" : this.relatedVideos[0],
          "custom" : { "source" : this._ended ? 'endScreen' : 'pauseScreen',
                       "countdown" : 0,
                       "autoplay" : true }
        };
        this.mb.publish(OO.EVENTS.DISCOVERY_API.SEND_CLICK_EVENT, eventData);
      },

      _resize: function() {
        this.rootWidth = this.rootElement.width();
        this.rootHeight = this.rootElement.height();
        // toaster height
        this.toasterHeight = this.rootHeight*4/10;
        this.toasterRoot.css('height', this.toasterHeight);
        // Text scaling
        this.smallFontSize = this.toasterHeight/10 > 14 ? 14 : this.toasterHeight/10;
        this.largeFontSize = this.toasterHeight/8 > 16 ? 16 : this.toasterHeight/8;
        var discoveryText = this.rootElement.find('div.discovery_copy');
        discoveryText.css('font-size', this.largeFontSize+'px');
        // outer size
        this.discoveryOuter.css('top', (discoveryText.height()+12)+'px');
        this.discoveryOuterHeight = this.toasterHeight - (discoveryText.height() + 12);
        // discovery image vertical center
        var discoveryImage = this.rootElement.find('div.discovery_image');
        var discoveryImageHolder = this.rootElement.find('div.discovery_image_holder');
        discoveryImageHolder.css('height', discoveryText.height()+'px');
        var imageHolderHeight = discoveryImageHolder.height();
        discoveryImage.css('bottom', (imageHolderHeight/2 - DISCOVERY_ICON_HEIGHT/2)+'px');
        // tile width
        this.tileHeight = this.discoveryOuterHeight;
        this.tileWidth = this.tileHeight*4/3;
        // slider width
        this.sliderWidth = this.tileWidth*_.size(this.relatedVideos);
        this.slider.css('width', this.sliderWidth);
        // set tile width
        if (this.rootElement.find('div.discovery_video')) {
          this.rootElement.find('div.discovery_video').css('width', this.tileWidth);
        }
        // change the width of the (not-yet-loaded) discovery images since _resize() is called early when moving to fullscreen
        if (this.numLoadedImageHTML < this.htmlIndex) {
          this.htmlIndex = -1;
          _.each(this.relatedVideos, _.bind(function(videoInfo, videoId) {
              this.relatedVideoHTML[++this.htmlIndex] = "<div class='discovery_video' style='width: "+this.tileWidth+"px;'>\
                <div data-id='"+videoId+"' data-embed='"+videoInfo.embed_code+"' class='discovery_video_image' style='background-image: url("+videoInfo.preview_image_url+");'>";
              if (!this.hideTitle) {
                this.relatedVideoHTML[this.htmlIndex] += "<div data-id='"+videoId+"' data-embed='"+videoInfo.embed_code+"' class='discovery_video_name' style='font-size: "+this.smallFontSize+"px'>"+videoInfo.name+"</div>";
              }
              this.relatedVideoHTML[++this.htmlIndex] = "</div></div>";
          }, this));
        }
        // when leaving fullscreen the slider doesn't reset its position if it scrolled too far to the right, so manually check and adjust
        var minSlideX = this._minSlideX();
        if (this._xTransformPos(this.slider.css('-webkit-transform')) <= minSlideX) {
          this.slider.css('-webkit-transform', 'translateX('+minSlideX+'px)');
          this.slider.css('-moz-transform', 'translateX('+minSlideX+'px)');
          this.slider.css('-ms-transform', 'translateX('+minSlideX+'px)');
          this.slider.css('transform', 'translateX('+minSlideX+'px)');
          // load any remaining promo images here since slider position will change when leaving fullscreen
          if (this.numLoadedImageHTML < this.htmlIndex) {
            this.slider.append(this.relatedVideoHTML.slice(this.numLoadedImageHTML).join(''));
          }
        }
      },

      _applyGradients: function() {
        if (this._isSliderAtMax()) {
          this.leftGradient.css('opacity', 0);
        }
        if (this._isSliderAtMin()) {
          this.rightGradient.css('opacity', 0);
        }
      },

      _startContinuousPlayback: function() {
        if (this._hasRelatedVideos()) {
          var embedCode = this.relatedVideos[0].embed_code;
          var countdown = "<div data-embed='"+embedCode+"' class='discovery-countdown-container'>\
              <div class='discovery-countdown'>\
                <div data-id='0' data-embed='"+embedCode+"' class='countdown-play'></div>\
                <div data-id='0' data-embed='"+embedCode+"' class='countdown-inner'></div>\
                <div data-id='0' data-embed='"+embedCode+"' class='countdown-mask'></div>\
                <div data-id='0' data-embed='"+embedCode+"' class='countdown-mask-two'></div>\
              </div>\
            </div>";
          var firstVideo = this.rootElement.find('div.discovery_first_video_image');
          firstVideo.append(countdown);
          countdown = this.rootElement.find('div.discovery-countdown');
          if (countdown) { countdown.css('background', '#'+this.accentColor.toString(16)); }
          var countdown_mask = this.rootElement.find('div.countdown-mask');
          if (countdown_mask) { countdown_mask.css('border-top-color', '#'+this.accentColor.toString(16)); }
          this.leftGradient = this.rootElement.find('div.discovery_left_gradient');
          this.rightGradient = this.rootElement.find('div.discovery_right_gradient');
          this.countdownTimerStartedAt = new Date().getTime();
          // TODO(ilyam): The countdown timer should not be hard-coded to 15s.
          this.playVideoTimer = _.delay(_.bind(this._playNextVideo, this), 15000);
        }
      },

      _removeContinuousPlayback: function() {
        if (this.playVideoTimer) {
          clearTimeout(this.playVideoTimer);
          this.playVideoTimer = null;
        }
        var countdown = this.rootElement.find('div.discovery-countdown-container');
        if (countdown) { countdown.remove(); }
        this.countdownTimerStartedAt = 0;
      },

      _playNextVideo: function() {
        this._sendAutoplayEvent();
        this.shouldPlay = true;
        this.mb.publish(OO.EVENTS.SET_EMBED_CODE, this.relatedVideos[0].embed_code);
      },

      _showToaster: function(flushed) {
        if (this._isPlayingAds) { return; }
        this.showingToaster = true;
        if (!this._hasRelatedVideos()) { return; }
        this._slide();
        this._sendDisplayEvent();
        this._applyGradients();
        var bot = (flushed || !this._showingControls) ? '15px' : '60px';
        this.rootElement.find('div.discovery_toaster').css('bottom', bot);
        this.rootElement.find('div.discovery_toaster').css('opacity', 1);
        // Display needs to be toggled otherwise the element intercepts click events
        this.rootElement.find('div.discovery_toaster').css('display', '');
        // Hiding the toaster is throwing off some of the size calculations,
        // so redraw once the element is visible again by deferring.
        _.defer(_.bind(this._resize, this));
        this._bindListeners();
      },

      _hideToaster: function() {
        this._removeContinuousPlayback();
        this.showingToaster = false;
        this.rootElement.find('div.discovery_toaster').css('opacity', 0);
        this.rootElement.find('div.discovery_toaster').css('display', 'none');
        this._unbindListeners();
      },

      _resetToaster: function() {
        this._hideToaster();
        this.holder = null;
        this.rootWidth = null;
        this.rootHeight = null;
        this.tileWidth = null;
        this.sliderWidth = null;
        this.toasterHeight = null;
        this.slider = null;
        this.scrollLeft = null;
        this.scrollRight = null;
        this.relatedVideos = [];
        if (this.leftGradient) { this.leftGradient.css('opacity', 0); }
        if (this.rightGradient) { this.rightGradient.css('opacity', 0); }
        // clear out existing toaster
        this.rootElement.find('div.discovery_holder').empty();
        this.rootElement.find('div.discovery_toaster').css('z-index', HIDDEN_ZINDEX);
      },

      _swipeStart: function(event) {
        this.swiping = true;
        var pos = this._getPagePositionFromEvent(event);
        this.initialSwipeX = pos[0];
        this.initialSwipeTime = event.timeStamp;
        if (this._tween !== null) { this._tween.stop(); this._tween = null; }
      },

      _swipeEnd: function(event) {
        if (!this.swiping) { return; }
        var pos = this._getPagePositionFromEvent(event);
        var newSwipeX = pos[0];
        var newSwipeTime = event.timeStamp;
        // second condition makes sure we don't store a funky velocity if the person keeps their finger in
        // the same spot for a while
        if (newSwipeX !== this.initialSwipeX || (newSwipeTime - this.initialSwipeTime) > 50) {
          this._slideDistance = newSwipeX - this.initialSwipeX;
          this._slideTime = newSwipeTime - this.initialSwipeTime;
          this._slideVelocity = this._slideDistance/this._slideTime;
        }
        // don't tween if we're already at a bound
        if ((this._isSliderAtMax() && this._slideVelocity >= 0) ||
            (this._isSliderAtMin() && this._slideVelocity <= 0)) { this.swiping = false; return; }
        this._tween = new OO.Tween(this._slideVelocity,
                                         SWIPE_DECELERATION,
                                         _.bind(this._slide, this));
        this._tween.start();
        this.swiping = false;
      },

      _swipeMove: function(event) {
        if (!this.swiping) { return; }
        this._removeContinuousPlayback();
        var pos = this._getPagePositionFromEvent(event);
        var newSwipeX = pos[0];
        var newSwipeTime = event.timeStamp;
        this._slideDistance = newSwipeX - this.initialSwipeX;
        this._slideTime = newSwipeTime - this.initialSwipeTime;
        this._slideVelocity = this._slideDistance/this._slideTime;
        var swipeDelta = newSwipeX - this.initialSwipeX;
        this._slide(swipeDelta);
        this.initialSwipeX = newSwipeX;
        this.initialSwipeTime = event.timeStamp;
        event.preventDefault();
        event.stopPropagation();

        // check if we should load more promo images when user swipes to the right (mobile)
        if (swipeDelta < 0) {
          xpos = this._xTransformPos(this.slider.css('-webkit-transform'));
          if (this.numLoadedImageHTML < this.htmlIndex && (xpos % this.rootWidth > -35 || swipeDelta < -60 || xpos > -50)) {
            //load the next four promo images
            var nextFourImagesIndex = this.numLoadedImageHTML + 8;
            this.slider.append(this.relatedVideoHTML.slice(this.numLoadedImageHTML, nextFourImagesIndex).join(''));
            this.numLoadedImageHTML = nextFourImagesIndex;
          }
        }
      },

      _getPagePositionFromEvent: function(event) {
        var e = event.originalEvent || event;
        if (!e.changedTouches || !e.changedTouches[0]) { return [e.pageX, e.pageY]; }
        return [e.changedTouches[0].pageX, e.changedTouches[0].pageY];
      },

      _xTransformPos: function(cssMatrix) {
        if (!cssMatrix || !_.isString(cssMatrix)) { return 0; }
        var array = cssMatrix.replace("matrix(", "").replace(")", "").replace(" ", "").split(',');
        if (!_.isArray(array) || _.size(array) < 5) { return 0;}
        return parseInt(cssMatrix.replace("matrix(", "").replace(")", "").split(", ")[4], 10);
      },

      _slide: function(pixels) {
        if (!this.slider) { return; }
        var translateX = 0;
        if (_.isNumber(pixels)) {
          var translate_web = this._xTransformPos(this.slider.css('-webkit-transform'));
          var translate_moz = this._xTransformPos(this.slider.css('-moz-transform'));
          var translate_ms = this._xTransformPos(this.slider.css('-ms-transform'));
          translateX = translate_moz || translate_web || translate_ms;
          translateX += pixels;
        } else {
          // if no distance is specified, reset to start position
          translateX = this._maxSlideX();
        }
        // ensure we don't slide too much
        if (translateX >= this._maxSlideX()) {
          this.leftGradient.css('opacity', 0);
          translateX = this._maxSlideX();
        } else {
          this.leftGradient.css('opacity', 1);
        }
        if (translateX <= this._minSlideX()) {
          this.rightGradient.css('opacity', 0);
          translateX = this._minSlideX();
        } else {
          this.rightGradient.css('opacity', 1);
        }
        if (translateX < this._maxSlideX() && translateX > this._minSlideX()) {
          this._removeContinuousPlayback();
        }
        this.slider.css('-webkit-transform', 'translateX('+translateX+'px)');
        this.slider.css('-moz-transform', 'translateX('+translateX+'px)');
        this.slider.css('-ms-transform', 'translateX('+translateX+'px)');
        this.slider.css('transform', 'translateX('+translateX+'px)');
      },

      _isSliderAtMax: function() {
        var translateX = this._xTransformPos(this.slider.css('-webkit-transform'));
        return translateX === this._maxSlideX();
      },

      _isSliderAtMin: function() {
        var translateX = this._xTransformPos(this.slider.css('-webkit-transform'));
        return translateX === this._minSlideX();
      },

      _maxSlideX: function() {
        return 0;
      },

      _minSlideX: function() {
        return (this.rootWidth - this.sliderWidth - this.rootWidth/10);
      },

      _scrollRight: function() {
        // check if we should load more promo images when user scrolls right with a mouse (desktop)
        // ideally we'd check if ( == 0) but the slider moves so quickly sometimes it doesn't catch the 0 position)
        if (this.numLoadedImageHTML < this.htmlIndex) {
          var slideDiff = this._xTransformPos(this.slider.css('-moz-transform')) || this._xTransformPos(this.slider.css('-webkit-transform')) ||
            this._xTransformPos(this.slider.css('-ms-transform'));
          if (slideDiff % this.rootWidth > -4) {
            // load the next four promo images
            var nextFourImagesIndex = this.numLoadedImageHTML + 8;
            this.slider.append(this.relatedVideoHTML.slice(this.numLoadedImageHTML, nextFourImagesIndex).join(''));
            this.numLoadedImageHTML = nextFourImagesIndex;
          }

        }
        this._slide(-SCROLL_DISTANCE);
      },

      _scrollLeft: function() {
        this._slide(SCROLL_DISTANCE);
      },

      _hasRelatedVideos: function() {
        return _.isArray(this.relatedVideos) && _.size(this.relatedVideos) > 0;
      }
    });

    // Return class definition.
    return DiscoveryToaster;
  });
  OO.plugin("GoogleIma", function(OO, _, $, W){
    /*
     * Google IMA SDK v3
     * https://developers.google.com/interactive-media-ads/docs/sdks/googlehtml5_ads_v3
     * https://developers.google.com/interactive-media-ads/docs/sdks/googlehtml5_apis_v3
     */
    var IMA_MODULE_TYPE = "google-ima-ads-manager";
    var MAX_AD_MANAGER_LOAD_TIME_OUT = 10000;
    var DEFAULT_ADS_REQUEST_TIME_OUT = 3000;
    var PLAYHEAD_UPDATE_INTERVAL = 200;
    var ext = OO.DEV ? '_debug.js' : '.js';
    var IMA_JS = "//imasdk.googleapis.com/js/sdkloader/ima3" + ext;
    var protocol = OO.isSSL ? "https:" : "http:";
    var bootJsSrc = protocol + IMA_JS;

    W.googleImaSdkLoadedCbList = W.googleImaSdkLoadedCbList  || [];
    W.googleImaSdkFailedCbList = W.googleImaSdkFailedCbList || [];
    W.googleImaSdkLoaded = false;

    var onBootStrapReady = function() {
      OO.log("Bootstrap Ready!!!", W.googleImaSdkLoaded);
      if (W.googleImaSdkLoaded) { return; }
      OO._.each(W.googleImaSdkLoadedCbList, function(fn) { fn(); }, OO);
    };

    var onBootStrapFailed = function() {
      OO.log("Bootstrap failed to load!");
      W.googleImaSdkLoaded = false;
      OO._.each(W.googleImaSdkFailedCbList, function(fn) { fn(); }, OO);
    };

    OO._.defer(function() {
      OO.loadScriptOnce(bootJsSrc, onBootStrapReady, onBootStrapFailed, 15000);
    });

    // helper function to convert types to boolean
    // the (!!) trick only works to verify if a string isn't the empty string
    // therefore, we must use a special case for that
    var convertToBoolean = function(value) {
      if (typeof value === 'string')
        return (value.indexOf("true") > -1 || value.indexOf("yes") > -1);
      return !!value;
    }

    var GoogleIma = function(messageBus, id) {
      this.preparePlatformExtensions();
      this.canSetupAdsRequest = true;

      if (this.platformExtensions.preConstructor) { this.platformExtensions.preConstructor(); }
      if (!OO.requiredInEnvironment('html5-playback') && !OO.requiredInEnvironment('cast-playback')) { return; }
      if (OO.isIE) { return; }
      // disable check for ads environment for now.
      //if (!OO.requiredInEnvironment('ads')) {return; }

      OO.EVENTS.GOOGLE_IMA_READY = "googleImaReady";
      OO.EVENTS.GOOGLE_RESUME_CONTENT = "googleResumeContent";
      OO.EVENTS.GOOGLE_IMA_CAN_SEEK = "googleImaCanSeek";
      OO.EVENTS.GOOGLE_IMA_CAN_PLAY = "googleImaCanPlay";
      OO.EVENTS.GOOGLE_IMA_ALL_ADS_DONE = "googleImaAllAdsDone";
      OO.EVENTS.GOOGLE_IMA_REMOVE_BUFFERING = "googleImaRemoveBuffering";

      this.Id = id;
      this.mb = messageBus;
      this.rootElement = null;

      this.currentEmbedCode = null;
      this.adsLoader = null;
      this.adTagUrl = null;
      this.adDisplayContainer = null;
      this.hasError = false;
      this.playheadUpdateTimer = null;
      this.linearAdStarted = false;
      this.adControls = null;
      this.showInAdControlBar = false;
      this.adPauseCalled = false;
      this.adsReady = false;
      this.imaAdsManagerActive = false;
      this.isLinearAd = false;
      this.adTagUrlFromEmbedHash = null;
      this.switchingAdsManager = false;
      this.additionalAdTagParameters = null;
      this.marqueePageOverride = false;
      this.adsRequested = false;
      this.contentEndedHandler = _.bind(this.onContentEnded, this);
      this.contentEnded = false;
      this.customPlayheadTracker = null;
      this.customPlayheadIntervalFunction = _.bind(this._customPlayheadUpdate, this);
      this.playWhenAdClick = null;
      this.isFullscreen = false;
      this.maxAdsRequestTimeout = DEFAULT_ADS_REQUEST_TIME_OUT;
      this.maxAdsRequestTimeoutPageOverride = false;
      this.isLivePlaying = false;
      this.googleResumeContentDispatched = false;
      this.contentResumeAlreadyCalled = false;

      W.googleImaSdkLoadedCbList.unshift(OO._.bind(this.onSdkLoaded, this));
      W.googleImaSdkFailedCbList.unshift(OO._.bind(this.onImaAdError, this));

      OO.StateMachine.create({
        initial:'Init',
        messageBus:this.mb,
        moduleName:'googleIma',
        target:this,
        events:[
          {name:OO.EVENTS.PLAYER_CREATED,                     from:'Init',                                       to:'PlayerCreated'},
          {name:OO.EVENTS.SET_EMBED_CODE,                     from:'*',                                          to:'EmbedCodeChanged'},
          {name:OO.EVENTS.AUTHORIZATION_FETCHED,              from:'*'},
          {name:OO.EVENTS.METADATA_FETCHED,                   from:'EmbedCodeChanged',                           to:'*'},
          {name:OO.EVENTS.PLAYER_CLICKED,                     from:'*',                                          to:'*'},
          {name:OO.EVENTS.INITIAL_PLAY,                       from:'*',                                          to:'*'},
          {name:OO.EVENTS.WILL_PLAY_ADS,                      from:'*',                                          to:'*'},
          {name:OO.EVENTS.PAUSE,                              from:'*',                                          to:'*'},
          {name:OO.EVENTS.FULLSCREEN_CHANGED,                 from:'*',                                          to:'*'},
          {name:OO.EVENTS.WILL_PLAY_FROM_BEGINNING,           from:'*',                                          to:'*'},
          {name:OO.EVENTS.SCRUBBING,                          from:'*',                                          to:'*'},
          {name:OO.EVENTS.SCRUBBED,                           from:'*',                                          to:'*'},
          {name:OO.EVENTS.SIZE_CHANGED,                       from:'*',                                          to:'*'}
        ]
      });
    };

    _.extend(GoogleIma.prototype, {
      onPlayerCreated: function(event, elementId, params) {
        // Setup timeout for IMA SDK load. Cleared by imaError and onSdkLoaded
        this.unblockPlaybackTimeout = _.delay(_.bind(this.onImaAdError, this), MAX_AD_MANAGER_LOAD_TIME_OUT);

        this.rootElement = $("#" + elementId + " .innerWrapper");
        this.mainVideo = this.rootElement.find("video.video");
        this.mainVideo.on("loadedmetadata", _.bind(this._onVideoMetaLoaded, this));
        this.mainVideo.on("ended", this.contentEndedHandler);

        if (this.platformExtensions.postOnPlayerCreated) { this.platformExtensions.postOnPlayerCreated(); }
        this.mb.intercept(OO.EVENTS.PLAY, 'googleIma', _.bind(this.onPlay, this));
      },

      _processParameters: function(params) {
        if (params && params[IMA_MODULE_TYPE]) {
          if (typeof params[IMA_MODULE_TYPE].adTagUrl !== 'undefined') {
            this.adTagUrl = this.adTagUrlFromEmbedHash = params[IMA_MODULE_TYPE].adTagUrl;
          }

          if (typeof params[IMA_MODULE_TYPE].additionalAdTagParameters !== 'undefined') {
            this.additionalAdTagParameters = params[IMA_MODULE_TYPE].additionalAdTagParameters;
          }

          if (typeof params.showInAdControlBar !== 'undefined') {
            this.showInAdControlBar = params.showInAdControlBar;
          } else {
            this.showInAdControlBar = !!params[IMA_MODULE_TYPE].showInAdControlBar;
          }

          if (typeof params[IMA_MODULE_TYPE].showAdMarquee !== 'undefined') {
            //this takes care of whether or not it's a boolean or a string true, false
            var showAdCountdownText = convertToBoolean(params[IMA_MODULE_TYPE].showAdMarquee);
            this.marqueePageOverride = true;
            this.mb.publish(OO.EVENTS.SHOW_AD_MARQUEE, showAdCountdownText);
          }

          if (typeof params[IMA_MODULE_TYPE].playWhenAdClick !== 'undefined') {
            var playAdClick = convertToBoolean(params[IMA_MODULE_TYPE].playWhenAdClick);
            this.playWhenAdClick = playAdClick;
          }

          if (typeof params[IMA_MODULE_TYPE].adRequestTimeout !== 'undefined') {
            var timeOut = parseInt(params[IMA_MODULE_TYPE].adRequestTimeout);
            if (!_.isNaN(timeOut)) {
              this.maxAdsRequestTimeoutPageOverride = true;
              this.maxAdsRequestTimeout = timeOut;
            }
          }
        }
      },

      _addDependentEvent: function() {
        //[gfrank] setting flag here based on CR [Aldi] in cause this function is reused later at a different place.
        this.googleResumeContentDispatched = false;
        this.mb.addDependent(OO.EVENTS.PLAYBACK_READY, OO.EVENTS.GOOGLE_IMA_READY, "googleIma", function(){});
        this.mb.addDependent(OO.EVENTS.PLAY, OO.EVENTS.GOOGLE_RESUME_CONTENT, "googleIma", function(){});
        this.mb.addDependent(OO.EVENTS.INITIAL_PLAY, OO.EVENTS.GOOGLE_IMA_CAN_PLAY, "googleIma", function(){});
        this.mb.addDependent(OO.EVENTS.CAN_SEEK, OO.EVENTS.GOOGLE_IMA_CAN_SEEK, "googleIma", function(){});
      },

      onSetEmbedCode: function(event, embedCode, params) {
        this.contentResumeAlreadyCalled = false;
        this.canSetupAdsRequest = true;
        this.customPlayheadTracker = {duration: 0, currentTime: 0};
        if (this.platformExtensions.preOnSetEmbedCode) { this.platformExtensions.preOnSetEmbedCode(); }
        this.currentEmbedCode = embedCode;
        this.isLinearAd = false;
        this.adTagUrl = null;
        if (this.adsManager) {
         this.switchingAdsManager = true;
         this.adsManager.destroy();
         // Remove PLAYED addDependency that is set on onAdsManagerLoaded, in case setEmbedCode is called prior ALL_ADS_COMPLETED
         this.mb.publish(OO.EVENTS.GOOGLE_IMA_ALL_ADS_DONE);
        }

        // https://developers.google.com/interactive-media-ads/faq#8
        // let the ad server know that these are legitimate ads requests, and not accidental duplicates
        if (this.adsLoader) { this.adsLoader.contentComplete(); }
        this.adsManager = null;
        this.linearAdStarted = false;
        this.adsRequested = false;
        this.adsReady = false;
        this.contentEnded = false;
        if (this.imaAdsManagerActive) {
          // Safety when setEmbedCode is called while IMA ads is still playing.
          this.mb.publish(OO.EVENTS.ADS_MANAGER_FINISHED_ADS);
          this.disptachContentResume();
          this.imaAdsManagerActive = false;
        }
        clearInterval(this.playheadUpdateTimer);
        this.playheadUpdateTimer = null;
        this.adPauseCalled = false;
        this.isLivePlaying = false;

        // If adTagUrl is set via page level override, enable dependentEvents. Else defer to onMetadataFetched
        this._processParameters(params);
        if (this.adTagUrlFromEmbedHash) { this._addDependentEvent(); }
      },

      onAuthorizationFetched:function(event, response) {
        this.authorization = response;
        this.isLivePlaying = (this.isLivePlaying || this.authorization.streams[0].is_live_stream);
      },

      onMetadataFetched: function(event, response) {
        if (this.platformExtensions.overrideOnMetadataFetched){
          this.platformExtensions.overrideOnMetadataFetched(event, response);
          return;
        }

        OO.log("Metadata Ready:", response, this.adTagUrl, this.adTagUrlFromEmbedHash);
        this.adTagUrl = this.adTagUrlFromEmbedHash;

        var responseChecker =
            (response &&
            response['modules'] &&
            response['modules'][IMA_MODULE_TYPE] &&
            response['modules'][IMA_MODULE_TYPE]['metadata']);

        if (!this.adTagUrl) {
          // set adTagUrl if it is not set yet.
          if (responseChecker) {
            var meta = response['modules'][IMA_MODULE_TYPE]['metadata'];
            this.adTagUrl = meta.adTagUrl || meta.tagUrl;
            if (this.rootElement && this.adTagUrl) { this._addDependentEvent(); }
          }
          this._unBlockPlaybackReady();
        }

        // checks whether the page level has already overridden
        // if not, it will publish the metadata's showAdMarquee parameter
        if (!this.marqueePageOverride) {
          if (responseChecker) {
            var meta = response['modules'][IMA_MODULE_TYPE]['metadata'];
            if (meta.showAdMarquee) {
              this.mb.publish(OO.EVENTS.SHOW_AD_MARQUEE, convertToBoolean(meta.showAdMarquee));
            }
          }
        }

        // playWhenAdClick will be null if not set on page-level
        if (this.playWhenAdClick === null) {
          if (responseChecker) {
            var meta = response['modules'][IMA_MODULE_TYPE]['metadata'];
            this.playWhenAdClick = meta.playWhenAdClick;
          }
        }

        if (!this.maxAdsRequestTimeoutPageOverride && responseChecker) {
          if (typeof response['modules'][IMA_MODULE_TYPE]['metadata'].adRequestTimeout !== 'undefined') {
            var timeOut = parseInt(response['modules'][IMA_MODULE_TYPE]['metadata'].adRequestTimeout);
            if (!_.isNaN(timeOut)) {
              this.maxAdsRequestTimeout = timeOut;
            }
          }
        }

        if (W.googleImaSdkLoaded) {
          this._setupAdsRequest();
        } else {
          W.googleImaSdkLoadedCbList.push(OO._.bind(this._setupAdsRequest, this));
        }

        if (this.platformExtensions.postOnMetadataFetched) { this.platformExtensions.postOnMetadataFetched(); }
      },

      onSdkLoaded: function() {
        if (this.platformExtensions.overrideOnSdkLoaded) {
          this.platformExtensions.overrideOnSdkLoaded();
          return;
        }
        OO.log("onSdkLoaded!");

        // [PBK-639] Corner case where Google's SDK 200s but isn't properly
        // loaded. Better safe than sorry..
        if (!(W.google && W.google.ima && W.google.ima.AdDisplayContainer)) {
          this.onImaAdError();
          return;
        }

        W.googleImaSdkLoaded = true;
        this.adDisplayContainer = new W.google.ima.AdDisplayContainer(this.rootElement.find("div.plugins")[0],
          this.rootElement.find("video.video")[0]);
        this.adsLoader = new W.google.ima.AdsLoader(this.adDisplayContainer);

        this.adsLoader.addEventListener(
          W.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
          _.bind(this.onAdsManagerLoaded, this),
          false);
        this.adsLoader.addEventListener(
          W.google.ima.AdErrorEvent.Type.AD_ERROR,
          _.bind(this.onImaAdError, this),
          false);
      },

      _onVideoMetaLoaded: function(event) {
        if (this.platformExtensions.overrideOnVideoMetaLoaded) {
          this.platformExtensions.overrideOnVideoMetaLoaded();
          return;
        }
        this.customPlayheadTracker.duration = this.mainVideo[0].duration;
        this._setCustomPlayheadTracker();
        if (this.imaAdsManagerActive) { return; }
        this._setupAdsRequest();
      },

      _setupAdsRequest: function() {
        if (this.adsRequested || !this.canSetupAdsRequest) { return; }
        if (!W.googleImaSdkLoaded) {
          W.googleImaSdkLoadedCbList.push(OO._.bind(this._setupAdsRequest, this));
          return;
        }
        if (!this.adTagUrl || !this.rootElement) { return; }

        var adsRequest = new W.google.ima.AdsRequest();
        if (this.additionalAdTagParameters) {
          var connector = this.adTagUrl.indexOf("?") > 0 ? "&" : "?";

          // Generate an array of key/value pairings, for faster string concat
          var paramArray = [], param = null;
          for (param in this.additionalAdTagParameters) {
            paramArray.push(param + "=" +  this.additionalAdTagParameters[param]);
          }
          this.adTagUrl += connector + paramArray.join("&");
        }

        adsRequest.adTagUrl = OO.getNormalizedTagUrl(this.adTagUrl, this.currentEmbedCode);
        // Specify the linear and nonlinear slot sizes. This helps the SDK to
        // select the correct creative if multiple are returned.
        var w = this.rootElement.width();
        adsRequest.linearAdSlotWidth = w;
        adsRequest.linearAdSlotHeight = this.rootElement.height();

        adsRequest.nonLinearAdSlotWidth = w;
        adsRequest.nonLinearAdSlotHeight = Math.min(150, w / 4);

        OO.log("setup Ads request", this.adTagUrl, this.rootElement);
        this.adsLoader.requestAds(adsRequest);
        _.delay(_.bind(this._adsRequestTimeout, this), this.maxAdsRequestTimeout);
        this.adsRequested = true;
      },

       onAdsManagerLoaded: function (adsManagerLoadedEvent) {
        // AdsManager was getting instantiated multiple times, prevent this.
        if (this.adsManager) {
          return;
        }

        // https://developers.google.com/interactive-media-ads/docs/sdks/googlehtml5_apis_v3#ima.AdsRenderingSettings
        var adsSettings = new W.google.ima.AdsRenderingSettings();
        adsSettings.restoreCustomPlaybackStateOnAdBreakComplete = true;
        this.adsManager = adsManagerLoadedEvent.getAdsManager(this.customPlayheadTracker, adsSettings);

        // Add listeners to the required events.
        this.adsManager.addEventListener(
            W.google.ima.AdEvent.Type.CLICK,
            _.bind(this.onAdClick, this), false, this);
        this.adsManager.addEventListener(
            W.google.ima.AdErrorEvent.Type.AD_ERROR,
            _.bind(this.onImaAdError, this), false, this);
        this.adsManager.addEventListener(
            W.google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,
            _.bind(this.onContentPauseRequested, this), false, this);
        this.adsManager.addEventListener(
            W.google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,
            _.bind(this.onContentResumeRequested, this), false, this);

        // Listen to any additional events, if necessary.
        var imaAdEvents = [
                      W.google.ima.AdEvent.Type.ALL_ADS_COMPLETED,
                      W.google.ima.AdEvent.Type.COMPLETE,
                      W.google.ima.AdEvent.Type.SKIPPED,
                      W.google.ima.AdEvent.Type.FIRST_QUARTILE,
                      W.google.ima.AdEvent.Type.LOADED,
                      W.google.ima.AdEvent.Type.MIDPOINT,
                      W.google.ima.AdEvent.Type.PAUSED,
                      W.google.ima.AdEvent.Type.RESUMED,
                      W.google.ima.AdEvent.Type.STARTED,
                      W.google.ima.AdEvent.Type.THIRD_QUARTILE];

        OO._.each(imaAdEvents, function(e) {
          this.adsManager.addEventListener(e, OO._.bind(this.onAdEvent, this), false, this);
        }, this);
        this._unBlockPlaybackReady();
        this.adsReady = true;
        this.mb.publish(OO.EVENTS.GOOGLE_IMA_CAN_PLAY);
        this.mb.publish(OO.EVENTS.GOOGLE_IMA_REMOVE_BUFFERING);
        if (this.unblockPlaybackTimeout) {
          clearTimeout(this.unblockPlaybackTimeout);
        }

        this.mb.addDependent(OO.EVENTS.PLAYED, OO.EVENTS.GOOGLE_IMA_ALL_ADS_DONE, "googleIma", function(){});
        if (this.platformExtensions.postOnAdsManagerLoaded) { this.platformExtensions.postOnAdsManagerLoaded(); }
      },

      _unBlockPlaybackReady: function() {
        this.mb.publish(OO.EVENTS.GOOGLE_IMA_READY);
      },

      _unblockMainContentPlay: function(forcePlay) {
        this.mb.publish(OO.EVENTS.GOOGLE_IMA_CAN_SEEK);
        this.disptachContentResume();
        this.mb.publish(OO.EVENTS.GOOGLE_IMA_CAN_PLAY);
        if (this.linearAdStarted) {
          OO.log("Linear ads started.");
        } else if (forcePlay) {
          this.mb.publish(OO.EVENTS.PLAY);
        }
      },

      _adsRequestTimeout: function() {
        if (!this.adsReady) {
          this.onImaAdError(W.google.ima.AdEvent.Type.FAILED_TO_REQUEST_ADS);
        }
      },

      onImaAdError: function(adErrorEvent) {
        if (this.unblockPlaybackTimeout) {
          clearTimeout(this.unblockPlaybackTimeout);
        }
        OO.log("Can not load Google IMA ADs!!",
          adErrorEvent && adErrorEvent.getError());
        this._unBlockPlaybackReady();
        this._unblockMainContentPlay(false);
        if (this.adsManager) {  this.adsManager.destroy(); }
        if (!this.showInAdControlBar) {
          _.delay(_.bind(function(){ this.mb.publish(OO.EVENTS.ENABLE_PLAYBACK_CONTROLS); }, this), 100);
        }
        this.mb.publish(OO.EVENTS.GOOGLE_IMA_REMOVE_BUFFERING);
        this.mb.publish(OO.EVENTS.ADS_ERROR);
      },

      onPlay: function() {
        if (this.switchingAdsManager && OO.supportMultiVideo) {
          this.switchingAdsManager = false;
        } else {
          this.resume();
          if (this.linearAdStarted && this.adsManager) { return false; }
        }
      },

      onPause: function() {
        if (this.adsManager && this.imaAdsManagerActive) {
          this.adPauseCalled = true;
          this.adsManager.pause();
          this.rootElement.find('div.oo_tap_panel').css('display', '');
          // (agunawan): a hack for iPad iOS8. Safari immediately register any elem click event right away.
          // Unlike any other version or even android and desktop browser.
          _.delay(_.bind(function() { this._createTapPanelClickListener(); }, this), 100);
        }
      },

      _createTapPanelClickListener: function() {
        // (TODO): May interfere with PBI ads_manager clickthrough. Consider to revise or remove.
        this.rootElement.find('div.oo_tap_panel').on("click", _.bind(
          function() {
            this.rootElement.find('div.oo_tap_panel').css('display', 'none');
            this.rootElement.find('div.oo_tap_panel').off("click");
            this.resume();
          }, this));
      },

      onContentPauseRequested: function() {
        if (!this.contentEnded) {
          this.mb.addDependent(OO.EVENTS.PLAY, OO.EVENTS.GOOGLE_RESUME_CONTENT, "googleIma", function(){});
          this.googleResumeContentDispatched = false;
        }
        this._dispatchWillPlayAdEvent();
        this.mb.publish(OO.EVENTS.ADS_MANAGER_HANDLING_ADS);
        OO.log("Content Pause Requested by Google IMA!");
        if (this.platformExtensions.preOnContentPauseRequested) { this.platformExtensions.preOnContentPauseRequested(); }
        // video div is used
        if (this.adsManager.isCustomPlaybackUsed()) {
          this.mainVideo.css("left", OO.CSS.VISIBLE_POSITION);
        } else {
          this.mainVideo.css("left", OO.CSS.INVISIBLE_POSITION);
        }
        this.mb.publish(OO.EVENTS.PAUSE);
        if (!this.showInAdControlBar) {
          _.delay(_.bind(function(){ this.mb.publish(OO.EVENTS.DISABLE_PLAYBACK_CONTROLS); }, this), 100);
        }
        this.imaAdsManagerActive = true;
        this.mainVideo.off("ended", this.contentEndedHandler);
        this._deleteCustomPlayheadTracker();
        this.mb.publish(OO.EVENTS.BUFFERING);
      },

      disptachContentResume: function() {
        if (!this.googleResumeContentDispatched) {
          this.googleResumeContentDispatched = true;
          this.mb.publish(OO.EVENTS.GOOGLE_RESUME_CONTENT);
        }
      },

      onContentResumeRequested: function() {
        if (this.contentResumeAlreadyCalled) {
          OO.log("Content Already resuming");
          return;
        }
        OO.log("Content Resume Requested by Google IMA!");
        if (this.platformExtensions.preOnContentResumeRequested) { this.platformExtensions.preOnContentResumeRequested(); }
        // plugins div was used
        if (!this.adsManager.isCustomPlaybackUsed()) {
          this.mainVideo.css("left", OO.CSS.VISIBLE_POSITION);
          this.mainVideo.css("visibility", "visible");
        }
        this._unblockMainContentPlay(!this.contentEnded);
        if (!this.showInAdControlBar) {
          _.delay(_.bind(function(){ this.mb.publish(OO.EVENTS.ENABLE_PLAYBACK_CONTROLS); }, this), 100);
        }
        this.imaAdsManagerActive = false;

        this.mb.publish(OO.EVENTS.ADS_MANAGER_FINISHED_ADS);
        this.mainVideo.on("ended", this.contentEndedHandler);
        this.mb.publish(OO.EVENTS.ADS_PLAYED);
        this._setCustomPlayheadTracker();
        this.mb.publish(OO.EVENTS.BUFFERED);
      },

      resume: function(e) {
        if (this.linearAdStarted && this.adsManager) {
          this.adsManager.resume();
          // adPauseCalled assignment should not needed if google SDK publishes RESUMED event
          this.adPauseCalled = false;
          this.mb.publish(OO.EVENTS.PLAYING);
        }
      },

      onAdClick: function(adEvent) {
        if (!this.linearAdStarted) {
          return;
        } else if (this.adPauseCalled) {
          this.resume();
        } else if (this.platformExtensions.onMobileAdClick) {
          // Mobile should always PAUSE ads upon clickthrough, when ads is playing
          this.platformExtensions.onMobileAdClick();
        } else if (!this.playWhenAdClick) {
          // Desktop depends on playWhenAdClick param
          this.onPause();
        }
        this.mb.publish(OO.EVENTS.ADS_CLICKED);
      },

      _dispatchWillPlayAdEvent: function() {
        // TODO: fill in other metadata useful for ooyala reporter.js
        var adItem = { type: "GOOGLE_IMA" };
        this.mb.publish(OO.EVENTS.WILL_PLAY_ADS, adItem);
        this.mb.publish(OO.EVENTS.GOOGLE_IMA_CAN_SEEK);
      },

      onAdEvent: function(adEvent) {
        // Retrieve the ad from the event. Some events (e.g. ALL_ADS_COMPLETED)
        // don't have ad object associated.
        var ad = adEvent.getAd();
        switch (adEvent.type) {
          case W.google.ima.AdEvent.Type.LOADED:
            // This is the first event sent for an ad - it is possible to
            // determine whether the ad is a video ad or an overlay.
            if (this.platformExtensions.preOnAdEventLoaded) { this.platformExtensions.preOnAdEventLoaded(); }
            this.isLinearAd = ad.isLinear();
            this._updateAdsManagerSize();
            break;
          case W.google.ima.AdEvent.Type.STARTED:
            // This event signalizes the ad has started - the video player
            // can adjust the UI, for example display a pause button and
            // remaining time.
            if (ad.isLinear()) {
              this.linearAdStarted = true;
              // For a linear ad, a timer can be started to poll for the remaining time.
              // Only publishes PlayheadTime event if it is NOT using <video> element, i.e. desktop
              // <video> element playhead is controlled by playback.js
              if (!this.adsManager.isCustomPlaybackUsed()) {
                this.playheadUpdateTimer = setInterval(
                    _.bind(function() {
                      var remainingTime = (this.adsManager && this.adsManager.getRemainingTime() > 0) ?
                        this.adsManager.getRemainingTime() : 0;
                      var adsDuration = (ad && ad.getDuration() > 0) ? ad.getDuration() : 0;
                      this.mb.publish(OO.EVENTS.PLAYHEAD_TIME_CHANGED,
                        Math.max(adsDuration - remainingTime, 0), adsDuration, 0);
                    }, this),
                    PLAYHEAD_UPDATE_INTERVAL); // every 200ms
              }
              this.mb.publish(OO.EVENTS.BUFFERED);
            }
            break;
          case W.google.ima.AdEvent.Type.PAUSED:
            this.adPauseCalled = true;
            this.mb.publish(OO.EVENTS.WILL_PAUSE_ADS);
            break;
          case W.google.ima.AdEvent.Type.RESUMED:
            this.adPauseCalled = false;
            break;
          case W.google.ima.AdEvent.Type.SKIPPED:
          case W.google.ima.AdEvent.Type.COMPLETE:
            // This event signalizes the ad has finished - the video player
            // can do appropriate UI actions, like removing the timer for
            // remaining time detection.
            if (ad.isLinear()) {
              this.linearAdStarted = false;
              clearInterval(this.playheadUpdateTimer);
              this.playheadUpdateTimer = null;
              this.adPauseCalled = false;
            }
            this.onAdMetrics(adEvent);

            // (agunawan): Google SDK is not publishing CONTENT_RESUME with livestream!!! !@#!@#!@#@!#@
            if (this.isLivePlaying) {
              // You should know by know why I did this. Yep iOS8.
              _.delay(_.bind(function() { this.onContentResumeRequested(); }, this), 100);
            }
            if (this.platformExtensions.onAdEventComplete) { this.platformExtensions.onAdEventComplete(adEvent); }
            break;
          case W.google.ima.AdEvent.Type.ALL_ADS_COMPLETED:
            OO.log("all google ima ads completed!");
            if (this.platformExtensions.preOnAdEventAllAdsCompleted) { this.platformExtensions.preOnAdEventAllAdsCompleted(); }
            // ADS_PLAYED must be published first before GOOGLE_IMA_ALL_ADS_DONE (PLAYED)
            // for discovery toaster to show after postroll
            this.mb.publish(OO.EVENTS.ADS_PLAYED);
            this.mb.publish(OO.EVENTS.GOOGLE_IMA_ALL_ADS_DONE);
            break;
          case W.google.ima.AdEvent.Type.FIRST_QUARTILE:
          case W.google.ima.AdEvent.Type.MIDPOINT:
          case W.google.ima.AdEvent.Type.THIRD_QUARTILE:
            this.onAdMetrics(adEvent);
            break;
          default:
            OO.log("other ima event:", adEvent);
            break;
        }
      },

      onAdMetrics: function(adEvent) {
        OO.log("Google IMA Ad playthrough", adEvent.type);
      },

      onInitialPlay: function() {
        if (this.platformExtensions.overrideOnInitialPlay) {
          this.platformExtensions.overrideOnInitialPlay();
          return;
        }
        if(OO.isAndroid && OO.isChrome) {
          this.mb.publish(OO.EVENTS.RELOAD_STREAM);
        }
        if (OO.supportMultiVideo) { this.rootElement.find('div.oo_tap_panel').css('display', ''); }
        this.adDisplayContainer.initialize();
        if (!OO.supportMultiVideo) {
          this.mainVideo[0].load();
        }
        if (this.adsManager) {
          try {
            this.mb.publish(OO.EVENTS.BUFFERING);
            //ad rules will start from this call
            var w = this.rootElement.width();
            var h = this.rootElement.height();
            this.adsManager.init(w, h, W.google.ima.ViewMode.NORMAL);

            //single ads will start here
            this.adsManager.start();
          } catch(adError) {
            this.onImaAdError(adError);
          }
        }
      },

      onFullscreenChanged: function(event, shouldEnterFullscreen) {
        if (!OO.supportMultiVideo) { return; }
        this.isFullscreen = shouldEnterFullscreen;
        this._updateAdsManagerSize();
      },

      _updateAdsManagerSize: function() {
        if (this.adsManager) {
          if (this.isLinearAd) {
            // For linear ad, set the size to the full video player size.
            this.adsManager.resize(this.rootElement.width(), this.rootElement.height(),
                this.isFullscreen ? W.google.ima.ViewMode.FULLSCREEN : W.google.ima.ViewMode.NORMAL);
          } else {
            // For nonlinear ads, the ad slot can be adjusted at this time.
            // In this example, we make the ad to be shown at the bottom
            // of the slot. We also make the slot a bit shorter, so there is
            // a padding at the bottom.
            this.adsManager.resize(this.rootElement.width(), this.rootElement.height() - 40,
                W.google.ima.ViewMode.NORMAL);
            this.adsManager.align(
                W.google.ima.AdSlotAlignment.HorizontalAlignment.CENTER,
                W.google.ima.AdSlotAlignment.VerticalAlignment.BOTTOM);
          }
        }
      },

      // This method handles post roll
      onContentEnded: function() {
        this.contentEnded = true;
        if (this.adsLoader) { this.adsLoader.contentComplete(); }
      },

      onWillPlayFromBeginning: function() {
        this.contentEnded = false;
      },

      // (agunawan): This is a container to be called on constructor. Do not call this unless you know what you are doing.
      _customPlayheadUpdate: function() { this.customPlayheadTracker.currentTime = this.mainVideo[0].currentTime; },

      // Please use this and only this method to instantialize the playheadTracker interval
      _setCustomPlayheadTracker: function() {
        // (agunawan) absolutely only a single customTracker must be instantialized
        if (!this.customPlayheadTracker.updateInterval) {
          this.customPlayheadTracker.updateInterval = setInterval(this.customPlayheadIntervalFunction, 1000);
        }
      },

      // Please use this and only this method to delete the playheadTracker interval
      _deleteCustomPlayheadTracker: function() {
        clearInterval(this.customPlayheadTracker.updateInterval);
        delete this.customPlayheadTracker.updateInterval;
      },

      onScrubbing: function() {
        this._deleteCustomPlayheadTracker();
      },

      onScrubbed: function() {
        this._setCustomPlayheadTracker();
      },

      onSizeChanged: function() {
        this._updateAdsManagerSize();
      },

      preparePlatformExtensions: function() {
        if (OO.isAndroid && OO.isChrome) {
          this.platformExtensions = new (function(imaModule) {
            this.imaModule = imaModule;
          })(this);
          _.extend(this.platformExtensions, {
            preConstructor: function(messageBus, id) {
              this.imaModule.loadedMetadataFired = false;
              this.imaModule.adsLoaderReady = false;
              this.imaModule.firstClick = true;
              this.imaModule.initialPlayCalled = false;
              this.imaModule.initCalled = false;
              this.imaModule.unBlockAndroidPlayback = null;
            },
            overrideOnSdkLoaded: function() {
              clearInterval(this.imaModule.unblockPlaybackTimeout);
              W.googleImaSdkLoaded = true;
            },
            preOnSetEmbedCode: function(event, embedCode) {
              this.imaModule.loadedMetadataFired = false;
              this.imaModule.unBlockAndroidPlayback = null;
              this.imaModule.initCalled = false;
              this.imaModule.adsLoaderReady = false;
              this.imaModule.initialPlayCalled = false;
            },
            overrideOnVideoMetaLoaded: function(event) {
              if (this.imaModule.imaAdsManagerActive) { return; }
              this.imaModule.loadedMetadataFired = true;
              this.imaModule.customPlayheadTracker.duration = this.imaModule.mainVideo[0].duration;
              this.imaModule._setCustomPlayheadTracker();
              this.imaModule.platformExtensions.androidImaInit();
            },
            overrideOnMetadataFetched: function(event, response){
              OO.log("Metadata Ready:", response, this.imaModuleadTagUrl, this.imaModule.adTagUrlFromEmbedHash);
              this.imaModule.adTagUrl = this.imaModule.adTagUrlFromEmbedHash;

              var responseChecker =
                  (response &&
                  response['modules'] &&
                  response['modules'][IMA_MODULE_TYPE] &&
                  response['modules'][IMA_MODULE_TYPE]['metadata']);

              if (!this.imaModule.adTagUrl) {
                // set adTagUrl if it is not set yet.
                if (responseChecker) {
                  var meta = response['modules'][IMA_MODULE_TYPE]['metadata'];
                  this.imaModule.adTagUrl = meta.adTagUrl || meta.tagUrl;
                  if (this.imaModule.rootElement && this.imaModule.adTagUrl) { this.imaModule._addDependentEvent(); }
                }
                this.imaModule._unBlockPlaybackReady();
              }

              // checks whether the page level has already overridden
              // if not, it will publish the metadata's showAdMarquee parameter
              if (!this.imaModule.marqueePageOverride) {
                if (responseChecker) {
                  var meta = response['modules'][IMA_MODULE_TYPE]['metadata'];
                  if (meta.showAdMarquee) {
                    this.imaModule.mb.publish(OO.EVENTS.SHOW_AD_MARQUEE, convertToBoolean(meta.showAdMarquee));
                  }
                }
              }

              //playWhenAdClick will be null if not set on page-level
              if (this.imaModule.playWhenAdClick === null) {
                if (responseChecker) {
                  var meta = response['modules'][IMA_MODULE_TYPE]['metadata'];
                  this.imaModule.playWhenAdClick = meta.playWhenAdClick;
                }
              }

              if (!this.imaModule.maxAdsRequestTimeoutPageOverride && responseChecker) {
                if (typeof response['modules'][IMA_MODULE_TYPE]['metadata'].adRequestTimeout !== 'undefined') {
                  var timeOut = parseInt(response['modules'][IMA_MODULE_TYPE]['metadata'].adRequestTimeout);
                  if (!_.isNaN(timeOut)) {
                    this.imaModule.maxAdsRequestTimeout = timeOut;
                  }
                }
              }
              this.imaModule._unBlockPlaybackReady();
              this.imaModule.mb.publish(OO.EVENTS.GOOGLE_IMA_CAN_SEEK);
              this.imaModule.mb.publish(OO.EVENTS.GOOGLE_IMA_CAN_PLAY);
            },
            postOnAdsManagerLoaded: function(event) {
              this.imaModule.adsLoaderReady = true;
              this.imaModule.platformExtensions.androidImaInit();
            },
            preOnContentResumeRequested: function() {
              //Protecting on Android from Resume Content getting called twice.
              this.imaModule.contentResumeAlreadyCalled = true;
            },
            preOnContentPauseRequested: function() {
              //reset flag to false if content paused.
              this.imaModule.contentResumeAlreadyCalled = false;
            },
            onMobileAdClick: function(event) {
              this.imaModule.onPause();
            },
            preOnAdEventLoaded: function() {
              if (this.imaModule.unBlockAndroidPlayback) { clearTimeout(this.imaModule.unBlockAndroidPlayback); }
            },
            overrideOnInitialPlay: function() {
              this.imaModule.initialPlayCalled = true;

              this.imaModule.adDisplayContainer = new W.google.ima.AdDisplayContainer(this.imaModule.rootElement.find("div.plugins")[0],
                this.imaModule.rootElement.find("video.video")[0]);
              this.imaModule.adsLoader = new W.google.ima.AdsLoader(this.imaModule.adDisplayContainer);

              this.imaModule.adsLoader.addEventListener(
                W.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
                _.bind(this.imaModule.onAdsManagerLoaded, this.imaModule),
                false);
              this.imaModule.adsLoader.addEventListener(
                W.google.ima.AdErrorEvent.Type.AD_ERROR,
                _.bind(this.imaModule.onImaAdError, this.imaModule),
                false);

              this.imaModule._setupAdsRequest();
              if(OO.isAndroid && OO.isChrome) {
                this.imaModule.mb.publish(OO.EVENTS.RELOAD_STREAM);
              }
              if (OO.supportMultiVideo) { this.imaModule.rootElement.find('div.oo_tap_panel').css('display', ''); }
              this.imaModule.adDisplayContainer.initialize();
              if (!OO.supportMultiVideo) {
                this.imaModule.mainVideo[0].load();
              }
              if (this.imaModule.adsManager) {
                try {
                  this.imaModule.platformExtensions.androidImaInit();
                } catch(adError) {
                  this.imaModule.onImaAdError(adError);
                }
              }
              if (this.imaModule.adTagUrl != null) {
                // Gate BUFFERED event when there is a valid adTagURL. Unlocked by imaError or successful ad request
                this.imaModule.mb.addDependent(OO.EVENTS.BUFFERED, OO.EVENTS.GOOGLE_IMA_REMOVE_BUFFERING, "googleIma", function(){});
              }
              this.imaModule.mb.publish(OO.EVENTS.BUFFERING);
            },
            onAdEventComplete: function(adEvent) {
              //PBW-1691: IMA SDK isn't calling content resume after post-roll so we
              //don't get the chance to re-enable controls. So detect if we just completed
              //the final ad in a post-roll pod and fire content resume.
              var adPodInfo = adEvent.getAd().getAdPodInfo();
              if ( adPodInfo.getAdPosition() == adPodInfo.getTotalAds()) {
                this.imaModule.contentResumeRequest = _.delay(_.bind(function() {
                    this.imaModule.onContentResumeRequested();
                  }, this), 500);
              }
            },
            androidImaInit: function() {
              if (this.imaModule.adsLoaderReady && this.imaModule.loadedMetadataFired &&
                  this.imaModule.initialPlayCalled && !this.imaModule.initCalled) {
                this.imaModule.initCalled = true;
                //ad rules will start from this call
                var w = this.imaModule.rootElement.width();
                var h = this.imaModule.rootElement.height();
                this.imaModule.adsManager.init(w, h, W.google.ima.ViewMode.NORMAL);
                //single ads will start here
                this.imaModule.adsManager.start();

                // IMA SDK is not correctly publishing contentResumeRequested.
                // (dustin) stealing agunawan's hack for iOS.
                var _this = this;
                this.imaModule.unBlockAndroidPlayback = _.delay(function() {
                  _this.imaModule.disptachContentResume();
                  _this.imaModule.mb.publish(OO.EVENTS.BUFFERED);
                }, DEFAULT_ADS_REQUEST_TIME_OUT);
              }
            }
          });
        }
        // Android 2.3.X tweaks
        else if (OO.isAndroid && !OO.isChrome) {
          this.platformExtensions = new (function(imaModule) {
            this.imaModule = imaModule;
          })(this);
          _.extend(this.platformExtensions, {
            postOnPlayerCreated: function() {
              // 2.3.X seems to need more than 3 seconds to finish a request,
              // so give it double the time
              this.imaModule.maxAdsRequestTimeout = 6000;
            },
            preOnAdEventAllAdsCompleted: function(adEvent) {
              // force the player to play after the preroll finishes,
              // IMA SDK isn't firing content resume events.
              _.delay(_.bind(function() {
                  this.imaModule.onContentResumeRequested();
                }, this), 500);
            }
          });
        }
        else if (OO.isIos) {
           this.platformExtensions = new (function(imaModule) {
            this.imaModule = imaModule;
          })(this);
          _.extend(this.platformExtensions, {
            preConstructor: function(messageBus, id) {
              this.imaModule.loadedMetadataFired = false;
              this.imaModule.adsLoaderReady = false;
              this.imaModule.initialPlayCalled = false;
              this.imaModule.initCalled = false;
              this.imaModule.canSetupAdsRequest = false;
              this.imaModule.unBlockIOSPlayback = null;
            },
            overrideOnSdkLoaded: function() {
              // As per google guideline: prevent adDisplayContainer and adsRequest without user action (tap)
              if (this.imaModule.unblockPlaybackTimeout) {
                clearTimeout(this.imaModule.unblockPlaybackTimeout);
              }
            },
            preOnSetEmbedCode: function(event, embedCode) {
              this.imaModule.loadedMetadataFired = false;
              this.imaModule.adsLoaderReady = false;
              this.imaModule.initialPlayCalled = false;
              this.imaModule.initCalled = false;
              this.imaModule.canSetupAdsRequest = false;
              this.imaModule.unBlockIOSPlayback = null;
              // IMA SDK is not correctly publishing contentResumeRequested after postroll.
              // Manually set ended listener for the next setEmbedCode
              this.imaModule.mainVideo.on("ended", this.imaModule.contentEndedHandler);
            },
            postOnMetadataFetched: function() {
              // Unblock PLAYBACK_READY and INITIAL_PLAY onMetadataFetched, otherwise player will not be able to play
              this.imaModule._unBlockPlaybackReady();
              this.imaModule.mb.publish(OO.EVENTS.GOOGLE_IMA_CAN_PLAY);
            },
            overrideOnVideoMetaLoaded: function(event) {
              if (this.imaModule.imaAdsManagerActive) { return; }
              this.imaModule.loadedMetadataFired = true;
              this.imaModule.customPlayheadTracker.duration = this.imaModule.mainVideo[0].duration;
              this.imaModule._setCustomPlayheadTracker();
              this.imaModule.platformExtensions.iosImaInit();
            },
            postOnAdsManagerLoaded: function(event) {
              this.imaModule.adsLoaderReady = true;
              this.imaModule.platformExtensions.iosImaInit();
            },
            onMobileAdClick: function(event) {
              this.imaModule.onPause();
            },
            // IMA SDK is not correctly publishing contentResumeRequested. Clear out iOS hack set on iosImaInit.
            preOnAdEventLoaded: function() {
              if (this.imaModule.unBlockIOSPlayback) { clearTimeout(this.imaModule.unBlockIOSPlayback); }
            },
            // IMA SDK is not correctly publishing contentResumeRequested. Prevent playback_control to still think ads is still playing
            preOnAdEventAllAdsCompleted: function() {
              if (OO.isIpad) {
                this.imaModule.rootElement.find('div.plugins').css('display', 'none');
              }
              this.imaModule.mb.publish(OO.EVENTS.ENABLE_PLAYBACK_CONTROLS);
              this.imaModule.mb.publish(OO.EVENTS.ADS_MANAGER_FINISHED_ADS);
            },
            preOnContentPauseRequested: function() {
              // PBW-1910: Google IMA recommended to enable plugins div to show skippable button on iPad
              if (OO.isIpad) {
                this.imaModule.rootElement.find('div.plugins').css('display', 'block');
              }
            },
            preOnContentResumeRequested: function() {
              if (OO.isIpad) {
                this.imaModule.rootElement.find('div.plugins').css('display', 'none');
              }
            },
            // User Click will always get registered as INITIAL_PLAY on iOS. IMA module (or ads manager in future) have to PUBLISH
            // PLAY event if it is already playedOnce. Reset playedOnce on complete / setEmbedCode
            overrideOnInitialPlay: function() {
              if (this.imaModule.initialPlayCalled) {
                this.imaModule.mb.publish(OO.EVENTS.PLAY);
                return;
              }

              this.imaModule.initialPlayCalled = true;
              W.googleImaSdkLoaded = true;

              // PBW-1910: Google IMA recommended to remove custom click through out of iOS.
              this.imaModule.adDisplayContainer = new W.google.ima.AdDisplayContainer(
                this.imaModule.rootElement.find("div.plugins")[0],
                this.imaModule.rootElement.find("video.video")[0]
              );
              this.imaModule.adsLoader = new W.google.ima.AdsLoader(this.imaModule.adDisplayContainer);

              this.imaModule.adsLoader.addEventListener(
                W.google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
                _.bind(this.imaModule.onAdsManagerLoaded, this.imaModule),
                false);
              this.imaModule.adsLoader.addEventListener(
                W.google.ima.AdErrorEvent.Type.AD_ERROR,
                _.bind(this.imaModule.onImaAdError, this.imaModule),
                false);

              this.imaModule.canSetupAdsRequest = true;
              this.imaModule._setupAdsRequest();

              if (OO.supportMultiVideo) { this.imaModule.rootElement.find('div.oo_tap_panel').css('display', ''); }
              this.imaModule.adDisplayContainer.initialize();
              if (!OO.supportMultiVideo) {
                this.imaModule.mainVideo[0].load();
              }

              this.imaModule.mb.publish(OO.EVENTS.BUFFERING);
              if (this.imaModule.adTagUrl != null) {
                // Gate BUFFERED event when there is a valid adTagURL. Unlocked by imaError or successful ad request
                this.imaModule.mb.addDependent(OO.EVENTS.BUFFERED, OO.EVENTS.GOOGLE_IMA_REMOVE_BUFFERING, "googleIma", function(){});
              }
              this.imaModule.platformExtensions.iosImaInit();
            },
            iosImaInit: function() {
              if (this.imaModule.adsLoaderReady && this.imaModule.loadedMetadataFired && this.imaModule.adsManager &&
                  this.imaModule.initialPlayCalled && !this.imaModule.initCalled) {
                this.imaModule.initCalled = true;
                //ad rules will start from this call
                var w = this.imaModule.rootElement.width();
                var h = this.imaModule.rootElement.height();
                this.imaModule.adsManager.init(w, h, W.google.ima.ViewMode.NORMAL);
                //single ads will start here
                this.imaModule.adsManager.start();

                // IMA SDK is not correctly publishing contentResumeRequested.
                // (agunawan) This is a hack. Google claims SDK always triggers contentResume event.
                // However I dont see it on iOS on these: solo midroll adSlot and skippable ads on iphone
                var _this = this;
                this.imaModule.unBlockIOSPlayback = _.delay(function() {
                  _this.imaModule.disptachContentResume();
                  _this.imaModule.mb.publish(OO.EVENTS.BUFFERED);
                }, DEFAULT_ADS_REQUEST_TIME_OUT);
              }
            }
          });
        }
        else {
          this.platformExtensions = {};
        }
      },

      __placeholder: true
    });

    // Return class definition.
    return GoogleIma;
  });
OO.plugin("OmniturePlugin", function(OO, _, $, W) {
  var OMNITURE = "omniture";

  var Omniture = OO.inherit(OO.AnalyticsBase, function(messageBus, id) {
    if (!OO.requiredInEnvironment('html5-playback') && !OO.requiredInEnvironment('cast-playback')) {return;}

    this.mb = messageBus;

    this.setup(this.mb, id, OMNITURE);
    this.currentEmbedcode = '';
    this.playingInstreamAd = false;

    this.mb.subscribe(OO.EVENTS.METADATA_FETCHED, OMNITURE, _.bind(this._metadataLoaded, this));
  });

  _.extend(Omniture.prototype, {
    _metadataLoaded: function(event, metadata) {
      if(!!this.metadata) { return; }  //don't load metadata twice

      this.metadata = {};
      if (metadata && metadata.modules) {
        this.module = metadata.modules['omniture-15upgrade-other'] || {};
        this.omnitureRoot = (this.module && this.module.metadata && this.module.metadata.omniture_root) || 's';
        this.s_code_url = this.module && this.module.metadata && this.module.metadata.s_code_url;
        if(_.isString(this.s_code_url)) {
          this.loadExternalAnalyticsJs(this.module.metadata.s_code_url);
        }
      }
      //this.loadExternalAnalyticsJs('http://dl.dropbox.com/u/25894664/s_code.espn2.js');  // testing only
    },

    loadSucceed: function() {
      // create omniture reference
      this.omniRoot = W[this.omnitureRoot];
      this.omni = this.omniRoot.Media;
    },

    reportEvent: function(eventName, arg1, arg2) {
      if (!this.omni) { return; }
      switch (eventName) {
        case OO.EVENTS.PLAYER_CREATED:
          // load omniture overrides
          this.playerId = (arg2 && arg2.omniture && arg2.omniture.trackingName) || arg1;
          this.account = (arg2 && arg2.omniture && arg2.omniture.account) || "";
          this.omniRoot.account = (_.isString(this.omniRoot.account) ?  this.omniRoot.account : '') + this.account;

          this.localSite = (arg2 && arg2.omniture && arg2.omniture.localSite) || "";
          this.omniRoot.prop15 = this.localSite + (_.isString(this.omniRoot.prop15) ?  this.omniRoot.prop15 : '');

          this.swid = (arg2 && arg2.omniture && arg2.omniture.SWID) || "";
          this.omniRoot.prop2 = this.swid;

          this.playType = (arg2 && arg2.omniture && arg2.omniture.playType) || "";
          this.omniRoot.eVar16 = this.playType;

          OO.log('omni:root, omni:playerId, omni:account, omni:prop15, omni:prop2 omni:eVar16',
            this.omnitureRoot, this.playerId, this.omniRoot.account,
            this.omniRoot.prop15, this.omniRoot.prop2, this.omniRoot.eVar16);
          break;

        case OO.EVENTS.EMBED_CODE_CHANGED:
          this.swid = (arg2 && arg2.omniture && arg2.omniture.SWID) || this.swid;
          this.omniRoot.prop2 = this.swid;

          this.playType = (arg2 && arg2.omniture && arg2.omniture.playType) || this.playType;
          this.omniRoot.eVar16 = this.playType;

          OO.log('omni:embed_code_changed, omni:prop2 omni:eVar16',
            this.omniRoot.prop2, this.omniRoot.eVar16);
          break;

        case OO.EVENTS.CONTENT_TREE_FETCHED :
          this.mediaDuration = arg1.duration / 1000;
          this.mediaTitle = arg1.title;
          OO.log('omni:fetch', this.mediaTitle, this.mediaDuration);
          break;
        case OO.EVENTS.PLAYBACK_READY :
          this.lastPlayhead = 0;
          this.playingMovie = null;
          this.omni.open(this.mediaTitle, this.mediaDuration, this.playerId);
          OO.log('omni:open',this.mediaTitle, this.mediaDuration, this.playerId);
          break;
        case OO.EVENTS.PLAYHEAD_TIME_CHANGED :
          if(this.playingMovie) {
            this.lastPlayhead = parseInt(arg1,10);
          }
          break;
        case OO.EVENTS.PLAY_STREAM :
          var isMovie = arg2.type == 'movie';
          var stream = arg1;
          if(isMovie) {
            this.playingMovie = arg1;
            this.omni.play(this.mediaTitle, this.lastPlayhead);
            OO.log('omni:play',this.mediaTitle, this.lastPlayhead);
          } else {
            this.playingMovie = null;
          }
          break;
        case OO.EVENTS.STREAM_PAUSED:
          if(this.playingMovie) {
            this.omni.stop(this.mediaTitle, this.lastPlayhead);
            OO.log('omni:stop',this.mediaTitle, this.lastPlayhead);
          }
          break;
        case OO.EVENTS.STREAM_PLAY_FAILED:
          if(this.playingMovie) {
            this.omni.stop(this.mediaTitle, this.lastPlayhead);
            OO.log('omni:stop',this.mediaTitle, this.lastPlayhead);
            this.omni.close(this.mediaTitle);
            OO.log('omni:close',this.mediaTitle);
          }
          break;
        case OO.EVENTS.STREAM_PLAYED:
          if(this.playingMovie) {
            this.omni.stop(this.mediaTitle, this.mediaDuration);
            OO.log('omni:stop',this.mediaTitle, this.lastPlayhead);
            this.omni.close(this.mediaTitle);
            OO.log('omni:close',this.mediaTitle);
          }
          break;
        case OO.EVENTS.SEEK_STREAM:
          if(this.playingMovie) {
            this.omni.stop(this.mediaTitle, this.lastPlayhead);
            OO.log('omni:stop',this.mediaTitle, this.lastPlayhead);
            this.omni.play(this.mediaTitle, this.lastPlayhead + parseInt(arg1,10));
            OO.log('omni:play',this.mediaTitle, this.lastPlayhead + parseInt(arg1,10));
          }
          break;
      }

    },

    __place_holder: true
  });

  return Omniture;
});
  (function(OO, $, _){
     OO.Spinner = function(messageBus, div, parent) {
      this.size = 50; // size of image
      this.mb = messageBus;
      if (!div || !div[0]) { return; }
      this.div = div;
      this.parent = parent;
      this.centerInParent();

      this.div.append('<img class="oo_spinner_img"></img>');
      this.img = this.div.find('.oo_spinner_img');
      this.img.css({ width: this.size, height: this.size });
      this.img.attr({ src: OO.get_img_base64('oo_spinner') });

      OO.StateMachine.create({
        initial:'Init',
        messageBus:this.mb,
        moduleName:'Spinner',
        target:this,
        events:[
          {name:OO.EVENTS.SIZE_CHANGED,               from:'*'}
        ]
      });

    };

    _.extend(OO.Spinner.prototype, {
      onSizeChanged: function(event) {
        this.centerInParent();
      },

      centerInParent: function() {
        var x = (this.parent.width() - this.size) / 2;
        var y = (this.parent.height() - this.size) / 2;
        this.div.css({marginTop:y + 'px', marginLeft: x + 'px'});
      },

      play: function() {
        this.div.show();
      },

      pause: function() {
        this.div.hide();
      }
    });
  }(OO, OO.$, OO._));(function(OO, $, _){
  /*
   *  Defines android-specific UI
   */
  var AndroidUi = function(messageBus, id) {
    // short circuit here if the page does not need android ui
    if (!OO.requiredInEnvironment('android-ui')) { return; }

    this.Id = id;
    this.mb = messageBus;

    OO.StateMachine.create({
      initial:'Init',
      messageBus:this.mb,
      moduleName:'AndroidUi',
      target:this,
      events:[
        {name:OO.EVENTS.PLAYER_CREATED,                           from:'Init',                                       to:'PlayerCreated'},
        {name:OO.EVENTS.CONTENT_TREE_FETCHED,                     from:'*',                                          to:'PromoReady'},
        {name:OO.EVENTS.PLAYBACK_READY,                           from:'PromoReady',                                 to:'PlaybackReady'},
        {name:OO.EVENTS.INITIAL_PLAY,                             from:"*"},
        {name:OO.EVENTS.SIZE_CHANGED,                             from:'*'}
      ]
    });
  };

  _.extend(AndroidUi.prototype, {
    onPlayerCreated: function(event, elementId, params) {
      this.elementId = elementId;
      this.rootElement = $('#'+this.elementId + " > div");
      this.params = params;
      this.accentColor = params.accentColor || 0x5D8ADD;

      // load the css
      OO.attachStyle(_.template(OO.get_css("basic_ui"))({
        elementId : this.elementId,
        liveIcon : OO.get_img_base64('icon_live'),
        rewindIcon : OO.get_img_base64('icon_rewind'),
        playIcon : OO.get_img_base64('icon_play'),
        pauseIcon : OO.get_img_base64('icon_pause'),
        errorIcon : OO.get_img_base64('icon_error'),
        playheadIcon : OO.get_img_base64('icon_playhead'),
        fullscreenOnIcon : OO.get_img_base64('icon_full_off'),
        fullscreenOffIcon : OO.get_img_base64('icon_full_on')
      }));


      // display the promo ui
      this.rootElement.append("<div class='plugins' style='display:none'></div>");
      this.rootElement.append('<div class="oo_promo"></div>');
      this.promoUi = new _PromoUi(this.rootElement.find('div.oo_promo'));
    },

    onContentTreeFetched: function(event, contentTree) {
      this.contentTree = contentTree;
      this.promoUi.setBackground(this.contentTree.promo_image || this.contentTree.thumbnail_image);
    },

    onPlaybackReady: function(event, playbackPackage) {
      var title = this.contentTree.title;

      // allow playback
      this.rootElement.find('div.oo_promo').bind('click', _.bind(this._promoClick, this));
      this.promoUi.allowPlayback();
    },

    onInitialPlay: function() {
      this.mb.publish(OO.EVENTS.PLAY);
    },

    _promoClick: function() {
      this.mb.publish(OO.EVENTS.INITIAL_PLAY);
    },

    __placeholder: true
  });

  var _PromoUi = function(promo) {
    this.promo = promo;
    this.init();
  };

  _.extend(_PromoUi.prototype, {
    init: function() {
      this.promo.append("<div class='oo_start_button'><img class='oo_start_spinner'></div>");
      var button = this.promo.find("img.oo_start_spinner");
      button.attr({ src: OO.get_img_base64('icon_spinner') });
    },

    setBackground: function(url) {
      this.promo.css('background-image','url('+url+')');
    },

    allowPlayback: function() {
      this.promo.find("div.oo_start_button").html('');
      this.promo.find("div.oo_start_button").css({'background-image': 'url('+OO.get_img_base64('icon_play')+')' });
    }

  });

  var _ErrorUi = function(container) {
    this.container = container;
    this.container.append('<div class="oo_error_image"></div>');
    this.container.append('<div class="oo_error_message"></div>');
  };

  _.extend(_ErrorUi.prototype, {
    show: function(error) {
      this.container.find('div.oo_error_message').html(OO.getLocalizedMessage(error));
      this.container.show();
    },
    hide: function() {
      this.container.hide();
    }
  });

  OO.registerModule('android_ui', function(messageBus, id) {
    return new AndroidUi(messageBus, id);
  });
}(OO, OO.$, OO._));
  (function(OO, _, $){
    /*
     *  AdsManager will manage the Ads config load and notify playback controller when they are ready.
     *  It will intercept willFetchAds event, and send adFetched event to notify playbck to continue.
     *  PlaybackController will timeout if willFetchAds does not return in OO.playerParams.maxAdsTimeout
     *  seconds.
     */
    var AdsManager = function(messageBus, id) {
      if (!OO.requiredInEnvironment('ads')) {return;}
      this.Id = id;
      this.mb = messageBus;
      this.vastPassThroughAdTagUrl = null; // Will allow run time override

      this.currentEmbedCode = null;
      this.firstAdsIsOoyala = false;
      this.adsItem = null;
      this.adsClickThrough = false;

      this.adIds = [];
      this.adPlayCounts = {};
      this.ignoreClickThrough = false;

      OO.StateMachine.create({
        initial:'Init',
        messageBus:this.mb,
        moduleName:'adsManager',
        target:this,
        events:[
          {name:OO.EVENTS.PLAYER_CREATED,                     from:'*',                                       to:'*'},
          {name:OO.EVENTS.EMBED_CODE_CHANGED,                 from:'*',                       to:'Init'},
          {name:OO.EVENTS.CONTENT_TREE_FETCHED,               from:'Init',                                       to:'WaitingForFirstAdRequest'},
          {name:OO.EVENTS.PLAYING,                            from:'WaitingForFirstAdRequest',                             to:'readyToFetchOtherAds'},
          {name:OO.EVENTS.WILL_PLAY_ADS,                      from:'*',                       to:'*'},
          {name:OO.EVENTS.PLAY_MIDROLL_STREAM,                from:'*',                       to:'*'},
          {name:OO.EVENTS.ADS_PLAYED,                         from:'*',                       to:'*'},
          {name:OO.EVENTS.LOAD_ALL_VAST_ADS,                  from:'*',                       to:'*'},
          {name:OO.EVENTS.PLAYER_CLICKED,                     from:'*',                       to:'*'},
          {name:OO.EVENTS.PLAY,                               from:'*',                       to:'*'}
        ]
      });
      // intercept WILL_FETCH_ADS here.
      this.mb.addDependent(OO.EVENTS.WILL_FETCH_ADS, OO.EVENTS.FIRST_AD_FETCHED, "adsManager", function() {});
    };

    _.extend(AdsManager.prototype, {
      onPlayerCreated: function(event, elementId, params) {
        if (params.vast && params.vast.tagUrl) {
          this.vastPassThroughAdTagUrl = params.vast.tagUrl;
        }
        this.ignoreClickThrough = !!params.ignoreClickThrough;
      },

      onWillPlayAds: function(event, adItem) {
        this.adsItem = adItem;
      },

      onPlayMidrollStream: function(event, streamUrl, adItem) {
        this.adsItem = adItem.item;
      },

      onAdsPlayed: function(event) {
        this.adsItem = null;
      },

      openUrl: function(url) {
        if (!url) { return; }
        window.open(url);
      },

      onPlayerClicked: function(event) {
        if (!this.adsItem || this.ignoreClickThrough) { return; }
        if (this.adsClickThrough) {
          this.adsClickThrough = false;
          this.mb.publish(OO.EVENTS.PLAY);
        } else {
          // Get VAST click throuhg.
          var clickThroughUrl = this.adsItem.data && this.adsItem.data.ClickThrough;
          var linearClickUrl = this.adsItem.data && this.adsItem.data.linear && this.adsItem.data.linear.ClickThrough;
          var ooyalaClickUrl = this.adsItem.click_url;

          if (clickThroughUrl || ooyalaClickUrl || linearClickUrl) {
            this.adsClickThrough = true;
            this.mb.publish(OO.EVENTS.ADS_CLICKED);
            this.openUrl(clickThroughUrl);
            this.openUrl(ooyalaClickUrl);
            this.openUrl(linearClickUrl);
            this.mb.publish(OO.EVENTS.PAUSE);
          }
        }
      },

      onLoadAllVastAds: function(event) {
        _.each(this.ads, function(ad, index){
          if (ad.type == "vast" && !ad.loader) {
            this._setVastAdLoader(ad);
          }
        }, this);
      },

      onPlaying: function(event) {
        this._incrementAdPlayCount();

        // TODO, fetch all ads that are not fetched yet.
        if (!this.firstAdsIsOoyala) { this._checkOoyalaAdsAuth(); }
        this.adsClickThrough = false;
        this.mb.publish(OO.EVENTS.LOAD_ALL_VAST_ADS);
      },

      onEmbedCodeChanged: function(event, embedCode) {
        this.currentEmbedCode = embedCode;
        this.ads = [];
        this.prerolls = [];
        this.firstAdsIsOoyala = false;
        this.adsItem = null;
      },

      _setVastAdLoader: function(ad) {
        if (ad && ad.type == "vast") {
           ad.loader = new OO.VastAdLoader(this.currentEmbedCode);
           ad.loader.on(OO.VastAdLoader.READY, "ads", _.bind(this._onVastReady, this));
           ad.loader.on(OO.VastAdLoader.ERROR, "ads", _.bind(this._onVastError, this));
           if (this.vastPassThroughAdTagUrl) {
             ad.origUrl = ad.origUrl || ad.url;
             ad.url = this.vastPassThroughAdTagUrl;
           }
           ad.loader.loadUrl(ad.url);
        }
      },

      onContentTreeFetched: function(event, content) {
        if (this.currentEmbedCode !== content.embed_code) { return false; }
        this.ads = OO.HM.safeArray("playbackControl.contentTree.ads", content.ads, []);

        // Select the ad set code(s) as well as any public ids for ads that don't belong to an ad set
        this.adIds = _.uniq(_.compact(_.map(this.ads, function(ad) {
          return ad.ad_set_code || ad.public_id;
        })));
        this.adPlayCounts = this._getAdPlayCounts();
        this._filterAdsByFrequency();
        this.prerolls = _.select(this.ads, function(ad, index) {
            // ad.time is null for cuepoints
            return (ad.time !== null && ad.time < 250);
          }, this);

        if (_.size(this.prerolls) > 0) {
          if (this.prerolls[0].type == "ooyala") {
             this._checkOoyalaAdsAuth();
          } else if (this.prerolls[0].type == "vast") {
             this._setVastAdLoader(this.prerolls[0]);
          }
        } else {
          // unblock willFetchAds if there is no preroll ads at all.
          this.mb.publish(OO.EVENTS.FIRST_AD_FETCHED, null);
        }
      },

      onPlay: function(event){
        this.adsClickThrough = false;
      },

      _onVastReady: function(event, loader) {
        this.mb.publish(OO.EVENTS.AD_CONFIG_READY, loader);
        this.mb.publish(OO.EVENTS.FIRST_AD_FETCHED, loader);
      },

      _onVastError: function(event, loader) {
        var ad = (loader.inlineAd && loader.inlineAd.ads[0]) || loader.wrapperAds;
        if (ad) {
          _.each(ad.error, function(url) {
            OO.pixelPing(url);
          }, this);
        }
        if (_.size(this.prerolls) > 0) {
          // check if there is any ooyala ads, if so, check ooyala auth.
          if (_.find(this.prerolls, function(ad) { return ad.type == "ooyala"; }, this)) {
            this._checkOoyalaAdsAuth();
          } else if (_.find(this.prerolls, function(ad) { return !ad.loader; }, this)){
            _.each(this.prerolls, function(ad) {
              if (ad.type == "vast" && !ad.loader) { this._setVastAdLoader(ad); }
            }, this);
          } else {
            this.mb.publish(OO.EVENTS.FIRST_AD_FETCHED, loader);
          }
        }
      },

      _checkOoyalaAdsAuth: function() {
        // check if we have any ooyala ads
        var ooyalaAds = _.select(this.ads, function(ad, index) { return !_.isEmpty(ad.ad_embed_code); }, this);
        var embedCodes = _.map(ooyalaAds, function(ad, index){ return ad.ad_embed_code; }, {});
        this.firstAdsIsOoyala = true;
        if(_.size(embedCodes) > 0) {
          OO.d('Ooyala Ads', this.embedCodes);
          var adsRequest = {
            pcode: OO.playerParams.pcode || "unknown",
            embedCode: embedCodes.join(","),
            server: OO.SERVER.AUTH,
            playerBrandingId: OO.playerParams.playerBrandingId || "unknown",
            params: {}
          };
          this.mb.publish(OO.EVENTS.WILL_FETCH_AD_AUTHORIZATION, adsRequest);
        }
      },

      _incrementAdPlayCount: function() {
        // Increment the play count for each ad id in the data store
        _.each(this.adIds, function(id) {
          this.adPlayCounts[id] = this.adPlayCounts[id] || 0;
          this.adPlayCounts[id] += 1;
        }, this);

        // TODO: Cull LRU from ad play counts so we don't run out of cookie/local storage space
        this._setAdPlayCounts(this.adPlayCounts);
      },

      _filterAdsByFrequency: function() {
        this.ads = _.reject(this.ads, function(ad) {
          var id = ad.ad_set_code || ad.public_id;
          var firstShown = ad.first_shown;
          var frequency = ad.frequency;

          if (!id || firstShown === null || firstShown === undefined || !frequency ||
              ["ooyala", "vast"].indexOf(ad.type) < 0) { return false; }

          var skipAd = true;
          var playCount = this.adPlayCounts[id] || 0;

          if (playCount >= firstShown && (playCount - firstShown) % frequency === 0) { skipAd = false; }
          OO.log("Frequency for ad that is played:", frequency, "first shown:", firstShown,
              "play count:", playCount, "in range =", !skipAd);

          return skipAd;
        }, this);
        this.mb.publish(OO.EVENTS.ADS_FILTERED, this.currentEmbedCode, this.ads);
      },

      _getAdPlayCounts: function() {
        var playCounts = {};
        var countsFromDataStore = OO.localStorage.getItem(OO.CONSTANTS.AD_PLAY_COUNT_KEY);
        if (countsFromDataStore) {
          countsFromDataStore = countsFromDataStore.split(OO.CONSTANTS.AD_PLAY_COUNT_DIVIDER);
          _.each(countsFromDataStore, function(count) {
            count = count.split(OO.CONSTANTS.AD_ID_TO_PLAY_COUNT_DIVIDER);
            if (count[0] !== undefined && count[1] !== undefined) {
              playCounts[count[0]] = parseInt(count[1], 10);
            }
          });
        }

        return playCounts;
      },

      _setAdPlayCounts: function(playCounts) {
        playCounts = _.map(playCounts, function(count, adId) {
          return (adId + OO.CONSTANTS.AD_ID_TO_PLAY_COUNT_DIVIDER + count);
        }).join(OO.CONSTANTS.AD_PLAY_COUNT_DIVIDER);

        OO.localStorage.setItem(OO.CONSTANTS.AD_PLAY_COUNT_KEY, playCounts);
      },

      __placeholder: true
    });

    OO.registerModule('adsManager', function(messageBus, id) {
      return new AdsManager(messageBus, id);
    });

  }(OO, OO._, OO.$));
// Dummy file that depends on all the ads modules, so it's easier for stitcher to grab them all
// Don't delete, it's required by stitcher.

  OO.exposeStaticApi('EVENTS', OO.EVENTS);
  OO.publicApi.$ = OO.$;
  OO.publicApi._ = OO._;

  OO.publicApi.__static.apiReady = true;
  OO.$(document).ready(function() {
    OO.publicApi.__static.docReady = true;
    OO.tryCallReady();
  });
}());

} catch (err) {
  if (err && window.console && window.console.log) { window.console.log(err, err.stack); }
}