/* Modernizr 2.0.6 (Custom Build) | MIT & BSD
 * Contains: fontface | borderradius | boxshadow | opacity | textshadow | cssanimations | audio | video | iepp | cssclasses | teststyles | testprop | testallprops | hasevent | prefixes | domprefixes | load
 */
;window.Modernizr=function(a,b,c){function D(a,b){var c=a.charAt(0).toUpperCase()+a.substr(1),d=(a+" "+o.join(c+" ")+c).split(" ");return C(d,b)}function C(a,b){for(var d in a)if(k[a[d]]!==c)return b=="pfx"?a[d]:!0;return!1}function B(a,b){return!!~(""+a).indexOf(b)}function A(a,b){return typeof a===b}function z(a,b){return y(n.join(a+";")+(b||""))}function y(a){k.cssText=a}var d="2.0.6",e={},f=!0,g=b.documentElement,h=b.head||b.getElementsByTagName("head")[0],i="modernizr",j=b.createElement(i),k=j.style,l,m=Object.prototype.toString,n=" -webkit- -moz- -o- -ms- -khtml- ".split(" "),o="Webkit Moz O ms Khtml".split(" "),p={},q={},r={},s=[],t=function(a,c,d,e){var f,h,j,k=b.createElement("div");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:i+(d+1),k.appendChild(j);f=["&shy;","<style>",a,"</style>"].join(""),k.id=i,k.innerHTML+=f,g.appendChild(k),h=c(k,a),k.parentNode.removeChild(k);return!!h},u=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=A(e[d],"function"),A(e[d],c)||(e[d]=c),e.removeAttribute(d))),e=null;return f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),v,w={}.hasOwnProperty,x;!A(w,c)&&!A(w.call,c)?x=function(a,b){return w.call(a,b)}:x=function(a,b){return b in a&&A(a.constructor.prototype[b],c)};var E=function(a,c){var d=a.join(""),f=c.length;t(d,function(a,c){var d=b.styleSheets[b.styleSheets.length-1],g=d.cssRules&&d.cssRules[0]?d.cssRules[0].cssText:d.cssText||"",h=a.childNodes,i={};while(f--)i[h[f].id]=h[f];e.fontface=/src/i.test(g)&&g.indexOf(c.split(" ")[0])===0},f,c)}(['@font-face {font-family:"font";src:url("https://")}'],["fontface"]);p.borderradius=function(){return D("borderRadius")},p.boxshadow=function(){return D("boxShadow")},p.textshadow=function(){return b.createElement("div").style.textShadow===""},p.opacity=function(){z("opacity:.55");return/^0.55$/.test(k.opacity)},p.cssanimations=function(){return D("animationName")},p.fontface=function(){return e.fontface},p.video=function(){var a=b.createElement("video"),c=!1;try{if(c=!!a.canPlayType){c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"');var d='video/mp4; codecs="avc1.42E01E';c.h264=a.canPlayType(d+'"')||a.canPlayType(d+', mp4a.40.2"'),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"')}}catch(e){}return c},p.audio=function(){var a=b.createElement("audio"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"'),c.mp3=a.canPlayType("audio/mpeg;"),c.wav=a.canPlayType('audio/wav; codecs="1"'),c.m4a=a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")}catch(d){}return c};for(var F in p)x(p,F)&&(v=F.toLowerCase(),e[v]=p[F](),s.push((e[v]?"":"no-")+v));y(""),j=l=null,a.attachEvent&&function(){var a=b.createElement("div");a.innerHTML="<elem></elem>";return a.childNodes.length!==1}()&&function(a,b){function s(a){var b=-1;while(++b<g)a.createElement(f[b])}a.iepp=a.iepp||{};var d=a.iepp,e=d.html5elements||"abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",f=e.split("|"),g=f.length,h=new RegExp("(^|\\s)("+e+")","gi"),i=new RegExp("<(/*)("+e+")","gi"),j=/^\s*[\{\}]\s*$/,k=new RegExp("(^|[^\\n]*?\\s)("+e+")([^\\n]*)({[\\n\\w\\W]*?})","gi"),l=b.createDocumentFragment(),m=b.documentElement,n=m.firstChild,o=b.createElement("body"),p=b.createElement("style"),q=/print|all/,r;d.getCSS=function(a,b){if(a+""===c)return"";var e=-1,f=a.length,g,h=[];while(++e<f){g=a[e];if(g.disabled)continue;b=g.media||b,q.test(b)&&h.push(d.getCSS(g.imports,b),g.cssText),b="all"}return h.join("")},d.parseCSS=function(a){var b=[],c;while((c=k.exec(a))!=null)b.push(((j.exec(c[1])?"\n":c[1])+c[2]+c[3]).replace(h,"$1.iepp_$2")+c[4]);return b.join("\n")},d.writeHTML=function(){var a=-1;r=r||b.body;while(++a<g){var c=b.getElementsByTagName(f[a]),d=c.length,e=-1;while(++e<d)c[e].className.indexOf("iepp_")<0&&(c[e].className+=" iepp_"+f[a])}l.appendChild(r),m.appendChild(o),o.className=r.className,o.id=r.id,o.innerHTML=r.innerHTML.replace(i,"<$1font")},d._beforePrint=function(){p.styleSheet.cssText=d.parseCSS(d.getCSS(b.styleSheets,"all")),d.writeHTML()},d.restoreHTML=function(){o.innerHTML="",m.removeChild(o),m.appendChild(r)},d._afterPrint=function(){d.restoreHTML(),p.styleSheet.cssText=""},s(b),s(l);d.disablePP||(n.insertBefore(p,n.firstChild),p.media="print",p.className="iepp-printshim",a.attachEvent("onbeforeprint",d._beforePrint),a.attachEvent("onafterprint",d._afterPrint))}(a,b),e._version=d,e._prefixes=n,e._domPrefixes=o,e.hasEvent=u,e.testProp=function(a){return C([a])},e.testAllProps=D,e.testStyles=t,g.className=g.className.replace(/\bno-js\b/,"")+(f?" js "+s.join(" "):"");return e}(this,this.document),function(a,b,c){function k(a){return!a||a=="loaded"||a=="complete"}function j(){var a=1,b=-1;while(p.length- ++b)if(p[b].s&&!(a=p[b].r))break;a&&g()}function i(a){var c=b.createElement("script"),d;c.src=a.s,c.onreadystatechange=c.onload=function(){!d&&k(c.readyState)&&(d=1,j(),c.onload=c.onreadystatechange=null)},m(function(){d||(d=1,j())},H.errorTimeout),a.e?c.onload():n.parentNode.insertBefore(c,n)}function h(a){var c=b.createElement("link"),d;c.href=a.s,c.rel="stylesheet",c.type="text/css";if(!a.e&&(w||r)){var e=function(a){m(function(){if(!d)try{a.sheet.cssRules.length?(d=1,j()):e(a)}catch(b){b.code==1e3||b.message=="security"||b.message=="denied"?(d=1,m(function(){j()},0)):e(a)}},0)};e(c)}else c.onload=function(){d||(d=1,m(function(){j()},0))},a.e&&c.onload();m(function(){d||(d=1,j())},H.errorTimeout),!a.e&&n.parentNode.insertBefore(c,n)}function g(){var a=p.shift();q=1,a?a.t?m(function(){a.t=="c"?h(a):i(a)},0):(a(),j()):q=0}function f(a,c,d,e,f,h){function i(){!o&&k(l.readyState)&&(r.r=o=1,!q&&j(),l.onload=l.onreadystatechange=null,m(function(){u.removeChild(l)},0))}var l=b.createElement(a),o=0,r={t:d,s:c,e:h};l.src=l.data=c,!s&&(l.style.display="none"),l.width=l.height="0",a!="object"&&(l.type=d),l.onload=l.onreadystatechange=i,a=="img"?l.onerror=i:a=="script"&&(l.onerror=function(){r.e=r.r=1,g()}),p.splice(e,0,r),u.insertBefore(l,s?null:n),m(function(){o||(u.removeChild(l),r.r=r.e=o=1,j())},H.errorTimeout)}function e(a,b,c){var d=b=="c"?z:y;q=0,b=b||"j",C(a)?f(d,a,b,this.i++,l,c):(p.splice(this.i++,0,a),p.length==1&&g());return this}function d(){var a=H;a.loader={load:e,i:0};return a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=r&&!s,u=s?l:n.parentNode,v=a.opera&&o.call(a.opera)=="[object Opera]",w="webkitAppearance"in l.style,x=w&&"async"in b.createElement("script"),y=r?"object":v||x?"img":"script",z=w?"img":y,A=Array.isArray||function(a){return o.call(a)=="[object Array]"},B=function(a){return Object(a)===a},C=function(a){return typeof a=="string"},D=function(a){return o.call(a)=="[object Function]"},E=[],F={},G,H;H=function(a){function f(a){var b=a.split("!"),c=E.length,d=b.pop(),e=b.length,f={url:d,origUrl:d,prefixes:b},g,h;for(h=0;h<e;h++)g=F[b[h]],g&&(f=g(f));for(h=0;h<c;h++)f=E[h](f);return f}function e(a,b,e,g,h){var i=f(a),j=i.autoCallback;if(!i.bypass){b&&(b=D(b)?b:b[a]||b[g]||b[a.split("/").pop().split("?")[0]]);if(i.instead)return i.instead(a,b,e,g,h);e.load(i.url,i.forceCSS||!i.forceJS&&/css$/.test(i.url)?"c":c,i.noexec),(D(b)||D(j))&&e.load(function(){d(),b&&b(i.origUrl,h,g),j&&j(i.origUrl,h,g)})}}function b(a,b){function c(a){if(C(a))e(a,h,b,0,d);else if(B(a))for(i in a)a.hasOwnProperty(i)&&e(a[i],h,b,i,d)}var d=!!a.test,f=d?a.yep:a.nope,g=a.load||a.both,h=a.callback,i;c(f),c(g),a.complete&&b.load(a.complete)}var g,h,i=this.yepnope.loader;if(C(a))e(a,0,i,0);else if(A(a))for(g=0;g<a.length;g++)h=a[g],C(h)?e(h,0,i,0):A(h)?H(h):B(h)&&b(h,i);else B(a)&&b(a,i)},H.addPrefix=function(a,b){F[a]=b},H.addFilter=function(a){E.push(a)},H.errorTimeout=1e4,b.readyState==null&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",G=function(){b.removeEventListener("DOMContentLoaded",G,0),b.readyState="complete"},0)),a.yepnope=d()}(this,this.document),Modernizr.load=function(){yepnope.apply(window,[].slice.call(arguments,0))};;
/*!	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() {
	
	var UNDEF = "undefined",
		OBJECT = "object",
		SHOCKWAVE_FLASH = "Shockwave Flash",
		SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
		FLASH_MIME_TYPE = "application/x-shockwave-flash",
		EXPRESS_INSTALL_ID = "SWFObjectExprInst",
		ON_READY_STATE_CHANGE = "onreadystatechange",
		
		win = window,
		doc = document,
		nav = navigator,
		
		plugin = false,
		domLoadFnArr = [main],
		regObjArr = [],
		objIdArr = [],
		listenersArr = [],
		storedAltContent,
		storedAltContentId,
		storedCallbackFn,
		storedCallbackObj,
		isDomLoaded = false,
		isExpressInstallActive = false,
		dynamicStylesheet,
		dynamicStylesheetMedia,
		autoHideShow = true,
	
	/* 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;
			if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
				plugin = true;
				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 };
	}(),
	
	/* Cross-browser onDomLoad
		- Will fire an event as soon as the DOM of a web page is loaded
		- Internet Explorer workaround based on Diego Perini's solution: http://javascript.nwbox.com/IEContentLoaded/
		- Regular onload serves as fallback
	*/ 
	onDomLoad = function() {
		if (!ua.w3) { return; }
		if ((typeof doc.readyState != UNDEF && doc.readyState == "complete") || (typeof doc.readyState == UNDEF && (doc.getElementsByTagName("body")[0] || doc.body))) { // function is fired after onload, e.g. when script is inserted dynamically 
			callDomLoadFunctions();
		}
		if (!isDomLoaded) {
			if (typeof doc.addEventListener != UNDEF) {
				doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, false);
			}		
			if (ua.ie && ua.win) {
				doc.attachEvent(ON_READY_STATE_CHANGE, function() {
					if (doc.readyState == "complete") {
						doc.detachEvent(ON_READY_STATE_CHANGE, arguments.callee);
						callDomLoadFunctions();
					}
				});
				if (win == top) { // if not inside an iframe
					(function(){
						if (isDomLoaded) { return; }
						try {
							doc.documentElement.doScroll("left");
						}
						catch(e) {
							setTimeout(arguments.callee, 0);
							return;
						}
						callDomLoadFunctions();
					})();
				}
			}
			if (ua.wk) {
				(function(){
					if (isDomLoaded) { return; }
					if (!/loaded|complete/.test(doc.readyState)) {
						setTimeout(arguments.callee, 0);
						return;
					}
					callDomLoadFunctions();
				})();
			}
			addLoadEvent(callDomLoadFunctions);
		}
	}();
	
	function callDomLoadFunctions() {
		if (isDomLoaded) { return; }
		try { // test if we can really add/remove elements to/from the DOM; we don't want to fire it too early
			var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span"));
			t.parentNode.removeChild(t);
		}
		catch (e) { return; }
		isDomLoaded = true;
		var dl = domLoadFnArr.length;
		for (var i = 0; i < dl; i++) {
			domLoadFnArr[i]();
		}
	}
	
	function addDomLoadEvent(fn) {
		if (isDomLoaded) {
			fn();
		}
		else { 
			domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+
		}
	}
	
	/* Cross-browser onload
		- Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/
		- Will fire an event as soon as a web page including all of its assets are loaded 
	 */
	function addLoadEvent(fn) {
		if (typeof win.addEventListener != UNDEF) {
			win.addEventListener("load", fn, false);
		}
		else if (typeof doc.addEventListener != UNDEF) {
			doc.addEventListener("load", fn, false);
		}
		else if (typeof win.attachEvent != UNDEF) {
			addListener(win, "onload", fn);
		}
		else if (typeof win.onload == "function") {
			var fnOld = win.onload;
			win.onload = function() {
				fnOld();
				fn();
			};
		}
		else {
			win.onload = fn;
		}
	}
	
	/* Main function
		- Will preferably execute onDomLoad, otherwise onload (as a fallback)
	*/
	function main() { 
		if (plugin) {
			testPlayerVersion();
		}
		else {
			matchVersions();
		}
	}
	
	/* Detect the Flash Player version for non-Internet Explorer browsers
		- Detecting the plug-in version via the object element is more precise than using the plugins collection item's description:
		  a. Both release and build numbers can be detected
		  b. Avoid wrong descriptions by corrupt installers provided by Adobe
		  c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports
		- Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available
	*/
	function testPlayerVersion() {
		var b = doc.getElementsByTagName("body")[0];
		var o = createElement(OBJECT);
		o.setAttribute("type", FLASH_MIME_TYPE);
		var t = b.appendChild(o);
		if (t) {
			var counter = 0;
			(function(){
				if (typeof t.GetVariable != UNDEF) {
					var d = t.GetVariable("$version");
					if (d) {
						d = d.split(" ")[1].split(",");
						ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
					}
				}
				else if (counter < 10) {
					counter++;
					setTimeout(arguments.callee, 10);
					return;
				}
				b.removeChild(o);
				t = null;
				matchVersions();
			})();
		}
		else {
			matchVersions();
		}
	}
	
	/* Perform Flash Player and SWF version matching; static publishing only
	*/
	function matchVersions() {
		var rl = regObjArr.length;
		if (rl > 0) {
			for (var i = 0; i < rl; i++) { // for each registered object element
				var id = regObjArr[i].id;
				var cb = regObjArr[i].callbackFn;
				var cbObj = {success:false, id:id};
				if (ua.pv[0] > 0) {
					var obj = getElementById(id);
					if (obj) {
						if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) { // Flash Player version >= published SWF version: Houston, we have a match!
							setVisibility(id, true);
							if (cb) {
								cbObj.success = true;
								cbObj.ref = getObjectById(id);
								cb(cbObj);
							}
						}
						else if (regObjArr[i].expressInstall && canExpressInstall()) { // show the Adobe Express Install dialog if set by the web page author and if supported
							var att = {};
							att.data = regObjArr[i].expressInstall;
							att.width = obj.getAttribute("width") || "0";
							att.height = obj.getAttribute("height") || "0";
							if (obj.getAttribute("class")) { att.styleclass = obj.getAttribute("class"); }
							if (obj.getAttribute("align")) { att.align = obj.getAttribute("align"); }
							// parse HTML object param element's name-value pairs
							var par = {};
							var p = obj.getElementsByTagName("param");
							var pl = p.length;
							for (var j = 0; j < pl; j++) {
								if (p[j].getAttribute("name").toLowerCase() != "movie") {
									par[p[j].getAttribute("name")] = p[j].getAttribute("value");
								}
							}
							showExpressInstall(att, par, id, cb);
						}
						else { // Flash Player and SWF version mismatch or an older Webkit engine that ignores the HTML object element's nested param elements: display alternative content instead of SWF
							displayAltContent(obj);
							if (cb) { cb(cbObj); }
						}
					}
				}
				else {	// if no Flash Player is installed or the fp version cannot be detected we let the HTML object element do its job (either show a SWF or alternative content)
					setVisibility(id, true);
					if (cb) {
						var o = getObjectById(id); // test whether there is an HTML object element or not
						if (o && typeof o.SetVariable != UNDEF) { 
							cbObj.success = true;
							cbObj.ref = o;
						}
						cb(cbObj);
					}
				}
			}
		}
	}
	
	function getObjectById(objectIdStr) {
		var r = null;
		var o = getElementById(objectIdStr);
		if (o && o.nodeName == "OBJECT") {
			if (typeof o.SetVariable != UNDEF) {
				r = o;
			}
			else {
				var n = o.getElementsByTagName(OBJECT)[0];
				if (n) {
					r = n;
				}
			}
		}
		return r;
	}
	
	/* Requirements for Adobe Express Install
		- only one instance can be active at a time
		- fp 6.0.65 or higher
		- Win/Mac OS only
		- no Webkit engines older than version 312
	*/
	function canExpressInstall() {
		return !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac) && !(ua.wk && ua.wk < 312);
	}
	
	/* Show the Adobe Express Install dialog
		- Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75
	*/
	function showExpressInstall(att, par, replaceElemIdStr, callbackFn) {
		isExpressInstallActive = true;
		storedCallbackFn = callbackFn || null;
		storedCallbackObj = {success:false, id:replaceElemIdStr};
		var obj = getElementById(replaceElemIdStr);
		if (obj) {
			if (obj.nodeName == "OBJECT") { // static publishing
				storedAltContent = abstractAltContent(obj);
				storedAltContentId = null;
			}
			else { // dynamic publishing
				storedAltContent = obj;
				storedAltContentId = replaceElemIdStr;
			}
			att.id = EXPRESS_INSTALL_ID;
			if (typeof att.width == UNDEF || (!/%$/.test(att.width) && parseInt(att.width, 10) < 310)) { att.width = "310"; }
			if (typeof att.height == UNDEF || (!/%$/.test(att.height) && parseInt(att.height, 10) < 137)) { att.height = "137"; }
			doc.title = doc.title.slice(0, 47) + " - Flash Player Installation";
			var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn",
				fv = "MMredirectURL=" + win.location.toString().replace(/&/g,"%26") + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title;
			if (typeof par.flashvars != UNDEF) {
				par.flashvars += "&" + fv;
			}
			else {
				par.flashvars = fv;
			}
			// IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it,
			// because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
			if (ua.ie && ua.win && obj.readyState != 4) {
				var newObj = createElement("div");
				replaceElemIdStr += "SWFObjectNew";
				newObj.setAttribute("id", replaceElemIdStr);
				obj.parentNode.insertBefore(newObj, obj); // insert placeholder div that will be replaced by the object element that loads expressinstall.swf
				obj.style.display = "none";
				(function(){
					if (obj.readyState == 4) {
						obj.parentNode.removeChild(obj);
					}
					else {
						setTimeout(arguments.callee, 10);
					}
				})();
			}
			createSWF(att, par, replaceElemIdStr);
		}
	}
	
	/* Functions to abstract and display alternative content
	*/
	function displayAltContent(obj) {
		if (ua.ie && ua.win && obj.readyState != 4) {
			// IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it,
			// because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
			var el = createElement("div");
			obj.parentNode.insertBefore(el, obj); // insert placeholder div that will be replaced by the alternative content
			el.parentNode.replaceChild(abstractAltContent(obj), el);
			obj.style.display = "none";
			(function(){
				if (obj.readyState == 4) {
					obj.parentNode.removeChild(obj);
				}
				else {
					setTimeout(arguments.callee, 10);
				}
			})();
		}
		else {
			obj.parentNode.replaceChild(abstractAltContent(obj), obj);
		}
	} 

	function abstractAltContent(obj) {
		var ac = createElement("div");
		if (ua.win && ua.ie) {
			ac.innerHTML = obj.innerHTML;
		}
		else {
			var nestedObj = obj.getElementsByTagName(OBJECT)[0];
			if (nestedObj) {
				var c = nestedObj.childNodes;
				if (c) {
					var cl = c.length;
					for (var i = 0; i < cl; i++) {
						if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) {
							ac.appendChild(c[i].cloneNode(true));
						}
					}
				}
			}
		}
		return ac;
	}
	
	/* Cross-browser dynamic SWF creation
	*/
	function createSWF(attObj, parObj, id) {
		var r, el = getElementById(id);
		if (ua.wk && ua.wk < 312) { return r; }
		if (el) {
			if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content
				attObj.id = id;
			}
			if (ua.ie && ua.win) { // Internet Explorer + the HTML object element + W3C DOM methods do not combine: fall back to outerHTML
				var att = "";
				for (var i in attObj) {
					if (attObj[i] != Object.prototype[i]) { // filter out prototype additions from other potential libraries
						if (i.toLowerCase() == "data") {
							parObj.movie = attObj[i];
						}
						else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
							att += ' class="' + attObj[i] + '"';
						}
						else if (i.toLowerCase() != "classid") {
							att += ' ' + i + '="' + attObj[i] + '"';
						}
					}
				}
				var par = "";
				for (var j in parObj) {
					if (parObj[j] != Object.prototype[j]) { // filter out prototype additions from other potential libraries
						par += '<param name="' + j + '" value="' + parObj[j] + '" />';
					}
				}
				el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>';
				objIdArr[objIdArr.length] = attObj.id; // stored to fix object 'leaks' on unload (dynamic publishing only)
				r = getElementById(attObj.id);	
			}
			else { // well-behaving browsers
				var o = createElement(OBJECT);
				o.setAttribute("type", FLASH_MIME_TYPE);
				for (var m in attObj) {
					if (attObj[m] != Object.prototype[m]) { // filter out prototype additions from other potential libraries
						if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
							o.setAttribute("class", attObj[m]);
						}
						else if (m.toLowerCase() != "classid") { // filter out IE specific attribute
							o.setAttribute(m, attObj[m]);
						}
					}
				}
				for (var n in parObj) {
					if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // filter out prototype additions from other potential libraries and IE specific param element
						createObjParam(o, n, parObj[n]);
					}
				}
				el.parentNode.replaceChild(o, el);
				r = o;
			}
		}
		return r;
	}
	
	function createObjParam(el, pName, pValue) {
		var p = createElement("param");
		p.setAttribute("name", pName);	
		p.setAttribute("value", pValue);
		el.appendChild(p);
	}
	
	/* Cross-browser SWF removal
		- Especially needed to safely and completely remove a SWF in Internet Explorer
	*/
	function removeSWF(id) {
		var obj = getElementById(id);
		if (obj && obj.nodeName == "OBJECT") {
			if (ua.ie && ua.win) {
				obj.style.display = "none";
				(function(){
					if (obj.readyState == 4) {
						removeObjectInIE(id);
					}
					else {
						setTimeout(arguments.callee, 10);
					}
				})();
			}
			else {
				obj.parentNode.removeChild(obj);
			}
		}
	}
	
	function removeObjectInIE(id) {
		var obj = getElementById(id);
		if (obj) {
			for (var i in obj) {
				if (typeof obj[i] == "function") {
					obj[i] = null;
				}
			}
			obj.parentNode.removeChild(obj);
		}
	}
	
	/* Functions to optimize JavaScript compression
	*/
	function getElementById(id) {
		var el = null;
		try {
			el = doc.getElementById(id);
		}
		catch (e) {}
		return el;
	}
	
	function createElement(el) {
		return doc.createElement(el);
	}
	
	/* Updated attachEvent function for Internet Explorer
		- Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks
	*/	
	function addListener(target, eventType, fn) {
		target.attachEvent(eventType, fn);
		listenersArr[listenersArr.length] = [target, eventType, fn];
	}
	
	/* Flash Player and SWF content version matching
	*/
	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;
	}
	
	/* Cross-browser dynamic CSS creation
		- Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php
	*/	
	function createCSS(sel, decl, media, newStyle) {
		if (ua.ie && ua.mac) { return; }
		var h = doc.getElementsByTagName("head")[0];
		if (!h) { return; } // to also support badly authored HTML pages that lack a head element
		var m = (media && typeof media == "string") ? media : "screen";
		if (newStyle) {
			dynamicStylesheet = null;
			dynamicStylesheetMedia = null;
		}
		if (!dynamicStylesheet || dynamicStylesheetMedia != m) { 
			// create dynamic stylesheet + get a global reference to it
			var s = createElement("style");
			s.setAttribute("type", "text/css");
			s.setAttribute("media", m);
			dynamicStylesheet = h.appendChild(s);
			if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) {
				dynamicStylesheet = doc.styleSheets[doc.styleSheets.length - 1];
			}
			dynamicStylesheetMedia = m;
		}
		// add style rule
		if (ua.ie && ua.win) {
			if (dynamicStylesheet && typeof dynamicStylesheet.addRule == OBJECT) {
				dynamicStylesheet.addRule(sel, decl);
			}
		}
		else {
			if (dynamicStylesheet && typeof doc.createTextNode != UNDEF) {
				dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" + decl + "}"));
			}
		}
	}
	
	function setVisibility(id, isVisible) {
		if (!autoHideShow) { return; }
		var v = isVisible ? "visible" : "hidden";
		if (isDomLoaded && getElementById(id)) {
			getElementById(id).style.visibility = v;
		}
		else {
			createCSS("#" + id, "visibility:" + v);
		}
	}

	/* Filter to avoid XSS attacks
	*/
	function urlEncodeIfNecessary(s) {
		var regex = /[\\\"<>\.;]/;
		var hasBadChars = regex.exec(s) != null;
		return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s;
	}
	
	/* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only)
	*/
	var cleanup = function() {
		if (ua.ie && ua.win) {
			window.attachEvent("onunload", function() {
				// remove listeners to avoid memory leaks
				var ll = listenersArr.length;
				for (var i = 0; i < ll; i++) {
					listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]);
				}
				// cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect
				var il = objIdArr.length;
				for (var j = 0; j < il; j++) {
					removeSWF(objIdArr[j]);
				}
				// cleanup library's main closures to avoid memory leaks
				for (var k in ua) {
					ua[k] = null;
				}
				ua = null;
				for (var l in swfobject) {
					swfobject[l] = null;
				}
				swfobject = null;
			});
		}
	}();
	
	return {
		/* Public API
			- Reference: http://code.google.com/p/swfobject/wiki/documentation
		*/ 
		registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr, callbackFn) {
			if (ua.w3 && objectIdStr && swfVersionStr) {
				var regObj = {};
				regObj.id = objectIdStr;
				regObj.swfVersion = swfVersionStr;
				regObj.expressInstall = xiSwfUrlStr;
				regObj.callbackFn = callbackFn;
				regObjArr[regObjArr.length] = regObj;
				setVisibility(objectIdStr, false);
			}
			else if (callbackFn) {
				callbackFn({success:false, id:objectIdStr});
			}
		},
		
		getObjectById: function(objectIdStr) {
			if (ua.w3) {
				return getObjectById(objectIdStr);
			}
		},
		
		embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {
			var callbackObj = {success:false, id:replaceElemIdStr};
			if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) {
				setVisibility(replaceElemIdStr, false);
				addDomLoadEvent(function() {
					widthStr += ""; // auto-convert to string
					heightStr += "";
					var att = {};
					if (attObj && typeof attObj === OBJECT) {
						for (var i in attObj) { // copy object to avoid the use of references, because web authors often reuse attObj for multiple SWFs
							att[i] = attObj[i];
						}
					}
					att.data = swfUrlStr;
					att.width = widthStr;
					att.height = heightStr;
					var par = {}; 
					if (parObj && typeof parObj === OBJECT) {
						for (var j in parObj) { // copy object to avoid the use of references, because web authors often reuse parObj for multiple SWFs
							par[j] = parObj[j];
						}
					}
					if (flashvarsObj && typeof flashvarsObj === OBJECT) {
						for (var k in flashvarsObj) { // copy object to avoid the use of references, because web authors often reuse flashvarsObj for multiple SWFs
							if (typeof par.flashvars != UNDEF) {
								par.flashvars += "&" + k + "=" + flashvarsObj[k];
							}
							else {
								par.flashvars = k + "=" + flashvarsObj[k];
							}
						}
					}
					if (hasPlayerVersion(swfVersionStr)) { // create SWF
						var obj = createSWF(att, par, replaceElemIdStr);
						if (att.id == replaceElemIdStr) {
							setVisibility(replaceElemIdStr, true);
						}
						callbackObj.success = true;
						callbackObj.ref = obj;
					}
					else if (xiSwfUrlStr && canExpressInstall()) { // show Adobe Express Install
						att.data = xiSwfUrlStr;
						showExpressInstall(att, par, replaceElemIdStr, callbackFn);
						return;
					}
					else { // show alternative content
						setVisibility(replaceElemIdStr, true);
					}
					if (callbackFn) { callbackFn(callbackObj); }
				});
			}
			else if (callbackFn) { callbackFn(callbackObj);	}
		},
		
		switchOffAutoHideShow: function() {
			autoHideShow = false;
		},
		
		ua: ua,
		
		getFlashPlayerVersion: function() {
			return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
		},
		
		hasFlashPlayerVersion: hasPlayerVersion,
		
		createSWF: function(attObj, parObj, replaceElemIdStr) {
			if (ua.w3) {
				return createSWF(attObj, parObj, replaceElemIdStr);
			}
			else {
				return undefined;
			}
		},
		
		showExpressInstall: function(att, par, replaceElemIdStr, callbackFn) {
			if (ua.w3 && canExpressInstall()) {
				showExpressInstall(att, par, replaceElemIdStr, callbackFn);
			}
		},
		
		removeSWF: function(objElemIdStr) {
			if (ua.w3) {
				removeSWF(objElemIdStr);
			}
		},
		
		createCSS: function(selStr, declStr, mediaStr, newStyleBoolean) {
			if (ua.w3) {
				createCSS(selStr, declStr, mediaStr, newStyleBoolean);
			}
		},
		
		addDomLoadEvent: addDomLoadEvent,
		
		addLoadEvent: addLoadEvent,
		
		getQueryParamValue: function(param) {
			var q = doc.location.search || doc.location.hash;
			if (q) {
				if (/\?/.test(q)) { q = q.split("?")[1]; } // strip question mark
				if (param == null) {
					return urlEncodeIfNecessary(q);
				}
				var pairs = q.split("&");
				for (var i = 0; i < pairs.length; i++) {
					if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
						return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1)));
					}
				}
			}
			return "";
		},
		
		// For internal usage only
		expressInstallCallback: function() {
			if (isExpressInstallActive) {
				var obj = getElementById(EXPRESS_INSTALL_ID);
				if (obj && storedAltContent) {
					obj.parentNode.replaceChild(storedAltContent, obj);
					if (storedAltContentId) {
						setVisibility(storedAltContentId, true);
						if (ua.ie && ua.win) { storedAltContent.style.display = "block"; }
					}
					if (storedCallbackFn) { storedCallbackFn(storedCallbackObj); }
				}
				isExpressInstallActive = false;
			} 
		}
	};
}();
;
/*	
 *	jQuery carouFredSel 5.3.0
 *	Demo's and documentation:
 *	caroufredsel.frebsite.nl
 *	
 *	Copyright (c) 2011 Fred Heusschen
 *	www.frebsite.nl
 *
 *	Dual licensed under the MIT and GPL licenses.
 *	http://en.wikipedia.org/wiki/MIT_License
 *	http://en.wikipedia.org/wiki/GNU_General_Public_License
 */


eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(G($){7($.1S.1K)H;$.1S.1K=G(y,z){7(1e.S==0){19(L,\'59 4c 69 1l "\'+1e.3H+\'".\');H 1e}7(1e.S>1){H 1e.1L(G(){$(1e).1K(y,z)})}8 A=1e,$16=1e[0];7(A.1m(\'4d\')){8 B=A.1v(\'5a\');A.V(\'5b\',L)}P{8 B=M}A.4e=G(o,b,c){o=3I($16,o);7(o.19){F.19=o.19;19(F,\'6a "19" 6b 6c 6d 6e 3g 6f 6g 4f-1f.\')}8 e=[\'9\',\'1h\',\'Q\',\'13\',\'15\',\'17\'];1l(8 a=0,l=e.S;a<l;a++){o[e[a]]=3I($16,o[e[a]])}7(I o.1h==\'14\'){7(o.1h<=50)o.1h={\'9\':o.1h};P o.1h={\'1g\':o.1h}}P{7(I o.1h==\'1i\')o.1h={\'1D\':o.1h}}7(I o.9==\'14\')o.9={\'N\':o.9};P 7(o.9==\'1a\')o.9={\'N\':o.9,\'R\':o.9,\'1t\':o.9};7(I o.9!=\'1f\')o.9={};7(b)2B=$.2c(L,{},$.1S.1K.4g,o);6=$.2c(L,{},$.1S.1K.4g,o);7(I 6.9.12!=\'1f\')6.9.12={};7(6.9.2C==0&&I c==\'14\'){6.9.2C=c}C.2d=(6.2d==\'4h\'||6.2d==\'1o\')?\'15\':\'13\';8 f=[[\'R\',\'3J\',\'2e\',\'1t\',\'5c\',\'2D\',\'1o\',\'2E\',\'1z\',0,1,2,3],[\'1t\',\'5c\',\'2D\',\'R\',\'3J\',\'2e\',\'2E\',\'1o\',\'3K\',3,2,1,0]];8 g=f[0].S,5d=(6.2d==\'2F\'||6.2d==\'1o\')?0:1;6.d={};1l(8 d=0;d<g;d++){6.d[f[0][d]]=f[5d][d]}8 h=A.X();7(I 6.9.1q==\'1u\'){6.9.1q=(h.1q(\':2G\').S>0)?\':N\':\'*\'}7(6[6.d[\'R\']]==\'Q\'){8 i=3L(h,6,\'2e\');6[6.d[\'R\']]=i}7(6[6.d[\'1t\']]==\'Q\'){8 i=3L(h,6,\'2D\');6[6.d[\'1t\']]=i}7(!6.9[6.d[\'R\']]){6.9[6.d[\'R\']]=(4i(h,6,\'2e\'))?\'1a\':h[6.d[\'2e\']](L)}7(!6.9[6.d[\'1t\']]){6.9[6.d[\'1t\']]=(4i(h,6,\'2D\'))?\'1a\':h[6.d[\'2D\']](L)}7(!6[6.d[\'1t\']]){6[6.d[\'1t\']]=6.9[6.d[\'1t\']]}7(I 6.9.N==\'1f\'){6.9.12.3h=6.9.N.3h;6.9.12.2n=6.9.N.2n;6.9.N=M}7(I 6.9.N==\'1i\'||I 6.9.N==\'G\'){6.9.12.2o=6.9.N;6.9.N=M}7(!6.9.N){7(6.9[6.d[\'R\']]==\'1a\'){6.9.12.1a=L}7(!6.9.12.1a){7(I 6[6.d[\'R\']]==\'14\'){6.9.N=1M.3i(6[6.d[\'R\']]/6.9[6.d[\'R\']])}P{8 j=4j($1H.3M(),6,\'3J\');6.9.N=1M.3i(j/6.9[6.d[\'R\']]);6[6.d[\'R\']]=6.9.N*6.9[6.d[\'R\']];7(!6.9.12.2o)6.1A=M}7(6.9.N==\'6h\'||6.9.N<1){19(L,\'21 a 4k 14 3j N 9: 6i 3g "1a".\');6.9.12.1a=L}}}7(!6[6.d[\'R\']]){7(6.9.1q!=\'*\'){6[6.d[\'R\']]=\'1a\'}P 7(!6.9.12.1a&&6.9[6.d[\'R\']]!=\'1a\'){6[6.d[\'R\']]=6.9.N*6.9[6.d[\'R\']];6.1A=M}P{6[6.d[\'R\']]=\'1a\'}}7(6.9.12.1a){6.3k=(6[6.d[\'R\']]==\'1a\')?4j($1H.3M(),6,\'3J\'):6[6.d[\'R\']];7(6.1A===M){6[6.d[\'R\']]=\'1a\'}6.9.N=2H(h,6,0)}P 7(6.9.1q!=\'*\'){6.9.12.3N=6.9.N;6.9.N=3l(h,6,0)}7(I 6.1d==\'1u\'){6.1d=0}7(I 6.1A==\'1u\'){6.1A=(6[6.d[\'R\']]==\'1a\')?M:\'4l\'}6.9.N=2I(6.9.N,6,6.9.12.2o,$16);6.9.12.1U=6.9.N;6.1p=M;6.1d=5e(6.1d);7(6.1A==\'2E\')6.1A=\'1o\';7(6.1A==\'4m\')6.1A=\'2F\';1w(6.1A){U\'4l\':U\'1o\':U\'2F\':7(6[6.d[\'R\']]!=\'1a\'){8 p=3O(2V(h,6),6);6.1p=L;6.1d[6.d[1]]=p[1];6.1d[6.d[3]]=p[0]}18;2p:6.1A=M;6.1p=(6.1d[0]==0&&6.1d[1]==0&&6.1d[2]==0&&6.1d[3]==0)?M:L;18}7(I 6.2f==\'1r\'&&6.2f)6.2f=\'6j\'+A.6k(\'6l\');7(I 6.9.2W!=\'14\')6.9.2W=6.9.N;7(I 6.1h.1g!=\'14\')6.1h.1g=5f;7(I 6.1h.9==\'1u\')6.1h.9=(6.9.12.1a||6.9.1q!=\'*\')?\'N\':6.9.N;6.Q=3m($16,6.Q,\'Q\');6.13=3m($16,6.13);6.15=3m($16,6.15);6.17=3m($16,6.17,\'17\');6.Q=$.2c(L,{},6.1h,6.Q);6.13=$.2c(L,{},6.1h,6.13);6.15=$.2c(L,{},6.1h,6.15);6.17=$.2c(L,{},6.1h,6.17);7(I 6.17.3P!=\'1r\')6.17.3P=M;7(I 6.17.2X!=\'G\'&&6.17.2X!==M)6.17.2X=$.1S.1K.5g;7(I 6.Q.1E!=\'1r\')6.Q.1E=L;7(I 6.Q.4n!=\'14\')6.Q.4n=0;7(I 6.Q.2Y!=\'14\')6.Q.2Y=(6.Q.1g<10)?6m:6.Q.1g*5;7(6.22){6.22=4o(6.22)}7(F.19){19(F,\'2Z R: \'+6.R);19(F,\'2Z 1t: \'+6.1t);7(6.3k)19(F,\'6n \'+6.d[\'R\']+\': \'+6.3k);19(F,\'5h 6o: \'+6.9.R);19(F,\'5h 6p: \'+6.9.1t);19(F,\'3Q 3j 9 N: \'+6.9.N);7(6.Q.1E)19(F,\'3Q 3j 9 4p 6q: \'+6.Q.9);7(6.13.W)19(F,\'3Q 3j 9 4p 4q: \'+6.13.9);7(6.15.W)19(F,\'3Q 3j 9 4p 5i: \'+6.15.9)}};A.5j=G(){A.1m(\'4d\',L);8 a={\'4r\':A.11(\'4r\'),\'4s\':A.11(\'4s\'),\'3n\':A.11(\'3n\'),\'2E\':A.11(\'2E\'),\'2F\':A.11(\'2F\'),\'4m\':A.11(\'4m\'),\'1o\':A.11(\'1o\'),\'R\':A.11(\'R\'),\'1t\':A.11(\'1t\'),\'4t\':A.11(\'4t\'),\'1z\':A.11(\'1z\'),\'3K\':A.11(\'3K\'),\'4u\':A.11(\'4u\')};1w(a.3n){U\'4v\':8 b=\'4v\';18;U\'5k\':8 b=\'5k\';18;2p:8 b=\'6r\'}$1H.11(a).11({\'6s\':\'2G\',\'3n\':b});A.1m(\'5l\',a).11({\'4r\':\'1o\',\'4s\':\'3R\',\'3n\':\'4v\',\'2E\':0,\'1o\':0,\'4t\':0,\'1z\':0,\'3K\':0,\'4u\':0});7(6.1p){A.X().1L(G(){8 m=2g($(1e).11(6.d[\'1z\']));7(2q(m))m=0;$(1e).1m(\'1N\',m)})}};A.5m=G(){A.4w();A.Z(J(\'4x\',F),G(e,a){e.1c();7(!C.1V){7(6.Q.W){6.Q.W.2J(2h(\'3S\',F))}}C.1V=L;7(6.Q.1E){6.Q.1E=M;A.V(J(\'2K\',F),a)}H L});A.Z(J(\'5n\',F),G(e){e.1c();7(C.1O){3o(O)}H L});A.Z(J(\'2K\',F),G(e,a,b){e.1c();1B=31(1B);7(a&&C.1O){O.1V=L;8 c=2r()-O.2L;O.1g-=c;7(O.1j)O.1j.1g-=c;7(O.1I)O.1I.1g-=c;3o(O,M)}7(!C.1W&&!C.1O){7(b)1B.3p+=2r()-1B.2L}7(!C.1W){7(6.Q.W){6.Q.W.2J(2h(\'5o\',F))}}C.1W=L;7(6.Q.5p){8 d=6.Q.2Y-1B.3p,3q=3T-1M.32(d*3T/6.Q.2Y);6.Q.5p.1x($16,3q,d)}H L});A.Z(J(\'1E\',F),G(e,b,c,d){e.1c();1B=31(1B);8 v=[b,c,d],t=[\'1i\',\'14\',\'1r\'],a=33(v,t);8 b=a[0],c=a[1],d=a[2];7(b!=\'13\'&&b!=\'15\')b=C.2d;7(I c!=\'14\')c=0;7(I d!=\'1r\')d=M;7(d){C.1V=M;6.Q.1E=L}7(!6.Q.1E){e.1X();H 19(F,\'2Z 3S: 21 2M.\')}7(C.1W){7(6.Q.W){6.Q.W.2s(2h(\'3S\',F));6.Q.W.2s(2h(\'5o\',F))}}C.1W=M;1B.2L=2r();8 f=6.Q.2Y+c;3r=f-1B.3p;3q=3T-1M.32(3r*3T/f);1B.Q=6t(G(){7(6.Q.5q){6.Q.5q.1x($16,3q,3r)}7(C.1O){A.V(J(\'1E\',F),b)}P{A.V(J(b,F),6.Q)}},3r);7(6.Q.5r){6.Q.5r.1x($16,3q,3r)}H L});A.Z(J(\'2N\',F),G(e){e.1c();7(O.1V){O.1V=M;C.1W=M;C.1O=L;O.2L=2r();23(O)}P{A.V(J(\'1E\',F))}H L});A.Z(J(\'13\',F)+\' \'+J(\'15\',F),G(e,b,f,g){e.1c();7(C.1V||A.1Y(\':2G\')){e.1X();H 19(F,\'2Z 3S 6u 2G: 21 2M.\')}7(6.9.2W>=K.T){e.1X();H 19(F,\'21 5s 9 (\'+K.T+\', \'+6.9.2W+\' 5t): 21 2M.\')}8 v=[b,f,g],t=[\'1f\',\'14/1i\',\'G\'],a=33(v,t);8 b=a[0],f=a[1],g=a[2];8 h=e.4y.4z(F.34.3s.S);7(I b!=\'1f\'||b==2i)b=6[h];7(I g==\'G\')b.1Z=g;7(I f!=\'14\'){7(6.9.1q!=\'*\'){f=\'N\'}P{8 i=[f,b.9,6[h].9];1l(8 a=0,l=i.S;a<l;a++){7(I i[a]==\'14\'||i[a]==\'5u\'||i[a]==\'N\'){f=i[a];18}}}1w(f){U\'5u\':e.1X();H A.1v(h+\'6v\',[b,g]);18;U\'N\':7(!6.9.12.1a&&6.9.1q==\'*\'){f=6.9.N}18}}7(O.1V){A.V(J(\'2N\',F));A.V(J(\'35\',F),[h,[b,f,g]]);e.1X();H 19(F,\'2Z 6w 2M.\')}7(b.1g>0){7(C.1O){7(b.35)A.V(J(\'35\',F),[h,[b,f,g]]);e.1X();H 19(F,\'2Z 6x 2M.\')}}7(b.4A&&!b.4A.1x($16)){e.1X();H 19(F,\'6y "4A" 6z M.\')}1B.3p=0;A.V(\'5v\'+h,[b,f]);7(6.22){8 s=6.22,c=[b,f];1l(8 j=0,l=s.S;j<l;j++){8 d=h;7(!s[j][1])c[0]=s[j][0].1v(\'5w\',h);7(!s[j][2])d=(d==\'13\')?\'15\':\'13\';c[1]=f+s[j][3];s[j][0].V(\'5v\'+d,c)}}H L});A.Z(J(\'6A\',F,M),G(e,f,g){e.1c();8 h=A.X();7(!6.1P){7(K.Y==0){7(6.36){A.V(J(\'15\',F),K.T-1)}H e.1X()}}7(6.1p)1J(h,6);7(I g!=\'14\'){7(6.9.12.1a){g=3U(h,6,K.T-1)}P 7(6.9.1q!=\'*\'){8 i=(I f.9==\'14\')?f.9:4B(A,6);g=5x(h,6,K.T-1,i)}P{g=6.9.N}g=3V(g,6,f.9,$16)}7(!6.1P){7(K.T-g<K.Y){g=K.T-K.Y}}7(6.9.12.1a){8 j=2H(h,6,K.T-g);7(6.9.N+g<=j&&g<K.T){g++;j=2H(h,6,K.T-g)}6.9.12.1U=6.9.N;6.9.N=2I(j,6,6.9.12.2o,$16)}P 7(6.9.1q!=\'*\'){8 j=3l(h,6,K.T-g);6.9.12.1U=6.9.N;6.9.N=2I(j,6,6.9.12.2o,$16)}7(6.1p)1J(h,6,L);7(g==0){e.1X();H 19(F,\'0 9 3g 1h: 21 2M.\')}19(F,\'5y \'+g+\' 9 4q.\');K.Y+=g;2O(K.Y>=K.T){K.Y-=K.T}7(!6.1P){7(K.Y==0&&f.3W)f.3W.1x($16);7(!6.36)2P(6,K.Y,F)}A.X().1n(K.T-g,K.T).6B(A);7(K.T<6.9.N+g){A.X().1n(0,(6.9.N+g)-K.T).3X(L).3t(A)}8 h=A.X(),2j=5z(h,6,g),1Q=5A(h,6),24=h.1F(g-1),25=2j.2Q(),2t=1Q.2Q();7(6.1p)1J(h,6);7(6.1A){8 p=3O(1Q,6),k=p[0],2k=p[1]}P{8 k=0,2k=0}8 l=(k<0)?6.1d[6.d[3]]:0;7(f.1C==\'5B\'&&6.9.N<g){8 m=h.1n(6.9.12.1U,g),3Y=6.9[6.d[\'R\']];m.1L(G(){8 a=$(1e);a.1m(\'3Z\',a.1Y(\':2G\')).3u()});6.9[6.d[\'R\']]=\'1a\'}P{8 m=M}8 n=3a(h.1n(0,g),6,\'R\'),26=41(2u(1Q,6,L),6,!6.1p);7(m)6.9[6.d[\'R\']]=3Y;7(6.1p){1J(h,6,L);7(2k>=0){1J(25,6,6.1d[6.d[1]])}1J(24,6,6.1d[6.d[3]])}7(6.1A){6.1d[6.d[1]]=2k;6.1d[6.d[3]]=k}8 o={},1s=f.1g;7(f.1C==\'3R\')1s=0;P 7(1s==\'Q\')1s=6.1h.1g/6.1h.9*g;P 7(1s<=0)1s=0;P 7(1s<10)1s=n/1s;O=20(1s,f.1D);7(6[6.d[\'R\']]==\'1a\'||6[6.d[\'1t\']]==\'1a\'){O.1b.1k([$1H,26])}7(6.1p){8 q=6.1d[6.d[3]];7(2t.4C(24).S){8 r={};r[6.d[\'1z\']]=24.1m(\'1N\');7(k<0)24.11(r);P O.1b.1k([24,r])}7(2t.4C(25).S){8 s={};s[6.d[\'1z\']]=25.1m(\'1N\');O.1b.1k([25,s])}7(2k>=0){8 t={};t[6.d[\'1z\']]=2t.1m(\'1N\')+6.1d[6.d[1]];O.1b.1k([2t,t])}}P{8 q=0}o[6.d[\'1o\']]=q;8 u=[2j,1Q,26,1s];7(f.27)f.27.3v($16,u);1T.27=3w(1T.27,$16,u);1w(f.1C){U\'2v\':U\'28\':U\'2w\':U\'29\':O.1j=20(O.1g,O.1D);O.1I=20(O.1g,O.1D);O.1g=0;18}1w(f.1C){U\'28\':U\'2w\':U\'29\':8 v=A.3X().3t($1H);18}1w(f.1C){U\'29\':v.X().1n(0,g).1G();U\'28\':U\'2w\':v.X().1n(6.9.N).1G();18}1w(f.1C){U\'2v\':O.1j.1b.1k([A,{\'2a\':0}]);18;U\'28\':v.11({\'2a\':0});O.1j.1b.1k([A,{\'R\':\'+=0\'},G(){v.1G()}]);O.1I.1b.1k([v,{\'2a\':1}]);18;U\'2w\':O=4D(O,A,v,6,L);18;U\'29\':O=4E(O,A,v,6,L,g);18}8 w=G(){8 b=6.9.N+g-K.T;7(b>0){A.X().1n(K.T).1G();2j=A.X().1n(K.T-(g-b)).5C().6C(A.X().1n(0,b).5C())}7(m){m.1L(G(){8 a=$(1e);7(!a.1m(\'3Z\'))a.3x()})}7(6.1p){8 c=A.X().1F(6.9.N+g-1);c.11(6.d[\'1z\'],c.1m(\'1N\'))}O.1b=[];7(O.1j)O.1j=20(O.4F,O.1D);8 d=G(){1w(f.1C){U\'2v\':U\'28\':A.11(\'1q\',\'\');18}O.1I=20(0,2i);C.1O=M;8 a=[2j,1Q,26];7(f.1Z)f.1Z.3v($16,a);1T.1Z=3w(1T.1Z,$16,a);7(1R.S){A.V(J(1R[0][0],F),1R[0][1]);1R.5D()}7(!C.1W)A.V(J(\'1E\',F))};1w(f.1C){U\'2v\':O.1j.1b.1k([A,{\'2a\':1},d]);23(O.1j);18;U\'29\':O.1j.1b.1k([A,{\'R\':\'+=0\'},d]);23(O.1j);18;2p:d();18}};O.1b.1k([A,o,w]);C.1O=L;A.11(6.d[\'1o\'],-(n-l));1B=31(1B);23(O);4G(6.2f,A.1v(J(\'3y\',F)));A.V(J(\'2R\',F),[M,26]);H L});A.Z(J(\'6D\',F,M),G(e,f,g){e.1c();8 h=A.X();7(!6.1P){7(K.Y==6.9.N){7(6.36){A.V(J(\'13\',F),K.T-1)}H e.1X()}}7(6.1p)1J(h,6);7(I g!=\'14\'){7(6.9.1q!=\'*\'){8 i=(I f.9==\'14\')?f.9:4B(A,6);g=5E(h,6,0,i)}P{g=6.9.N}g=3V(g,6,f.9,$16)}8 j=(K.Y==0)?K.T:K.Y;7(!6.1P){7(6.9.12.1a){8 k=2H(h,6,g),i=3U(h,6,j-1)}P{8 k=6.9.N,i=6.9.N}7(g+k>j){g=j-i}}7(6.9.12.1a){8 k=4H(h,6,g,j);2O(6.9.N-g>=k&&g<K.T){g++;k=4H(h,6,g,j)}6.9.12.1U=6.9.N;6.9.N=2I(k,6,6.9.12.2o,$16)}P 7(6.9.1q!=\'*\'){8 k=3l(h,6,g);6.9.12.1U=6.9.N;6.9.N=2I(k,6,6.9.12.2o,$16)}7(6.1p)1J(h,6,L);7(g==0){e.1X();H 19(F,\'0 9 3g 1h: 21 2M.\')}19(F,\'5y \'+g+\' 9 5i.\');K.Y-=g;2O(K.Y<0){K.Y+=K.T}7(!6.1P){7(K.Y==6.9.N&&f.3W)f.3W.1x($16);7(!6.36)2P(6,K.Y,F)}7(K.T<6.9.N+g){A.X().1n(0,(6.9.N+g)-K.T).3X(L).3t(A)}8 h=A.X(),2j=4I(h,6),1Q=4J(h,6,g),24=h.1F(g-1),25=2j.2Q(),2t=1Q.2Q();7(6.1p)1J(h,6);7(6.1A){8 p=3O(1Q,6),l=p[0],2k=p[1]}P{8 l=0,2k=0}7(f.1C==\'5B\'&&6.9.12.1U<g){8 m=h.1n(6.9.12.1U,g),3Y=6.9[6.d[\'R\']];m.1L(G(){8 a=$(1e);a.1m(\'3Z\',a.1Y(\':2G\')).3u()});6.9[6.d[\'R\']]=\'1a\'}P{8 m=M}8 n=3a(h.1n(0,g),6,\'R\'),26=41(2u(1Q,6,L),6,!6.1p);7(m)6.9[6.d[\'R\']]=3Y;7(6.1A){7(6.1d[6.d[1]]<0){6.1d[6.d[1]]=0}}7(6.1p){1J(h,6,L);1J(25,6,6.1d[6.d[1]])}7(6.1A){6.1d[6.d[1]]=2k;6.1d[6.d[3]]=l}8 o={},1s=f.1g;7(f.1C==\'3R\')1s=0;P 7(1s==\'Q\')1s=6.1h.1g/6.1h.9*g;P 7(1s<=0)1s=0;P 7(1s<10)1s=n/1s;O=20(1s,f.1D);7(6[6.d[\'R\']]==\'1a\'||6[6.d[\'1t\']]==\'1a\'){O.1b.1k([$1H,26])}7(6.1p){8 q=2t.1m(\'1N\');7(2k>=0){q+=6.1d[6.d[1]]}2t.11(6.d[\'1z\'],q);7(24.4C(25).S){8 r={};r[6.d[\'1z\']]=25.1m(\'1N\');O.1b.1k([25,r])}8 s=24.1m(\'1N\');7(l>=0){s+=6.1d[6.d[3]]}8 t={};t[6.d[\'1z\']]=s;O.1b.1k([24,t])}o[6.d[\'1o\']]=-n;7(l<0){o[6.d[\'1o\']]+=l}8 u=[2j,1Q,26,1s];7(f.27)f.27.3v($16,u);1T.27=3w(1T.27,$16,u);1w(f.1C){U\'2v\':U\'28\':U\'2w\':U\'29\':O.1j=20(O.1g,O.1D);O.1I=20(O.1g,O.1D);O.1g=0;18}1w(f.1C){U\'28\':U\'2w\':U\'29\':8 v=A.3X().3t($1H);18}1w(f.1C){U\'29\':v.X().1n(6.9.12.1U).1G();18;U\'28\':U\'2w\':v.X().1n(0,g).1G();v.X().1n(6.9.N).1G();18}1w(f.1C){U\'2v\':O.1j.1b.1k([A,{\'2a\':0}]);18;U\'28\':v.11({\'2a\':0});O.1j.1b.1k([A,{\'R\':\'+=0\'},G(){v.1G()}]);O.1I.1b.1k([v,{\'2a\':1}]);18;U\'2w\':O=4D(O,A,v,6,M);18;U\'29\':O=4E(O,A,v,6,M,g);18}8 w=G(){8 b=6.9.N+g-K.T,5F=(6.1p)?6.1d[6.d[3]]:0;A.11(6.d[\'1o\'],5F);7(b>0){A.X().1n(K.T).1G()}8 c=A.X().1n(0,g).3t(A).2Q();7(b>0){1Q=2V(h,6)}7(m){m.1L(G(){8 a=$(1e);7(!a.1m(\'3Z\'))a.3x()})}7(6.1p){7(K.T<6.9.N+g){8 d=A.X().1F(6.9.N-1);d.11(6.d[\'1z\'],d.1m(\'1N\')+6.1d[6.d[3]])}c.11(6.d[\'1z\'],c.1m(\'1N\'))}O.1b=[];7(O.1j)O.1j=20(O.4F,O.1D);8 e=G(){1w(f.1C){U\'2v\':U\'28\':A.11(\'1q\',\'\');18}O.1I=20(0,2i);C.1O=M;8 a=[2j,1Q,26];7(f.1Z)f.1Z.3v($16,a);1T.1Z=3w(1T.1Z,$16,a);7(1R.S){A.V(J(1R[0][0],F),1R[0][1]);1R.5D()}7(!C.1W)A.V(J(\'1E\',F))};1w(f.1C){U\'2v\':O.1j.1b.1k([A,{\'2a\':1},e]);23(O.1j);18;U\'29\':O.1j.1b.1k([A,{\'R\':\'+=0\'},e]);23(O.1j);18;2p:e();18}};O.1b.1k([A,o,w]);C.1O=L;1B=31(1B);23(O);4G(6.2f,A.1v(J(\'3y\',F)));A.V(J(\'2R\',F),[M,26]);H L});A.Z(J(\'2S\',F),G(e,b,c,d,f,g,h){e.1c();8 v=[b,c,d,f,g,h],t=[\'1i/14/1f\',\'14\',\'1r\',\'1f\',\'1i\',\'G\'],a=33(v,t);8 f=a[3],g=a[4],h=a[5];b=3b(a[0],a[1],a[2],K,A);7(b==0)H;7(I f!=\'1f\')f=M;7(C.1O){7(I f!=\'1f\'||f.1g>0)H M}7(g!=\'13\'&&g!=\'15\'){7(6.1P){7(b<=K.T/2)g=\'15\';P g=\'13\'}P{7(K.Y==0||K.Y>b)g=\'15\';P g=\'13\'}}7(g==\'13\')b=K.T-b;A.V(J(g,F),[f,b,h]);H L});A.Z(J(\'6E\',F),G(e,a,b){e.1c();8 c=A.1v(J(\'3z\',F));H A.1v(J(\'4K\',F),[c-1,a,\'13\',b])});A.Z(J(\'6F\',F),G(e,a,b){e.1c();8 c=A.1v(J(\'3z\',F));H A.1v(J(\'4K\',F),[c+1,a,\'15\',b])});A.Z(J(\'4K\',F),G(e,a,b,c,d){e.1c();7(I a!=\'14\')a=A.1v(J(\'3z\',F));8 f=6.17.9||6.9.N,2n=1M.3i(K.T/f);7(a<0)a=2n;7(a>2n)a=0;H A.1v(J(\'2S\',F),[a*f,0,L,b,c,d])});A.Z(J(\'5G\',F),G(e,s){e.1c();7(s)s=3b(s,0,L,K,A);P s=0;s+=K.Y;7(s!=0){2O(s>K.T)s-=K.T;A.6G(A.X().1n(s,K.T))}H L});A.Z(J(\'22\',F),G(e,s){e.1c();7(s)s=4o(s);P 7(6.22)s=6.22;P H 19(F,\'59 6H 3g 22.\');8 n=A.1v(J(\'3y\',F)),x=L;1l(8 j=0,l=s.S;j<l;j++){7(!s[j][0].1v(J(\'2S\',F),[n,s[j][3],L])){x=M}}H x});A.Z(J(\'35\',F),G(e,a,b){e.1c();7(I a==\'G\'){a.1x($16,1R)}P 7(2T(a)){1R=a}P 7(I a!=\'1u\'){1R.1k([a,b])}H 1R});A.Z(J(\'6I\',F),G(e,b,c,d,f){e.1c();8 v=[b,c,d,f],t=[\'1i/1f\',\'1i/14/1f\',\'1r\',\'14\'],a=33(v,t);8 b=a[0],c=a[1],d=a[2],f=a[3];7(I b==\'1f\'&&I b.3c==\'1u\')b=$(b);7(I b==\'1i\')b=$(b);7(I b!=\'1f\'||I b.3c==\'1u\'||b.S==0)H 19(F,\'21 a 4k 1f.\');7(I c==\'1u\')c=\'42\';7(6.1p){b.1L(G(){8 m=2g($(1e).11(6.d[\'1z\']));7(2q(m))m=0;$(1e).1m(\'1N\',m)})}8 g=c,3A=\'3A\';7(c==\'42\'){7(d){7(K.Y==0){c=K.T-1;3A=\'5H\'}P{c=K.Y;K.Y+=b.S}7(c<0)c=0}P{c=K.T-1;3A=\'5H\'}}P{c=3b(c,f,d,K,A)}7(g!=\'42\'&&!d){7(c<K.Y)K.Y+=b.S}7(K.Y>=K.T)K.Y-=K.T;8 h=A.X().1F(c);7(h.S){h[3A](b)}P{A.5I(b)}K.T=A.X().S;8 i=A.1v(\'4L\');3B(6,K.T,F);2P(6,K.Y,F);A.V(J(\'4M\',F));A.V(J(\'2R\',F),[L,i]);H L});A.Z(J(\'6J\',F),G(e,b,c,d){e.1c();8 v=[b,c,d],t=[\'1i/14/1f\',\'1r\',\'14\'],a=33(v,t);8 b=a[0],c=a[1],d=a[2];7(I b==\'1u\'||b==\'42\'){A.X().2Q().1G()}P{b=3b(b,d,c,K,A);8 f=A.X().1F(b);7(f.S){7(b<K.Y)K.Y-=f.S;f.1G()}}K.T=A.X().S;8 g=A.1v(\'4L\');3B(6,K.T,F);2P(6,K.Y,F);A.V(J(\'2R\',F),[L,g]);H L});A.Z(J(\'27\',F)+\' \'+J(\'1Z\',F),G(e,a){e.1c();8 b=e.4y.4z(F.34.3s.S);7(2T(a))1T[b]=a;7(I a==\'G\')1T[b].1k(a);H 1T[b]});A.Z(J(\'5a\',F,M),G(e,a){e.1c();H A.1v(J(\'3y\',F),a)});A.Z(J(\'3y\',F),G(e,a){e.1c();7(K.Y==0)8 b=0;P 8 b=K.T-K.Y;7(I a==\'G\')a.1x($16,b);H b});A.Z(J(\'3z\',F),G(e,a){e.1c();8 b=6.17.9||6.9.N;8 c=1M.32(K.T/b-1);7(K.Y==0)8 d=0;P 7(K.Y<K.T%b)8 d=0;P 7(K.Y==b&&!6.1P)8 d=c;P 8 d=1M.6K((K.T-K.Y)/b);7(d<0)d=0;7(d>c)d=c;7(I a==\'G\')a.1x($16,d);H d});A.Z(J(\'6L\',F),G(e,a){e.1c();$i=2V(A.X(),6);7(I a==\'G\')a.1x($16,$i);H $i});A.Z(J(\'1W\',F)+\' \'+J(\'1V\',F)+\' \'+J(\'1O\',F),G(e,a){e.1c();8 b=e.4y.4z(F.34.3s.S);7(I a==\'G\')a.1x($16,C[b]);H C[b]});A.Z(J(\'5w\',F,M),G(e,a,b,c){e.1c();H A.1v(J(\'4f\',F),[a,b,c])});A.Z(J(\'4f\',F),G(e,a,b,c){e.1c();8 d=M;7(I a==\'G\'){a.1x($16,6)}P 7(I a==\'1f\'){2B=$.2c(L,{},2B,a);7(b!==M)d=L;P 6=$.2c(L,{},6,a)}P 7(I a!=\'1u\'){7(I b==\'G\'){8 f=43(\'6.\'+a);7(I f==\'1u\')f=\'\';b.1x($16,f)}P 7(I b!=\'1u\'){7(I c!==\'1r\')c=L;43(\'2B.\'+a+\' = b\');7(c!==M)d=L;P 43(\'6.\'+a+\' = b\')}P{H 43(\'6.\'+a)}}7(d){1J(A.X(),6);A.4e(2B);A.4N();8 g=44(A,6);A.V(J(\'2R\',F),[L,g])}H 6});A.Z(J(\'4M\',F),G(e,a,b){e.1c();7(I a==\'1u\'||a.S==0)a=$(\'6M\');P 7(I a==\'1i\')a=$(a);7(I a!=\'1f\')H 19(F,\'21 a 4k 1f.\');7(I b!=\'1i\'||b.S==0)b=\'a.5J\';a.6N(b).1L(G(){8 h=1e.5K||\'\';7(h.S>0&&A.X().5L($(h))!=-1){$(1e).2l(\'4O\').4O(G(e){e.2b();A.V(J(\'2S\',F),h)})}});H L});A.Z(J(\'2R\',F),G(e,b,c){e.1c();7(!6.17.1y)H;7(b){8 d=6.17.9||6.9.N,l=1M.32(K.T/d);7(6.17.2X){6.17.1y.X().1G();6.17.1y.1L(G(){1l(8 a=0;a<l;a++){8 i=A.X().1F(3b(a*d,0,L,K,A));$(1e).5I(6.17.2X(a+1,i))}})}6.17.1y.1L(G(){$(1e).X().2l(6.17.3d).1L(G(a){$(1e).Z(6.17.3d,G(e){e.2b();A.V(J(\'2S\',F),[a*d,0,L,6.17])})})})}6.17.1y.1L(G(){$(1e).X().2s(2h(\'5M\',F)).1F(A.1v(J(\'3z\',F))).2J(2h(\'5M\',F))});H L});A.Z(J(\'4L\',F),G(e){8 a=A.X(),3C=6.9.N;7(6.9.12.1a)3C=2H(a,6,0);P 7(6.9.1q!=\'*\')3C=3l(a,6,0);7(!6.1P&&K.Y!=0&&3C>K.Y){7(6.9.12.1a){8 b=3U(a,6,K.Y)-K.Y}P 7(6.9.1q!=\'*\'){8 b=5N(a,6,K.Y)-K.Y}P{b=6.9.N-K.Y}19(F,\'6O 6P-1P: 6Q \'+b+\' 9 4q.\');A.V(\'13\',b)}6.9.N=2I(3C,6,6.9.12.2o,$16);H 44(A,6)});A.Z(J(\'5b\',F,M),G(e,a){e.1c();A.V(J(\'5O\',F),a);H L});A.Z(J(\'5O\',F),G(e,a){e.1c();1B=31(1B);A.1m(\'4d\',M);A.V(J(\'5n\',F));7(a){A.V(J(\'5G\',F))}7(6.1p){1J(A.X(),6)}A.11(A.1m(\'5l\'));A.4w();A.4P();$1H.6R(A);H L})};A.4w=G(){A.2l(J(\'\',F,M))};A.4N=G(){A.4P();3B(6,K.T,F);2P(6,K.Y,F);7(6.Q.2m){8 c=3D(6.Q.2m);$1H.Z(J(\'45\',F,M),G(){A.V(J(\'2K\',F),[c[0],c[1]])}).Z(J(\'46\',F,M),G(){A.V(J(\'2N\',F))})}7(6.Q.W){6.Q.W.Z(J(6.Q.3d,F,M),G(e){e.2b();8 a=(C.1W)?\'1E\':\'2K\';A.V(J(a,F))})}7(6.13.W){6.13.W.Z(J(6.13.3d,F,M),G(e){e.2b();A.V(J(\'13\',F))});7(6.13.2m){8 c=3D(6.13.2m);6.13.W.Z(J(\'45\',F,M),G(){A.V(J(\'2K\',F),[c[0],c[1]])}).Z(J(\'46\',F,M),G(){A.V(J(\'2N\',F))})}}7(6.15.W){6.15.W.Z(J(6.15.3d,F,M),G(e){e.2b();A.V(J(\'15\',F))});7(6.15.2m){8 c=3D(6.15.2m);6.15.W.Z(J(\'45\',F,M),G(){A.V(J(\'2K\',F),[c[0],c[1]])}).Z(J(\'46\',F,M),G(){A.V(J(\'2N\',F))})}}7($.1S.2x){7(6.13.2x){7(!C.4Q){C.4Q=L;$1H.2x(G(e,a){7(a>0){e.2b();8 b=4R(6.13.2x);A.V(J(\'13\',F),b)}})}}7(6.15.2x){7(!C.4S){C.4S=L;$1H.2x(G(e,a){7(a<0){e.2b();8 b=4R(6.15.2x);A.V(J(\'15\',F),b)}})}}}7($.1S.3E){8 d=(6.13.4T)?G(){A.V(J(\'13\',F))}:2i,3F=(6.15.4T)?G(){A.V(J(\'15\',F))}:2i;7(3F||3F){7(!C.3E){C.3E=L;8 f={\'6S\':30,\'6T\':30,\'6U\':L};1w(6.2d){U\'4h\':U\'5P\':f.6V=3F;f.6W=d;18;2p:f.6X=3F;f.6Y=d}$1H.3E(f)}}}7(6.17.1y){7(6.17.2m){8 c=3D(6.17.2m);6.17.1y.Z(J(\'45\',F,M),G(){A.V(J(\'2K\',F),[c[0],c[1]])}).Z(J(\'46\',F,M),G(){A.V(J(\'2N\',F))})}}7(6.13.2y||6.15.2y){$(3G).Z(J(\'5Q\',F,M),G(e){8 k=e.5R;7(k==6.15.2y){e.2b();A.V(J(\'15\',F))}7(k==6.13.2y){e.2b();A.V(J(\'13\',F))}})}7(6.17.3P){$(3G).Z(J(\'5Q\',F,M),G(e){8 k=e.5R;7(k>=49&&k<58){k=(k-49)*6.9.N;7(k<=K.T){e.2b();A.V(J(\'2S\',F),[k,0,L,6.17])}}})}7(6.Q.1E){A.V(J(\'1E\',F),6.Q.4n)}};A.4P=G(){8 a=J(\'\',F,M);$(3G).2l(a);$1H.2l(a);7(6.Q.W)6.Q.W.2l(a);7(6.13.W)6.13.W.2l(a);7(6.15.W)6.15.W.2l(a);7(6.17.1y){6.17.1y.2l(a);7(6.17.2X){6.17.1y.X().1G()}}3B(6,\'3u\',F);2P(6,\'2s\',F)};8 C={\'2d\':\'15\',\'1W\':L,\'1O\':M,\'1V\':M,\'4S\':M,\'4Q\':M,\'3E\':M},K={\'T\':A.X().S,\'Y\':0},1B={\'6Z\':2i,\'Q\':2i,\'35\':2i,\'2L\':2r(),\'3p\':0},O={\'1V\':M,\'1g\':0,\'2L\':0,\'1D\':\'\',\'1b\':[]},1T={\'27\':[],\'1Z\':[]},1R=[],F=$.2c(L,{},$.1S.1K.5S,z),6={},2B=y,$1H=A.70(\'<\'+F.4U.4c+\' 71="\'+F.4U.5T+\'" />\').3M();F.3H=A.3H;A.4e(2B,L,B);A.5j();A.5m();A.4N();7(2T(6.9.2C)){8 D=6.9.2C}P{8 D=[];7(6.9.2C!=0){D.1k(6.9.2C)}}7(6.2f){D.72(5U(6.2f))}7(D.S>0){1l(8 a=0,l=D.S;a<l;a++){8 s=D[a];7(s==0){4V}7(s===L){s=47.73.5K;7(s.S<1){4V}}P 7(s===\'5V\'){s=1M.3i(1M.5V()*K.T)}7(A.1v(J(\'2S\',F),[s,0,L,{1C:\'3R\'}])){18}}}8 E=44(A,6,M),5W=2V(A.X(),6);7(6.5X){6.5X.1x($16,5W,E)}A.V(J(\'2R\',F),[L,E]);A.V(J(\'4M\',F));H A};$.1S.1K.4g={\'22\':M,\'36\':L,\'1P\':L,\'2d\':\'1o\',\'9\':{\'2C\':0},\'1h\':{\'1D\':\'74\',\'1g\':5f,\'2m\':M,\'2x\':M,\'4T\':M,\'3d\':\'4O\',\'35\':M}};$.1S.1K.5S={\'19\':M,\'34\':{\'3s\':\'\',\'5Y\':\'75\'},\'4U\':{\'4c\':\'76\',\'5T\':\'77\'},\'4W\':{}};$.1S.1K.5g=G(a,b){H\'<a 78="#"><5Z>\'+a+\'</5Z></a>\'};G 20(d,e){H{1b:[],1g:d,4F:d,1D:e,2L:2r()}}G 23(s){7(I s.1j==\'1f\'){23(s.1j)}1l(8 a=0,l=s.1b.S;a<l;a++){8 b=s.1b[a];7(!b)4V;7(b[3])b[0].4x();b[0].60(b[1],{61:b[2],1g:s.1g,1D:s.1D})}7(I s.1I==\'1f\'){23(s.1I)}}G 3o(s,c){7(I c!=\'1r\')c=L;7(I s.1j==\'1f\'){3o(s.1j,c)}1l(8 a=0,l=s.1b.S;a<l;a++){8 b=s.1b[a];b[0].4x(L);7(c){b[0].11(b[1]);7(I b[2]==\'G\')b[2]()}}7(I s.1I==\'1f\'){3o(s.1I,c)}}G 31(t){7(t.Q)79(t.Q);H t}G 3w(b,t,c){7(b.S){1l(8 a=0,l=b.S;a<l;a++){b[a].3v(t,c)}}H[]}G 7a(a,c,x,d,f){8 o={\'1g\':d,\'1D\':a.1D};7(I f==\'G\')o.61=f;c.60({2a:x},o)}G 4D(a,b,c,o,d){8 e=2u(4I(b.X(),o),o,L)[0],4X=2u(c.X(),o,L)[0],48=(d)?-4X:e,2z={},3e={};2z[o.d[\'R\']]=4X;2z[o.d[\'1o\']]=48;3e[o.d[\'1o\']]=0;a.1j.1b.1k([b,{\'2a\':1}]);a.1I.1b.1k([c,3e,G(){$(1e).1G()}]);c.11(2z);H a}G 4E(a,b,c,o,d,n){8 e=2u(4J(b.X(),o,n),o,L)[0],4Y=2u(c.X(),o,L)[0],48=(d)?-4Y:e,2z={},3e={};2z[o.d[\'R\']]=4Y;2z[o.d[\'1o\']]=0;3e[o.d[\'1o\']]=48;a.1I.1b.1k([c,3e,G(){$(1e).1G()}]);c.11(2z);H a}G 3B(o,t,c){7(t==\'3x\'||t==\'3u\'){8 f=t}P 7(o.9.2W>=t){19(c,\'21 5s 9: 7b 7c (\'+t+\' 9, \'+o.9.2W+\' 5t).\');8 f=\'3u\'}P{8 f=\'3x\'}8 s=(f==\'3x\')?\'2s\':\'2J\',h=2h(\'2G\',c);7(o.Q.W)o.Q.W[f]()[s](h);7(o.13.W)o.13.W[f]()[s](h);7(o.15.W)o.15.W[f]()[s](h);7(o.17.1y)o.17.1y[f]()[s](h)}G 2P(o,f,c){7(o.1P||o.36)H;8 a=(f==\'2s\'||f==\'2J\')?f:M,4a=2h(\'7d\',c);7(o.Q.W&&a){o.Q.W[a](4a)}7(o.13.W){8 b=a||(f==0)?\'2J\':\'2s\';o.13.W[b](4a)}7(o.15.W){8 b=a||(f==o.9.N)?\'2J\':\'2s\';o.15.W[b](4a)}}G 3I(a,b){7(I b==\'G\')b=b.1x(a);7(I b==\'1u\')b={};H b}G 3m(a,b,c){7(I c!=\'1i\')c=\'\';b=3I(a,b);7(I b==\'1i\'){8 d=4Z(b);7(d==-1)b=$(b);P b=d}7(c==\'17\'){7(I b==\'1r\')b={\'3P\':b};7(I b.3c!=\'1u\')b={\'1y\':b};7(I b.1y==\'G\')b.1y=b.1y.1x(a);7(I b.1y==\'1i\')b.1y=$(b.1y);7(I b.9!=\'14\')b.9=M}P 7(c==\'Q\'){7(I b.3c!=\'1u\')b={\'W\':b};7(I b==\'1r\')b={\'1E\':b};7(I b==\'14\')b={\'2Y\':b};7(I b.W==\'G\')b.W=b.W.1x(a);7(I b.W==\'1i\')b.W=$(b.W)}P{7(I b.3c!=\'1u\')b={\'W\':b};7(I b==\'14\')b={\'2y\':b};7(I b.W==\'G\')b.W=b.W.1x(a);7(I b.W==\'1i\')b.W=$(b.W);7(I b.2y==\'1i\')b.2y=4Z(b.2y)}H b}G 3b(a,b,c,d,e){7(I a==\'1i\'){7(2q(a))a=$(a);P a=2g(a)}7(I a==\'1f\'){7(I a.3c==\'1u\')a=$(a);a=e.X().5L(a);7(a==-1)a=0;7(I c!=\'1r\')c=M}P{7(I c!=\'1r\')c=L}7(2q(a))a=0;P a=2g(a);7(2q(b))b=0;P b=2g(b);7(c){a+=d.Y}a+=b;7(d.T>0){2O(a>=d.T){a-=d.T}2O(a<0){a+=d.T}}H a}G 3U(i,o,s){8 t=0,x=0;1l(8 a=s;a>=0;a--){8 j=i.1F(a);t+=(j.1Y(\':N\'))?j[o.d[\'2e\']](L):0;7(t>o.3k)H x;7(a==0)a=i.S;x++}}G 5N(i,o,s){H 51(i,o.9.1q,o.9.12.3N,s)}G 5x(i,o,s,m){H 51(i,o.9.1q,m,s)}G 51(i,f,m,s){8 t=0,x=0;1l(8 a=s,l=i.S-1;a>=0;a--){x++;7(x==l)H x;8 j=i.1F(a);7(j.1Y(f)){t++;7(t==m)H x}7(a==0)a=i.S}}G 4B(a,o){H o.9.12.3N||a.X().1n(0,o.9.N).1q(o.9.1q).S}G 2H(i,o,s){8 t=0,x=0;1l(8 a=s,l=i.S-1;a<=l;a++){8 j=i.1F(a);t+=(j.1Y(\':N\'))?j[o.d[\'2e\']](L):0;7(t>o.3k)H x;x++;7(x==l)H x;7(a==l)a=-1}}G 4H(i,o,s,l){8 v=2H(i,o,s);7(!o.1P){7(s+v>l)v=l-s}H v}G 3l(i,o,s){H 52(i,o.9.1q,o.9.12.3N,s)}G 5E(i,o,s,m){H 52(i,o.9.1q,m+1,s)-1}G 52(i,f,m,s){8 t=0,x=0;1l(8 a=s,l=i.S-1;a<=l;a++){x++;7(x==l)H x;8 j=i.1F(a);7(j.1Y(f)){t++;7(t==m)H x}7(a==l)a=-1}}G 2V(i,o){H i.1n(0,o.9.N)}G 5z(i,o,n){H i.1n(n,o.9.12.1U+n)}G 5A(i,o){H i.1n(0,o.9.N)}G 4I(i,o){H i.1n(0,o.9.12.1U)}G 4J(i,o,n){H i.1n(n,o.9.N+n)}G 1J(i,o,m){8 x=(I m==\'1r\')?m:M;7(I m!=\'14\')m=0;i.1L(G(){8 j=$(1e);8 t=2g(j.11(o.d[\'1z\']));7(2q(t))t=0;j.1m(\'62\',t);j.11(o.d[\'1z\'],((x)?j.1m(\'62\'):m+j.1m(\'1N\')))})}G 44(a,o,p){8 b=a.3M(),$i=a.X(),$v=2V($i,o),4b=41(2u($v,o,L),o,p);b.11(4b);7(o.1p){8 p=o.1d,r=p[o.d[1]];7(o.1A){7(r<0)r=0}8 c=$v.2Q();c.11(o.d[\'1z\'],c.1m(\'1N\')+r);a.11(o.d[\'2E\'],p[o.d[0]]);a.11(o.d[\'1o\'],p[o.d[3]])}a.11(o.d[\'R\'],4b[o.d[\'R\']]+(3a($i,o,\'R\')*2));a.11(o.d[\'1t\'],53($i,o,\'1t\'));H 4b}G 2u(i,o,a){8 b=3a(i,o,\'R\',a),63=53(i,o,\'1t\',a);H[b,63]}G 53(i,o,a,b){7(I b!=\'1r\')b=M;7(I o[o.d[a]]==\'14\'&&b)H o[o.d[a]];7(I o.9[o.d[a]]==\'14\')H o.9[o.d[a]];8 c=(a.54().2U(\'R\')>-1)?\'2e\':\'2D\';H 3L(i,o,c)}G 3L(i,o,b){8 s=0;1l(8 a=0,l=i.S;a<l;a++){8 j=i.1F(a);8 m=(j.1Y(\':N\'))?j[o.d[b]](L):0;7(s<m)s=m}H s}G 4j(b,o,c){7(!b.1Y(\':N\'))H 0;8 d=b[o.d[c]](),55=(o.d[c].54().2U(\'R\')>-1)?[\'7e\',\'7f\']:[\'7g\',\'7h\'];1l(8 a=0,l=55.S;a<l;a++){8 m=2g(b.11(55[a]));d-=(2q(m))?0:m}H d}G 3a(i,o,b,c){7(I c!=\'1r\')c=M;7(I o[o.d[b]]==\'14\'&&c)H o[o.d[b]];7(I o.9[o.d[b]]==\'14\')H o.9[o.d[b]]*i.S;8 d=(b.54().2U(\'R\')>-1)?\'2e\':\'2D\',s=0;1l(8 a=0,l=i.S;a<l;a++){8 j=i.1F(a);s+=(j.1Y(\':N\'))?j[o.d[d]](L):0}H s}G 4i(i,o,b){8 s=M,v=M;1l(8 a=0,l=i.S;a<l;a++){8 j=i.1F(a);8 c=(j.1Y(\':N\'))?j[o.d[b]](L):0;7(s===M)s=c;P 7(s!=c)v=L;7(s==0)v=L}H v}G J(n,c,a,b){7(I a!=\'1r\')a=L;7(I b!=\'1r\')b=L;7(a)n=c.34.3s+n;7(b)n=n+\'.\'+c.34.5Y;H n}G 2h(n,c){H(I c.4W[n]==\'1i\')?c.4W[n]:n}G 41(a,o,p){7(I p!=\'1r\')p=L;8 b=(o.1p&&p)?o.1d:[0,0,0,0];8 c={};c[o.d[\'R\']]=a[0]+b[1]+b[3];c[o.d[\'1t\']]=a[1]+b[0]+b[2];H c}G 33(c,d){8 e=[];1l(8 a=0,64=c.S;a<64;a++){1l(8 b=0,65=d.S;b<65;b++){7(d[b].2U(I c[a])>-1&&I e[b]==\'1u\'){e[b]=c[a];18}}}H e}G 5e(p){7(I p==\'1u\')H[0,0,0,0];7(I p==\'14\')H[p,p,p,p];P 7(I p==\'1i\')p=p.3f(\'7i\').66(\'\').3f(\'7j\').66(\'\').3f(\' \');7(!2T(p)){H[0,0,0,0]}1l(8 i=0;i<4;i++){p[i]=2g(p[i])}1w(p.S){U 0:H[0,0,0,0];U 1:H[p[0],p[0],p[0],p[0]];U 2:H[p[0],p[1],p[0],p[1]];U 3:H[p[0],p[1],p[2],p[1]];2p:H[p[0],p[1],p[2],p[3]]}}G 3O(a,o){8 x=(I o[o.d[\'R\']]==\'14\')?1M.32(o[o.d[\'R\']]-3a(a,o,\'R\')):0;1w(o.1A){U\'1o\':H[0,x];U\'2F\':H[x,0];U\'4l\':2p:H[1M.32(x/2),1M.3i(x/2)]}}G 3V(x,o,a,b){8 v=x;7(I a==\'G\'){v=a.1x(b,v)}P 7(I a==\'1i\'){8 p=a.3f(\'+\'),m=a.3f(\'-\');7(m.S>p.S){8 c=L,56=m[0],2A=m[1]}P{8 c=M,56=p[0],2A=p[1]}1w(56){U\'7k\':v=(x%2==1)?x-1:x;18;U\'7l\':v=(x%2==0)?x-1:x;18;2p:v=x;18}2A=2g(2A);7(!2q(2A)){7(c)2A=-2A;v+=2A}}7(I v!=\'14\')v=1;7(v<1)v=1;H v}G 2I(x,o,a,b){8 v=3V(x,o,a,b),i=o.9.12;7(I i.3h==\'14\'&&v<i.3h)v=i.3h;7(I i.2n==\'14\'&&v>i.2n)v=i.2n;7(v<1)v=1;H v}G 4o(s){7(!2T(s))s=[[s]];7(!2T(s[0]))s=[s];1l(8 j=0,l=s.S;j<l;j++){7(I s[j][0]==\'1i\')s[j][0]=$(s[j][0]);7(I s[j][1]!=\'1r\')s[j][1]=L;7(I s[j][2]!=\'1r\')s[j][2]=L;7(I s[j][3]!=\'14\')s[j][3]=0}H s}G 4Z(k){7(k==\'2F\')H 39;7(k==\'1o\')H 37;7(k==\'4h\')H 38;7(k==\'5P\')H 40;H-1}G 4G(n,v){7(n)3G.2f=n+\'=\'+v+\'; 7m=/\'}G 5U(n){n+=\'=\';8 b=3G.2f.3f(\';\');1l(8 a=0,l=b.S;a<l;a++){8 c=b[a];2O(c.7n(0)==\' \'){c=c.67(1,c.S)}7(c.2U(n)==0){H c.67(n.S,c.S)}}H 0}G 3D(p){7(p&&I p==\'1i\'){8 i=(p.2U(\'7o\')>-1)?L:M,r=(p.2U(\'2N\')>-1)?L:M}P{8 i=r=M}H[i,r]}G 4R(a){H(I a==\'14\')?a:2i}G 2T(a){H I(a)==\'1f\'&&(a 7p 7q)}G 2r(){H 7r 7s().2r()}G 19(d,m){7(I d==\'1f\'){8 s=\' (\'+d.3H+\')\';d=d.19}P{8 s=\'\'}7(!d)H M;7(I m==\'1i\')m=\'1K\'+s+\': \'+m;P m=[\'1K\'+s+\':\',m];7(47.57&&47.57.68)47.57.68(m);H M}$.1S.5J=G(o){H 1e.1K(o)}})(7t);',62,464,'||||||opts|if|var|items||||||||||||||||||||||||||||||||conf|function|return|typeof|cf_e|itms|true|false|visible|scrl|else|auto|width|length|total|case|trigger|button|children|first|bind||css|visibleConf|prev|number|next|tt0|pagination|break|debug|variable|anims|stopPropagation|padding|this|object|duration|scroll|string|pre|push|for|data|slice|left|usePadding|filter|boolean|a_dur|height|undefined|triggerHandler|switch|call|container|marginRight|align|tmrs|fx|easing|play|eq|remove|wrp|post|sz_resetMargin|carouFredSel|each|Math|cfs_origCssMargin|isScrolling|circular|c_new|queu|fn|clbk|old|isStopped|isPaused|stopImmediatePropagation|is|onAfter|sc_setScroll|Not|synchronise|sc_startScroll|l_cur|l_old|w_siz|onBefore|crossfade|uncover|opacity|preventDefault|extend|direction|outerWidth|cookie|parseInt|cf_c|null|c_old|pR|unbind|pauseOnHover|max|adjust|default|isNaN|getTime|removeClass|l_new|ms_getSizes|fade|cover|mousewheel|key|css_o|adj|opts_orig|start|outerHeight|top|right|hidden|gn_getVisibleItemsNext|cf_getItemsAdjust|addClass|pause|startTime|scrolling|resume|while|nv_enableNavi|last|updatePageStatus|slideTo|is_array|indexOf|gi_getCurrentItems|minimum|anchorBuilder|pauseDuration|Carousel||sc_clearTimers|ceil|cf_sortParams|events|queue|infinite||||ms_getTotalSize|gn_getItemIndex|jquery|event|ani_o|split|to|min|floor|of|maxDimention|gn_getVisibleItemsNextFilter|go_getNaviObject|position|sc_stopScroll|timePassed|perc|dur2|prefix|appendTo|hide|apply|sc_callCallbacks|show|currentPosition|currentPage|before|nv_showNavi|vI|bt_pauseOnHoverConfig|touchwipe|wN|document|selector|go_getObject|innerWidth|marginBottom|ms_getTrueLargestSize|parent|org|cf_getAlignPadding|keys|Number|none|stopped|100|gn_getVisibleItemsPrev|cf_getAdjust|onEnd|clone|orgW|isHidden||cf_mapWrapperSizes|end|eval|sz_setSizes|mouseenter|mouseleave|window|cur_l||di|sz|element|cfs_isCarousel|_cfs_init|configuration|defaults|up|ms_hasVariableSizes|ms_getTrueInnerSize|valid|center|bottom|delay|cf_getSynchArr|scrolled|backward|textAlign|float|marginTop|marginLeft|absolute|_cfs_unbind_events|stop|type|substr|conditions|gn_getVisibleOrg|not|fx_cover|fx_uncover|orgDuration|cf_setCookie|gn_getVisibleItemsNextTestCircular|gi_getOldItemsNext|gi_getNewItemsNext|slideToPage|updateSizes|linkAnchors|_cfs_bind_buttons|click|_cfs_unbind_buttons|mousewheelPrev|bt_mousesheelNumber|mousewheelNext|wipe|wrapper|continue|classnames|new_w|old_w|cf_getKeyCode||gn_getItemsPrevFilter|gn_getItemsNextFilter|ms_getLargestSize|toLowerCase|arr|sta|console||No|_cfs_currentPosition|_cfs_destroy|innerHeight|dx|cf_getPadding|500|pageAnchorBuilder|Item|forward|_cfs_build|fixed|cfs_origCss|_cfs_bind_events|finish|paused|onPausePause|onPauseEnd|onPauseStart|enough|needed|page|_cfs_slide_|_cfs_configuration|gn_getScrollItemsPrevFilter|Scrolling|gi_getOldItemsPrev|gi_getNewItemsPrev|directscroll|get|shift|gn_getScrollItemsNextFilter|new_m|jumpToStart|after|append|caroufredsel|hash|index|selected|gn_getVisibleItemsPrevFilter|destroy|down|keyup|keyCode|configs|classname|cf_readCookie|random|itm|onCreate|namespace|span|animate|complete|cfs_tempCssMargin|s2|l1|l2|join|substring|log|found|The|option|should|be|moved|the|second|Infinity|Set|caroufredsel_cookie_|attr|id|2500|Available|widths|heights|automatically|relative|overflow|setTimeout|or|Page|resumed|currently|Callback|returned|_cfs_slide_prev|prependTo|concat|_cfs_slide_next|prevPage|nextPage|prepend|carousel|insertItem|removeItem|round|currentVisible|body|find|Preventing|non|sliding|replaceWith|min_move_x|min_move_y|preventDefaultEvents|wipeUp|wipeDown|wipeLeft|wipeRight|timer|wrap|class|unshift|location|swing|cfs|div|caroufredsel_wrapper|href|clearTimeout|fx_fade|hiding|navigation|disabled|paddingLeft|paddingRight|paddingTop|paddingBottom|px|em|even|odd|path|charAt|immediate|instanceof|Array|new|Date|jQuery'.split('|'),0,{}));
/*
VideoJS - HTML5 Video Player
v2.0.2

This file is part of VideoJS. Copyright 2010 Zencoder, Inc.

VideoJS is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

VideoJS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with VideoJS.  If not, see <http://www.gnu.org/licenses/>.
*/

// Self-executing function to prevent global vars and help with minification
(function(window, undefined){
  var document = window.document;

// Using jresig's Class implementation http://ejohn.org/blog/simple-javascript-inheritance/
(function(){var initializing=false, fnTest=/xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/; this.JRClass = function(){}; JRClass.extend = function(prop) { var _super = this.prototype; initializing = true; var prototype = new this(); initializing = false; for (var name in prop) { prototype[name] = typeof prop[name] == "function" && typeof _super[name] == "function" && fnTest.test(prop[name]) ? (function(name, fn){ return function() { var tmp = this._super; this._super = _super[name]; var ret = fn.apply(this, arguments); this._super = tmp; return ret; }; })(name, prop[name]) : prop[name]; } function JRClass() { if ( !initializing && this.init ) this.init.apply(this, arguments); } JRClass.prototype = prototype; JRClass.constructor = JRClass; JRClass.extend = arguments.callee; return JRClass;};})();

// Video JS Player Class
var VideoJS = JRClass.extend({

  // Initialize the player for the supplied video tag element
  // element: video tag
  init: function(element, setOptions){

    // Allow an ID string or an element
    if (typeof element == 'string') {
      this.video = document.getElementById(element);
    } else {
      this.video = element;
    }
    // Store reference to player on the video element.
    // So you can acess the player later: document.getElementById("video_id").player.play();
    this.video.player = this;
    this.values = {}; // Cache video values.
    this.elements = {}; // Store refs to controls elements.

    // Default Options
    this.options = {
      autoplay: false,
      preload: true,
      useBuiltInControls: false, // Use the browser's controls (iPhone)
      controlsBelow: false, // Display control bar below video vs. in front of
      controlsAtStart: false, // Make controls visible when page loads
      controlsHiding: true, // Hide controls when not over the video
      defaultVolume: 0.85, // Will be overridden by localStorage volume if available
      playerFallbackOrder: ["html5", "flash", "links"], // Players and order to use them
      flashPlayer: "htmlObject",
      flashPlayerVersion: false // Required flash version for fallback
    };
    // Override default options with global options
    if (typeof VideoJS.options == "object") { _V_.merge(this.options, VideoJS.options); }
    // Override default & global options with options specific to this player
    if (typeof setOptions == "object") { _V_.merge(this.options, setOptions); }
    // Override preload & autoplay with video attributes
    if (this.getPreloadAttribute() !== undefined) { this.options.preload = this.getPreloadAttribute(); }
    if (this.getAutoplayAttribute() !== undefined) { this.options.autoplay = this.getAutoplayAttribute(); }

    // Store reference to embed code pieces
    this.box = this.video.parentNode;
    this.linksFallback = this.getLinksFallback();
    this.hideLinksFallback(); // Will be shown again if "links" player is used

    // Loop through the player names list in options, "html5" etc.
    // For each player name, initialize the player with that name under VideoJS.players
    // If the player successfully initializes, we're done
    // If not, try the next player in the list
    this.each(this.options.playerFallbackOrder, function(playerType){
      if (this[playerType+"Supported"]()) { // Check if player type is supported
        this[playerType+"Init"](); // Initialize player type
        return true; // Stop looping though players
      }
    });

    // Start Global Listeners - API doesn't exist before now
    this.activateElement(this, "player");
    this.activateElement(this.box, "box");
  },
  /* Behaviors
  ================================================================================ */
  behaviors: {},
  newBehavior: function(name, activate, functions){
    this.behaviors[name] = activate;
    this.extend(functions);
  },
  activateElement: function(element, behavior){
    // Allow passing and ID string
    if (typeof element == "string") { element = document.getElementById(element); }
    this.behaviors[behavior].call(this, element);
  },
  /* Errors/Warnings
  ================================================================================ */
  errors: [], // Array to track errors
  warnings: [],
  warning: function(warning){
    this.warnings.push(warning);
    this.log(warning);
  },
  /* History of errors/events (not quite there yet)
  ================================================================================ */
  history: [],
  log: function(event){
    if (!event) { return; }
    if (typeof event == "string") { event = { type: event }; }
    if (event.type) { this.history.push(event.type); }
    if (this.history.length >= 50) { this.history.shift(); }
    try { console.log(event.type); } catch(e) { try { opera.postError(event.type); } catch(e){} }
  },
  /* Local Storage
  ================================================================================ */
  setLocalStorage: function(key, value){
    if (!localStorage) { return; }
    try {
      localStorage[key] = value;
    } catch(e) {
      if (e.code == 22 || e.code == 1014) { // Webkit == 22 / Firefox == 1014
        this.warning(VideoJS.warnings.localStorageFull);
      }
    }
  },
  /* Helpers
  ================================================================================ */
  getPreloadAttribute: function(){
    if (typeof this.video.hasAttribute == "function" && this.video.hasAttribute("preload")) {
      var preload = this.video.getAttribute("preload");
      // Only included the attribute, thinking it was boolean
      if (preload === "" || preload === "true") { return "auto"; }
      if (preload === "false") { return "none"; }
      return preload;
    }
  },
  getAutoplayAttribute: function(){
    if (typeof this.video.hasAttribute == "function" && this.video.hasAttribute("autoplay")) {
      var autoplay = this.video.getAttribute("autoplay");
      if (autoplay === "false") { return false; }
      return true;
    }
  },
  // Calculates amoutn of buffer is full
  bufferedPercent: function(){ return (this.duration()) ? this.buffered()[1] / this.duration() : 0; },
  // Each that maintains player as context
  // Break if true is returned
  each: function(arr, fn){
    if (!arr || arr.length === 0) { return; }
    for (var i=0,j=arr.length; i<j; i++) {
      if (fn.call(this, arr[i], i)) { break; }
    }
  },
  extend: function(obj){
    for (var attrname in obj) {
      if (obj.hasOwnProperty(attrname)) { this[attrname]=obj[attrname]; }
    }
  }
});
VideoJS.player = VideoJS.prototype;

////////////////////////////////////////////////////////////////////////////////
// Player Types
////////////////////////////////////////////////////////////////////////////////

/* Flash Object Fallback (Player Type)
================================================================================ */
VideoJS.player.extend({
  flashSupported: function(){
    if (!this.flashElement) { this.flashElement = this.getFlashElement(); }
    // Check if object exists & Flash Player version is supported
    if (this.flashElement && this.flashPlayerVersionSupported()) {
      return true;
    } else {
      return false;
    }
  },
  flashInit: function(){
    this.replaceWithFlash();
    this.element = this.flashElement;
    this.video.src = ""; // Stop video from downloading if HTML5 is still supported
    var flashPlayerType = VideoJS.flashPlayers[this.options.flashPlayer];
    this.extend(VideoJS.flashPlayers[this.options.flashPlayer].api);
    (flashPlayerType.init.context(this))();
  },
  // Get Flash Fallback object element from Embed Code
  getFlashElement: function(){
    var children = this.video.children;
    for (var i=0,j=children.length; i<j; i++) {
      if (children[i].className == "vjs-flash-fallback") {
        return children[i];
      }
    }
  },
  // Used to force a browser to fall back when it's an HTML5 browser but there's no supported sources
  replaceWithFlash: function(){
    // this.flashElement = this.video.removeChild(this.flashElement);
    if (this.flashElement) {
      this.box.insertBefore(this.flashElement, this.video);
      this.video.style.display = "none"; // Removing it was breaking later players
    }
  },
  // Check if browser can use this flash player
  flashPlayerVersionSupported: function(){
    var playerVersion = (this.options.flashPlayerVersion) ? this.options.flashPlayerVersion : VideoJS.flashPlayers[this.options.flashPlayer].flashPlayerVersion;
    return VideoJS.getFlashVersion() >= playerVersion;
  }
});
VideoJS.flashPlayers = {};
VideoJS.flashPlayers.htmlObject = {
  flashPlayerVersion: 9,
  init: function() { return true; },
  api: { // No video API available with HTML Object embed method
    width: function(width){
      if (width !== undefined) {
        this.element.width = width;
        this.box.style.width = width+"px";
        this.triggerResizeListeners();
        return this;
      }
      return this.element.width;
    },
    height: function(height){
      if (height !== undefined) {
        this.element.height = height;
        this.box.style.height = height+"px";
        this.triggerResizeListeners();
        return this;
      }
      return this.element.height;
    }
  }
};


/* Download Links Fallback (Player Type)
================================================================================ */
VideoJS.player.extend({
  linksSupported: function(){ return true; },
  linksInit: function(){
    this.showLinksFallback();
    this.element = this.video;
  },
  // Get the download links block element
  getLinksFallback: function(){ return this.box.getElementsByTagName("P")[0]; },
  // Hide no-video download paragraph
  hideLinksFallback: function(){
    if (this.linksFallback) { this.linksFallback.style.display = "none"; }
  },
  // Hide no-video download paragraph
  showLinksFallback: function(){
    if (this.linksFallback) { this.linksFallback.style.display = "block"; }
  }
});

////////////////////////////////////////////////////////////////////////////////
// Class Methods
// Functions that don't apply to individual videos.
////////////////////////////////////////////////////////////////////////////////

// Combine Objects - Use "safe" to protect from overwriting existing items
VideoJS.merge = function(obj1, obj2, safe){
  for (var attrname in obj2){
    if (obj2.hasOwnProperty(attrname) && (!safe || !obj1.hasOwnProperty(attrname))) { obj1[attrname]=obj2[attrname]; }
  }
  return obj1;
};
VideoJS.extend = function(obj){ this.merge(this, obj, true); };

VideoJS.extend({
  // Add VideoJS to all video tags with the video-js class when the DOM is ready
  setupAllWhenReady: function(options){
    // Options is stored globally, and added ot any new player on init
    VideoJS.options = options;
    VideoJS.DOMReady(VideoJS.setup);
  },

  // Run the supplied function when the DOM is ready
  DOMReady: function(fn){
    VideoJS.addToDOMReady(fn);
  },

  // Set up a specific video or array of video elements
  // "video" can be:
  //    false, undefined, or "All": set up all videos with the video-js class
  //    A video tag ID or video tag element: set up one video and return one player
  //    An array of video tag elements/IDs: set up each and return an array of players
  setup: function(videos, options){
    var returnSingular = false,
    playerList = [],
    videoElement;

    // If videos is undefined or "All", set up all videos with the video-js class
    if (!videos || videos == "All") {
      videos = VideoJS.getVideoJSTags();
    // If videos is not an array, add to an array
    } else if (typeof videos != 'object' || videos.nodeType == 1) {
      videos = [videos];
      returnSingular = true;
    }

    // Loop through videos and create players for them
    for (var i=0; i<videos.length; i++) {
      if (typeof videos[i] == 'string') {
        videoElement = document.getElementById(videos[i]);
      } else { // assume DOM object
        videoElement = videos[i];
      }
      playerList.push(new VideoJS(videoElement, options));
    }

    // Return one or all depending on what was passed in
    return (returnSingular) ? playerList[0] : playerList;
  },

  // Find video tags with the video-js class
  getVideoJSTags: function() {
    var videoTags = document.getElementsByTagName("video"),
    videoJSTags = [], videoTag;

    for (var i=0,j=videoTags.length; i<j; i++) {
      videoTag = videoTags[i];
      if (videoTag.className.indexOf("video-js") != -1) {
        videoJSTags.push(videoTag);
      }
    }
    return videoJSTags;
  },

  // Check if the browser supports video.
  browserSupportsVideo: function() {
    if (typeof VideoJS.videoSupport != "undefined") { return VideoJS.videoSupport; }
    VideoJS.videoSupport = !!document.createElement('video').canPlayType;
    return VideoJS.videoSupport;
  },

  getFlashVersion: function(){
    // Cache Version
    if (typeof VideoJS.flashVersion != "undefined") { return VideoJS.flashVersion; }
    var version = 0, desc;
    if (typeof navigator.plugins != "undefined" && typeof navigator.plugins["Shockwave Flash"] == "object") {
      desc = navigator.plugins["Shockwave Flash"].description;
      if (desc && !(typeof navigator.mimeTypes != "undefined" && navigator.mimeTypes["application/x-shockwave-flash"] && !navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)) {
        version = parseInt(desc.match(/^.*\s+([^\s]+)\.[^\s]+\s+[^\s]+$/)[1], 10);
      }
    } else if (typeof window.ActiveXObject != "undefined") {
      try {
        var testObject = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
        if (testObject) {
          version = parseInt(testObject.GetVariable("$version").match(/^[^\s]+\s(\d+)/)[1], 10);
        }
      }
      catch(e) {}
    }
    VideoJS.flashVersion = version;
    return VideoJS.flashVersion;
  },

  // Browser & Device Checks
  isIE: function(){ return !+"\v1"; },
  isIPad: function(){ return navigator.userAgent.match(/iPad/i) !== null; },
  isIPhone: function(){ return navigator.userAgent.match(/iPhone/i) !== null; },
  isIOS: function(){ return VideoJS.isIPhone() || VideoJS.isIPad(); },
  iOSVersion: function() {
    var match = navigator.userAgent.match(/OS (\d+)_/i);
    if (match && match[1]) { return match[1]; }
  },
  isAndroid: function(){ return navigator.userAgent.match(/Android/i) !== null; },
  androidVersion: function() {
    var match = navigator.userAgent.match(/Android (\d+)\./i);
    if (match && match[1]) { return match[1]; }
  },

  warnings: {
    // Safari errors if you call functions on a video that hasn't loaded yet
    videoNotReady: "Video is not ready yet (try playing the video first).",
    // Getting a QUOTA_EXCEEDED_ERR when setting local storage occasionally
    localStorageFull: "Local Storage is Full"
  }
});

// Shim to make Video tag valid in IE
if(VideoJS.isIE()) { document.createElement("video"); }

// Expose to global
window.VideoJS = window._V_ = VideoJS;

/* HTML5 Player Type
================================================================================ */
VideoJS.player.extend({
  html5Supported: function(){
    if (VideoJS.browserSupportsVideo() && this.canPlaySource()) {
      return true;
    } else {
      return false;
    }
  },
  html5Init: function(){
    this.element = this.video;

    this.fixPreloading(); // Support old browsers that used autobuffer
    this.supportProgressEvents(); // Support browsers that don't use 'buffered'

    // Set to stored volume OR 85%
    this.volume((localStorage && localStorage.volume) || this.options.defaultVolume);

    // Update interface for device needs
    if (VideoJS.isIOS()) {
      this.options.useBuiltInControls = true;
      this.iOSInterface();
    } else if (VideoJS.isAndroid()) {
      this.options.useBuiltInControls = true;
      this.androidInterface();
    }

    // Add VideoJS Controls
    if (!this.options.useBuiltInControls) {
      this.video.controls = false;

      if (this.options.controlsBelow) { _V_.addClass(this.box, "vjs-controls-below"); }

      // Make a click on th video act as a play button
      this.activateElement(this.video, "playToggle");

      // Build Interface
      this.buildStylesCheckDiv(); // Used to check if style are loaded
      this.buildAndActivatePoster();
      this.buildBigPlayButton();
      this.buildAndActivateSpinner();
      this.buildAndActivateControlBar();
      this.loadInterface(); // Show everything once styles are loaded
      this.getSubtitles();
    }
  },
  /* Source Managemet
  ================================================================================ */
  canPlaySource: function(){
    // Cache Result
    if (this.canPlaySourceResult) { return this.canPlaySourceResult; }
    // Loop through sources and check if any can play
    var children = this.video.children;
    for (var i=0,j=children.length; i<j; i++) {
      if (children[i].tagName.toUpperCase() == "SOURCE") {
        var canPlay = this.video.canPlayType(children[i].type) || this.canPlayExt(children[i].src);
        if (canPlay == "probably" || canPlay == "maybe") {
          this.firstPlayableSource = children[i];
          this.canPlaySourceResult = true;
          return true;
        }
      }
    }
    this.canPlaySourceResult = false;
    return false;
  },
  // Check if the extention is compatible, for when type won't work
  canPlayExt: function(src){
    if (!src) { return ""; }
    var match = src.match(/\.([^\.]+)$/);
    if (match && match[1]) {
      var ext = match[1].toLowerCase();
      // Android canPlayType doesn't work
      if (VideoJS.isAndroid()) {
        if (ext == "mp4" || ext == "m4v") { return "maybe"; }
      // Allow Apple HTTP Streaming for iOS
      } else if (VideoJS.isIOS()) {
        if (ext == "m3u8") { return "maybe"; }
      }
    }
    return "";
  },
  // Force the video source - Helps fix loading bugs in a handful of devices, like the iPad/iPhone poster bug
  // And iPad/iPhone javascript include location bug. And Android type attribute bug
  forceTheSource: function(){
    this.video.src = this.firstPlayableSource.src; // From canPlaySource()
    this.video.load();
  },
  /* Device Fixes
  ================================================================================ */
  // Support older browsers that used "autobuffer"
  fixPreloading: function(){
    if (typeof this.video.hasAttribute == "function" && this.video.hasAttribute("preload") && this.video.preload != "none") {
      this.video.autobuffer = true; // Was a boolean
    } else {
      this.video.autobuffer = false;
      this.video.preload = "none";
    }
  },

  // Listen for Video Load Progress (currently does not if html file is local)
  // Buffered does't work in all browsers, so watching progress as well
  supportProgressEvents: function(e){
    _V_.addListener(this.video, 'progress', this.playerOnVideoProgress.context(this));
  },
  playerOnVideoProgress: function(event){
    this.setBufferedFromProgress(event);
  },
  setBufferedFromProgress: function(event){ // HTML5 Only
    if(event.total > 0) {
      var newBufferEnd = (event.loaded / event.total) * this.duration();
      if (newBufferEnd > this.values.bufferEnd) { this.values.bufferEnd = newBufferEnd; }
    }
  },

  iOSInterface: function(){
    if(VideoJS.iOSVersion() < 4) { this.forceTheSource(); } // Fix loading issues
    if(VideoJS.isIPad()) { // iPad could work with controlsBelow
      this.buildAndActivateSpinner(); // Spinner still works well on iPad, since iPad doesn't have one
    }
  },

  // Fix android specific quirks
  // Use built-in controls, but add the big play button, since android doesn't have one.
  androidInterface: function(){
    this.forceTheSource(); // Fix loading issues
    _V_.addListener(this.video, "click", function(){ this.play(); }); // Required to play
    this.buildBigPlayButton(); // But don't activate the normal way. Pause doesn't work right on android.
    _V_.addListener(this.bigPlayButton, "click", function(){ this.play(); }.context(this));
    this.positionBox();
    this.showBigPlayButtons();
  },
  /* Wait for styles (TODO: move to _V_)
  ================================================================================ */
  loadInterface: function(){
    if(!this.stylesHaveLoaded()) {
      // Don't want to create an endless loop either.
      if (!this.positionRetries) { this.positionRetries = 1; }
      if (this.positionRetries++ < 100) {
        setTimeout(this.loadInterface.context(this),10);
        return;
      }
    }
    this.hideStylesCheckDiv();
    this.showPoster();
    if (this.video.paused !== false) { this.showBigPlayButtons(); }
    if (this.options.controlsAtStart) { this.showControlBars(); }
    this.positionAll();
  },
  /* Control Bar
  ================================================================================ */
  buildAndActivateControlBar: function(){
    /* Creating this HTML
      <div class="vjs-controls">
        <div class="vjs-play-control">
          <span></span>
        </div>
        <div class="vjs-progress-control">
          <div class="vjs-progress-holder">
            <div class="vjs-load-progress"></div>
            <div class="vjs-play-progress"></div>
          </div>
        </div>
        <div class="vjs-time-control">
          <span class="vjs-current-time-display">00:00</span><span> / </span><span class="vjs-duration-display">00:00</span>
        </div>
        <div class="vjs-volume-control">
          <div>
            <span></span><span></span><span></span><span></span><span></span><span></span>
          </div>
        </div>
        <div class="vjs-fullscreen-control">
          <div>
            <span></span><span></span><span></span><span></span>
          </div>
        </div>
      </div>
    */

    // Create a div to hold the different controls
    this.controls = _V_.createElement("div", { className: "vjs-controls" });
    // Add the controls to the video's container
    this.box.appendChild(this.controls);
    this.activateElement(this.controls, "controlBar");
    this.activateElement(this.controls, "mouseOverVideoReporter");

    // Build the play control
    this.playControl = _V_.createElement("div", { className: "vjs-play-control", innerHTML: "<span></span>" });
    this.controls.appendChild(this.playControl);
    this.activateElement(this.playControl, "playToggle");

    // Build the progress control
    this.progressControl = _V_.createElement("div", { className: "vjs-progress-control" });
    this.controls.appendChild(this.progressControl);

    // Create a holder for the progress bars
    this.progressHolder = _V_.createElement("div", { className: "vjs-progress-holder" });
    this.progressControl.appendChild(this.progressHolder);
    this.activateElement(this.progressHolder, "currentTimeScrubber");

    // Create the loading progress display
    this.loadProgressBar = _V_.createElement("div", { className: "vjs-load-progress" });
    this.progressHolder.appendChild(this.loadProgressBar);
    this.activateElement(this.loadProgressBar, "loadProgressBar");

    // Create the playing progress display
    this.playProgressBar = _V_.createElement("div", { className: "vjs-play-progress" });
    this.progressHolder.appendChild(this.playProgressBar);
    this.activateElement(this.playProgressBar, "playProgressBar");

    // Create the progress time display (00:00 / 00:00)
    this.timeControl = _V_.createElement("div", { className: "vjs-time-control" });
    this.controls.appendChild(this.timeControl);

    // Create the current play time display
    this.currentTimeDisplay = _V_.createElement("span", { className: "vjs-current-time-display", innerHTML: "00:00" });
    this.timeControl.appendChild(this.currentTimeDisplay);
    this.activateElement(this.currentTimeDisplay, "currentTimeDisplay");

    // Add time separator
    this.timeSeparator = _V_.createElement("span", { innerHTML: " / " });
    this.timeControl.appendChild(this.timeSeparator);

    // Create the total duration display
    this.durationDisplay = _V_.createElement("span", { className: "vjs-duration-display", innerHTML: "00:00" });
    this.timeControl.appendChild(this.durationDisplay);
    this.activateElement(this.durationDisplay, "durationDisplay");

    // Create the volumne control
    this.volumeControl = _V_.createElement("div", {
      className: "vjs-volume-control",
      innerHTML: "<div><span></span><span></span><span></span><span></span><span></span><span></span></div>"
    });
    this.controls.appendChild(this.volumeControl);
    this.activateElement(this.volumeControl, "volumeScrubber");

    this.volumeDisplay = this.volumeControl.children[0];
    this.activateElement(this.volumeDisplay, "volumeDisplay");

    // Crete the fullscreen control
    this.fullscreenControl = _V_.createElement("div", {
      className: "vjs-fullscreen-control",
      innerHTML: "<div><span></span><span></span><span></span><span></span></div>"
    });
    this.controls.appendChild(this.fullscreenControl);
    this.activateElement(this.fullscreenControl, "fullscreenToggle");
  },
  /* Poster Image
  ================================================================================ */
  buildAndActivatePoster: function(){
    this.updatePosterSource();
    if (this.video.poster) {
      this.poster = document.createElement("img");
      // Add poster to video box
      this.box.appendChild(this.poster);

      // Add poster image data
      this.poster.src = this.video.poster;
      // Add poster styles
      this.poster.className = "vjs-poster";
      this.activateElement(this.poster, "poster");
    } else {
      this.poster = false;
    }
  },
  /* Big Play Button
  ================================================================================ */
  buildBigPlayButton: function(){
    /* Creating this HTML
      <div class="vjs-big-play-button"><span></span></div>
    */
    this.bigPlayButton = _V_.createElement("div", {
      className: "vjs-big-play-button",
      innerHTML: "<span></span>"
    });
    this.box.appendChild(this.bigPlayButton);
    this.activateElement(this.bigPlayButton, "bigPlayButton");
  },
  /* Spinner (Loading)
  ================================================================================ */
  buildAndActivateSpinner: function(){
    this.spinner = _V_.createElement("div", {
      className: "vjs-spinner",
      innerHTML: "<div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>"
    });
    this.box.appendChild(this.spinner);
    this.activateElement(this.spinner, "spinner");
  },
  /* Styles Check - Check if styles are loaded (move ot _V_)
  ================================================================================ */
  // Sometimes the CSS styles haven't been applied to the controls yet
  // when we're trying to calculate the height and position them correctly.
  // This causes a flicker where the controls are out of place.
  buildStylesCheckDiv: function(){
    this.stylesCheckDiv = _V_.createElement("div", { className: "vjs-styles-check" });
    this.stylesCheckDiv.style.position = "absolute";
    this.box.appendChild(this.stylesCheckDiv);
  },
  hideStylesCheckDiv: function(){ this.stylesCheckDiv.style.display = "none"; },
  stylesHaveLoaded: function(){
    if (this.stylesCheckDiv.offsetHeight != 5) {
       return false;
    } else {
      return true;
    }
  },
  /* VideoJS Box - Holds all elements
  ================================================================================ */
  positionAll: function(){
    this.positionBox();
    this.positionControlBars();
    this.positionPoster();
  },
  positionBox: function(){
    // Set width based on fullscreen or not.
    if (this.videoIsFullScreen) {
      this.box.style.width = "";
      this.element.style.height="";
      if (this.options.controlsBelow) {
        this.box.style.height = "";
        this.element.style.height = (this.box.offsetHeight - this.controls.offsetHeight) + "px";
      }
    } else {
      this.box.style.width = this.width() + "px";
      this.element.style.height=this.height()+"px";
      if (this.options.controlsBelow) {
        this.element.style.height = "";
        // this.box.style.height = this.video.offsetHeight + this.controls.offsetHeight + "px";
      }
    }
  },
  /* Subtitles
  ================================================================================ */
  getSubtitles: function(){
    var tracks = this.video.getElementsByTagName("TRACK");
    for (var i=0,j=tracks.length; i<j; i++) {
      if (tracks[i].getAttribute("kind") == "subtitles" && tracks[i].getAttribute("src")) {
        this.subtitlesSource = tracks[i].getAttribute("src");
        this.loadSubtitles();
        this.buildSubtitles();
      }
    }
  },
  loadSubtitles: function() { _V_.get(this.subtitlesSource, this.parseSubtitles.context(this)); },
  parseSubtitles: function(subText) {
    var lines = subText.split("\n"),
        line = "",
        subtitle, time, text;
    this.subtitles = [];
    this.currentSubtitle = false;
    this.lastSubtitleIndex = 0;

    for (var i=0; i<lines.length; i++) {
      line = _V_.trim(lines[i]); // Trim whitespace and linebreaks
      if (line) { // Loop until a line with content

        // First line - Number
        subtitle = {
          id: line, // Subtitle Number
          index: this.subtitles.length // Position in Array
        };

        // Second line - Time
        line = _V_.trim(lines[++i]);
        time = line.split(" --> ");
        subtitle.start = this.parseSubtitleTime(time[0]);
        subtitle.end = this.parseSubtitleTime(time[1]);

        // Additional lines - Subtitle Text
        text = [];
        for (var j=i; j<lines.length; j++) { // Loop until a blank line or end of lines
          line = _V_.trim(lines[++i]);
          if (!line) { break; }
          text.push(line);
        }
        subtitle.text = text.join('<br/>');

        // Add this subtitle
        this.subtitles.push(subtitle);
      }
    }
  },

  parseSubtitleTime: function(timeText) {
    var parts = timeText.split(':'),
        time = 0;
    // hours => seconds
    time += parseFloat(parts[0])*60*60;
    // minutes => seconds
    time += parseFloat(parts[1])*60;
    // get seconds
    var seconds = parts[2].split(/\.|,/); // Either . or ,
    time += parseFloat(seconds[0]);
    // add miliseconds
    ms = parseFloat(seconds[1]);
    if (ms) { time += ms/1000; }
    return time;
  },

  buildSubtitles: function(){
    /* Creating this HTML
      <div class="vjs-subtitles"></div>
    */
    this.subtitlesDisplay = _V_.createElement("div", { className: 'vjs-subtitles' });
    this.box.appendChild(this.subtitlesDisplay);
    this.activateElement(this.subtitlesDisplay, "subtitlesDisplay");
  },

  /* Player API - Translate functionality from player to video
  ================================================================================ */
  addVideoListener: function(type, fn){ _V_.addListener(this.video, type, fn.rEvtContext(this)); },

  play: function(){
    this.video.play();
    return this;
  },
  onPlay: function(fn){ this.addVideoListener("play", fn); return this; },

  pause: function(){
    this.video.pause();
    return this;
  },
  onPause: function(fn){ this.addVideoListener("pause", fn); return this; },
  paused: function() { return this.video.paused; },

  currentTime: function(seconds){
    if (seconds !== undefined) {
      try { this.video.currentTime = seconds; }
      catch(e) { this.warning(VideoJS.warnings.videoNotReady); }
      this.values.currentTime = seconds;
      return this;
    }
    return this.video.currentTime;
  },
  onCurrentTimeUpdate: function(fn){
    this.currentTimeListeners.push(fn);
  },

  duration: function(){
    return this.video.duration;
  },

  buffered: function(){
    // Storing values allows them be overridden by setBufferedFromProgress
    if (this.values.bufferStart === undefined) {
      this.values.bufferStart = 0;
      this.values.bufferEnd = 0;
    }
    if (this.video.buffered && this.video.buffered.length > 0) {
      var newEnd = this.video.buffered.end(0);
      if (newEnd > this.values.bufferEnd) { this.values.bufferEnd = newEnd; }
    }
    return [this.values.bufferStart, this.values.bufferEnd];
  },

  volume: function(percentAsDecimal){
    if (percentAsDecimal !== undefined) {
      // Force value to between 0 and 1
      this.values.volume = Math.max(0, Math.min(1, parseFloat(percentAsDecimal)));
      this.video.volume = this.values.volume;
      this.setLocalStorage("volume", this.values.volume);
      return this;
    }
    if (this.values.volume) { return this.values.volume; }
    return this.video.volume;
  },
  onVolumeChange: function(fn){ _V_.addListener(this.video, 'volumechange', fn.rEvtContext(this)); },

  width: function(width){
    if (width !== undefined) {
      this.video.width = width; // Not using style so it can be overridden on fullscreen.
      this.box.style.width = width+"px";
      this.triggerResizeListeners();
      return this;
    }
    return this.video.offsetWidth;
  },
  height: function(height){
    if (height !== undefined) {
      this.video.height = height;
      this.box.style.height = height+"px";
      this.triggerResizeListeners();
      return this;
    }
    return this.video.offsetHeight;
  },

  supportsFullScreen: function(){
    if(typeof this.video.webkitEnterFullScreen == 'function') {
      // Seems to be broken in Chromium/Chrome
      if (!navigator.userAgent.match("Chrome") && !navigator.userAgent.match("Mac OS X 10.5")) {
        return true;
      }
    }
    return false;
  },

  html5EnterNativeFullScreen: function(){
    try {
      this.video.webkitEnterFullScreen();
    } catch (e) {
      if (e.code == 11) { this.warning(VideoJS.warnings.videoNotReady); }
    }
    return this;
  },

  // Turn on fullscreen (window) mode
  // Real fullscreen isn't available in browsers quite yet.
  enterFullScreen: function(){
    if (this.supportsFullScreen()) {
      this.html5EnterNativeFullScreen();
    } else {
      this.enterFullWindow();
    }
  },

  exitFullScreen: function(){
    if (this.supportsFullScreen()) {
      // Shouldn't be called
    } else {
      this.exitFullWindow();
    }
  },

  enterFullWindow: function(){
    this.videoIsFullScreen = true;
    // Storing original doc overflow value to return to when fullscreen is off
    this.docOrigOverflow = document.documentElement.style.overflow;
    // Add listener for esc key to exit fullscreen
    _V_.addListener(document, "keydown", this.fullscreenOnEscKey.rEvtContext(this));
    // Add listener for a window resize
    _V_.addListener(window, "resize", this.fullscreenOnWindowResize.rEvtContext(this));
    // Hide any scroll bars
    document.documentElement.style.overflow = 'hidden';
    // Apply fullscreen styles
    _V_.addClass(this.box, "vjs-fullscreen");
    // Resize the box, controller, and poster
    this.positionAll();
  },

  // Turn off fullscreen (window) mode
  exitFullWindow: function(){
    this.videoIsFullScreen = false;
    document.removeEventListener("keydown", this.fullscreenOnEscKey, false);
    window.removeEventListener("resize", this.fullscreenOnWindowResize, false);
    // Unhide scroll bars.
    document.documentElement.style.overflow = this.docOrigOverflow;
    // Remove fullscreen styles
    _V_.removeClass(this.box, "vjs-fullscreen");
    // Resize the box, controller, and poster to original sizes
    this.positionAll();
  },

  onError: function(fn){ this.addVideoListener("error", fn); return this; },
  onEnded: function(fn){
    this.addVideoListener("ended", fn); return this;
  }
});

////////////////////////////////////////////////////////////////////////////////
// Element Behaviors
// Tell elements how to act or react
////////////////////////////////////////////////////////////////////////////////

/* Player Behaviors - How VideoJS reacts to what the video is doing.
================================================================================ */
VideoJS.player.newBehavior("player", function(player){
    this.onError(this.playerOnVideoError);
    // Listen for when the video is played
    this.onPlay(this.playerOnVideoPlay);
    this.onPlay(this.trackCurrentTime);
    // Listen for when the video is paused
    this.onPause(this.playerOnVideoPause);
    this.onPause(this.stopTrackingCurrentTime);
    // Listen for when the video ends
    this.onEnded(this.playerOnVideoEnded);
    // Set interval for load progress using buffer watching method
    // this.trackCurrentTime();
    this.trackBuffered();
    // Buffer Full
    this.onBufferedUpdate(this.isBufferFull);
  },{
    playerOnVideoError: function(event){
      this.log(event);
      this.log(this.video.error);
    },
    playerOnVideoPlay: function(event){ this.hasPlayed = true; },
    playerOnVideoPause: function(event){},
    playerOnVideoEnded: function(event){
      this.currentTime(0);
      this.pause();
    },

    /* Load Tracking -------------------------------------------------------------- */
    // Buffer watching method for load progress.
    // Used for browsers that don't support the progress event
    trackBuffered: function(){
      this.bufferedInterval = setInterval(this.triggerBufferedListeners.context(this), 500);
    },
    stopTrackingBuffered: function(){ clearInterval(this.bufferedInterval); },
    bufferedListeners: [],
    onBufferedUpdate: function(fn){
      this.bufferedListeners.push(fn);
    },
    triggerBufferedListeners: function(){
      this.isBufferFull();
      this.each(this.bufferedListeners, function(listener){
        (listener.context(this))();
      });
    },
    isBufferFull: function(){
      if (this.bufferedPercent() == 1) { this.stopTrackingBuffered(); }
    },

    /* Time Tracking -------------------------------------------------------------- */
    trackCurrentTime: function(){
      if (this.currentTimeInterval) { clearInterval(this.currentTimeInterval); }
      this.currentTimeInterval = setInterval(this.triggerCurrentTimeListeners.context(this), 100); // 42 = 24 fps
      this.trackingCurrentTime = true;
    },
    // Turn off play progress tracking (when paused or dragging)
    stopTrackingCurrentTime: function(){
      clearInterval(this.currentTimeInterval);
      this.trackingCurrentTime = false;
    },
    currentTimeListeners: [],
    // onCurrentTimeUpdate is in API section now
    triggerCurrentTimeListeners: function(late, newTime){ // FF passes milliseconds late as the first argument
      this.each(this.currentTimeListeners, function(listener){
        (listener.context(this))(newTime || this.currentTime());
      });
    },

    /* Resize Tracking -------------------------------------------------------------- */
    resizeListeners: [],
    onResize: function(fn){
      this.resizeListeners.push(fn);
    },
    // Trigger anywhere the video/box size is changed.
    triggerResizeListeners: function(){
      this.each(this.resizeListeners, function(listener){
        (listener.context(this))();
      });
    }
  }
);
/* Mouse Over Video Reporter Behaviors - i.e. Controls hiding based on mouse location
================================================================================ */
VideoJS.player.newBehavior("mouseOverVideoReporter", function(element){
    // Listen for the mouse move the video. Used to reveal the controller.
    _V_.addListener(element, "mousemove", this.mouseOverVideoReporterOnMouseMove.context(this));
    // Listen for the mouse moving out of the video. Used to hide the controller.
    _V_.addListener(element, "mouseout", this.mouseOverVideoReporterOnMouseOut.context(this));
  },{
    mouseOverVideoReporterOnMouseMove: function(){
      this.showControlBars();
      clearInterval(this.mouseMoveTimeout);
      this.mouseMoveTimeout = setTimeout(this.hideControlBars.context(this), 4000);
    },
    mouseOverVideoReporterOnMouseOut: function(event){
      // Prevent flicker by making sure mouse hasn't left the video
      var parent = event.relatedTarget;
      while (parent && parent !== this.box) {
        parent = parent.parentNode;
      }
      if (parent !== this.box) {
        this.hideControlBars();
      }
    }
  }
);
/* Mouse Over Video Reporter Behaviors - i.e. Controls hiding based on mouse location
================================================================================ */
VideoJS.player.newBehavior("box", function(element){
    this.positionBox();
    _V_.addClass(element, "vjs-paused");
    this.activateElement(element, "mouseOverVideoReporter");
    this.onPlay(this.boxOnVideoPlay);
    this.onPause(this.boxOnVideoPause);
  },{
    boxOnVideoPlay: function(){
      _V_.removeClass(this.box, "vjs-paused");
      _V_.addClass(this.box, "vjs-playing");
    },
    boxOnVideoPause: function(){
      _V_.removeClass(this.box, "vjs-playing");
      _V_.addClass(this.box, "vjs-paused");
    }
  }
);
/* Poster Image Overlay
================================================================================ */
VideoJS.player.newBehavior("poster", function(element){
    this.activateElement(element, "mouseOverVideoReporter");
    this.activateElement(element, "playButton");
    this.onPlay(this.hidePoster);
    this.onEnded(this.showPoster);
    this.onResize(this.positionPoster);
  },{
    showPoster: function(){
      if (!this.poster) { return; }
      this.poster.style.display = "block";
      this.positionPoster();
    },
    positionPoster: function(){
      // Only if the poster is visible
      if (!this.poster || this.poster.style.display == 'none') { return; }
      this.poster.style.height = this.height() + "px"; // Need incase controlsBelow
      this.poster.style.width = this.width() + "px"; // Could probably do 100% of box
    },
    hidePoster: function(){
      if (!this.poster) { return; }
      this.poster.style.display = "none";
    },
    // Update poster source from attribute or fallback image
    // iPad breaks if you include a poster attribute, so this fixes that
    updatePosterSource: function(){
      if (!this.video.poster) {
        var images = this.video.getElementsByTagName("img");
        if (images.length > 0) { this.video.poster = images[0].src; }
      }
    }
  }
);
/* Control Bar Behaviors
================================================================================ */
VideoJS.player.newBehavior("controlBar", function(element){
    if (!this.controlBars) {
      this.controlBars = [];
      this.onResize(this.positionControlBars);
    }
    this.controlBars.push(element);
    _V_.addListener(element, "mousemove", this.onControlBarsMouseMove.context(this));
    _V_.addListener(element, "mouseout", this.onControlBarsMouseOut.context(this));
  },{
    showControlBars: function(){
      if (!this.options.controlsAtStart && !this.hasPlayed) { return; }
      this.each(this.controlBars, function(bar){
        bar.style.display = "block";
      });
    },
    // Place controller relative to the video's position (now just resizing bars)
    positionControlBars: function(){
      this.updatePlayProgressBars();
      this.updateLoadProgressBars();
    },
    hideControlBars: function(){
      if (this.options.controlsHiding && !this.mouseIsOverControls) {
        this.each(this.controlBars, function(bar){
          bar.style.display = "none";
        });
      }
    },
    // Block controls from hiding when mouse is over them.
    onControlBarsMouseMove: function(){ this.mouseIsOverControls = true; },
    onControlBarsMouseOut: function(event){
      this.mouseIsOverControls = false;
    }
  }
);
/* PlayToggle, PlayButton, PauseButton Behaviors
================================================================================ */
// Play Toggle
VideoJS.player.newBehavior("playToggle", function(element){
    if (!this.elements.playToggles) {
      this.elements.playToggles = [];
      this.onPlay(this.playTogglesOnPlay);
      this.onPause(this.playTogglesOnPause);
    }
    this.elements.playToggles.push(element);
    _V_.addListener(element, "click", this.onPlayToggleClick.context(this));
  },{
    onPlayToggleClick: function(event){
      if (this.paused()) {
        this.play();
      } else {
        this.pause();
      }
    },
    playTogglesOnPlay: function(event){
      this.each(this.elements.playToggles, function(toggle){
        _V_.removeClass(toggle, "vjs-paused");
        _V_.addClass(toggle, "vjs-playing");
      });
    },
    playTogglesOnPause: function(event){
      this.each(this.elements.playToggles, function(toggle){
        _V_.removeClass(toggle, "vjs-playing");
        _V_.addClass(toggle, "vjs-paused");
      });
    }
  }
);
// Play
VideoJS.player.newBehavior("playButton", function(element){
    _V_.addListener(element, "click", this.onPlayButtonClick.context(this));
  },{
    onPlayButtonClick: function(event){ this.play(); }
  }
);
// Pause
VideoJS.player.newBehavior("pauseButton", function(element){
    _V_.addListener(element, "click", this.onPauseButtonClick.context(this));
  },{
    onPauseButtonClick: function(event){ this.pause(); }
  }
);
/* Play Progress Bar Behaviors
================================================================================ */
VideoJS.player.newBehavior("playProgressBar", function(element){
    if (!this.playProgressBars) {
      this.playProgressBars = [];
      this.onCurrentTimeUpdate(this.updatePlayProgressBars);
    }
    this.playProgressBars.push(element);
  },{
    // Ajust the play progress bar's width based on the current play time
    updatePlayProgressBars: function(newTime){
      var progress = (newTime !== undefined) ? newTime / this.duration() : this.currentTime() / this.duration();
      if (isNaN(progress)) { progress = 0; }
      this.each(this.playProgressBars, function(bar){
        if (bar.style) { bar.style.width = _V_.round(progress * 100, 2) + "%"; }
      });
    }
  }
);
/* Load Progress Bar Behaviors
================================================================================ */
VideoJS.player.newBehavior("loadProgressBar", function(element){
    if (!this.loadProgressBars) { this.loadProgressBars = []; }
    this.loadProgressBars.push(element);
    this.onBufferedUpdate(this.updateLoadProgressBars);
  },{
    updateLoadProgressBars: function(){
      this.each(this.loadProgressBars, function(bar){
        if (bar.style) { bar.style.width = _V_.round(this.bufferedPercent() * 100, 2) + "%"; }
      });
    }
  }
);

/* Current Time Display Behaviors
================================================================================ */
VideoJS.player.newBehavior("currentTimeDisplay", function(element){
    if (!this.currentTimeDisplays) {
      this.currentTimeDisplays = [];
      this.onCurrentTimeUpdate(this.updateCurrentTimeDisplays);
    }
    this.currentTimeDisplays.push(element);
  },{
    // Update the displayed time (00:00)
    updateCurrentTimeDisplays: function(newTime){
      if (!this.currentTimeDisplays) { return; }
      // Allows for smooth scrubbing, when player can't keep up.
      var time = (newTime) ? newTime : this.currentTime();
      this.each(this.currentTimeDisplays, function(dis){
        dis.innerHTML = _V_.formatTime(time);
      });
    }
  }
);

/* Duration Display Behaviors
================================================================================ */
VideoJS.player.newBehavior("durationDisplay", function(element){
    if (!this.durationDisplays) {
      this.durationDisplays = [];
      this.onCurrentTimeUpdate(this.updateDurationDisplays);
    }
    this.durationDisplays.push(element);
  },{
    updateDurationDisplays: function(){
      if (!this.durationDisplays) { return; }
      this.each(this.durationDisplays, function(dis){
        if (this.duration()) { dis.innerHTML = _V_.formatTime(this.duration()); }
      });
    }
  }
);

/* Current Time Scrubber Behaviors
================================================================================ */
VideoJS.player.newBehavior("currentTimeScrubber", function(element){
    _V_.addListener(element, "mousedown", this.onCurrentTimeScrubberMouseDown.rEvtContext(this));
  },{
    // Adjust the play position when the user drags on the progress bar
    onCurrentTimeScrubberMouseDown: function(event, scrubber){
      event.preventDefault();
      this.currentScrubber = scrubber;

      this.stopTrackingCurrentTime(); // Allows for smooth scrubbing

      this.videoWasPlaying = !this.paused();
      this.pause();

      _V_.blockTextSelection();
      this.setCurrentTimeWithScrubber(event);
      _V_.addListener(document, "mousemove", this.onCurrentTimeScrubberMouseMove.rEvtContext(this));
      _V_.addListener(document, "mouseup", this.onCurrentTimeScrubberMouseUp.rEvtContext(this));
    },
    onCurrentTimeScrubberMouseMove: function(event){ // Removeable
      this.setCurrentTimeWithScrubber(event);
    },
    onCurrentTimeScrubberMouseUp: function(event){ // Removeable
      _V_.unblockTextSelection();
      document.removeEventListener("mousemove", this.onCurrentTimeScrubberMouseMove, false);
      document.removeEventListener("mouseup", this.onCurrentTimeScrubberMouseUp, false);
      if (this.videoWasPlaying) {
        this.play();
        this.trackCurrentTime();
      }
    },
    setCurrentTimeWithScrubber: function(event){
      var newProgress = _V_.getRelativePosition(event.pageX, this.currentScrubber);
      var newTime = newProgress * this.duration();
      this.triggerCurrentTimeListeners(0, newTime); // Allows for smooth scrubbing
      // Don't let video end while scrubbing.
      if (newTime == this.duration()) { newTime = newTime - 0.1; }
      this.currentTime(newTime);
    }
  }
);
/* Volume Display Behaviors
================================================================================ */
VideoJS.player.newBehavior("volumeDisplay", function(element){
    if (!this.volumeDisplays) {
      this.volumeDisplays = [];
      this.onVolumeChange(this.updateVolumeDisplays);
    }
    this.volumeDisplays.push(element);
    this.updateVolumeDisplay(element); // Set the display to the initial volume
  },{
    // Update the volume control display
    // Unique to these default controls. Uses borders to create the look of bars.
    updateVolumeDisplays: function(){
      if (!this.volumeDisplays) { return; }
      this.each(this.volumeDisplays, function(dis){
        this.updateVolumeDisplay(dis);
      });
    },
    updateVolumeDisplay: function(display){
      var volNum = Math.ceil(this.volume() * 6);
      this.each(display.children, function(child, num){
        if (num < volNum) {
          _V_.addClass(child, "vjs-volume-level-on");
        } else {
          _V_.removeClass(child, "vjs-volume-level-on");
        }
      });
    }
  }
);
/* Volume Scrubber Behaviors
================================================================================ */
VideoJS.player.newBehavior("volumeScrubber", function(element){
    _V_.addListener(element, "mousedown", this.onVolumeScrubberMouseDown.rEvtContext(this));
  },{
    // Adjust the volume when the user drags on the volume control
    onVolumeScrubberMouseDown: function(event, scrubber){
      // event.preventDefault();
      _V_.blockTextSelection();
      this.currentScrubber = scrubber;
      this.setVolumeWithScrubber(event);
      _V_.addListener(document, "mousemove", this.onVolumeScrubberMouseMove.rEvtContext(this));
      _V_.addListener(document, "mouseup", this.onVolumeScrubberMouseUp.rEvtContext(this));
    },
    onVolumeScrubberMouseMove: function(event){
      this.setVolumeWithScrubber(event);
    },
    onVolumeScrubberMouseUp: function(event){
      this.setVolumeWithScrubber(event);
      _V_.unblockTextSelection();
      document.removeEventListener("mousemove", this.onVolumeScrubberMouseMove, false);
      document.removeEventListener("mouseup", this.onVolumeScrubberMouseUp, false);
    },
    setVolumeWithScrubber: function(event){
      var newVol = _V_.getRelativePosition(event.pageX, this.currentScrubber);
      this.volume(newVol);
    }
  }
);
/* Fullscreen Toggle Behaviors
================================================================================ */
VideoJS.player.newBehavior("fullscreenToggle", function(element){
    _V_.addListener(element, "click", this.onFullscreenToggleClick.context(this));
  },{
    // When the user clicks on the fullscreen button, update fullscreen setting
    onFullscreenToggleClick: function(event){
      if (!this.videoIsFullScreen) {
        this.enterFullScreen();
      } else {
        this.exitFullScreen();
      }
    },

    fullscreenOnWindowResize: function(event){ // Removeable
      this.positionControlBars();
    },
    // Create listener for esc key while in full screen mode
    fullscreenOnEscKey: function(event){ // Removeable
      if (event.keyCode == 27) {
        this.exitFullScreen();
      }
    }
  }
);
/* Big Play Button Behaviors
================================================================================ */
VideoJS.player.newBehavior("bigPlayButton", function(element){
    if (!this.elements.bigPlayButtons) {
      this.elements.bigPlayButtons = [];
      this.onPlay(this.bigPlayButtonsOnPlay);
      this.onEnded(this.bigPlayButtonsOnEnded);
    }
    this.elements.bigPlayButtons.push(element);
    this.activateElement(element, "playButton");
  },{
    bigPlayButtonsOnPlay: function(event){ this.hideBigPlayButtons(); },
    bigPlayButtonsOnEnded: function(event){ this.showBigPlayButtons(); },
    showBigPlayButtons: function(){
      this.each(this.elements.bigPlayButtons, function(element){
        element.style.display = "block";
      });
    },
    hideBigPlayButtons: function(){
      this.each(this.elements.bigPlayButtons, function(element){
        element.style.display = "none";
      });
    }
  }
);
/* Spinner
================================================================================ */
VideoJS.player.newBehavior("spinner", function(element){
    if (!this.spinners) {
      this.spinners = [];
      _V_.addListener(this.video, "loadeddata", this.spinnersOnVideoLoadedData.context(this));
      _V_.addListener(this.video, "loadstart", this.spinnersOnVideoLoadStart.context(this));
      _V_.addListener(this.video, "seeking", this.spinnersOnVideoSeeking.context(this));
      _V_.addListener(this.video, "seeked", this.spinnersOnVideoSeeked.context(this));
      _V_.addListener(this.video, "canplay", this.spinnersOnVideoCanPlay.context(this));
      _V_.addListener(this.video, "canplaythrough", this.spinnersOnVideoCanPlayThrough.context(this));
      _V_.addListener(this.video, "waiting", this.spinnersOnVideoWaiting.context(this));
      _V_.addListener(this.video, "stalled", this.spinnersOnVideoStalled.context(this));
      _V_.addListener(this.video, "suspend", this.spinnersOnVideoSuspend.context(this));
      _V_.addListener(this.video, "playing", this.spinnersOnVideoPlaying.context(this));
      _V_.addListener(this.video, "timeupdate", this.spinnersOnVideoTimeUpdate.context(this));
    }
    this.spinners.push(element);
  },{
    showSpinners: function(){
      this.each(this.spinners, function(spinner){
        spinner.style.display = "block";
      });
      clearInterval(this.spinnerInterval);
      this.spinnerInterval = setInterval(this.rotateSpinners.context(this), 100);
    },
    hideSpinners: function(){
      this.each(this.spinners, function(spinner){
        spinner.style.display = "none";
      });
      clearInterval(this.spinnerInterval);
    },
    spinnersRotated: 0,
    rotateSpinners: function(){
      this.each(this.spinners, function(spinner){
        // spinner.style.transform =       'scale(0.5) rotate('+this.spinnersRotated+'deg)';
        spinner.style.WebkitTransform = 'scale(0.5) rotate('+this.spinnersRotated+'deg)';
        spinner.style.MozTransform =    'scale(0.5) rotate('+this.spinnersRotated+'deg)';
      });
      if (this.spinnersRotated == 360) { this.spinnersRotated = 0; }
      this.spinnersRotated += 45;
    },
    spinnersOnVideoLoadedData: function(event){ this.hideSpinners(); },
    spinnersOnVideoLoadStart: function(event){ this.showSpinners(); },
    spinnersOnVideoSeeking: function(event){ /* this.showSpinners(); */ },
    spinnersOnVideoSeeked: function(event){ /* this.hideSpinners(); */ },
    spinnersOnVideoCanPlay: function(event){ /* this.hideSpinners(); */ },
    spinnersOnVideoCanPlayThrough: function(event){ this.hideSpinners(); },
    spinnersOnVideoWaiting: function(event){
      // Safari sometimes triggers waiting inappropriately
      // Like after video has played, any you play again.
      this.showSpinners();
    },
    spinnersOnVideoStalled: function(event){},
    spinnersOnVideoSuspend: function(event){},
    spinnersOnVideoPlaying: function(event){ this.hideSpinners(); },
    spinnersOnVideoTimeUpdate: function(event){
      // Safari sometimes calls waiting and doesn't recover
      if(this.spinner.style.display == "block") { this.hideSpinners(); }
    }
  }
);
/* Subtitles
================================================================================ */
VideoJS.player.newBehavior("subtitlesDisplay", function(element){
    if (!this.subtitleDisplays) {
      this.subtitleDisplays = [];
      this.onCurrentTimeUpdate(this.subtitleDisplaysOnVideoTimeUpdate);
      this.onEnded(function() { this.lastSubtitleIndex = 0; }.context(this));
    }
    this.subtitleDisplays.push(element);
  },{
    subtitleDisplaysOnVideoTimeUpdate: function(time){
      // Assuming all subtitles are in order by time, and do not overlap
      if (this.subtitles) {
        // If current subtitle should stay showing, don't do anything. Otherwise, find new subtitle.
        if (!this.currentSubtitle || this.currentSubtitle.start >= time || this.currentSubtitle.end < time) {
          var newSubIndex = false,
              // Loop in reverse if lastSubtitle is after current time (optimization)
              // Meaning the user is scrubbing in reverse or rewinding
              reverse = (this.subtitles[this.lastSubtitleIndex].start > time),
              // If reverse, step back 1 becase we know it's not the lastSubtitle
              i = this.lastSubtitleIndex - (reverse) ? 1 : 0;
          while (true) { // Loop until broken
            if (reverse) { // Looping in reverse
              // Stop if no more, or this subtitle ends before the current time (no earlier subtitles should apply)
              if (i < 0 || this.subtitles[i].end < time) { break; }
              // End is greater than time, so if start is less, show this subtitle
              if (this.subtitles[i].start < time) {
                newSubIndex = i;
                break;
              }
              i--;
            } else { // Looping forward
              // Stop if no more, or this subtitle starts after time (no later subtitles should apply)
              if (i >= this.subtitles.length || this.subtitles[i].start > time) { break; }
              // Start is less than time, so if end is later, show this subtitle
              if (this.subtitles[i].end > time) {
                newSubIndex = i;
                break;
              }
              i++;
            }
          }

          // Set or clear current subtitle
          if (newSubIndex !== false) {
            this.currentSubtitle = this.subtitles[newSubIndex];
            this.lastSubtitleIndex = newSubIndex;
            this.updateSubtitleDisplays(this.currentSubtitle.text);
          } else if (this.currentSubtitle) {
            this.currentSubtitle = false;
            this.updateSubtitleDisplays("");
          }
        }
      }
    },
    updateSubtitleDisplays: function(val){
      this.each(this.subtitleDisplays, function(disp){
        disp.innerHTML = val;
      });
    }
  }
);

////////////////////////////////////////////////////////////////////////////////
// Convenience Functions (mini library)
// Functions not specific to video or VideoJS and could probably be replaced with a library like jQuery
////////////////////////////////////////////////////////////////////////////////

VideoJS.extend({

  addClass: function(element, classToAdd){
    if ((" "+element.className+" ").indexOf(" "+classToAdd+" ") == -1) {
      element.className = element.className === "" ? classToAdd : element.className + " " + classToAdd;
    }
  },
  removeClass: function(element, classToRemove){
    if (element.className.indexOf(classToRemove) == -1) { return; }
    var classNames = element.className.split(/\s+/);
    classNames.splice(classNames.lastIndexOf(classToRemove),1);
    element.className = classNames.join(" ");
  },
  createElement: function(tagName, attributes){
    return this.merge(document.createElement(tagName), attributes);
  },

  // Attempt to block the ability to select text while dragging controls
  blockTextSelection: function(){
    document.body.focus();
    document.onselectstart = function () { return false; };
  },
  // Turn off text selection blocking
  unblockTextSelection: function(){ document.onselectstart = function () { return true; }; },

  // Return seconds as MM:SS
  formatTime: function(secs) {
    var seconds = Math.round(secs);
    var minutes = Math.floor(seconds / 60);
    minutes = (minutes >= 10) ? minutes : "0" + minutes;
    seconds = Math.floor(seconds % 60);
    seconds = (seconds >= 10) ? seconds : "0" + seconds;
    return minutes + ":" + seconds;
  },

  // Return the relative horizonal position of an event as a value from 0-1
  getRelativePosition: function(x, relativeElement){
    return Math.max(0, Math.min(1, (x - this.findPosX(relativeElement)) / relativeElement.offsetWidth));
  },
  // Get an objects position on the page
  findPosX: function(obj) {
    var curleft = obj.offsetLeft;
    while(obj = obj.offsetParent) {
      curleft += obj.offsetLeft;
    }
    return curleft;
  },
  getComputedStyleValue: function(element, style){
    return window.getComputedStyle(element, null).getPropertyValue(style);
  },

  round: function(num, dec) {
    if (!dec) { dec = 0; }
    return Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
  },

  addListener: function(element, type, handler){
    if (element.addEventListener) {
      element.addEventListener(type, handler, false);
    } else if (element.attachEvent) {
      element.attachEvent("on"+type, handler);
    }
  },
  removeListener: function(element, type, handler){
    if (element.removeEventListener) {
      element.removeEventListener(type, handler, false);
    } else if (element.attachEvent) {
      element.detachEvent("on"+type, handler);
    }
  },

  get: function(url, onSuccess){
    if (typeof XMLHttpRequest == "undefined") {
      XMLHttpRequest = function () {
        try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e) {}
        try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (f) {}
        try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (g) {}
        //Microsoft.XMLHTTP points to Msxml2.XMLHTTP.3.0 and is redundant
        throw new Error("This browser does not support XMLHttpRequest.");
      };
    }
    var request = new XMLHttpRequest();
    request.open("GET",url);
    request.onreadystatechange = function() {
      if (request.readyState == 4 && request.status == 200) {
        onSuccess(request.responseText);
      }
    }.context(this);
    request.send();
  },

  trim: function(string){ return string.toString().replace(/^\s+/, "").replace(/\s+$/, ""); },

  // DOM Ready functionality adapted from jQuery. http://jquery.com/
  bindDOMReady: function(){
    if (document.readyState === "complete") {
      return VideoJS.onDOMReady();
    }
    if (document.addEventListener) {
      document.addEventListener("DOMContentLoaded", VideoJS.DOMContentLoaded, false);
      window.addEventListener("load", VideoJS.onDOMReady, false);
    } else if (document.attachEvent) {
      document.attachEvent("onreadystatechange", VideoJS.DOMContentLoaded);
      window.attachEvent("onload", VideoJS.onDOMReady);
    }
  },

  DOMContentLoaded: function(){
    if (document.addEventListener) {
      document.removeEventListener( "DOMContentLoaded", VideoJS.DOMContentLoaded, false);
      VideoJS.onDOMReady();
    } else if ( document.attachEvent ) {
      if ( document.readyState === "complete" ) {
        document.detachEvent("onreadystatechange", VideoJS.DOMContentLoaded);
        VideoJS.onDOMReady();
      }
    }
  },

  // Functions to be run once the DOM is loaded
  DOMReadyList: [],
  addToDOMReady: function(fn){
    if (VideoJS.DOMIsReady) {
      fn.call(document);
    } else {
      VideoJS.DOMReadyList.push(fn);
    }
  },

  DOMIsReady: false,
  onDOMReady: function(){
    if (VideoJS.DOMIsReady) { return; }
    if (!document.body) { return setTimeout(VideoJS.onDOMReady, 13); }
    VideoJS.DOMIsReady = true;
    if (VideoJS.DOMReadyList) {
      for (var i=0; i<VideoJS.DOMReadyList.length; i++) {
        VideoJS.DOMReadyList[i].call(document);
      }
      VideoJS.DOMReadyList = null;
    }
  }
});
VideoJS.bindDOMReady();

// Allows for binding context to functions
// when using in event listeners and timeouts
Function.prototype.context = function(obj){
  var method = this,
  temp = function(){
    return method.apply(obj, arguments);
  };
  return temp;
};

// Like context, in that it creates a closure
// But insteaad keep "this" intact, and passes the var as the second argument of the function
// Need for event listeners where you need to know what called the event
// Only use with event callbacks
Function.prototype.evtContext = function(obj){
  var method = this,
  temp = function(){
    var origContext = this;
    return method.call(obj, arguments[0], origContext);
  };
  return temp;
};

// Removeable Event listener with Context
// Replaces the original function with a version that has context
// So it can be removed using the original function name.
// In order to work, a version of the function must already exist in the player/prototype
Function.prototype.rEvtContext = function(obj, funcParent){
  if (this.hasContext === true) { return this; }
  if (!funcParent) { funcParent = obj; }
  for (var attrname in funcParent) {
    if (funcParent[attrname] == this) {
      funcParent[attrname] = this.evtContext(obj);
      funcParent[attrname].hasContext = true;
      return funcParent[attrname];
    }
  }
  return this.evtContext(obj);
};

// jQuery Plugin
if (window.jQuery) {
  (function($) {
    $.fn.VideoJS = function(options) {
      this.each(function() {
        VideoJS.setup(this, options);
      });
      return this;
    };
    $.fn.player = function() {
      return this[0].player;
    };
  })(jQuery);
}


// Expose to global
window.VideoJS = window._V_ = VideoJS;

// End self-executing function
})(window);;
/*
 * jQuery Templates Plugin 1.0.0pre
 * http://github.com/jquery/jquery-tmpl
 * Requires jQuery 1.4.2
 *
 * Copyright Software Freedom Conservancy, Inc.
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 */
(function(a){var r=a.fn.domManip,d="_tmplitem",q=/^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,b={},f={},e,p={key:0,data:{}},i=0,c=0,l=[];function g(g,d,h,e){var c={data:e||(e===0||e===false)?e:d?d.data:{},_wrap:d?d._wrap:null,tmpl:null,parent:d||null,nodes:[],calls:u,nest:w,wrap:x,html:v,update:t};g&&a.extend(c,g,{nodes:[],parent:d});if(h){c.tmpl=h;c._ctnt=c._ctnt||c.tmpl(a,c);c.key=++i;(l.length?f:b)[i]=c}return c}a.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(f,d){a.fn[f]=function(n){var g=[],i=a(n),k,h,m,l,j=this.length===1&&this[0].parentNode;e=b||{};if(j&&j.nodeType===11&&j.childNodes.length===1&&i.length===1){i[d](this[0]);g=this}else{for(h=0,m=i.length;h<m;h++){c=h;k=(h>0?this.clone(true):this).get();a(i[h])[d](k);g=g.concat(k)}c=0;g=this.pushStack(g,f,i.selector)}l=e;e=null;a.tmpl.complete(l);return g}});a.fn.extend({tmpl:function(d,c,b){return a.tmpl(this[0],d,c,b)},tmplItem:function(){return a.tmplItem(this[0])},template:function(b){return a.template(b,this[0])},domManip:function(d,m,k){if(d[0]&&a.isArray(d[0])){var g=a.makeArray(arguments),h=d[0],j=h.length,i=0,f;while(i<j&&!(f=a.data(h[i++],"tmplItem")));if(f&&c)g[2]=function(b){a.tmpl.afterManip(this,b,k)};r.apply(this,g)}else r.apply(this,arguments);c=0;!e&&a.tmpl.complete(b);return this}});a.extend({tmpl:function(d,h,e,c){var i,k=!c;if(k){c=p;d=a.template[d]||a.template(null,d);f={}}else if(!d){d=c.tmpl;b[c.key]=c;c.nodes=[];c.wrapped&&n(c,c.wrapped);return a(j(c,null,c.tmpl(a,c)))}if(!d)return[];if(typeof h==="function")h=h.call(c||{});e&&e.wrapped&&n(e,e.wrapped);i=a.isArray(h)?a.map(h,function(a){return a?g(e,c,d,a):null}):[g(e,c,d,h)];return k?a(j(c,null,i)):i},tmplItem:function(b){var c;if(b instanceof a)b=b[0];while(b&&b.nodeType===1&&!(c=a.data(b,"tmplItem"))&&(b=b.parentNode));return c||p},template:function(c,b){if(b){if(typeof b==="string")b=o(b);else if(b instanceof a)b=b[0]||{};if(b.nodeType)b=a.data(b,"tmpl")||a.data(b,"tmpl",o(b.innerHTML));return typeof c==="string"?(a.template[c]=b):b}return c?typeof c!=="string"?a.template(null,c):a.template[c]||a.template(null,q.test(c)?c:a(c)):null},encode:function(a){return(""+a).split("<").join("&lt;").split(">").join("&gt;").split('"').join("&#34;").split("'").join("&#39;")}});a.extend(a.tmpl,{tag:{tmpl:{_default:{$2:"null"},open:"if($notnull_1){__=__.concat($item.nest($1,$2));}"},wrap:{_default:{$2:"null"},open:"$item.calls(__,$1,$2);__=[];",close:"call=$item.calls();__=call._.concat($item.wrap(call,__));"},each:{_default:{$2:"$index, $value"},open:"if($notnull_1){$.each($1a,function($2){with(this){",close:"}});}"},"if":{open:"if(($notnull_1) && $1a){",close:"}"},"else":{_default:{$1:"true"},open:"}else if(($notnull_1) && $1a){"},html:{open:"if($notnull_1){__.push($1a);}"},"=":{_default:{$1:"$data"},open:"if($notnull_1){__.push($.encode($1a));}"},"!":{open:""}},complete:function(){b={}},afterManip:function(f,b,d){var e=b.nodeType===11?a.makeArray(b.childNodes):b.nodeType===1?[b]:[];d.call(f,b);m(e);c++}});function j(e,g,f){var b,c=f?a.map(f,function(a){return typeof a==="string"?e.key?a.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g,"$1 "+d+'="'+e.key+'" $2'):a:j(a,e,a._ctnt)}):e;if(g)return c;c=c.join("");c.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/,function(f,c,e,d){b=a(e).get();m(b);if(c)b=k(c).concat(b);if(d)b=b.concat(k(d))});return b?b:k(c)}function k(c){var b=document.createElement("div");b.innerHTML=c;return a.makeArray(b.childNodes)}function o(b){return new Function("jQuery","$item","var $=jQuery,call,__=[],$data=$item.data;with($data){__.push('"+a.trim(b).replace(/([\\'])/g,"\\$1").replace(/[\r\t\n]/g," ").replace(/\$\{([^\}]*)\}/g,"{{= $1}}").replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,function(m,l,k,g,b,c,d){var j=a.tmpl.tag[k],i,e,f;if(!j)throw"Unknown template tag: "+k;i=j._default||[];if(c&&!/\w$/.test(b)){b+=c;c=""}if(b){b=h(b);d=d?","+h(d)+")":c?")":"";e=c?b.indexOf(".")>-1?b+h(c):"("+b+").call($item"+d:b;f=c?e:"(typeof("+b+")==='function'?("+b+").call($item):("+b+"))"}else f=e=i.$1||"null";g=h(g);return"');"+j[l?"close":"open"].split("$notnull_1").join(b?"typeof("+b+")!=='undefined' && ("+b+")!=null":"true").split("$1a").join(f).split("$1").join(e).split("$2").join(g||i.$2||"")+"__.push('"})+"');}return __;")}function n(c,b){c._wrap=j(c,true,a.isArray(b)?b:[q.test(b)?b:a(b).html()]).join("")}function h(a){return a?a.replace(/\\'/g,"'").replace(/\\\\/g,"\\"):null}function s(b){var a=document.createElement("div");a.appendChild(b.cloneNode(true));return a.innerHTML}function m(o){var n="_"+c,k,j,l={},e,p,h;for(e=0,p=o.length;e<p;e++){if((k=o[e]).nodeType!==1)continue;j=k.getElementsByTagName("*");for(h=j.length-1;h>=0;h--)m(j[h]);m(k)}function m(j){var p,h=j,k,e,m;if(m=j.getAttribute(d)){while(h.parentNode&&(h=h.parentNode).nodeType===1&&!(p=h.getAttribute(d)));if(p!==m){h=h.parentNode?h.nodeType===11?0:h.getAttribute(d)||0:0;if(!(e=b[m])){e=f[m];e=g(e,b[h]||f[h]);e.key=++i;b[i]=e}c&&o(m)}j.removeAttribute(d)}else if(c&&(e=a.data(j,"tmplItem"))){o(e.key);b[e.key]=e;h=a.data(j.parentNode,"tmplItem");h=h?h.key:0}if(e){k=e;while(k&&k.key!=h){k.nodes.push(j);k=k.parent}delete e._ctnt;delete e._wrap;a.data(j,"tmplItem",e)}function o(a){a=a+n;e=l[a]=l[a]||g(e,b[e.parent.key+n]||e.parent)}}}function u(a,d,c,b){if(!a)return l.pop();l.push({_:a,tmpl:d,item:this,data:c,options:b})}function w(d,c,b){return a.tmpl(a.template(d),c,b,this)}function x(b,d){var c=b.options||{};c.wrapped=d;return a.tmpl(a.template(b.tmpl),b.data,c,b.item)}function v(d,c){var b=this._wrap;return a.map(a(a.isArray(b)?b.join(""):b).filter(d||"*"),function(a){return c?a.innerText||a.textContent:a.outerHTML||s(a)})}function t(){var b=this.nodes;a.tmpl(null,null,null,this).insertBefore(b[0]);a(b).remove()}})(jQuery);;
/*
 * DreamWall Project Overlay
 */
(function($) {

	var DWProjectOverlay = function(element, options) {

		// Reference to object
		var self = this;
		
		// Defaults are below
		var settings = $.extend({}, $.fn.DWProjectOverlay.defaults, options);
		self.imagePath = Drupal.settings.basePath + 'sites/all/themes/dreamwall/images';

		// Useful variables. Play carefully.
		var vars = {};
		vars['selectecProjectId'] = undefined;
		vars['selectecMediaId'] = undefined;
		vars['project'] = undefined;
		
		// jQuery Object
		var $overlay = $('#overlay_wrapper');
		var $mediaObject = $('.overlay_media_object',$overlay);
		var $mediaDescription = $('.overlay_media_description',$overlay);
		var $mediaDetail = $('.overlay_media_details',$overlay);
		var $mediaList = null;
		
		// JQuery template		
		var markupMediaDetail = '<h3>' + Drupal.t('Linked media') + '</h3>' +
		'<div class="media_linked_content">' +
			'<ul class="thumbs" id="overlay_project_media_list">' +
				'<li class="movie">' +
					'<img class="loader" src="'+ self.imagePath + '/loader.gif" alt="' + Drupal.t('Loading in progress') + '" />' +
				'</li>' +
			'</ul>' +
		'</div>' +
		'<a class="project_link" href="${url}">' + Drupal.t('Project detail') + '<span class="more"><img src="'+ self.imagePath + '/icons/more.png" alt="Détail du projet" /></span></a>';		
		
		var markupMediaList = '<li class="${type}">' +
		'<div class="content">' +
			'<div class="description">' +
				'<h3>${title}</h3>' +
				'<a class="view" href="#" data-media="${nid}">' + Drupal.t('View') + '</a>' +
			'</div>' +
			'<div class="thumbnail">' +
				'<img class="thumb" src="${thumbnail_url}" alt="${title}" title="${title}" />' +
				'<a class="media_icon"><img src="'+ self.imagePath + '/icons/media_${type}.png" alt="' + Drupal.t('View') + '" /></a>' +
			'</div>' +
		'</div>' ;
		'</li>' ;
 
		// Compile markup string as a named template
		$.template( "templateMediaDetail", markupMediaDetail );
		$.template( "templateMediaList", markupMediaList );

		// Methods
		this.init = function() {
			
            $(element).closest('div.content').eq(0).click(function( e ) {
            	
                e.preventDefault();    
                if ( $(element).data('project') !== undefined ) {
                	vars['selectecProjectId'] = $(element).data('project');
                } else {
                	vars['selectecProjectId'] = $("#project_header").data('project');
                }
                vars['selectedMediaId'] = $(element).data('media');
                
                // load ajax
			    $.ajax({
				    url : Drupal.settings.basePath + 'ajax/project/' + vars['selectecProjectId'],
				    type : 'get',
				    dataType : 'json',
				    success : function(o) {
					    if (o.error == false) {
					    	vars['project'] = o.data;
					    	self.initOverlay();
					    }
				    }
			    });
                
            });
		};
		
		this.initOverlay = function () {

			// Display overlay
            $overlay.show();
			
            var project = vars['project'];
            
            // Populate Overlay
            $('.overlay_media_title h2',$overlay).html(project['title'] + ' <span>'+project['year']+'</span>');
            
            // Media Detail
            $mediaDetail.empty();
            $.tmpl('templateMediaDetail',project).appendTo($mediaDetail);
            
            // Media List
            $mediaList = $('#overlay_project_media_list');
            $mediaList.empty();            
            
            if ( project['mediaList'].length == 0 ) { 
            
            	// If no media get project image
            	$mediaObject.html('<img src="' + project['image_url'] + '" alt="' + project['title'] + '" />');
            	$('h3',$mediaDescription).text(project['title']);
            	$('p',$mediaDescription).text(project['description']);                	
            	
			} else {
            	
            	// Init mediaListObject
	            vars['mediaListObject'] = {};
	            $.each(project['mediaList'], function(key, value) {
	            	vars['mediaListObject'][value['nid']] = value; 
	            });
	            
	            // Populate media List template
	            $.tmpl('templateMediaList',project['mediaList']).appendTo($mediaList);
	            
	            // Display selected media
	            if ( vars['selectedMediaId'] == undefined ) {
	            	vars['selectedMediaId'] = project['mediaList'][0]['nid'];
	            }
	            self.loadMedia(vars['selectedMediaId']);
	            
	            $('li',$mediaList).click( function(e) {
	            	e.preventDefault();
	            	var mediaId = $('a.view',this).data('media');
	            	self.loadMedia(mediaId);
	            });
	            
	            self.loadMediaList();
            }
            
            // Close overlay
            $('.overlay_media_close, .overlay_mask',$overlay).click( function(e) {
            	e.preventDefault();
            	
            	$mediaObject.empty();
            	$mediaDetail.empty();
            	$mediaList.trigger("destroy");
            	
            	$overlay.hide();
            });
		};
		
		this.loadMedia = function ( mediaId ) {
        	var media = vars['mediaListObject'][mediaId];
        	if ( media['type'] == 'video') {
        		
        		var videoData = { poster : media['image_url'], source : media['url'], autoplay : 1 };
        		var $videoContainer = $mediaObject;
        		
        		// Display DreamWall Player
        		DWVideoPlayer($videoContainer, videoData);
        		
        	} else {
        		$mediaObject.html('<img src="' + media['image_url'] + '" alt="' + media['title'] + '" />');
        	}
            $('h3',$mediaDescription ).text(media['title']);
            $('p',$mediaDescription ).text(media['description']);            				
		};
		
		this.loadMediaList = function () {
			
			if ( $mediaList.find('li').length > 3 ){	
				
				// Add navigation
				var navigation = '<ul class="media_linked_navigation">' +
										'<li class="prev"><a href="#" title="' + Drupal.t('Previous') + '"><img src="' + self.imagePath + '/icons/top.png" alt="' + Drupal.t('Previous') + '"></a></li>' +
										'<li class="next"><a href="#" title="' + Drupal.t('Next') + '"><img src="' + self.imagePath + '/icons/bottom.png" alt="' + Drupal.t('Next') + '"></a></li>' + 
									  '</ul>' ;
				$mediaList.before(navigation);
				
				// Enable CarouFredSel
				$mediaList.carouFredSel({
					circular: false,
					infinite: false,
					width: 160,
					align: "top",
					direction: "up",
					height: 330,
					items: {
						visible: 3,
						width: 160,
						height: 110
					},
					scroll: {
						items: 3,
						easing: "swing",
						duration: 500
					},
					auto: false,
					prev: {
						button: ".media_linked_navigation .prev",
						key: "left"
					},
					next: {
						button: ".media_linked_navigation .next",
						key: "right"
					}
				});
				
			}
					
			
		};
				
		// Init
		self.init();
	};

	// Init Jquery plugins
	$.fn.DWProjectOverlay = function(options) {
		return this.each(function() {
			var element = $(this);
			if (element.data('dwProjectOverlay')) {
				return;
			}
			var dwProjectOverlay = new DWProjectOverlay(this, options);
			element.data('dwProjectOverlay', dwProjectOverlay);
		});
	};

	// Default values
	$.fn.DWProjectOverlay.defaults = {};
	
	function DWVideoPlayer ($videoPlayer, videoData) {
		
		var videoDefault = { 
			poster : 'http://video-js.zencoder.com/oceans-clip.png',
			width: 720,
			height: 405, 
			source: '',
			autoplay: 0 };
		
		var videoData = $.extend({}, videoDefault, videoData);
		
		if ( videoData.source.match(/^http:\/\/(?:www\.){0,1}vimeo\.com\/(\d+)$/) ) {
	    	
			// Vimeo
			videoData.vimeoId = videoData.source.match(/^http:\/\/(?:www\.){0,1}vimeo\.com\/(\d+)$/)[1];
			var videoPlayerMarkup = '<iframe src="http://player.vimeo.com/video/${vimeoId}?title=0&amp;byline=0&amp;portrait=0&amp;color=fd0000&amp;autoplay=${autoplay}" width="${width}" height="${height}" frameborder="0"></iframe>';

			$.template( "templateVideoPlayer", videoPlayerMarkup );
			$videoPlayer.empty();
			$.tmpl('templateVideoPlayer',videoData).appendTo($videoPlayer);			
		
		} else if ( videoData.source.match(/watch\?v=(.+)(.*)/)) {
			
			// Youtube
			videoData.youtubeId = videoData.source.match(/v=(.*)(.*)/)[0].split('=')[1];
			var videoPlayerMarkup = '<iframe width="720" height="405" src="http://www.youtube.com/embed/${youtubeId}?autoplay=${autoplay}" frameborder="0" allowfullscreen></iframe>';

			$.template( "templateVideoPlayer", videoPlayerMarkup );
			$videoPlayer.empty();
			$.tmpl('templateVideoPlayer',videoData).appendTo($videoPlayer);			
			
		} else if ( videoData.source.match(/dailymotion\.com\/video\/(.+)(.*)/)) {
			
			// Dailymotion
			videoData.dailymotionId = videoData.source.match(/video\/(.*)(.*)/)[0].split('video/')[1];
			var videoPlayerMarkup = '<iframe width="720" height="405" src="http://www.dailymotion.com/embed/video/${dailymotionId}?width=720&theme=slayer&foreground=%23FFFFFF&highlight=%23FD0000&background=%23000000&autoPlay=${autoplay}" frameborder="0"></iframe>';
			
			$.template( "templateVideoPlayer", videoPlayerMarkup );
			$videoPlayer.empty();
			$.tmpl('templateVideoPlayer',videoData).appendTo($videoPlayer);			
			
		} else if ( videoData.source.match(/\.webm$/) ) {
			
			// VideoJS
			var videoPlayerMarkup = '<div class="video-js-box dreamPlayer-css">' +
				'<video id="example_video_1" class="video-js" width="${width}" height="${height}" controls="controls" preload="auto" poster="${poster}">' +
				'<source src="${source}" type=\'video/webm; codecs="vp8, vorbis"\' />' +
				'<source src="http://video-js.zencoder.com/oceans-clip.mp4" type=\'video/mp4; codecs="avc1.42E01E, mp4a.40.2"\' />' +
			'<object id="flash_fallback_1" class="vjs-flash-fallback" width="${width}" height="${height}" type="application/x-shockwave-flash"' +
			'	data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf">' +
			'<param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" />' +
			'<param name="allowfullscreen" value="true" />' +
			'<param name="flashvars" value=\'config={"playlist":["${poster}", {"url": "http://video-js.zencoder.com/oceans-clip.mp4","autoPlay":false,"autoBuffering":true}]}\' />' +
			'<img src="${poster}" width="${width}" height="${height}" alt="Poster Image" title="No video playback capabilities." />' +
			'</object>' +
			'</video>' +
			'<object type="image/svg+xml" data="' + Drupal.settings.basePath + 'sites/all/themes/dreamwall/images/video-dreamwall-logo.svg" class="dreamLogo"  name="dreamLogo" >' +
			'<img src="' + Drupal.settings.basePath + 'sites/all/themes/dreamwall/images/video-dreamwall-logo.png" width="100" height="20" class="dreamLogo" alt="" title="DreamWall" />' +
			'</object>' +
			'</div>';
			
			$.template( "templateVideoPlayer", videoPlayerMarkup );
			$videoPlayer.empty();
			$.tmpl('templateVideoPlayer',videoData).appendTo($videoPlayer);

			$('video',$videoPlayer).VideoJS();
			if ( videoData.autoplay ) {
				$('video',$videoPlayer)[0].player.play();				
			}
			
		}	
		
	}

})(jQuery);;
(function($){
	
	jQuery.fn.groupListElement = function() {

	    var $list = $(this[0]);
	    var args = arguments[0] || {};
	    var groupClassName = args.groupClassName || 'li_group';
	    var size = args.size || 1;

	    if ( $list.length > 0 ) {

	        var wrapper = '<li class="' + groupClassName + '"><ul></ul></li>';

	        while ( $('> li[class!="' + groupClassName + '"]',$list).slice(0, size).length >= 1) {
	            $('> li[class!="' + groupClassName + '"]',$list).slice(0, size)
	                .wrapAll(wrapper);
	        }

	    }

	    return $list;

	};
	
	$(function(){
		
		opened_multiLink();
		promoBox();
		
		sticky();
		dw_news();
		dw_projects();

		// STICKY FUNCTION
		function sticky(){
			$('#sticky_box li .button').click( function(e){
				e.preventDefault();
				var sticker = $(this).parents('#sticky_box li');
				var endPosition = $(sticker).width()-31;
				if($(sticker).css('right')=='0px'){
					$(sticker).animate({
						right:-endPosition
					});
				} else {
					$(sticker).animate({
						right:0
					});
				}
			});
			$('#sticky_search_form').submit(function(){
				var actionPath = $(this).attr('action') + '/' + $(this).find('.sticky_search_keyword').val();
				$(this).attr('action',actionPath);
			});			
		}		
				
		// Clicking any item inside an activity box redirects user to detail page
		function opened_multiLink(){
			$('#activity-list').find('li').click(function(e){
				e.preventDefault();
				var clicked = e.target;
				if (!$(clicked).attr('href')){
					var url = $(this).find('h2 a').attr('href');
					if (url) window.location = url;
				}
			});
			$('.view-promobox').find('li').click(function(e){
				e.preventDefault();
				var clicked = e.target;
				if (!$(clicked).attr('href')){
					var url = $(this).find('h2 a').attr('href');
					if (url) window.location = url;
				}
			});
		}
		
		//Controls & carousel setup
		function promoBox(){
			var $promoBox = $('.promobox').eq(0);
			if ($promoBox.length > 0){
				var controls = '<div id="promoBoxControls" class="controls"></div>';
				$promoBox.find('ul.items').before(controls).cycle({timeout:5000,pause:1,pager:'#promoBoxControls'});
			}
		}
		
		// Projects
		function dw_projects(){
			
			//Activity & Date filtering
			var categorySelect = $('.portfolio .portfolio_gallery .select');
			categorySelect.hover(function(){
				$(this).find('ul').slideDown();
			},function(){
				$(this).find('ul').slideUp("fast");
			});
			
			var $thumbs = $('ul.thumbs li div.content');
			$thumbs.live({
			  mouseenter: function(){
				$(this).find('.thumbnail').animate({left:'-=140'},300);
			  },
			  mouseleave: function(){
				$(this).find('.thumbnail').animate({left:'+=140'},300);
			  }
			});
			
			var $ativityList = $('#activity-list li');
			$ativityList.live({
			  mouseenter: function(){
				$(this).find('.info > img').animate({left:'-=280'},300);
			  },
			  mouseleave: function(){
				$(this).find('.info > img').animate({left:'+=280'},300);
			  }
			});
						
			categorySelect.find('a').click(function(e){
				e.preventDefault();
				
				var list = $(this).parents('ul');
				list.prev().find('span').text($(this).text());
				list.find('li').removeClass('current');
				$(this).parent().addClass('current');
				list.hide();
				
				var current_category = $('.category_select .current a').attr('rel');
				var current_date = $('.date_select .current a').attr('rel');
				
				var url = Drupal.settings.basePath + Drupal.settings.pathPrefix + 'projects/' + current_category ;
				
				if ( current_date ) {
					url += '/' + current_date;
				}
				
				window.location = url;
			});
			
			
			$('.portfolio .thumbs_container').each(function(){
				
				var $portfolioSlider = $(this);
				
				if ( $portfolioSlider.find('li').length > 9){
					
					var imagePath = Drupal.settings.basePath + 'sites/all/themes/dreamwall/images';
					var pagination = '<ul class="portfolio_navigation">' + 
										'<li class="prev"><a href="#" title="' + Drupal.t('Previous') + '"><img alt="' + Drupal.t('Previous') + '" src="' + imagePath + '/icons/top.png" /></a></li>' +
										'<li class="next"><a href="#" title="' + Drupal.t('Next') + '"><img alt="' + Drupal.t('Next') + '" src="' + imagePath + '/icons/bottom.png" /></a></li>' + 
									 '</ul>';
					
					// Add pagination
					$portfolioSlider.before(pagination);

					// Group li.thumbs by 3
					$('ul.thumbs',$portfolioSlider).groupListElement({groupClassName: 'li_group', size : 3});
					
					// Enable CarouFredSel
					$("ul.thumbs", $portfolioSlider).carouFredSel({
						circular: false,
						infinite: false,
						width: 510,
						align: "top",
						direction: "up",
						height: 354,
						items: {
							visible: 3,
							height: 118
						},
						scroll: {
							items: 3,
							easing: "swing",
							duration: 500
						},
						auto: false,
						prev: {
							button: ".portfolio_navigation .prev",
							key: "left"
						},
						next: {
							button: ".portfolio_navigation .next",
							key: "right"
						}
					});					
					
				}				
			});
						
			//Media slider			
			$('.media_slider_container').each(function(){
				
				var $mediaSlider = $(this);
								
				if ($mediaSlider.find('li').length > 3) {
					
					// Add pagination
					var pagination = '<ul class="media_slider_navigation">' + 
									 '<li class="prev"><a href="#" title="' + Drupal.t('Previous') + '">' + Drupal.t('Previous') + '</a></li>' + 
									 '<li class="next"><a href="#" title="' + Drupal.t('Next') + '">' + Drupal.t('Next') + '</a></li>' + 
									 '</ul>';
					$mediaSlider.before(pagination);
					
					// Enable CarouselFredSel
					$('ul', $mediaSlider).carouFredSel({
						circular: false,
						infinite: false,
						width: 494,
						align: "top",
						items: 3,
						scroll: {
							items: 3,
							easing: "swing",
							duration: 1000,
							mousewheel: true
						},
						auto: false,
						prev: {
							button: ".media_slider_navigation .prev",
							key: "left"
						},
						next: {
							button: ".media_slider_navigation .next",
							key: "right"
						}
					});			
				}				
			});

			// Project Overlay
			$('a.project-overlay').DWProjectOverlay({});
		}
		
		function dw_news(){

			$('.image_container').each(function(){
				if ($(this).find('.field-items li').length > 1){
					// Add navigation
					var navigation = '<nav>' + 
									 '	<ul class="news_navigation">' + 
									 '		<li class="prev"><a href="#">Précédent</a></li>' +
									 '		<li class="next"><a href="#">Suivant</a></li>' + 
									 '	</ul>' + 
									 '	<div class="dots"></div>' +
									 '</nav>' ;
					$(this).append(navigation);
					// Enable CarouFredSel
					$('ul.field-items',this).carouFredSel({
						items: 1,
						scroll: {
							duration: 5000,
							fx: "crossfade"
						},
						auto: {
							pauseDuration: 1000,
							delay: 1000
						},
						prev: {
							button: ".news_navigation .prev a",
							key: "left"
						},
						next: {
							button: ".news_navigation .next a",
							key: "right"
						},
						pagination: ".dots"
					});
					
				}
			});
			
		}
		
		
	});
}(jQuery));;

