var Sx={Object:function(c,a){function b(){}b.prototype=c;var d=new b();if(a){Sx.mix(d,a,true)}return d},mix:function(c,b,d){for(var a in b){if(!(d&&c[a])){c[a]=b[a]}}return c},extend:function(e,d,b,a){var f=d.prototype;var c=Sx.Object(f);e.prototype=c;c.constructor=e;e.superclass=f;if(d!=Object&&f.constructor==Object.prototype.constructor){f.constructor=d}if(b){Sx.mix(c,b)}if(a){Sx.mix(e,a)}return e},Element:function(e,c){var b=window.document.createElement(e);for(var a in c){var d=Sx.Modifiers[a];if(d){d(b,c[a])}else{b.setAttribute(a,c[a])}}return b},Modifiers:{html:function(a,b){a.innerHTML=b},cls:function(a,b){Sx.addClass(a,b)},style:function(a,b){Sx.setStyle(a,b)}},_reCl:function(a){return new RegExp("(^|\\s)"+a+"(\\s|$)")},hasClass:function(b,a){return Sx._reCl(a).test(b.className)},addClass:function(b,a){if(!Sx.hasClass(b,a)){b.className+=(b.className!=""?" ":"")+a}},removeClass:function(b,a){b.className=b.className.replace(Sx._reCl(a),"$1")},changeClass:function(b,a){if(b._chgCl){Sx.removeClass(b,b._chgCl)}if(a){b._chgCl=a;Sx.addClass(b,a)}},setStyle:function(b,c){for(var a in c){b.style[a]=c[a]}},getPosition:function(a,b){var c={x:0,y:0};while(a&&a!=b){c.x+=a.offsetLeft;c.y+=a.offsetTop;a=a.offsetParent}return c},hide:function(a){a.style.display="none";return a},show:function(a){a.style.display="";return a},getElementsByClassName:function(b,a,f){var e;if(!f&&b.constructor&&b.constructor.prototype.getElementsByClassName){e=b.constructor.prototype.getElementsByClassName.call(b,a)}else{e=[];var g=Sx._reCl(a);var h=b.getElementsByTagName(f||"*");for(var c,d=0;c=h[d];d++){if(g.test(c.className)){e.push(c)}}}return e},findAll:function(c,a){var b=c.split(" ");return Sx._find(b,[a||window.document])},find:function(b,a){return this.findAll(b,a)[0]},_find:function(b,l){if(b.length==0){return l}var h=[];var g=b.shift();var e=g.split(".");for(var c,f=0;c=l[f];f++){var k;if(e[0]==""){k=Sx.getElementsByClassName(c,e[1])}else{if(e[0].charAt(0)=="#"){var a=e[0].slice(1);k=[c.getElementById(a)]}else{if(e[1]){k=Sx.getElementsByClassName(c,e[1],e[0])}else{k=c.getElementsByTagName(e[0])}}}if(!(k instanceof Array)){for(var d=0;d<k.length;d++){h.push(k[d])}}else{h.push.apply(h,k)}}return Sx._find(b,h)},replace:function(c,b){var a=c.parentNode;if(a){a.insertBefore(b,c);a.removeChild(c)}},remove:function(b){var a=b.parentNode;if(a){a.removeChild(b)}},addEvent:function(a,c,b){if(a.addEventListener){a.addEventListener(c,b,false)}else{a.attachEvent("on"+c,b)}},removeEvent:function(a,c,b){if(a.removeEventListener){a.removeEventListener(c,b,false)}else{a.detachEvent("on"+c,b)}},bind:function(a,c){var b=Array.prototype.slice.call(arguments,2);return function(){var d=b.concat(Array.prototype.slice.call(arguments,0));return a.apply(c||null,d)}},capitalize:function(a){return a.replace(/\b[a-z]/g,function(b){return b.toUpperCase()})},_xmlEntities:[["&","&amp;"],["'","&apos;"],['"',"&quot;"],["<","&lt;"],[">","&gt;"]],escapeXml:function(a){Sx._xmlEntities.forEach(function(b){a=a.replace(new RegExp(b[0],"g"),b[1])});return a},urlEncode:function(b){var c=[];for(var a in b){if(b[a]!=undefined){c.push(a+"="+encodeURIComponent(b[a]))}}return c.join("&")},doPost:function(c){var b=Sx.mix({method:"post",action:c.url},c.form);var d=window.document.body.appendChild(Sx.Element("form",b));for(var a in c.data){if(c.data[a]!=undefined){d.appendChild(Sx.Element("input",{type:"hidden",name:a,value:c.data[a]}))}}d.submit();window.document.body.removeChild(d)},buildSwfObject:function(d,c,a,e){c=c||{};e=e||{};e.flashvars=Sx.urlEncode(a);if(Sx.isIE()){c.classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";e.movie=d}else{c.data=d;c.type="application/x-shockwave-flash"}html_attrs=[];for(var b in c){html_attrs.push(b+'="'+c[b]+'"')}html_params=[];for(var b in e){html_params.push('<param name="'+b+'" value="'+e[b]+'"/>')}return"<object "+html_attrs.join(" ")+">"+html_params.join("")+"</object>"},memoize:function(b,c){var a;return function(){return(a!=undefined)?a:(a=b.call(c||window))}}};Sx.isIE=Sx.memoize(function(){return(!+"\v1")});Sx.isIE6=Sx.memoize(function(){return navigator.userAgent.match(/MSIE 6.0/)!=null});Sx.isIE7=Sx.memoize(function(){return navigator.userAgent.match(/MSIE 7.0/)!=null});Sx.isIpad=Sx.memoize(function(){return navigator.userAgent.match(/iPad/i)!=null});Sx.isMobileSafari=Sx.memoize(function(){return navigator.userAgent.match(/Apple.*Mobile.*Safari/)!=null});Sx.Array={forEach:function(c,d){for(var b=0,a=this.length;b<a;b++){c.call(d,this[b],b,this)}},map:function(d,e){var c=[];for(var b=0,a=this.length;b<a;b++){c[b]=d.call(e,this[b],b,this)}return c},filter:function(d,e){var c=[];for(var b=0,a=this.length;b<a;b++){if(d.call(e,this[b],b,this)){c.push(this[b])}}return c}};Sx.mix(Array.prototype,Sx.Array,true);Sx.Controller={addListener:function(b,a){if(!this._listeners){this._listeners=[]}this._listeners.push({listener:b,prefix:a||""});return this},removeListener:function(a){if(!this._listeners){return}this._listeners=this._listeners.filter(function(b){return b.listener!=a})},setDelegate:function(a,b){if(this._delegate){this.removeListener(this._delegate)}this.addListener(a,b);this._delegate=a;return this},fire:function(a,e){if(!this._listeners){return}for(var d,c=0;d=this._listeners[c];c++){var b="on"+Sx.capitalize(d.prefix)+Sx.capitalize(a);if(d.listener[b]){d.listener[b](this,e)}}}};Sx.Duration=function(a){this.hour=Math.floor(a/3600);this.minutes=Math.floor(a%3600/60);this.seconds=Math.floor(a%60)};Sx.Duration.prototype={reduced:function(){return(this.hour?this.hour+":":"")+String(100+this.minutes).slice(1)+":"+String(100+this.seconds).slice(1)},full:function(){return(this.hour?this.hour+"h ":"")+(this.minutes?this.minutes+"min ":"")+this.seconds+"s"}};Sx.fixUrl=function(a){if(a.search(/^https?:\/\//)<0){var d=window.location;if(a.charAt(0)!="/"){var c=d.pathname.split("/");c.pop();var b=c.join("/")+"/";if(a.slice(0,2)=="./"){a=b+a.slice(2)}else{a=b+a}}a=d.protocol+"//"+d.host+a}return a};Sx.genUid=function(d,a){d=d||32;a=a||"0z";var e=a.charCodeAt(0);a=a.charCodeAt(1)-e;var c="";for(var b=0;b<d;b++){c+=String.fromCharCode(e+Math.round(Math.random()*a))}return c};Sx.Callbacks={_idx:0,register:function(b){var a="_"+this._idx++;this[a]=function(c){b(c);delete Sx.Callbacks[a]};return"Sx.Callbacks."+a}};Sx.Get=function(c){var d=this;var e=Sx.Callbacks.register(function(g){if(!d._stopped&&c.onComplete){c.onComplete(g)}document.body.removeChild(b)});var f=c.data||{};f.t=new Date().getTime();f.callback=e;var a="?"+Sx.urlEncode(f);var b=Sx.Element("script",{src:c.url+a});document.body.appendChild(b)};Sx.Post=function(a){var d="sx_iframe_"+Sx.Callbacks._idx++;var b=Sx.Element("div",{html:'<iframe name="'+d+'" style="display:none" src=""/>'}).firstChild;document.body.appendChild(b);var c=this;Sx.addEvent(b,"load",function(){if(!c._stopped&&a.onComplete){a.onComplete()}setTimeout(function(){document.body.removeChild(b)},0)});a.form=a.form||{};a.form.target=d;Sx.doPost(a)};Sx.Get.prototype=Sx.Post.prototype={stop:function(){this._stopped=true}};Sx.Video=function(c,b){var a,d=Sx.Element("video");if(d.play){if(d.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2')){a=Sx.Html5Video}}if(!a||b){a=Sx.FlvVideo}return new a(c)};Sx.SwfManager={_uid:0,getUid:function(){return"swf"+this._uid},register:function(b){var a=this.getUid();this._uid++;this[a]=b;return"Sx.SwfManager."+a}};Sx.FlvVideo=function(a){this._delayedCalls=[];this.addListener(this);var b=Sx.buildSwfObject("http://static.stupeflix.com/player/1.0/assets/player.swf",{id:Sx.SwfManager.getUid(),width:"100%",height:"100%"},{jshandler:Sx.SwfManager.register(this)+".fire"},{allowfullscreen:"true",allowscriptaccess:"always",wmode:"transparent"});a.innerHTML=b;this._video=a.firstChild};Sx.mix(Sx.FlvVideo.prototype,Sx.Controller);Sx.mix(Sx.FlvVideo.prototype,{_callAS:function(){this._delayedCalls.push(arguments)},makeDelayedCalls:function(){this._callAS=function(){return this._video.callMethod.apply(this._video,arguments)};var a;while(a=this._delayedCalls.shift()){this._callAS.apply(this,a)}},onInit:function(){this.makeDelayedCalls()},onDurationChange:function(a,b){this._duration=b.time;this._bytesTotal=this._callAS("get","bytesTotal");this.fire("loadedMetadata");this.fire("canPlayThrough")},onLoadStateChange:function(a,b){if(b.loadState=="ready"){setTimeout(Sx.bind(function(){this.play();this.pause()},this),0)}},onBytesLoadedChange:function(a,b){this._bytesLoaded=b.bytes;this.fire("progress",this.getProgress())},onPlayingChange:function(b,c){var a=!c.playing;if(a!=this.paused){this.fire(a?"pause":"play");this.paused=a}},onCurrentTimeChange:function(a,b){this._currentTime=b.time;this.fire("timeUpdate")},onComplete:function(){this.fire("ended")},getProgress:function(){return(this._bytesLoaded/this._bytesTotal)||0},getDisplay:function(){return this._video},getDuration:function(){return this._duration||0},getCurrentTime:function(){return this._currentTime||0},isPaused:function(){return this.paused},isMuted:function(){return this._callAS("get","muted")},load:function(a){this._callAS("loadURL",a)},play:function(){this._callAS("play")},pause:function(){this._callAS("pause")},seek:function(a){this._callAS("seek",a)},mute:function(a){this._callAS("set","muted",a!=undefined?a:true)}});Sx.Html5Video=function(a){this._video=a.appendChild(Sx.Element("video"));Sx.addEvent(this._video,"loadedmetadata",Sx.bind(this.fire,this,"loadedMetadata"));Sx.addEvent(this._video,"canplaythrough",Sx.bind(this.fire,this,"canPlayThrough"));Sx.addEvent(this._video,"progress",Sx.bind(this.onProgress,this));Sx.addEvent(this._video,"play",Sx.bind(this.fire,this,"play"));Sx.addEvent(this._video,"pause",Sx.bind(this.fire,this,"pause"));Sx.addEvent(this._video,"timeupdate",Sx.bind(this.fire,this,"timeUpdate"));Sx.addEvent(this._video,"ended",Sx.bind(this.fire,this,"ended"));return this};Sx.mix(Sx.Html5Video.prototype,Sx.Controller);Sx.mix(Sx.Html5Video.prototype,{onProgress:function(){this.fire("progress",this.getProgress())},getProgress:function(){var a=this._video.buffered;return(a.length?a.end():0)/this.getDuration()},getDisplay:function(){return this._video},getCurrentTime:function(){return this._video.currentTime},getDuration:function(){return this._video.duration},isPaused:function(){return this._video.paused},isMuted:function(a){return this._video.muted},load:function(a){this._video.src=a;this._video.load()},play:function(){this._video.play()},pause:function(){this._video.pause()},seek:function(a){this._video.currentTime=a},mute:function(a){this._video.muted=(a!=undefined?a:true)}});Sx.Event=function(b){if(b instanceof Sx.Event){return b}this.event=b;this.type=b.type;this.target=b.target||b.srcElement;if(this.type.match(/(click|mouse|menu)/i)){var a=Sx.find("html");this.pageX=b.pageX||b.clientX+a.scrollLeft;this.pageY=b.pageY||b.clientY+a.scrollTop}};Sx.mix(Sx.Event.prototype,{stop:function(){return this.preventDefault().stopPropagation()},stopPropagation:function(){this.event.stopPropagation?this.event.stopPropagation():(this.event.cancelBubble=false);return this},preventDefault:function(){this.event.preventDefault?this.event.preventDefault():(this.event.returnValue=false);return this}});Sx.Drag=function(a){this.document=window.document;this.bound={dragStart:Sx.bind(this.dragStart,this),drag:Sx.bind(this.drag,this),dragEnd:Sx.bind(this.dragEnd,this)};Sx.addEvent(a,"mousedown",this.bound.dragStart)};Sx.mix(Sx.Drag.prototype,Sx.Controller);Sx.mix(Sx.Drag.prototype,{dragStart:function(a){a=new Sx.Event(a);Sx.addEvent(this.document,"mousemove",this.bound.drag);Sx.addEvent(this.document,"mouseup",this.bound.dragEnd);this.deltaX=0;this.deltaY=0;this.event=a;a.preventDefault();this.fire("dragStart",this)},drag:function(a){a=new Sx.Event(a);this.deltaX=a.pageX-this.event.pageX;this.deltaY=a.pageY-this.event.pageY;this.event=a;this.fire("drag",this);return false},dragEnd:function(a){Sx.removeEvent(this.document,"mousemove",this.bound.drag);Sx.removeEvent(this.document,"mouseup",this.bound.dragEnd);this.event=new Sx.Event(a);this.fire("dragEnd",this)}});Sx.MobilePlayer=function(b,d,a,c){this.video=Sx.Element("video",{src:c.file,poster:c.image,width:d,height:a,controls:true});b.appendChild(this.video)};Sx.Player=function(b,d,a,c){if(typeof(b)=="string"){b=window.document.getElementById(b)}if(Sx.isMobileSafari()){return new Sx.MobilePlayer(b,d,a,c)}this.view=b.appendChild(Sx.Element("div",{cls:"SxPlayer"+(Sx.isIE()?" SxPlayerIE":""),style:{width:typeof(d)=="number"?d+"px":d,height:typeof(d)=="number"?a+"px":a}}));this.options=c;this.options.file=Sx.fixUrl(c.file);this.poster=new Sx.Player.Poster(c.image);this.view.appendChild(this.poster.view);Sx.addEvent(this.poster.view,"click",Sx.bind(this.start,this))};Sx.mix(Sx.Player.prototype,Sx.Controller);Sx.mix(Sx.Player.prototype,{buildCmdBar:function(){this.cmdBar=this.view.appendChild(Sx.Element("table",{cls:"cmdBar"}));var b=this.cmdBar.appendChild(Sx.Element("tbody")).appendChild(Sx.Element("tr"));this.playBtn=b.appendChild(Sx.Element("td",{cls:"playBtn"}));Sx.addEvent(this.playBtn,"click",Sx.bind(this.onPlayBtnClicked,this));this.elapsedTime=b.appendChild(Sx.Element("td",{cls:"time eTime"}));this.pgBar=b.appendChild(Sx.Element("td",{cls:"pgBar"}));new Sx.Drag(this.pgBar).addListener(this,"seekBar");var a=this.pgBar.appendChild(Sx.Element("div",{cls:"bg"}));this.loadBar=a.appendChild(Sx.Element("div",{cls:"loadBar"}));this.readBar=a.appendChild(Sx.Element("div",{cls:"readBar"}));this.readHead=a.appendChild(Sx.Element("div",{cls:"readHead"}));this.remainingTime=b.appendChild(Sx.Element("td",{cls:"time rTime"}));this.muteBtn=b.appendChild(Sx.Element("td",{cls:"muteBtn"}));Sx.addEvent(this.muteBtn,"click",Sx.bind(this.onMuteBtnClicked,this))},buildEndSlate:function(){if(!this.options.actions){return}this.endSlate=this.view.appendChild(Sx.Element("div",{cls:"endSlate"}));var a=this.endSlate.appendChild(Sx.Element("div"));this.options.actions.forEach(function(d){var c=a.appendChild(Sx.Element("button",{html:d[0],cls:d[3]||""}));var b=d[1];if(!(b instanceof Function)){b=function(){window.top.location=d[1]}}Sx.addEvent(c,"click",b)});this.endSlate.style.display="block";a.style.marginTop=-a.offsetHeight/2+"px";this.endSlate.style.display=""},start:function(){Sx.addClass(this.view,"loading");this.view.removeChild(this.poster.view);this.video=new Sx.Video(this.view).addListener(this,"video");this.buildEndSlate();this.buildCmdBar();this.video.load(this.options.file)},onVideoLoadedMetadata:function(){Sx.removeClass(this.view,"loading");this.onVideoProgress();this.onVideoTimeUpdate();this.video.play()},onVideoPlay:function(){Sx.changeClass(this.playBtn,"pause")},onVideoPause:function(){Sx.changeClass(this.playBtn,"play")},onVideoProgress:function(b,a){this._progress=a||this.video.getProgress();this.loadBar.style.width=(this._progress*100)+"%"},onVideoTimeUpdate:function(a){if(this._seeking){return}this._refreshPgBar(this.video.getCurrentTime())},_refreshPgBar:function(b){var c=this.video.getDuration();var a=Math.round(100*b/c)+"%";this.readHead.style.left=this.readBar.style.width=a;this.elapsedTime.innerHTML=new Sx.Duration(b).reduced();this.remainingTime.innerHTML="-"+new Sx.Duration(c-b).reduced()},onVideoEnded:function(){this._ended=true;this.video.pause();Sx.addClass(this.view,"ended")},onVideoLeaveEndSlate:function(){this._ended=false;Sx.removeClass(this.view,"ended")},onPlayBtnClicked:function(){if(this._ended){this.onVideoLeaveEndSlate();this.video.seek(0);this._refreshPgBar(0)}if(this.video.isPaused()){this.video.play()}else{this.video.pause()}},onSeekBarDragStart:function(a){this._seeking=true;(this._seekPlaying=this._ended||!this.video.isPaused())&&this.video.pause();Sx.addClass(this.view,"seeking");var b=Sx.getPosition(this.pgBar);this._x=a.event.pageX-b.x;this.onSeekBarDrag(a)},onSeekBarDrag:function(a){this._x+=a.deltaX;var b=Math.min(Math.max(this._x/this.pgBar.offsetWidth,0),this._progress);var c=b*this.video.getDuration();if(b<1){this.onVideoLeaveEndSlate()}this.video.seek(c);this._refreshPgBar(c)},onSeekBarDragEnd:function(){this._seeking=false;Sx.removeClass(this.view,"seeking");if(!this._ended&&this._seekPlaying){this.video.play()}},onMuteBtnClicked:function(){var a=this.video.isMuted();Sx[a?"removeClass":"addClass"](this.view,"muted");this.video.mute(!a)}});Sx.Player.Poster=function(a){this.view=Sx.Element("div",{cls:"poster"});this.image=this.view.appendChild(Sx.Element("img"));this.view.appendChild(Sx.Element("div"));Sx.addEvent(this.image,"load",Sx.bind(this.onImageLoaded,this));this.setImage(a)};Sx.mix(Sx.Player.Poster.prototype,{setImage:function(a){Sx.addClass(this.view,"loading");this.image.src=a},onImageLoaded:function(){Sx.removeClass(this.view,"loading");this.image.style[this.image.offsetWidth>this.image.offsetHeight?"height":"width"]="100%"}});
