
if(!WWESL){var WWESL={};}
WWESL.AdController=Class.create(Base,{initialize:function(application){this.CLASS_NAME='AdController';this.application=application;this.bannerUrl=WWESL_CONFIG.get('applicationUrls').doubleClickAd;this.dbPreRollUrl=WWESL_CONFIG.get('applicationUrls').doubleClickPreRoll||WWESL_CONFIG.get('doubleClickPreRoll');this.siteName=WWESL_CONFIG.get('siteName');this.zoneName=WWESL_CONFIG.get('zoneName');this.setup();this.initEvents();},setup:function(){this.adFrame=document.getElementById('bannerAdFrame');this.adFrame.style.display='block';},initEvents:function(){this.subscribe('CategoryLoaded',this.reload.bind(this));this.subscribe('PageSelected',this.reload.bind(this));this.subscribe('VideoLoaded',this.getPreRoll.bind(this));this.subscribe('VideoStarted',this.syncBanner.bind(this));},reload:function(event){var params={};if(event.category){params=event.category.adParams;if(event.category.adParams&&event.category.adParams.zoneName){this.zoneName=event.category.adParams.zoneName;}}else if(event.video){params=event.video.adParams;}else if(event.params){params=event.params;}
this.adFrame.src=this.getBannerUrl(params);},reloadWithUrl:function(url){this.adFrame.src=url;},getBannerUrl:function(params){var url=this.bannerUrl;if(this.zoneName){url+=this.zoneName;}
url+=this.compileParams(params);return url+this.getOrd();},compileParams:function(params){var pieces=[];for(var prop in params){if(prop!=='zoneName'){if(typeof params[prop]!=='string'){for(var i=0,j=params[prop].length;i<j;i++){pieces[pieces.length]=prop+'='+params[prop][i];}}else{pieces[pieces.length]=prop+'='+params[prop];}}}
return';'+pieces.join(';');},getOrd:function(){return';ord='+Math.round(Math.random()*100000000);},getPreRoll:function(event){this.video=event.video;var url=this.dbPreRollUrl;if(this.zoneName){url+=this.zoneName;}
if(this.video.adParams){url+=this.compileParams(this.video.adParams);}
url+=';tile=1';url+=this.getOrd();this.application.communicator.loadScript(url,'adCallback',function(params){this.checkForLC(params);}.bind(this));this.waitingForResponse=true;setTimeout(function(){if(this.waitingForResponse){window.adCallback=function(){};window.lcCallback=function(){};this.broadcast('PreRollLoaded',{video:this.video});}
this.waitingForResponse=false;}.bind(this),20000);},checkForLC:function(params){if(params.bannerURL.indexOf('.asx')!=-1||params.bannerURL.indexOf('lightningcast.com')!=-1){this.log('DoubleClick returned an embedded playlist for LightningCast!');window.lcCallback=function(params){this.waitingForResponse=false;params.video=this.video;this.broadcast('PreRollLoaded',params);}.bind(this);this.sendLCRequest(params.bannerURL);}else{this.waitingForResponse=false;params.video=this.video;this.broadcast('PreRollLoaded',params);}},sendLCRequest:function(url){try{var isIE=navigator.appName.indexOf("Microsoft")!=-1;var movie=(isIE)?window.lcGateway:document.lcGateway;movie.getAds(WWESL_CONFIG.get('lightningCastParams'));}catch(e){this.error('Could not request data from LightningCast');}},syncBanner:function(params){if(params.masterAdID){var newParams={dc_seed:params.masterAdID,tile:"2"};this.reload({params:newParams});}else if(params.syncBanner){this.reloadWithUrl(params.syncBanner);if(params.redirectImpURL){this.application.communicator.get(params.redirectImpURL);}}}});if(!WWESL){var WWESL={};}
WWESL.AlertController=Class.create(Base,{initialize:function(application){this.CLASS_NAME='AlertController';this.application=application;this.errorCodes=WWESL_CONFIG.get('errorCodes');this.getXaml();this.initEvents();},getXaml:function(){this.xaml=this.application.find('alertBox');this.message=this.application.find('alertMessageText');this.button=this.application.find('alertButton');this.buttonLabel=this.application.find('alertButtonText');this.button.addEventListener('MouseLeftButtonDown',this.onClick.bind(this));},initEvents:function(){for(var type in this.errorCodes){this.subscribe(type,this.show.bind(this));}
this.subscribe('CategorySelected',this.hide.bind(this));},show:function(event){this.broadcast('AlertRaised');var error=this.errorCodes[event.type];this.message.text=error.message;this.callback=event.callback||function(){};this.xaml.visibility='visible';this.xaml.opacity=1;setTimeout(this.hide.bind(this),5000);},hide:function(){if(this.tween){this.tween.stop();}
if(this.xaml.opacity==0){return;}
this.tween=new Tween({obj:this.xaml,prop:'opacity',end:0},0.5).addListener('onMotionFinished',function(){this.xaml.visibility='collapsed';}.bind(this)).start();},onClick:function(){if(this.callback){this.callback();}
this.hide();}});WWESL.AnalyticsController=Class.create(Base,{initialize:function(){this.CLASS_NAME='AnalyticsController';this.defaultParams=WWESL_CONFIG.get('analyticsParams');this.propTracker=[];this.setup();},setup:function(){if(typeof s=='undefined'){this.log('Omniture not present');}else{this.sender=s;this.initEvents();}},initEvents:function(){this.subscribe('CategoryLoaded',this.sendMacro.bind(this));this.subscribe('VideoLoaded',this.sendMacro.bind(this));},apply:function(params){for(var prop in params){this.propTracker[this.propTracker.length]=prop;this.sender[prop]=params[prop];}},reset:function(){for(var i=0,j=this.propTracker.length;i<j;i++){this.sender[this.propTracker[i]]=null;delete this.sender[this.propTracker[i]];}
this.propTracker=[];},getParams:function(event){var params={};if(this.defaultParams[event.type]){for(var prop in this.defaultParams[event.type]){params[prop]=this.defaultParams[event.type][prop];}}
if(event.category&&event.category.analyticParams){for(var prop in event.category.analyticParams){params[prop]=event.category.analyticParams[prop];}}
if(event.video&&event.video.analyticParams){for(var prop in event.video.analyticParams){params[prop]=event.video.analyticParams[prop];}}
return params;},sendMacro:function(event){if(event.type=='CategoryLoaded'&&WWESL_STATE.get('categoryDefer')){return;}
this.apply(this.getParams(event));void(this.sender.t());this.reset();},sendMicro:function(event){this.apply(this.getParams(event));void(this.sender.tl());this.reset();}});if(!WWESL){var WWESL={};}
WWESL.Application=Class.create(SL.Application,{initialize:function(){this.CLASS_NAME='Application';this.parent({source:'/silverlight/xaml/base.xaml',background:'#000000',width:'978',height:'650',isWindowless:'true'});this.setDebugLevel('SILENT');},main:function(){WWESL.Plugin=this.plugin;this.initEvents();this.configuration=new WWESL.Configuration(this);this.loading=new WWESL.Loading(this);this.alertController=new WWESL.AlertController(this);this.getComponents();},getComponents:function(){if(!WWESL.Initialization){setTimeout(this.getComponents.bind(this),250);return;}
this.appState=new WWESL.ApplicationState(this);this.communicator=new WWESL.Communicator(this);this.grid=new WWESL.Grid(this);this.gridNav=new WWESL.GridNavigation(this);this.navigation=new WWESL.Navigation(this);this.breadcrumbNav=new WWESL.BreadcrumbNav(this);this.videoModule=new WWESL.VideoModule(this);this.related=new WWESL.Related(this);this.skinController=new WWESL.SkinController(this);this.adController=new WWESL.AdController(this);this.analyticsController=new WWESL.AnalyticsController(this);this.getInitialData();this.readyTries=0;this.ready();},initEvents:function(){this.subscribe('CategoryLoaded',function(event){this.currentCategory=event.category;this.appState.set('categoryId',this.currentCategory.id);}.bind(this));this.subscribe('VideoLoaded',function(event){this.activeVideo=event.video;this.appState.set('videoId',this.activeVideo.id);this.appState.set('videoTitle',this.activeVideo.title);}.bind(this));this.subscribe('CategorySelected',function(event){this.getCategory(event.categoryId);}.bind(this));this.subscribe('VideoSelected',function(event){this.getVideo(event.videoId);}.bind(this));this.subscribe('SearchSubmitted',function(event){this.getSearch(event.query);this.appState.set('query',event.query);}.bind(this));},waitFor:function(obj){if(!this.readyQueue){this.readyQueue=[];}
this.readyQueue.push(obj);},nowReady:function(obj){if(!this.readyQueue||this.readyQueue.length<1){return;}
for(var i=0,el=null;el=this.readyQueue[i];i++){if(el===obj){this.readyQueue.splice(i,1);}}},ready:function(){this.log('Are all components ready to start and do we have data?');if((!this.readyQueue||this.readyQueue.length===0)&&this.currentCategory){this.start();}else{if(this.readyTries<10){setTimeout(this.ready.bind(this),1000);this.readyTries++;}else{this.broadcast('ApplicationError',{callback:function(){window.location.reload();}});}}},start:function(){this.log('Starting Application');WWESL_STATE.set('applicationInitialized',true);this.broadcast('ApplicationInitialized');},getInitialData:function(){this.getCategory();this.getVideo();WWESL.DeepLink=null;},getCategory:function(categoryId){WWESL_STATE.set('categoryDefer',false)
if(!categoryId){if(WWESL.DeepLink&&(WWESL.DeepLink.categoryId||WWESL.DeepLink.legacyUrl)){this.currentCategoryId=WWESL.DeepLink.categoryId;this.currentLegacyUrl=WWESL.DeepLink.legacyUrl;if(WWESL.DeepLink.videoId){WWESL_STATE.set('categoryDefer',true)}
this.communicator.getCategory({categoryId:WWESL.DeepLink.categoryId,url:WWESL.DeepLink.legacyUrl,videoId:WWESL.DeepLink.videoId});return;}else{this.currentCategoryId=this.config('navigation')[0].id;}}else{this.currentCategoryId=categoryId;}
this.communicator.getCategory({categoryId:this.currentCategoryId});},getVideo:function(videoId){if(!videoId&&WWESL.DeepLink&&WWESL.DeepLink.videoId){this.activeVideoId=WWESL.DeepLink.videoId;this.communicator.getVideo({videoId:this.activeVideoId,url:WWESL.DeepLink.legacyUrl,categoryId:WWESL.DeepLink.categoryId},true);}else if(videoId){this.activeVideoId=videoId;this.communicator.getVideo({videoId:this.activeVideoId,categoryId:this.currentCategoryId,url:this.currentLegacyUrl});}},getSearch:function(query){this.query=query;this.communicator.getSearch({query:this.query});},config:function(property){return this.configuration.get(property);}});if(!WWESL){var WWESL={};}
WWESL.BreadcrumbNav=Class.create(Base,{initialize:function(application){this.CLASS_NAME='BreadcrumbNav';this.application=application;this.application.waitFor(this);this.teardownFirst=false;this.isNew=true;this.initEvents();this.setup();},initEvents:function(){this.subscribe('CategorySelected',this.checkForTopLevel.bind(this));this.subscribe('SearchSubmitted',this.prepareForSearch.bind(this));this.subscribe('CategoryLoaded',this.update.bind(this));this.subscribe('BreadcrumbSelected',this.onSelect.bind(this));this.subscribe('ActivePlayerClosed',this.removeVideo.bind(this));this.subscribe('ActivePlayerHidden',this.removeVideo.bind(this));this.subscribe('VideoRefreshed',this.removeVideo.bind(this));this.subscribe('RelatedCategorySelected',this.makeNew.bind(this));this.subscribe('RecessedPlayerClicked',this.addVideo.bind(this));this.subscribe('VideoLoaded',this.addVideo.bind(this));},setup:function(){this.application.getZip(WWESL_CONFIG.get('xamlPath')+'xaml.zip',function(zip){this.xaml=new SL.Partial(zip.get('breadcrumb.xaml'));this.xaml.attach(this.application.find('breadcrumbHolder'));this.buttonHolder=this.application.find('breadcrumbButtonHolder');this.loadingText=this.xaml.find('loadingText');this.items=[];zip.destroy();zip=null;this.application.nowReady(this);}.bind(this));},checkForTopLevel:function(event){if(event.topLevel){this.teardownFirst=true;}},prepareForSearch:function(event){this.wasSearch=true;this.teardownFirst=true;},makeNew:function(event){this.isNew=true;},update:function(event){if(!WWESL_STATE.get('applicationInitialized')){setTimeout(this.update.bind(this,event),500);return;}
if(this.wasSearch){if(event.category&&(!event.category.contents||event.category.contents.length<1)){event.category.title='Search Results';}
this.wasSearch=false;}
if(this.teardownFirst){this.teardown();this.teardownFirst=false;}
var data={},existsInBreadcrumb=false;if(event.video){if(!WWESL_STATE.get('playerActive')){return;}
data=event.video;}else if(event.category){data=event.category;}
if(this.isNew){this.updateWithBreadcrumbs(data);return;}
for(var i=0,j=this.items.length;i<j;i++){if(this.items[i].id==data.id){this.items[i].select();existsInBreadcrumb=true;}else{this.items[i].deselect();}}
if(!existsInBreadcrumb){this.items.push(new WWESL.BreadcrumbItem(this.application.plugin,data,this.items.length));}
this.display();},updateWithBreadcrumbs:function(data){if(data.breadcrumbs){this.teardown();this.isNew=false;if(!data.breadcrumbs.length){data.breadcrumbs=[data.breadcrumbs];}
for(var i=0,crumb=null;crumb=data.breadcrumbs[i];i++){crumb.type='category';if(crumb.name){crumb.title=crumb.name;}
if(this.items[i-1]){this.items[i-1].deselect();}
this.items.push(new WWESL.BreadcrumbItem(this.application.plugin,crumb,this.items.length));}
WWESL_STATE.set('topLevelCategoryId',data.breadcrumbs[0].id);this.broadcast('CategoryRefreshed');this.display();}},display:function(){var offset=0;for(var i=0,j=this.items.length;i<j;i++){if(!this.items[i].container){if(i===0){this.items[i].isFirst();}
this.items[i].display(this.buttonHolder,offset);}
offset+=this.items[i].width+WWESL_CONFIG.get('breadcrumbSpacing');}
WWESL_STATE.set('topLevelCategoryId',this.items[0].id);},onSelect:function(event){this.removeAfter(event.selectedIndex);if(event.query){this.broadcast('SearchSubmitted',{query:event.query});}else{this.broadcast('CategorySelected',{categoryId:event.id});}},removeAfter:function(after){var removeThisMany=0;for(var i=0,j=this.items.length;i<j;i++){this.items[i].deselect();if(after<i){this.items[i].destroy();this.buttonHolder.children.removeAt(after+1);removeThisMany++;}}
this.items.splice(after+1,removeThisMany);},removeVideo:function(){var lastIndex=this.items.length-1;if(this.items[lastIndex]&&this.items[lastIndex].type=='video'){this.items[lastIndex].destroy();this.items.splice(lastIndex,1);this.buttonHolder.children.removeAt(lastIndex);if(this.items[lastIndex-1]){this.items[lastIndex-1].select();}}},addVideo:function(event){if(event.type==='RecessedPlayerClicked'){}else if(WWESL_STATE.get('playerRecessed')){return;}
var data;if(event.video){data=event.video}else{data={type:'video',title:WWESL_STATE.get('videoTitle')};}
this.items[this.items.length-1].deselect();if(WWESL_STATE.get('carouselCategoryId')){var lastIndex=this.items.length-1;if(this.items[lastIndex]&&this.items[lastIndex].type==='category'){var lastCategory=this.items[lastIndex];}
if(lastCategory&&lastCategory.id!==WWESL_STATE.get('carouselCategoryId')){return;}}
this.items.push(new WWESL.BreadcrumbItem(this.application.plugin,data,this.items.length));this.display();},teardown:function(){for(var i=0,j=this.items.length;i<j;i++){this.items[i].destroy();this.items[i]=null;this.buttonHolder.children.removeAt(0);}
this.items=[];}});WWESL.BreadcrumbItem=Class.create(SL.Partial,{include:[SL.Events],initialize:function(plugin,data,index){this.CLASS_NAME='BreadcrumbItem';this.plugin=plugin;var xaml=this.makeXaml();this.parent(xaml);this.index=index;this.title=data.title;this.id=data.id;this.type=data.type;this.setup();this.initEvents();this.select();},makeXaml:function(){var xaml=Silverlight.createElement(this.plugin,'Canvas');this.separator=Silverlight.createElement(this.plugin,'TextBlock',{text:'>',fontfamily:'Arial',fontsize:10,foreground:'#FFDDDDDD',top:4,left:-12});this.label=Silverlight.createElement(this.plugin,'TextBlock',{fontfamily:'Arial',fontsize:10,foreground:'#FFDDDDDD',top:4});this.hit=Silverlight.createElement(this.plugin,'Rectangle',{width:100,height:23,fill:'#FFFF0000',opacity:0});xaml.children.add(this.separator);xaml.children.add(this.label);xaml.children.add(this.hit);return xaml;},setup:function(){if(this.title==='Search Results'){this.query=WWESL_STATE.get('query');this.label.text='';this.label.inlines.add(Silverlight.createElement(WWESL.Plugin,'Run',{text:'Search Results for '}));this.label.inlines.add(Silverlight.createElement(WWESL.Plugin,'Run',{text:this.query,'FontWeight':'Bold',foreground:WWESL_CONFIG.get('textColor')}));}else{this.label.text=this.title;}
this.width=this.label.actualWidth;this.hit.width=this.width;},initEvents:function(){this.hit.cursor='Hand';this.addEventListener(this.hit,'MouseEnter',this.onOver.bind(this));this.addEventListener(this.hit,'MouseLeave',this.onOut.bind(this));this.addEventListener(this.hit,'MouseLeftButtonDown',this.onClick.bind(this));},display:function(container,offset){this.set('Canvas.Left',offset);this.attach(container);},isFirst:function(){this.separator.visibility='collapsed';},destroy:function(){this.removeEventListener(this.hit,'MouseEnter');this.removeEventListener(this.hit,'MouseLeave');this.removeEventListener(this.hit,'MouseLeftButtonDown');this.hit=null;this.label=null;this.separator=null;this.xaml=null;this.plugin=null;this.width=0;},onOver:function(){this.label.foreground=WWESL_CONFIG.get('breadcrumbTextHoverColor');},onOut:function(){this.label.foreground=WWESL_CONFIG.get('breadcrumbTextColor');},onClick:function(){this.broadcast('BreadcrumbSelected',{selectedIndex:this.index,id:this.id,query:this.query});this.select();},select:function(){this.selected=true;this.hit.visibility='collapsed';},deselect:function(){this.selected=false;this.hit.visibility='visible';}});if(!WWESL){var WWESL={};}
WWESL.Carousel=Class.create(SL.Partial,{initialize:function(player,xaml){this.CLASS_NAME='Carousel';this.player=player;this.application=this.player.application;this.parent(xaml);this.thumbArray=[];this.selectedThumb=0;this.thumbWidth=0;this.itemWidth=0;this.lock=false;this.videoLoadedTries=0;this.ready=false;this.createThumbs();this.setup();this.initEvents();},setup:function(){},initEvents:function(){this.subscribe('RecessedPlayerClicked',function(){this.deferPopulate=true;}.bind(this));this.subscribe('ActivePlayerOpened',this.populate.bind(this));this.subscribe('VideoLoaded',this.onVideoLoaded.bind(this));this.subscribe('PlaylistEnd',this.goToNext.bind(this));},populate:function(){if(!this.ready){setTimeout(this.populate.bind(this),500);return;}
if(this.deferPopulate){this.deferPopulate=false;return;}
if(this.checkCurrentCategory()){return;}
this.resetPositions();var items=this.player.application.grid.getPageContents();this.contents=[];this.contentIndex=0;this.selectedIndex=0;for(var i=0,j=0,item=null;item=items[i];i++){if(item&&item.type==='video'){this.contents[this.contents.length]=item;if(item.id==WWESL_STATE.get('videoId')){this.contentIndex=j;this.selectedIndex=j;}
j++;}}
this.updateThumbs();this.scrollMax=-1*(this.contents.length-5)*this.itemWidth;this.scrollMax=this.scrollMax>0?0:this.scrollMax;this.activateArrows();},checkCurrentCategory:function(){if(WWESL_STATE.get('categoryId')===WWESL_STATE.get('carouselCategoryId')){return true;}
WWESL_STATE.set('carouselCategoryId',WWESL_STATE.get('categoryId'));},onVideoLoaded:function(event){if(!this.ready||!this.contents||WWESL_STATE.get('categoryId')!==WWESL_STATE.get('carouselCategoryId')){this.videoLoadedTries++;if(this.videoLoadedTries<10){setTimeout(this.onVideoLoaded.bind(this,event),500);}
return;}
this.videoLoadedTries=0;for(var i=0,j=this.contents.length;i<j;i++){if(event.video.id==this.contents[i].id){this.selectedIndex=i;}}
this.showSelected(event.video.id);},updateThumbs:function(){for(var i=0,j=this.contents.length;i<j;i++){this.thumbArray[i].setData(this.contents[i]);}
for(var i=this.contents.length,j=WWESL_CONFIG.get('gridSize');i<j;i++){if(this.thumbArray[i]){this.thumbArray[i].clear();}}},resetPositions:function(){if(this.scrollInterval){clearInterval(this.scrollInterval);this.scrollInterval=null;}
this.thumbHolder['Canvas.Left']=this.thumbHolderX;this.detailsHolder['Canvas.Left']=this.detailsHolderX;this.targetHolder['Canvas.Left']=this.thumbHolderX;},activateArrows:function(){if(this.contents.length<5){this.buttonRight.opacity=0.3;this.buttonLeft.opacity=0.3;this.buttonRight.isHitTestVisible=false;this.buttonLeft.isHitTestVisible=false;return;}
if(this.thumbHolder['Canvas.Left']<=this.scrollMax){this.buttonRight.opacity=0.3;this.buttonRight.isHitTestVisible=false;}else{this.buttonRight.opacity=0.7;this.buttonRight.isHitTestVisible=true;}
if(this.thumbHolder['Canvas.Left']>=this.thumbHolderX){this.buttonLeft.opacity=0.3;this.buttonLeft.isHitTestVisible=false;}else{this.buttonLeft.opacity=0.7;this.buttonLeft.isHitTestVisible=true;}},scrollLeft:function(){this.scroll(-1);if(this.scrollInterval){clearInterval(this.scrollInterval);this.scrollInterval=null;}
this.scrollInterval=setInterval(this.scroll.bind(this,-1),20);},scrollRight:function(){this.scroll(1);if(this.scrollInterval){clearInterval(this.scrollInterval);this.scrollInterval=null;}
this.scrollInterval=setInterval(this.scroll.bind(this,1),20);},stopScroll:function(){if(this.scrollInterval){clearInterval(this.scrollInterval);this.scrollInterval=null;}},scroll:function(dir){this.thumbHolder['Canvas.Left']+=this.scrollSpeed*dir;if(this.thumbHolder['Canvas.Left']<this.scrollMax){this.thumbHolder['Canvas.Left']=this.scrollMax;}else if(this.thumbHolder['Canvas.Left']>this.thumbHolderX){this.thumbHolder['Canvas.Left']=this.thumbHolderX;}
this.detailsHolder['Canvas.Left']=this.thumbHolder['Canvas.Left'];this.targetHolder['Canvas.Left']=this.thumbHolder['Canvas.Left'];this.activateArrows();},scrollTo:function(position){this.stopScroll();this.thumbHolder['Canvas.Left']=position;if(this.thumbHolder['Canvas.Left']<this.scrollMax){this.thumbHolder['Canvas.Left']=this.scrollMax;}else if(this.thumbHolder['Canvas.Left']>this.thumbHolderX){this.thumbHolder['Canvas.Left']=this.thumbHolderX;}
this.detailsHolder['Canvas.Left']=this.thumbHolder['Canvas.Left'];this.targetHolder['Canvas.Left']=this.thumbHolder['Canvas.Left'];this.activateArrows();},doOver:function(control){control.opacity=1;},doOn:function(control){control.opacity=0.7;},goToNext:function(event){this.selectedIndex=(this.selectedIndex+1>=this.contents.length)?0:this.selectedIndex+1;if(this.contents[this.selectedIndex]){this.broadcast('VideoRefreshed');this.broadcast('VideoSelected',{videoId:this.contents[this.selectedIndex].id});}},setSelectedIndex:function(index){this.selectedIndex=index;},showSelected:function(id){for(var i=0,j=this.thumbArray.length;i<j;i++){this.thumbArray[i].checkSelected(id);}},shiftPosition:function(position){if(position-this.itemWidth<-this.thumbHolder['Canvas.Left']){this.scrollTo(-position+this.itemWidth);}else if(position>-this.thumbHolder['Canvas.Left']+this.clipWidth){this.scrollTo(-position+this.itemWidth+(this.itemWidth*3));}}});WWESL.ActiveCarousel=Class.create(WWESL.Carousel,{initialize:function(player,xaml){this.parent(player,xaml);},setup:function(){this.itemWidth=WWESL_CONFIG.get('activeCarouselItemWidth');this.clipWidth=WWESL_CONFIG.get('activeCarouselClipWidth');this.scrollSpeed=10;this.thumbWidth=660;this.thumbHolder=this.find('big_thumbs');this.detailsHolder=this.find('big_thumbs_details');this.targetHolder=this.find('big_thumbs_targets');this.thumbHolderX=this.thumbHolder['Canvas.Left'];this.detailsHolderX=this.detailsHolder['Canvas.Left'];this.targetHolderX=this.targetHolder['Canvas.Left'];this.buttonLeft=this.find("big_thumbs_prev_btn");this.buttonLeft.cursor='Hand';this.buttonLeft.addEventListener('MouseLeftButtonDown',this.scrollRight.bind(this));this.buttonLeft.addEventListener('MouseLeftButtonUp',this.stopScroll.bind(this));this.buttonLeft.addEventListener('mouseEnter',function(){this.doOver(this.buttonLeft);}.bind(this));this.buttonLeft.addEventListener('mouseLeave',function(){this.doOn(this.buttonLeft);}.bind(this));this.buttonRight=this.find("big_thumbs_next_btn");this.buttonRight.cursor='Hand';this.buttonRight.addEventListener('MouseLeftButtonDown',this.scrollLeft.bind(this));this.buttonRight.addEventListener('MouseLeftButtonUp',this.stopScroll.bind(this));this.buttonRight.addEventListener('mouseEnter',function(){this.doOver(this.buttonRight);}.bind(this));this.buttonRight.addEventListener('mouseLeave',function(){this.doOn(this.buttonRight);}.bind(this));},createThumbs:function(){this.thumbArray=[];this.application.getZip(WWESL_CONFIG.get('xamlPath')+'xaml.zip',function(zip){for(var i=0;i<WWESL_CONFIG.get('gridSize');i++){this.thumbArray[i]=new WWESL.CarouselItem(this,i,zip.get('carouselThumb.xaml'),zip.get('carouselDetails.xaml'));}
zip.destroy();zip=null;this.ready=true;}.bind(this));}});WWESL.RecessedCarousel=Class.create(WWESL.Carousel,{initialize:function(player,xaml){this.parent(player,xaml);this.CLASS_NAME='Recessed Carousel';},setup:function(){this.itemWidth=WWESL_CONFIG.get('miniCarouselItemWidth');this.clipWidth=WWESL_CONFIG.get('miniCarouselClipWidth');this.scrollSpeed=4;this.thumbWidth=342;this.thumbHolder=this.find('mini_thumbs');this.detailsHolder=this.find('mini_thumbs_details');this.targetHolder=this.find('mini_thumbs_targets');this.thumbHolderX=this.thumbHolder['Canvas.Left'];this.detailsHolderX=this.detailsHolder['Canvas.Left'];this.targetHolderX=this.targetHolder['Canvas.Left'];this.buttonLeft=this.find("mini_thumbs_prev_btn");this.buttonLeft.cursor='Hand';this.buttonLeft.addEventListener('MouseLeftButtonDown',this.scrollRight.bind(this));this.buttonLeft.addEventListener('MouseLeftButtonUp',this.stopScroll.bind(this));this.buttonLeft.addEventListener('mouseEnter',function(){this.doOver(this.buttonLeft);}.bind(this));this.buttonLeft.addEventListener('mouseLeave',function(){this.doOn(this.buttonLeft);}.bind(this));this.buttonRight=this.find("mini_thumbs_next_btn");this.buttonRight.cursor='Hand';this.buttonRight.addEventListener('MouseLeftButtonDown',this.scrollLeft.bind(this));this.buttonRight.addEventListener('MouseLeftButtonUp',this.stopScroll.bind(this));this.buttonRight.addEventListener('mouseEnter',function(){this.doOver(this.buttonRight);}.bind(this));this.buttonRight.addEventListener('mouseLeave',function(){this.doOn(this.buttonRight);}.bind(this));},createThumbs:function(){this.thumbArray=[];this.application.getZip(WWESL_CONFIG.get('xamlPath')+'xaml.zip',function(zip){for(var i=0;i<WWESL_CONFIG.get('gridSize');i++){this.thumbArray[i]=new WWESL.MiniCarouselItem(this,i,zip.get('carouselMiniThumb.xaml'),zip.get('carouselDetails.xaml'));}
zip.destroy();zip=null;this.ready=true;}.bind(this));},goToNext:function(event){if(this.contents){this.selectedIndex=(this.selectedIndex+1>=this.contents.length)?0:this.selectedIndex+1;}},checkCurrentCategory:function(){if(WWESL_STATE.get('categoryId')===WWESL_STATE.get('recessedCarouselCategoryId')){return true;}
WWESL_STATE.set('recessedCarouselCategoryId',WWESL_STATE.get('categoryId'));}});WWESL.CarouselItem=Class.create(Base,{initialize:function(carousel,index,thumb,details){this.carousel=carousel;this.index=index;this.thumb=new WWESL.CarouselThumb(this,thumb);this.details=new WWESL.CarouselDetails(this,details);this.ready=true;},setData:function(data){if(!this.ready){setTimeout(this.setData.bind(this,data),200);return;}
this.data=data;this.thumb.setData(data);this.details.setData(data);},clear:function(){this.thumb.hide();this.details.hide();},moveTo:function(x){this.thumb.moveTo(x);this.details.moveTo(x);},currentPosition:function(){return this.thumb.get('Canvas.Left');},reset:function(){this.thumb.position();this.details.position();},hide:function(){this.thumb.hide();this.details.hide();},setActive:function(){this.thumb.setActive();},setDeactive:function(){this.thumb.setDeactive();},checkSelected:function(id){if(!this.ready||!this.data){setTimeout(this.checkSelected.bind(this,id),200);return;}
if(id.toString()===this.data.id.toString()){this.setActive();this.carousel.shiftPosition(this.currentPosition());}else{this.setDeactive();}},destroy:function(){this.carousel=null;this.application=null;this.thumb.destroy();this.thumb=null;this.details.destroy();this.details=null;}});WWESL.MiniCarouselItem=Class.create(WWESL.CarouselItem,{initialize:function(carousel,index,thumb,details){this.carousel=carousel;this.index=index;this.thumb=new WWESL.MiniCarouselThumb(this,thumb);this.details=new WWESL.MiniCarouselDetails(this,details);this.ready=true;}});WWESL.CarouselThumb=Class.create(SL.Partial,{initialize:function(item,xaml){this.item=item;this.parent(xaml);this.init();},init:function(){this.attach(this.item.carousel.thumbHolder);this.title=this.find('title');this.title.text=this.item.index.toString();this.background=this.find('background');this.thumbnail=this.find('thumbnail');this.position();},position:function(){this.set('visibility','visible');this.set('Canvas.Left',WWESL_CONFIG.get('activeCarouselItemWidth')*this.item.index);},setData:function(data){this.set('visibility','visible');this.data=data;this.setThumbnail(data.thumbnail);this.setTitle(data.title);},moveTo:function(x){this.set('Canvas.Left',x);},setThumbnail:function(url){this.thumbnail.source=WWESL_CONFIG.get('gridLoadingImage');if(url){this.thumbnail.source=WWESL_CONFIG.get('assetBase')+url;}},setTitle:function(title){this.title.text=title.toUpperCase();},hide:function(){this.set('visibility','collapsed');},setActive:function(){this.background.fill='#FFFFFFFF';this.title.foreground='#FF000000';try{this.find('blackShadow').visibility='collapsed';this.find('whiteShadow').visibility='visible';}catch(e){}},setDeactive:function(){this.background.fill='#FF000000';this.title.foreground='#FFFFFFFF';try{this.find('blackShadow').visibility='visible';this.find('whiteShadow').visibility='collapsed';}catch(e){}},destroy:function(){this.item=null;}});WWESL.MiniCarouselThumb=Class.create(WWESL.CarouselThumb,{position:function(){this.set('Canvas.Left',WWESL_CONFIG.get('miniCarouselItemWidth')*this.item.index);},setActive:function(){this.background.visibility='visible';},setDeactive:function(){this.background.visibility='collapsed';}});WWESL.CarouselDetails=Class.create(SL.Partial,{initialize:function(item,xaml){this.item=item;this.parent(xaml);this.init();},init:function(){this.createTarget();this.detailsScale=this.find('detailsScale');this.details=this.find('details');this.thumbnail=this.find('thumbnail');this.title=this.find('title');this.date=this.find('date');this.description=this.find('description');this.attach(this.item.carousel.detailsHolder);this.item.carousel.targetHolder.children.add(this.target);this.position();this.initEvents();},createTarget:function(){this.target=Silverlight.createElement(WWESL.Plugin,'Rectangle',{width:"106",height:"94",fill:"#FFFF0000",opacity:"0",cursor:'Hand'});},position:function(){this.target.visibility='visible';this.target['Canvas.Left']=WWESL_CONFIG.get('activeCarouselItemWidth')*this.item.index;this.details['Canvas.Left']=this.target['Canvas.Left']-36;this.details['Canvas.Top']=-130;},initEvents:function(){this.overTween=new Tween([{obj:this.detailsScale,prop:'scaleX',end:1,func:Tween.easeOutExpo},{prop:'scaleY'},{obj:this.details,prop:'opacity',end:1}],0.5);this.outTween=new Tween([{obj:this.detailsScale,prop:'scaleX',end:0.5,func:Tween.easeOutExpo},{prop:'scaleY'},{obj:this.details,prop:'opacity',end:0},{prop:'Canvas.Left',end:this.details['Canvas.Left']}],0.1);this.outTween.addListener('onMotionFinished',this.hideDetails.bind(this));this.enterToken=this.target.addEventListener('MouseEnter',this.onOver.bind(this));this.leaveToken=this.target.addEventListener('MouseLeave',this.onOut.bind(this));this.downToken=this.target.addEventListener('MouseLeftButtonDown',this.onClick.bind(this));},onOver:function(s,a){this.broadcast('CarrouselItemOver');this.details.visibility='Visible';this.outTween.stop();this.overTween.startFromHere();},onOut:function(s,a){this.overTween.stop();this.outTween.startFromHere();},onClick:function(){this.broadcast('VideoRefreshed');this.broadcast('VideoSelected',{videoId:this.data.id});this.item.carousel.setSelectedIndex(this.item.index);this.onOut();},hideDetails:function(){this.details.visibility='Collapsed';},setData:function(data){this.target.visibility='visible';this.data=data;this.setThumbnail(data.thumbnail);this.setTitle(data.title);this.setDate(data.date,data.type);this.setDescription(data.description);},moveTo:function(x){this.target['Canvas.Left']=x;this.details['Canvas.Left']=this.target['Canvas.Left']-36;},hide:function(){this.target.visibility='collapsed';},setThumbnail:function(url){this.thumbnail.source=WWESL_CONFIG.get('gridLoadingImage');this.thumbnail.visibility='visible';if(url){this.thumbnail.source=WWESL_CONFIG.get('assetBase')+url;}},setTitle:function(title){this.date.foreground=WWESL.Parameters.videoTextColor;this.description.foreground=WWESL.Parameters.videoTextColor;this.title.foreground=WWESL.Parameters.videoBoldTextColor;this.title.text=title.toString().toUpperCase();},setDate:function(date,type){this.date.text=date?date:'';},setDescription:function(text){this.description.text=text?text:'';},destroy:function(){this.item=null;this.target.removeEventListener('MouseEnter',this.enterToken);this.target.removeEventListener('MouseLeave',this.leaveToken);this.target.removeEventListener('MouseLeftButtonDown',this.downToken);}});WWESL.MiniCarouselDetails=Class.create(WWESL.CarouselDetails,{createTarget:function(){this.target=Silverlight.createElement(WWESL.Plugin,'Rectangle',{width:"53",height:"40",fill:"#FFFF0000",opacity:"0",cursor:'Hand'});},position:function(){this.target['Canvas.Left']=WWESL_CONFIG.get('miniCarouselItemWidth')*this.item.index;this.details['Canvas.Left']=this.target['Canvas.Left']-36;this.details['Canvas.Top']=-160;},onOver:function(s,a){this.broadcast('CarrouselItemOver');this.details.visibility='Visible';var absolute=Silverlight.absolute(this.details),newLeft=this.details['Canvas.Left'];if(absolute.x+178>978){newLeft=this.details['Canvas.Left']-(absolute.x+178-970);}
this.overTween=new Tween([{obj:this.detailsScale,prop:'scaleX',end:1,func:Tween.easeOutExpo},{prop:'scaleY'},{obj:this.details,prop:'opacity',end:1},{prop:'Canvas.Left',end:newLeft}],0.5);this.outTween.stop();this.overTween.startFromHere();}});if(!WWESL){var WWESL={};}
WWESL.Communicator=Class.create(Base,{initialize:function(application){this.CLASS_NAME='Communicator';this.application=application;this.urls=WWESL_CONFIG.get('applicationUrls');this.currentToken=0;this.requests=[];},get:function(url,params){var token=this.currentToken++,self=this;this.requests[token]=new myXMLHttpRequest();this.requests[token].open('GET',url,true);this.requests[token].onreadystatechange=function(){switch(this.readyState){case myXMLHttpRequest.LOADING:if(params.onLoading){params.onLoading(this);}
break;case myXMLHttpRequest.DONE:self.broadcast('RequestDone',{response:this});if(params.onComplete){params.onComplete(this,token);}
self.requests[token].onreadystatechange=null;self.requests[token]=null;break;}};this.requests[token].send(null);return token;},checkForAbort:function(testToken){return this.currentCategoryToken!==testToken;},loadScript:function(url,callbackName,callback){var scriptElement=document.createElement('script');window[callbackName]=function(response){callback(response);}
scriptElement.type='text/javascript';scriptElement.src=url;document.body.appendChild(scriptElement);},getCategory:function(params){var url=this.urls.categoryRequest+'/',paramsString=this.compileParams(params);this.log(url+paramsString);if(WWESL_CONFIG.get('proxy')){url=this.urls.proxy+encodeURIComponent(url);paramsString=encodeURIComponent(paramsString);}
try{var token=this.get(url+paramsString,{onLoading:function(){this.log('Loading category: '+params.categoryId);}.bind(this),onComplete:function(response,token){if(this.checkForAbort(token)){this.log('This is not the most recent category request: Abort');return;}
try{var category=eval('('+response.responseText+')');if(category['video-category'].error=='true'){this.broadcast('EmptyContentsError');this.broadcast('RelatedCategorySelected');this.broadcast('CategoryErrorOccurred',params);}
if(category['video-category'].type){this.broadcast('CategoryLoaded',{category:category['video-category']});}}catch(e){this.error(e);this.broadcast('CategoryErrorOccurred',params);}}.bind(this)});this.currentCategoryToken=token;}catch(e){this.error(e);this.broadcast('CategoryErrorOccurred',params);}},getVideo:function(params,deepLink){var url=this.urls.videoInfoRequest+'/',paramsString=this.compileParams(params);this.log(url+paramsString);if(WWESL_CONFIG.get('proxy')){url=this.urls.proxy+encodeURIComponent(url);paramsString=encodeURIComponent(paramsString);}
try{this.currentVideoToken=this.get(url+paramsString,{onLoading:function(){this.log('Loading video: '+params.videoId);}.bind(this),onComplete:function(response,token){try{if(this.currentVideoToken!==token){this.log('This is not the most recent video request: Abort');return;}
var video=eval('('+response.responseText+')');if(video['video'].error=='true'){this.broadcast('VideoErrorOccurred',params);}
if(video['video'].id){if(deepLink){this.broadcast('DeepLinkVideoLoaded',{video:video['video']});}else{this.broadcast('VideoLoaded',{video:video['video']});}}}catch(e){this.error(e);this.broadcast('VideoErrorOccurred',params);}}.bind(this)});}catch(e){this.error(e);this.broadcast('VideoErrorOccurred',{videoId:videoId});}},getSearch:function(params){var url=this.urls.searchRequest+'?',paramsString=this.compileParams(params);this.log(url+paramsString);if(WWESL_CONFIG.get('proxy')){url=this.urls.proxy+encodeURIComponent(url);paramsString=encodeURIComponent(paramsString);}
try{this.currentCategoryToken=this.get(url+paramsString,{onLoading:function(){this.log('Loading Search for '+params.query);}.bind(this),onComplete:function(response,token){if(this.checkForAbort(token)){this.log('This is not the most recent category request: Abort');return;}
try{var category=eval('('+response.responseText+')');if(category['video-category'].error=='true'){this.broadcast('SearchErrorOccurred',params);}
if(category['video-category'].type){category['video-category'].search=true;this.broadcast('CategoryLoaded',{category:category['video-category']});}}catch(e){this.error(e);this.broadcast('SearchErrorOccurred',params);}}.bind(this)});}catch(e){this.error(e);this.broadcast('SearchErrorOccurred',params);}},compileParams:function(params){var pieces=[];if(parseInt(params.categoryId)>0){delete params.url;}
for(var key in params){if(typeof params[key]!=='undefined'){if(typeof params[key]==='string'){params[key]=params[key].replace(/\s+/g,'+');}
if(params[key]!==''){pieces[pieces.length]=key+'/'+params[key];}}}
return pieces.join('/');}});if(!WWESL){var WWESL={};}
WWESL.Configuration=Class.create(Base,{initialize:function(application){this.CLASS_NAME='Configuration';this.application=application;this.application.waitFor(this);window.WWESL_CONFIG=this;this.getInitalizationData();},compileData:function(){if(WWESL.Initialization){for(var property in WWESL.Initialization){WWESL.Parameters[property]=WWESL.Initialization[property];}}else{this.error('Initialization Not Set!');}
this.application.nowReady(this);},getInitalizationData:function(){var self=this,request=new myXMLHttpRequest(),token=request.open('GET',WWESL.InitUri,true);request.onreadystatechange=function(){switch(this.readyState){case myXMLHttpRequest.DONE:self.broadcast('RequestDone',{response:this});var json=eval('('+this.responseText+')');WWESL.Initialization=json['category'];self.compileData();token=null;break;}};request.send(null);},get:function(property){var value=WWESL.Parameters[property];if(typeof value!=='undefined'){return value;}else{this.warn('Configuration property "'+property+'" is not set.');return'';}}});if(!WWESL){var WWESL={};}
WWESL.Grid=Class.create(Base,{initialize:function(application){this.CLASS_NAME='Grid';this.application=application;this.application.waitFor(this);this.ready=false;this.initEvents();this.setup();},setup:function(){this.size=WWESL_CONFIG.get('gridSize');this.rows=WWESL_CONFIG.get('gridRows');this.columns=this.size/this.rows;this.extraColumns=WWESL_CONFIG.get('gridExtraColumns');this.extraSize=this.rows*this.extraColumns;this.totalSize=this.size+this.extraSize;this.container=this.application.find('gridHolder');this.scaler=this.application.find('gridScaler');this.hitTarget=this.application.find('gridHit');this.hitBlocker=this.application.find('gridBlocker');this.hitTarget.cursor='Hand';this.hitTarget.addEventListener('MouseLeftButtonDown',function(){this.broadcast('CategoryLoaded',{category:this.category});}.bind(this));this.currentPage=1;this.items=[];this.activeItems=[];this.extraItems=[];this.application.getZip(WWESL_CONFIG.get('xamlPath')+'xaml.zip',function(zip){for(var i=0;i<this.totalSize;i++){if(i<this.size){var item=new WWESL.GridItem(this.application,i,zip.get('gridItem.xaml'),zip.get('gridItemDetails.xaml'));this.items[this.items.length]=item;this.activeItems[this.activeItems.length]=item;}else{var item=new WWESL.SimpleGridItem(this.application,i,zip.get('gridItem.xaml'));this.items[this.items.length]=item;this.extraItems[this.extraItems.length]=item;}}
zip.destroy();zip=null;this.application.nowReady(this);this.ready=true;}.bind(this));},initEvents:function(){this.subscribe('ApplicationInitialized',this.display.bind(this));this.subscribe('CategorySelected',this.pause.bind(this));this.subscribe('CategoryLoaded',this.setData.bind(this));this.subscribe('PageSelected',this.goTo.bind(this));this.subscribe('GridVideoSelected',this.zoomIn.bind(this));this.subscribe('ActivePlayerClosed',this.zoomOut.bind(this));this.subscribe('ActivePlayerHidden',this.zoomOut.bind(this));this.subscribe('DeepLinkVideoLoaded',this.initDeepLink.bind(this));},display:function(){this.hitBlocker.visibility='collapsed';var startIndex=this.startIndex(),fullPage=true;for(var i=0;i<this.size;i++){if(this.category.contents[startIndex+i]){this.activeItems[i].setData(this.category.contents[startIndex+i]);}else{this.activeItems[i].clear();fullPage=false;}}
for(var i=0;i<this.extraSize;i++){if(fullPage){var data=this.activeItems[Math.round(Math.random()*this.extraSize)].data;if(data){data=this.cloneObject(data);data.type='video';}
this.extraItems[i].setData(data);}else{this.extraItems[i].clear();}}
this.transition(0,1,0);},transition:function(index,num,iteration){if(iteration<this.columns+this.rows-1){var offset=0,count=num;while(count--){var currentIndex=index+(4*offset++);if(currentIndex<this.totalSize){this.items[currentIndex].transition();}else{break;}}
setTimeout(this.transition.bind(this,index+1,num+1,iteration+1),100);}else{for(var i=0,j=this.items.length;i<j;i++){this.items[i].updateThumb();this.items[i].transitioning=false;}}},setData:function(event){this.category=event.category;if(this.category.contents&&!this.category.contents.length){this.category.contents=[this.category.contents];}
this.log(this.category);if(!this.category.contents||(this.category.contents.length<1&&!WWESL_STATE.get('categoryDefer'))){if(this.category.search){setTimeout(this.broadcast.bind(this,'EmptySearchError'),500);}else{setTimeout(this.broadcast.bind(this,'EmptyContentsError'),500);}
this.category.contents=[];}
this.currentPage=1;if(WWESL_STATE.get('applicationInitialized')){this.display();}},getPageContents:function(){return this.category.contents.slice(this.startIndex(),this.startIndex()+this.size);},pause:function(){this.hitBlocker.visibility='visible';},goTo:function(event){this.currentPage=event.page;this.display();},startIndex:function(){return(this.currentPage-1)*this.size;},zoomIn:function(event){if(WWESL_STATE.get('zoomedIn')){return;}
this.broadcast('GridZoomIn');WWESL_STATE.set('zoomedIn',true);var offset=this.translatePosition(event.position);this.zoomInTween=new Tween([{obj:this.scaler,prop:'ScaleX',end:WWESL_CONFIG.get('gridZoomScale'),func:Tween.easeOutExpo},{prop:'ScaleY'},{obj:this.container,prop:'Canvas.Left',end:offset.x},{prop:'Canvas.Top',end:offset.y},{prop:'opacity',end:0.5}],0.5);this.zoomInTween.addListener('onMotionFinished',function(){this.broadcast('GridZoomInComplete');}.bind(this));this.hitTarget.visibility='visible';this.zoomInTween.startFromHere();},zoomOut:function(){this.broadcast('GridZoomOut');WWESL_STATE.set('zoomedOut',true);if(!this.zoomOutTween){this.zoomOutTween=new Tween([{obj:this.scaler,prop:'ScaleX',end:1,func:Tween.easeOutExpo},{prop:'ScaleY'},{obj:this.container,prop:'Canvas.Top',end:WWESL_CONFIG.get('gridPosition').top},{prop:'Canvas.Left',end:WWESL_CONFIG.get('gridPosition').left},{prop:'opacity',end:1}],0.5);this.zoomOutTween.addListener('onMotionFinished',function(){this.hitTarget.visibility='collapsed';}.bind(this));}
this.zoomOutTween.startFromHere();},translatePosition:function(position){var deltaX=WWESL_CONFIG.get('gridZoomTarget').x-position.x*WWESL_CONFIG.get('gridZoomScale');var deltaY=WWESL_CONFIG.get('gridZoomTarget').y-position.y*WWESL_CONFIG.get('gridZoomScale');var newX=WWESL_CONFIG.get('gridPosition').left+deltaX+12;var newY=WWESL_CONFIG.get('gridPosition').top+deltaY+50;return{x:newX,y:newY};},initDeepLink:function(event){if(!WWESL_STATE.get('applicationInitialized')){setTimeout(this.initDeepLink.bind(this,event),500);return;}
var selectedItem=null;if(!this.category.selectedVideoIndex){this.category.contents.push(event.video);this.category.selectedVideoIndex=this.category.contents.length-1;}
this.category.selectedVideoIndex=this.category.selectedVideoIndex.valueOf();selectedItem=this.items[this.category.selectedVideoIndex%this.size];var page=Math.ceil(this.category.selectedVideoIndex/this.size);page=page===0?1:page;this.application.gridNav.goTo(page);setTimeout(function(){selectedItem.select();},500);},cloneObject:function(object){var newObject={};for(var property in object){newObject[property]=object[property];}
return newObject;}});if(!WWESL){var WWESL={};}
WWESL.SimpleGridItem=Class.create(Base,{initialize:function(application,id,xaml){this.CLASS_NAME='SimpleGridItem';this.application=application;this.id=id;this.width=WWESL_CONFIG.get('gridWidth');this.height=WWESL_CONFIG.get('gridHeight');this.spacing=WWESL_CONFIG.get('gridSpacing');this.createItem(xaml);this.transitioning=false;this.subscribe('PageTurnComplete',function(){this.transitioning=false;}.bind(this));},createItem:function(xaml){this.item=new WWESL.Item(xaml);this.item.attach(this.application.find('gridHolder'));this.item.setGridPosition(this.id,WWESL_CONFIG.get('gridRows'),this.width,this.height,this.spacing);},setData:function(data){this.data=data;this.item.setData(data);},clear:function(){this.item.clear();},transition:function(){if(!this.transitioning){this.item.transition();this.transitioning=true;}},updateThumb:function(){this.item.updateThumb();}});WWESL.GridItem=Class.create(WWESL.SimpleGridItem,{initialize:function(application,id,itemXaml,detailsXaml){this.parent(application,id,itemXaml);this.CLASS_NAME='GridItem';this.createDetails(detailsXaml);},createDetails:function(xaml){this.details=new WWESL.Details(xaml);this.details.attach(this.application.find('gridDetailsHolder'));this.details.setGridPosition(this.id,WWESL_CONFIG.get('gridRows'),this.width,this.height,this.spacing);},setData:function(data){this.data=data;this.item.setData(data);this.details.setData(data);},clear:function(){this.item.clear();this.details.clear();},select:function(){this.details.onClick();}});WWESL.Item=Class.create(SL.Partial,{initialize:function(xaml){this.parent(xaml);this.CLASS_NAME='GridItem Item';this.front=this.find('front');this.back=this.find('back');this.gridPromo=this.find('gridPromo');this.videoBg=this.find('videoBg');this.categoryBg=this.find('categoryBg');this.videoBlur=this.find('videoTextBlur');this.categoryBlur=this.find('categoryTextBlur');this.thumbnail=this.find('thumbnail');this.title=this.find('title');if(WWESL_CONFIG.get('templates')!=''&&WWESL_CONFIG.get('templates').gridPromo){this.gridPromo.source=WWESL_CONFIG.get('templates').gridPromo;}
this.subscribe('GridPromoUpdated',function(event){this.gridPromo.source=event.source;}.bind(this));this.setupTransition();},setGridPosition:function(index,rows,width,height,spacing){this.fragment['Canvas.Top']=(height+spacing)*(index%rows);this.fragment['Canvas.Left']=(width+spacing)*Math.floor(index/rows);},setData:function(data){this.front.visibility='visible';this.data=data;this.setType(data.type);this.setThumbnail(data.thumbnail);this.setTitle(data.title);},setType:function(type){if(type=='category'){this.categoryBg.visibility='visible';this.videoBg.visibility='collapsed';try{this.videoBlur.visibility='collapsed';this.categoryBlur.visibility='visible';}catch(e){}
this.title.foreground=WWESL.Parameters.categoryTextColor;}else{this.videoBg.visibility='visible';this.categoryBg.visibility='collapsed';try{this.videoBlur.visibility='visible';this.categoryBlur.visibility='collapsed';}catch(e){}
this.title.foreground=WWESL.Parameters.videoTextColor;}},setThumbnail:function(url){this.thumbnail.source=WWESL_CONFIG.get('gridLoadingImage');this.source=url;},updateThumb:function(){this.thumbnail.source=WWESL_CONFIG.get('assetBase')+this.source;},setTitle:function(title){if(title){this.title.text=title.toUpperCase();}else{this.title.text='';}},clear:function(){this.front.visibility='collapsed';this.thumbnail.source='';},setupTransition:function(){this.tween=new Tween({obj:this.find('scaler'),prop:'scaleX',begin:0,end:1,func:Tween.easeOutExpo},0.5);},transition:function(){if(this.front.visibility.toLowerCase()=='visible'){this.tween.start();}}});WWESL.Details=Class.create(SL.Partial,{initialize:function(xaml){this.parent(xaml);this.CLASS_NAME='GridItem Details';this.target=this.find('target');this.targetScale=this.find('targetScale');this.details=this.find('details');this.detailsScale=this.find('detailsScale');this.thumbnail=this.find('thumbnail');this.categoryBg=this.find('categoryChrome');this.videoBg=this.find('videoChrome');this.videoBlur=this.find('videoTextBlur');this.categoryBlur=this.find('categoryTextBlur');this.title=this.find('title');this.date=this.find('date');this.description=this.find('description');this.initEvents();},setData:function(data){this.target.visibility='visible';this.data=data;this.setType(data.type);this.setThumbnail(data.thumbnail);this.setTitle(data.title);this.setDate(data.date,data.type);this.setDescription(data.description);},setType:function(type){this.type=type;if(type=='category'){this.categoryBg.visibility='visible';this.date.foreground=WWESL.Parameters.categoryTextColor;this.description.foreground=WWESL.Parameters.categoryTextColor;this.title.foreground=WWESL.Parameters.categoryBoldTextColor;try{this.videoBlur.visibility='collapsed';this.categoryBlur.visibility='visible';}catch(e){}}else{this.categoryBg.visibility='collapsed';this.date.foreground=WWESL.Parameters.videoTextColor;this.description.foreground=WWESL.Parameters.videoTextColor;this.title.foreground=WWESL.Parameters.videoBoldTextColor;try{this.videoBlur.visibility='visible';this.categoryBlur.visibility='collapsed';}catch(e){}}},setThumbnail:function(url){this.thumbnail.source=WWESL_CONFIG.get('gridLoadingImage');this.thumbnail.visibility='visible';if(url){this.thumbnail.source=WWESL_CONFIG.get('assetBase')+url;}},setTitle:function(title){if(title){this.title.text=title.toUpperCase();}else{this.title.text='';}},setDate:function(date,type){if(type=='category'){this.date.text='CATEGORY';return;}
this.date.text=date?date:'';},setDescription:function(text){this.description.text=text?text:'';},setGridPosition:function(index,rows,width,height,spacing){this.fragment['Canvas.Top']=(height+spacing)*(index%rows);this.fragment['Canvas.Left']=(width+spacing)*Math.floor(index/rows);this.alterPosition();},alterPosition:function(){var absPos=Silverlight.absolute(this.details),container=Silverlight.absolute(this.container);if(absPos.x<container.x){this.details['Canvas.Left']+=container.x-absPos.x;}
if(absPos.y<container.y){this.details['Canvas.Top']+=container.y-absPos.y;}
if(absPos.x+this.details.width>container.x+this.container.width){this.details['Canvas.Left']-=(absPos.x+this.details.width)-(container.x+this.container.width);}
if(absPos.y+this.details.height>container.y+this.container.height){this.details['Canvas.Top']-=(absPos.y+this.details.height)-(container.y+this.container.height);}
if(absPos.x+this.details.width>WWESL.Parameters.adHolderX&&absPos.y+this.details.height>WWESL.Parameters.adHolderY){this.details['Canvas.Left']-=((absPos.x+this.details.width)-WWESL.Parameters.adHolderX)/2;}
var targetMiddleX=this.target['Canvas.Left']+(this.target.width/2),targetMiddleY=this.target['Canvas.Top']+(this.target.height/2),offsetX=this.details['Canvas.Left']-this.target['Canvas.Left'],offsetY=this.details['Canvas.Top']-this.target['Canvas.Top'],pointX=targetMiddleX-offsetX,pointY=targetMiddleY-offsetY,pointPercent=[pointX/this.details.width,pointY/this.details.height];this.details.renderTransformOrigin=pointPercent.join(',');},initEvents:function(){this.overTween=new Tween([{obj:this.targetScale,prop:'scaleX',end:1.1,func:Tween.easeOutExpo},{prop:'scaleY'},{obj:this.detailsScale,prop:'scaleX',end:1},{prop:'scaleY'},{obj:this.details,prop:'opacity',end:1}],0.5);this.outTween=new Tween([{obj:this.targetScale,prop:'scaleX',end:1,func:Tween.easeOutExpo},{prop:'scaleY'},{obj:this.detailsScale,prop:'scaleX',end:.5},{prop:'scaleY'},{obj:this.details,prop:'opacity',end:0}],0.1);this.outTween.addListener('onMotionFinished',this.hideDetails.bind(this));this.target.addEventListener('MouseEnter',this.onOver.bind(this));this.target.addEventListener('MouseLeave',this.onOut.bind(this));this.target.addEventListener('MouseLeftButtonDown',this.onClick.bind(this));},onOver:function(s,a){this.details.visibility='Visible';this.outTween.stop();this.overTween.startFromHere();},onOut:function(s,a){this.overTween.stop();this.outTween.startFromHere();},onClick:function(){if(!this.data||!this.data.id){this.error('Cannot launch player: no data');this.broadcast('VideoErrorOccurred');return;}
if(this.type=='category'){this.broadcast('CategorySelected',{categoryId:this.data.id});}else{this.broadcast('VideoSelected',{videoId:this.data.id});this.broadcast('GridVideoSelected',{position:this.centerOfTarget()});}
this.onOut();},hideDetails:function(){this.details.visibility='Collapsed';},centerOfTarget:function(){if(!this._centerOfTarget){this._centerOfTarget=Silverlight.absolute(this.target);this._centerOfTarget.x+=WWESL_CONFIG.get('gridWidth')/2;this._centerOfTarget.y+=WWESL_CONFIG.get('gridHeight')/2;}
return this._centerOfTarget;},clear:function(){this.onOut();this.target.visibility='collapsed';this.thumbnail.source='';}});if(!WWESL){var WWESL={};}
WWESL.GridNavigation=Class.create(Base,{initialize:function(application){this.CLASS_NAME='GridNavigation';this.application=application;this.application.waitFor(this);this.arrowWidth=WWESL_CONFIG.get('gridNavArrowWidth');this.buttonWidth=WWESL_CONFIG.get('gridNavButtonWidth');this.container=this.application.find('gridNavHolder');this.setup();this.initEvents();},setup:function(){this.application.getZip(WWESL_CONFIG.get('xamlPath')+'xaml.zip',function(zip){this.xaml=new SL.Partial(zip.get('gridNavigation.xaml'));this.xaml.attach(this.container);this.xaml.set('visibility','collapsed');this.getElements();zip.destroy();zip=null;this.application.nowReady(this);this.ready=true;}.bind(this));},initEvents:function(){this.subscribe('CategoryLoaded',this.setData.bind(this));this.subscribe('ApplicationInitialized',this.display.bind(this));this.subscribe('GridZoomIn',this.hide.bind(this));this.subscribe('GridZoomOut',this.show.bind(this));},selectPage:function(){this.broadcast('PageSelected',{page:this.currentPage,category:this.category});},goTo:function(page){this.currentPage=page;this.display();this.selectPage();},getElements:function(){this.backButton=this.xaml.find('back');this.backArrow=this.xaml.find('back_arrow');this.backHit=this.xaml.find('back_hit');this.backHit.cursor='Hand';this.backHit.addEventListener('MouseEnter',this.onMouseEnterArrow.bind(this));this.backHit.addEventListener('MouseLeave',this.onMouseLeaveArrow.bind(this));this.backHit.addEventListener('MouseLeftButtonDown',this.onBack.bind(this,i));this.nextButton=this.xaml.find('next');this.nextArrow=this.xaml.find('next_arrow');this.nextHit=this.xaml.find('next_hit');this.nextHit.cursor='Hand';this.nextHit.addEventListener('MouseEnter',this.onMouseEnterArrow.bind(this));this.nextHit.addEventListener('MouseLeave',this.onMouseLeaveArrow.bind(this));this.nextHit.addEventListener('MouseLeftButtonDown',this.onNext.bind(this));this.buttons=[];this.textBlocks=[];this.hits=[];for(var i=0;i<5;i++){this.buttons[this.buttons.length]=this.xaml.find('button_'+i);this.textBlocks[this.textBlocks.length]=this.xaml.find('text_'+i);var hit=this.xaml.find('hit_'+i);hit.cursor='Hand';hit.addEventListener('MouseEnter',this.onMouseEnter.bind(this,i));hit.addEventListener('MouseLeave',this.onMouseLeave.bind(this,i));hit.addEventListener('MouseLeftButtonDown',this.onClick.bind(this,i));this.hits[this.hits.length]=hit;}},setData:function(event){this.category=event.category;this.numPages=Math.ceil(event.category.contents.length/WWESL_CONFIG.get('gridSize'));this.currentPage=1;this.windowStart=1;this.windowSize=this.numPages<5?this.numPages:5;if(this.ready){this.update();}},display:function(){this.center();this.centerText();if(this.numPages>1){this.xaml.set('visibility','visible');}
this.update();},update:function(){this.moveWindow();this.setText();this.centerText();this.enableArrows();this.center();if(this.numPages>1){this.xaml.set('visibility','visible');}else{this.xaml.set('visibility','collapsed');}},moveWindow:function(){if(this.currentPage>this.windowStart+(this.windowSize-1)){this.windowStart+=this.currentPage-(this.windowStart+(this.windowSize-1));}else if(this.currentPage<this.windowStart){this.windowStart-=this.windowStart-this.currentPage;}},center:function(){for(var i=0;i<5;i++){if(i>this.windowSize-1){this.buttons[i].visibility='Collapsed';}else{this.buttons[i].visibility='Visible';}}
this.width=this.arrowWidth*2+(this.windowSize*(this.buttonWidth+1));this.nextButton['Canvas.Left']=this.width-this.arrowWidth+1;this.xaml.fragment['Canvas.Left']=Math.round(-this.width/2);},centerText:function(){for(var i=0;i<5;i++){var aWidth=this.textBlocks[i].actualWidth,offset=Math.round(this.buttonWidth/2-aWidth/2);this.textBlocks[i]['Canvas.Left']=offset;}},setText:function(){for(var i=0;i<5;i++){this.textBlocks[i].text=(this.windowStart+i).toString();if((this.windowStart+i)==this.currentPage){this.textBlocks[i].foreground=WWESL_CONFIG.get('textHoverColor');this.hits[i].visibility='Collapsed';}else{this.textBlocks[i].foreground=WWESL_CONFIG.get('textColor');this.hits[i].visibility='Visible';}}},disableArrows:function(){this.backHit.isHitTestVisible=false;this.nextHit.isHitTestVisible=false;this.backArrow.fill=WWESL_CONFIG.get('textDisabledColor');this.nextArrow.fill=WWESL_CONFIG.get('textDisabledColor');},enableArrows:function(){if(this.currentPage>1){this.backHit.isHitTestVisible=true;this.backArrow.fill=WWESL_CONFIG.get('textColor');}else{this.backHit.isHitTestVisible=false;this.backArrow.fill=WWESL_CONFIG.get('textDisabledColor');}
if(this.currentPage<this.numPages){this.nextHit.isHitTestVisible=true;this.nextArrow.fill=WWESL_CONFIG.get('textColor');}else{this.nextHit.isHitTestVisible=false;this.nextArrow.fill=WWESL_CONFIG.get('textDisabledColor');}},onMouseEnter:function(index){this.textBlocks[index].foreground=WWESL_CONFIG.get('textHoverColor');},onMouseLeave:function(index){this.textBlocks[index].foreground=WWESL_CONFIG.get('textColor');},onClick:function(index){this.currentPage=Number(this.textBlocks[index].text);this.update();this.selectPage();},onBack:function(){this.currentPage=this.currentPage>1?this.currentPage-1:1;this.update();this.selectPage();},onNext:function(){this.currentPage=this.currentPage<this.numPages?this.currentPage+1:this.numPages;this.update();this.selectPage();},onMouseEnterArrow:function(sender){this[sender.name.replace('_hit','')+'Arrow'].fill=WWESL_CONFIG.get('textHoverColor');},onMouseLeaveArrow:function(sender){this[sender.name.replace('_hit','')+'Arrow'].fill=WWESL_CONFIG.get('textColor');},show:function(){if(!this.showTween){this.showTween=new Tween({obj:this.container,prop:'opacity',end:1,func:Tween.easeOutExpo},1);}
this.showTween.startFromHere();},hide:function(){if(!this.hideTween){this.hideTween=new Tween({obj:this.container,prop:'opacity',end:0,func:Tween.easeOutExpo},1);}
this.hideTween.startFromHere();}});if(!WWESL){var WWESL={};}
WWESL.Loading=Class.create(Base,{initialize:function(application){this.CLASS_NAME='Loading';this.application=application;this.setupSpinner();this.setupMovie();this.initEvents();},initEvents:function(){this.subscribe('CategorySelected',this.showSpinner.bind(this));this.subscribe('SearchSubmitted',this.showSpinner.bind(this));this.subscribe('CategoryLoaded',this.hideSpinner.bind(this));this.subscribe('VideoLoaded',this.hideSpinner.bind(this));this.subscribe('AlertRaised',this.hideSpinner.bind(this));this.subscribe('ApplicationInitialized',this.hideSpinner.bind(this));this.subscribe('EnterFullScreen',this.enterFullScreen.bind(this));this.subscribe('ExitFullScreen',this.exitFullScreen.bind(this));this.subscribe('ActivePlayerOpened',this.hideSpinner.bind(this));},setupSpinner:function(){this.spinnerImage=this.application.find('spinnerImage');this.oldSpinnerPosition={x:this.spinnerImage['Canvas.Left'],y:this.spinnerImage['Canvas.Top']};this.spinnerAnimation=this.application.find('spinnerAnimation');this.spinnerAnimation.begin();},setupMovie:function(){this.movieContainer=this.application.find('loadingMovie');this.movieElement=this.application.find('loadingMovieElement');},showSpinner:function(){this.spinnerImage.visibility='visible';this.spinnerAnimation.begin();},hideSpinner:function(){this.spinnerImage.visibility='collapsed';this.spinnerAnimation.stop();},showMove:function(){this.movieContainer.visibility='visible';this.movieElement.play();},hideMovie:function(){this.movieContainer.visibility='collapsed';this.movieElement.stop();},enterFullScreen:function(){this.spinnerImage['Canvas.Left']=this.application.plugin.content.actualWidth/2-this.spinnerImage.width/2-21;this.spinnerImage['Canvas.Top']=this.application.plugin.content.actualHeight/2-this.spinnerImage.height/2-84;},exitFullScreen:function(){this.spinnerImage['Canvas.Left']=this.oldSpinnerPosition.x;this.spinnerImage['Canvas.Top']=this.oldSpinnerPosition.y;}});if(!WWESL){var WWESL={};}
WWESL.Navigation=Class.create(Base,{initialize:function(application){this.CLASS_NAME='Navigation';this.application=application;this.application.waitFor(this);this.params=WWESL_CONFIG.get('navigation');this.setup();},setup:function(){this.application.getZip(WWESL_CONFIG.get('xamlPath')+'xaml.zip',function(zip){this.xaml=new SL.Partial(zip.get('topNav.xaml'));this.xaml.attach(this.application.find('topNavHolder'));this.buttons=[];for(var i=0,j=this.params.length;i<j;i++){this.buttons[this.buttons.length]=new WWESL.NavButton(this.params,i,this.xaml.find('buttons'),zip.get('topNavButton.xaml'));}
this.subscribe('CategoryLoaded',this.checkForSelected.bind(this));this.subscribe('CategoryRefreshed',this.checkForSelected.bind(this));zip.destroy();zip=null;this.application.nowReady(this);}.bind(this));},setupSearch:function(){this.searchForm=document.getElementById('searchForm');this.searchForm.style.display='block';this.queryInput=document.getElementById('query');Schematic.Event.add(this.searchForm,'submit',function(event){event.stopPropagation();event.preventDefault();if(this.queryInput.value.length>128){this.broadcast('SearchQueryTooLong');return false;}
if(this.queryInput.value=='Search'||this.queryInput.value.match(/^\s*$/)!==null){return false;}
this.broadcast('SearchSubmitted',{query:this.queryInput.value});}.bind(this));Schematic.Event.add(this.queryInput,'focus',function(){if(this.queryInput.value=='Search'){this.queryInput.value='';}}.bind(this));Schematic.Event.add(this.queryInput,'blur',function(){if(this.queryInput.value==''){this.queryInput.value='Search';}}.bind(this));},onOver:function(){this.searchSubmit.source=this.searchSubmit.source.replace('_sel.jpg','.jpg');},onOut:function(){this.searchSubmit.source=this.searchSubmit.source.replace('.jpg','_sel.jpg');},onSubmit:function(){if(!this.queryInput){return;}
this.broadcast('SearchSubmitted',{query:this.queryInput.value});},checkForSelected:function(event){for(var i=0,j=this.buttons.length;i<j;i++){this.buttons[i].checkForSelected(event);}}});WWESL.NavButton=Class.create(SL.Partial,{initialize:function(params,index,container,xaml){this.parent(xaml);this.CLASS_NAME='NavButton';this.index=index;this.container=container;this.params=params[index];this.setup(params);this.initEvents();this.attach(this.container);},setup:function(params){this.offset=this.getOffset(params,this.index);this.set('Canvas.Left',this.offset);this.hit=this.find('hit');this.hit.width=parseInt(this.params.width);this.label=this.find('label');this.label.text=this.params.name;this.label['Canvas.Left']=this.hit.width/2-this.label.actualWidth/2;this.label['Canvas.Top']=this.hit.height/2-this.label.actualHeight/2;if(WWESL_STATE.get('categoryId')==this.params.id){this.select();}},getOffset:function(params,index){var offset=0;for(var i=0;i<index;i++){offset+=parseInt(params[i].width);}
return offset;},initEvents:function(){this.hit.cursor='Hand';this.hit.addEventListener('MouseEnter',this.onOver.bind(this));this.hit.addEventListener('MouseLeave',this.onOut.bind(this));this.hit.addEventListener('MouseLeftButtonDown',this.onClick.bind(this));},checkForSelected:function(event){if(this.selected){this.deselect();}
if(this.deferSelecting){this.deferSelecting=false;return;}
if(event.category&&event.category.id==this.params.id){this.select();}
if(WWESL_STATE.get('topLevelCategoryId')==this.params.id){this.select();}},onOver:function(){this.label.foreground=WWESL_CONFIG.get('textHoverColor');},onOut:function(){if(this.selected){return;}
this.label.foreground=WWESL_CONFIG.get('textColor');},onClick:function(){this.broadcast('CategorySelected',{categoryId:this.params.id,topLevel:true});},select:function(){this.selected=true;this.label.foreground=WWESL_CONFIG.get('textHoverColor');},deselect:function(defer){this.selected=false;this.hit.visibility='visible';this.label.foreground=WWESL_CONFIG.get('textColor');if(defer){this.deferSelecting=true;}}});if(!WWESL){var WWESL={};}
WWESL.Parameters={textColor:'#FFE03635',textHoverColor:'#FFFFFFFF',textDisabledColor:'#33FFFFFF',assetBase:'',proxy:false,xamlPath:'/silverlight/xaml/',siteName:'wwe.silverlight',zoneName:'featured_index',doubleClickPreRoll:'http://ad.doubleclick.net/pfadx/',wwePreRoll:'http://wmsvod.wwe.com/wwe/sponsor300.wmv',wweLoading:'/silverlight/images/loadwwe.wmv',lightningCastParams:{networkId:'11375',lname:'WWE:WWE',region:'StandardBanner',format:'Video-Windows-300-320x240'},applicationWidth:978,gridSize:30,gridRows:5,gridColumns:6,gridExtraColumns:3,gridWidth:106,gridHeight:94,gridSpacing:4,adHolderX:656,adHolderY:373,categoryTextColor:'#FF333333',videoTextColor:'#FFBBBBBB',categoryBoldTextColor:'#FF333333',videoBoldTextColor:'#FFE03635',gridPosition:{left:21,top:84},gridZoomScale:1.5,gridZoomTarget:{x:356,y:264},gridItemThumbSpecs:{stretch:'Fill',left:3,top:4,width:100,height:75},gridDetailsThumbSpecs:{stretch:'Fill',left:5,top:4,width:170,height:126},gridLoadingImage:'/silverlight/images/loading.jpg',gridNavArrowWidth:18,gridNavButtonWidth:38,breadcrumbSpacing:20,breadcrumbTextColor:'#FFDDDDDD',breadcrumbTextHoverColor:'#FFFFFFFF',posterSpecs:{top:'0',left:'430'},posterTimer:10000,recessedPlayerOrigin:{x:427,y:59},mediaElement:'mainMediaPlayer',loaderElement:'mainMediaLoader',mediaEndAtProgress:0.9895,mediaFlagAtProgress:0.95,mediaFlagInterval:5000,defaultVideoMode:'SD',videoActiveClosePosWD:{x:489,y:-12},videoActiveCromePosWD:{x:-116,y:-33,w:671,h:468},videoActiveCromeWD:'/silverlight/images/video_player/video_player_big_bckg.png',videoActiveMediaWD:{x:-50,y:16,w:532,h:300},videoActiveClosePosSD:{x:424,y:-12},videoActiveCromePosSD:{x:-45,y:-43,w:523,h:474},videoActiveCromeSD:'/silverlight/images/video_player/video_player_backg.png',videoActiveMediaSD:{x:16,y:16,w:400,h:300},playImgPath:'/silverlight/images/video_player/video_player_play_btn_on.jpg',pauseImgPath:'/silverlight/images/video_player/video_player_pause_btn_on.jpg',volumeImgPath:'/silverlight/images/video_player/video_player_volume_btn_on.jpg',muteImgPath:'/silverlight/images/video_player/video_player_mute_btn_on.jpg',diggURL:'http://digg.com/submit?url=',delURL:'http://del.icio.us/post?url=',videoDeepLink:'http://www.wwe.com/wwe/?videoId={0}&categoryId={1}',activeCarouselItemWidth:110,miniCarouselItemWidth:57,activeCarouselClipWidth:435,miniCarouselClipWidth:224,relatedButtonHeight:23,errorCodes:{'ApplicationError':{message:'There was a problem accessing WWE.com. Please check your Internet connection and reload the page.'},'VideoErrorOccurred':{message:'This video could not be requested. Please try again.'},'CategoryErrorOccurred':{message:'This category could not be requested. Please try again.'},'EmptyContentsError':{message:'This category is empty. Please choose another one.'},'EmptySearchError':{message:'Your search returned zero results. Please try again.'},'SearchQueryTooLong':{message:'Your search is too long. Please enter 128 characters or less.'},'VideoNotFound':{message:'The video you selected was not found. Please choose another one.'}}};if(!WWESL){var WWESL={};}
WWESL.Playlist=Class.create(Base,{initialize:function(videoData){if(!videoData.bannerURL||videoData.bannerURL=='mms://stream10.instream.com/sample_content/blankvid.wmv'||videoData.bannerURL.indexOf('doubleclick.net/EMEA/test_eugenio/wmv/motif_splash_320x240_450K.wmv')>-1){this.missingAd=true;this.videos=[videoData.video.source];}else{this.missingAd=false;this.videos=[videoData.bannerURL,videoData.video.source];}
if(videoData.video&&videoData.video.widescreen===true||videoData.video.widescreen==='true'){this.aspectRatio='WD';}else{this.aspectRatio='SD';}
this.currentIndex=-1;this.total=this.videos.length;},getNext:function(){this.currentIndex++;if(this.currentIndex<this.total){return this.videos[this.currentIndex];}else{return null;}},isAd:function(){if(this.missingAd){return false;}
return(this.currentIndex)==0;},isPreroll:function(){if(this.missingAd){return false;}
return(this.currentIndex)==0;},isFeatured:function(){if(this.missingAd){return true;}
return(this.currentIndex)==1;}});if(!WWESL){var WWESL={};}
WWESL.Related=Class.create(Base,{initialize:function(application){this.CLASS_NAME='Related';this.application=application;this.application.waitFor(this);this.initEvents();this.createElements();},initEvents:function(){this.subscribe('VideoLoaded',this.loadData.bind(this));this.subscribe('ActivePlayerOpened',this.show.bind(this));this.subscribe('ActivePlayerClosed',this.hide.bind(this));this.subscribe('ActivePlayerHidden',this.hide.bind(this));this.subscribe('VideoSelected',this.hide.bind(this));},createElements:function(){this.buttons=[];this.application.getZip(WWESL_CONFIG.get('xamlPath')+'xaml.zip',function(zip){this.xaml=new SL.Partial(zip.get('related.xaml'));this.xaml.attach(this.application.find('relatedHolder'));this.buttonHolder=this.xaml.find('buttonHolder');this.buttonMaker=zip;this.setupScroll();this.application.nowReady(this);}.bind(this));},setupScroll:function(){this.scrollUpBtn=this.xaml.find('scrollUp');this.scrollUpBtn.addEventListener('MouseEnter',this.onOver.bind(this));this.scrollUpBtn.addEventListener('MouseLeave',this.onOut.bind(this));this.scrollUpBtn.addEventListener('MouseLeftButtonDown',this.onClick.bind(this,-1));this.scrollUpBtn.addEventListener('MouseLeftButtonUp',this.onRelease.bind(this));this.scrollDownBtn=this.xaml.find('scrollDown');this.scrollDownBtn.addEventListener('MouseEnter',this.onOver.bind(this));this.scrollDownBtn.addEventListener('MouseLeave',this.onOut.bind(this));this.scrollDownBtn.addEventListener('MouseLeftButtonDown',this.onClick.bind(this,1));this.scrollDownBtn.addEventListener('MouseLeftButtonUp',this.onRelease.bind(this));},updateScroll:function(){if(this.buttonHolder['Canvas.Top']<=this.topBounds){this.scrollDownBtn.opacity=0.4;this.scrollDownBtn.isHitTestVisible=false;this.scrollDownBtn.cursor='Default';}else{this.scrollDownBtn.opacity=0.7;this.scrollDownBtn.isHitTestVisible=true;this.scrollDownBtn.cursor='Hand';}
if(this.buttonHolder['Canvas.Top']>=0){this.scrollUpBtn.opacity=0.4;this.scrollUpBtn.isHitTestVisible=false;this.scrollDownBtn.cursor='Default';}else{this.scrollUpBtn.opacity=0.7;this.scrollUpBtn.isHitTestVisible=true;this.scrollDownBtn.cursor='Hand';}},loadData:function(event){if(!event.video.related){this.hide();return;}
if(event.video.related.length===undefined){event.video.related=[event.video.related];}
this.clear();for(var i=0,j=event.video.related.length;i<j;i++){this.buttons[this.buttons.length]=new WWESL.RelatedItem(this,this.buttonMaker.get('relatedButton.xaml'),event.video.related[i],i);}
this.topBounds=-(this.buttons.length-3)*WWESL_CONFIG.get('relatedButtonHeight');this.buttonHolder['Canvas.Top']=0;this.updateScroll();if(this.buttons.length>0&&WWESL_STATE.get('playerActive')){this.show();}else{this.hide();}},clear:function(){for(var i=0,j=this.buttons.length;i<j;i++){this.buttons[i].destroy();delete this.buttons[i];if(this.buttonHolder.children.count>0){this.buttonHolder.children.removeAt(0);}}
this.buttons=[];},show:function(){if(this.buttons.length<1){return;}
this.xaml.set('visibility','visible');},hide:function(){this.xaml.set('visibility','collapsed');},onOver:function(sender){if(sender.opacity!=0.4){sender.opacity=1;}},onOut:function(sender){sender.opacity=0.7;},onClick:function(direction){this.startScroll(direction*-4);},onRelease:function(){this.stopScroll();},startScroll:function(speed){if(this.scrollInterval){clearInterval(this.scrollInterval);this.scrollInterval=null;}
this.scroll(speed);this.updateScroll();this.scrollInterval=setInterval(this.scroll.bind(this,speed),50);},scroll:function(speed){var newPosition=this.buttonHolder['Canvas.Top']+speed;if(newPosition>0){this.buttonHolder['Canvas.Top']=0;}else if(newPosition<this.topBounds){this.buttonHolder['Canvas.Top']=this.topBounds;}else{this.buttonHolder['Canvas.Top']=newPosition;}},stopScroll:function(){if(this.scrollInterval){clearInterval(this.scrollInterval);this.scrollInterval=null;}
this.updateScroll();}});WWESL.RelatedItem=Class.create(Base,{initialize:function(container,xaml,data,index){this.CLASS_NAME='RelatedItem';this.container=container;this.xaml=new SL.Partial(xaml);this.data=data;this.index=index;this.setup();},setup:function(){this.text=this.xaml.find('text');if(this.data.title){this.text.text=this.data.title;}else if(this.data.name){this.text.text=this.data.name;}
this.xaml.set('Canvas.Top',this.xaml.get('height')*this.index);this.hit=this.xaml.find('hit');this.hitToken=this.hit.addEventListener('MouseLeftButtonDown',this.select.bind(this));this.hit.cursor='Hand';this.xaml.attach(this.container.buttonHolder);},select:function(){var id=this.data.id||this.data.key;this.broadcast('RelatedCategorySelected');this.broadcast('CategorySelected',{categoryId:id});},destroy:function(){this.container=null;this.hit.removeEventListener('MouseLeftButtonDown',this.hitToken);}});if(!WWESL){var WWESL={};}
WWESL.SkinController=Class.create(Base,{initialize:function(application){this.CLASS_NAME='SkinController';this.application=application;this.setup();},setup:function(){this.template={};this.posterHolder=this.application.find('posterHolder');this.scrimImage=this.application.find('scrim');this.rightPromoImage=this.application.find('rightPromoImage');this.leftPromoImage=this.application.find('leftPromoImage');this.initEvents();},initEvents:function(){this.subscribe('ApplicationInitialized',this.beginDisplay.bind(this));this.subscribe('CategoryLoaded',this.update.bind(this));this.subscribe('VideoLoaded',this.update.bind(this));this.subscribe('RecessedPlayerHidden',this.beginPosterDisplay.bind(this));this.subscribe('RecessedPlayerOpened',this.hidePosters.bind(this));this.subscribe('ActivePlayerOpened',this.showPromos.bind(this));this.subscribe('ActivePlayerHidden',this.hidePromos.bind(this));},update:function(event){var params;if(event.category){params=event.category.templates;}else if(event.video){params=event.video.templates;}
for(var property in params){this['setup_'+property](params[property]);}},setup_posters:function(posterArray){if(typeof posterArray==='string'){posterArray=[posterArray];}
this.template.posters=[];var tempArray=[],tempValue,unique;for(var i=0,j=posterArray.length;i<j;i++){tempValue=posterArray[i];unique=true;for(var ii=0,jj=tempArray.length;ii<jj;ii++){if(tempValue===tempArray[ii]){unique=false;}}
if(unique){this.template.posters[this.template.posters.length]=tempValue;tempArray[tempArray.length]=tempValue;}}
this.beginPosterDisplay();},setup_posterRand:function(){},setup_scrim:function(value){if(!value){return;}
this.scrimImage.source=WWESL_CONFIG.get('assetBase')+value;},setup_gridPromo:function(value){this.broadcast('GridPromoUpdated',{source:WWESL_CONFIG.get('assetBase')+value});},setup_rightPromo:function(value){try{this.rightPromoImage.source=WWESL_CONFIG.get('assetBase')+value[0];this.rightPromoImage.cursor='Hand';if(this.rightPromoImageToken){this.rightPromoImage.removeEventListener('MouseLeftButtonUp',this.rightPromoImageToken);}
this.rightPromoImageToken=this.rightPromoImage.addEventListener('MouseLeftButtonUp',function(){window.open(value[1]);});}catch(e){}},setup_leftPromo:function(value){try{this.leftPromoImage.source=WWESL_CONFIG.get('assetBase')+value[0];this.leftPromoImage.cursor='Hand';if(this.leftPromoImageToken){this.leftPromoImage.removeEventListener('MouseLeftButtonUp',this.leftPromoImageToken);}
this.leftPromoImageToken=this.leftPromoImage.addEventListener('MouseLeftButtonUp',function(){window.open(value[1]);});}catch(e){}},showPromos:function(){this.rightPromoImage.visibility='visible';this.leftPromoImage.visibility='visible';},hidePromos:function(){this.rightPromoImage.visibility='collapsed';this.leftPromoImage.visibility='collapsed';},beginDisplay:function(){if(!WWESL_STATE.get('applicationInitialized')){return;}
this.beginPosterDisplay();},beginPosterDisplay:function(){if(!this.template.posters||!WWESL_STATE.get('applicationInitialized')){return;}
this.teardownPosters();setTimeout(function(){this.postersLoading=[];this.postersInQueue=[];this.currentPoster=null;this.currentPosterIndex=0;this.createPosters();}.bind(this),800);},createPosters:function(){for(var i=0,j=this.template.posters.length;i<j;i++){this.postersLoading.push(new WWESL.Poster(this,i,this.template.posters[i]));}},posterLoaded:function(index){this.postersInQueue[index]=this.postersLoading[index];if(index==0){this.displayPoster();}},displayPoster:function(){if(WWESL_STATE.get('playerRecessed')){return;}
if(this.postersInQueue[this.currentPosterIndex]){for(var i=0,j=this.postersInQueue.length;i<j;i++){if(this.postersInQueue[i]&&this.postersInQueue[i].hide){this.postersInQueue[i].hide();}}
this.currentPoster=this.postersInQueue[this.currentPosterIndex];this.currentPoster.show();}else{setTimeout(this.displayPoster.bind(this),2000);return;}
if(this.template.posters.length<=1){return;}
this.currentPosterIndex=(this.currentPosterIndex+1>=this.template.posters.length)?0:this.currentPosterIndex+1;if(!this.posterInterval){this.posterInterval=setInterval(this.displayPoster.bind(this),WWESL_CONFIG.get('posterTimer'));}},teardownPosters:function(){if(!this.postersInQueue){return;}
for(var i=0,j=this.postersInQueue.length;i<j;i++){if(this.postersInQueue[i]&&this.postersInQueue[i].hide){this.postersInQueue[i].hide(true);}}
if(this.posterInterval){clearInterval(this.posterInterval);this.posterInterval=null;}
setTimeout(function(){try{for(var i=0,j=this.posterHolder.children.count;i<j;i++){this.posterHolder.children.removeAt(0);}}catch(e){}}.bind(this),700);},hidePosters:function(){if(!this.postersInQueue){return;}
for(var i=0,j=this.postersInQueue.length;i<j;i++){if(this.postersInQueue[i]&&this.postersInQueue[i].hide){this.postersInQueue[i].hide();}}}});WWESL.Poster=Class.create(Base,{include:[SL.Events],initialize:function(parent,index,source){this.CLASS_NAME='Poster';this.parent=parent;this.index=index;this.source=WWESL_CONFIG.get('assetBase')+source;this.image=Silverlight.createElement(WWESL.Plugin,'Image',WWESL_CONFIG.get('posterSpecs'));this.showTween=new Tween({obj:this.image,prop:'Canvas.Left',end:0,func:Tween.easeOutExpo},1);this.hideTween=new Tween({obj:this.image,prop:'Canvas.Left',end:WWESL_CONFIG.get('posterSpecs')['Canvas.Left'],func:Tween.easeOutExpo},0.5);this.addEventListener(this.image,'DownloadProgressChanged',this.onLoad.bind(this));this.parent.posterHolder.children.add(this.image);this.image.source=this.source;},onLoad:function(){if(!this.image){return;}
if(this.image.downloadProgress<1){return;}
this.parent.posterLoaded(this.index);this.removeEventListener(this.image,'DownloadProgressChanged');},show:function(){this.showTween.stop();this.hideTween.stop();this.showTween.startFromHere();},hide:function(destroy){if(destroy){this.hideTween.addListener('onMotionFinished',this.destroy.bind(this));}
this.showTween.stop();this.hideTween.stop();this.hideTween.startFromHere();},destroy:function(){this.removeEventListener(this.image,'DownloadProgressChanged');this.parent=null;this.image=null;}});WWESL.ApplicationState=Class.create(Base,{initialize:function(application){this.application=application;window.WWESL_STATE=this;this.state={};this.set('zoomedIn',false);},set:function(property,value){if(typeof this[property]=='function'){this[property](value);}else{this.state[property]=value;}},get:function(property){return this.state[property];},zoomedIn:function(value){this.state.zoomedIn=value;this.state.zoomedOut=!value;},zoomedOut:function(value){this.state.zoomedOut=value;this.state.zoomedIn=!value;}});if(!WWESL){var WWESL={};}
WWESL.VideoController=Class.create(Base,{initialize:function(application){this.CLASS_NAME='VideoController';this.endReached=true;this.flagSet=false;this.application=application;this.initEvents();this.setup();},initEvents:function(){this.subscribe('PlayClicked',this.handlePlay.bind(this));this.subscribe('ScrubChanged',this.handleScrub.bind(this));this.subscribe('FullScreenClicked',this.handleFullScreen.bind(this));this.subscribe('VolumeClicked',this.handleVolume.bind(this));this.subscribe('DiggClicked',this.handleDigg.bind(this));this.subscribe('DelClicked',this.handleDelicious.bind(this));this.subscribe('ActivePlayerClosed',this.handleVideoClose.bind(this));this.subscribe('VideoSelected',function(){this.stop();this.mediaLoader.position="00:00:00";this.mediaLoader.play();}.bind(this));},setup:function(){this.mediaPlayer=this.application.find(WWESL.Parameters.mediaElement);this.mediaPlayer.volume=1;this.mediaPlayer.addEventListener('MediaEnded',this.handleVideoEnded.bind(this));this.mediaPlayer.addEventListener('MediaFailed',function(){this.broadcast('VideoNotFound');}.bind(this));this.mediaPlayer.addEventListener('downloadProgressChanged',this.handleDownloadProgressChanged.bind(this));this.mediaPlayer.addEventListener('currentStateChanged',this.handleVideoLoaded.bind(this));this.mediaLoader=this.application.find(WWESL.Parameters.loaderElement);this.mediaLoader.source=WWESL.Parameters.wweLoading;this.mediaLoader.addEventListener('MediaEnded',this.handleLoaderEnded.bind(this));},play:function(source){if(source){this.log('Playing video file: '+source);WWESL_STATE.set('moviePlaying',true);this.mediaPlayer.autoPlay=true;this.mediaPlayer.source=source;if(this.playlist&&this.playlist.isAd()){this.broadcast('VideoStarted',this.setData);}
if(this.playlist&&this.playlist.isFeatured()){this.broadcast('ChromeModeChanged',{mode:this.playlist.aspectRatio});}
WWESL_STATE.set('playingStatus','play');this.mediaPlayer.play();this.broadcast('PlaySet',{mode:WWESL_STATE.get('playingStatus')});this.doMediaUpdate();}},doPlaySet:function(setData){if(setData&&setData.video){this.playlist=new WWESL.Playlist(setData);this.setData=setData;WWESL_STATE.set('playingList',true);this.play(this.playlist.getNext());}},stop:function(){if(WWESL_STATE.get('moviePlaying')){WWESL_STATE.set('moviePlaying',false);this.mediaPlayer.stop();this.mediaPlayer.position="00:00:00";this.mediaPlayer.source='';}},doMediaUpdate:function(){var finalProgress=0;try{var currentPosition=this.mediaPlayer.position.seconds;var naturalduration=this.mediaPlayer.naturalDuration.seconds;finalProgress=(1-(naturalduration-currentPosition)/naturalduration);this.broadcast('ScrubSet',{progress:finalProgress});var curMinutes=""+Math.floor(this.mediaPlayer.position.seconds/60);curMinutes=curMinutes.length<2?"0"+curMinutes:curMinutes;var curSeconds=""+Math.floor(this.mediaPlayer.position.seconds%60);curSeconds=curSeconds.length<2?"0"+curSeconds:curSeconds;var finMinutes=""+Math.floor(this.mediaPlayer.naturalDuration.seconds/60);finMinutes=finMinutes.length<2?"0"+finMinutes:finMinutes;var finSeconds=""+Math.floor(this.mediaPlayer.naturalDuration.seconds%60);finSeconds=finSeconds.length<2?"0"+finSeconds:finSeconds;var strProgress=curMinutes+":"+curSeconds+"/"+finMinutes+":"+finSeconds;this.broadcast('DurationSet',{duration:strProgress});}
catch(e){}
if(!this.flagSet&&finalProgress>=WWESL_CONFIG.get('mediaFlagAtProgress')){this.flagSet=true;this.endReached=false;setTimeout(this.handleVideoEnded.bind(this),WWESL_CONFIG.get('mediaFlagInterval'));}
if(finalProgress>=WWESL_CONFIG.get('mediaEndAtProgress')){this.handleVideoEnded();}else if(WWESL_STATE.get('moviePlaying')){setTimeout(this.doMediaUpdate.bind(this),400);}},handlePlay:function(){if(WWESL_STATE.get('moviePlaying')){if(WWESL_STATE.get('playingStatus')){switch(WWESL_STATE.get('playingStatus')){case'play':WWESL_STATE.set('playingStatus','pause');this.mediaPlayer.pause();break;case'pause':WWESL_STATE.set('playingStatus','play');this.mediaPlayer.play();break;}}else{WWESL_STATE.set('playingStatus','play');this.mediaPlayer.play();}
this.broadcast('PlaySet',{mode:WWESL_STATE.get('playingStatus')});}},handleScrub:function(event){if(!this.playlist.isAd()&&event.progress){var mediaDuration=this.mediaPlayer.naturalDuration.seconds;var currentPlayTimeSelected=mediaDuration*event.progress;if(currentPlayTimeSelected>mediaDuration){currentPlayTimeSelected=mediaDuration;}else if(currentPlayTimeSelected<0){currentPlayTimeSelected=0;}
var position=this.mediaPlayer.position;position.seconds=currentPlayTimeSelected;this.mediaPlayer.position=position;this.mediaPlayer.play();var finalProgress=(1-(mediaDuration-position.seconds)/mediaDuration);this.broadcast('ScrubSet',{progress:finalProgress});}},handleVolume:function(){this.mediaPlayer.volume=this.mediaPlayer.volume>0?0:1;var mode=this.mediaPlayer.volume>0?'loud':'mute';this.broadcast('VolumeSet',{mode:mode});},handleFullScreen:function(){this.application.plugin.content.fullScreen=!this.application.plugin.content.fullScreen;},handleVideoClose:function(){this.stop();},handleDigg:function(){if(this.setData&&this.setData.video){var categoryId=WWESL_STATE.get('categoryId');window.open(WWESL.Parameters.diggURL+encodeURIComponent(this.setData.video.shareUrl+'?category='+categoryId));}},handleDelicious:function(){if(this.setData&&this.setData.video){var categoryId=WWESL_STATE.get('categoryId');window.open(WWESL.Parameters.delURL+encodeURIComponent(this.setData.video.shareUrl+'?category='+categoryId));}},handleDownloadProgressChanged:function(){},handleVideoLoaded:function(){if(this.mediaPlayer.currentState=="Playing"&&this.mediaPlayer.bufferingProgress==1){this.mediaLoader.stop();this.broadcast('VideoPlaying');}},handleVideoEnded:function(element){if(!this.endReached&&this.flagSet){this.stop();this.endReached=true;this.flagSet=false;this.stop();var next=this.playlist.getNext();if(next){this.play(next);}
else{this.broadcast("PlaylistEnd");}}},handleLoaderEnded:function(){this.mediaLoader.position="00:00:00";this.mediaLoader.play();}});if(!WWESL){var WWESL={};}
WWESL.VideoController=Class.create(Base,{initialize:function(application){this.CLASS_NAME='VideoController';this.endReached=true;this.flagSet=false;this.application=application;this.initEvents();this.setup();},initEvents:function(){this.subscribe('PlayClicked',this.handlePlay.bind(this));this.subscribe('ScrubChanged',this.handleScrub.bind(this));this.subscribe('FullScreenClicked',this.handleFullScreen.bind(this));this.subscribe('VolumeClicked',this.handleVolume.bind(this));this.subscribe('DiggClicked',this.handleDigg.bind(this));this.subscribe('DelClicked',this.handleDelicious.bind(this));this.subscribe('ActivePlayerClosed',this.handleVideoClose.bind(this));this.subscribe('VideoSelected',function(){this.stop();this.mediaLoader.position="00:00:00";this.mediaLoader.play();}.bind(this));},setup:function(){this.mediaPlayer=this.application.find(WWESL.Parameters.mediaElement);this.mediaPlayer.volume=1;this.mediaPlayer.addEventListener('MediaEnded',this.handleVideoEnded.bind(this));this.mediaPlayer.addEventListener('MediaFailed',function(){this.broadcast('VideoNotFound');}.bind(this));this.mediaPlayer.addEventListener('downloadProgressChanged',this.handleDownloadProgressChanged.bind(this));this.mediaPlayer.addEventListener('currentStateChanged',this.handleVideoLoaded.bind(this));this.mediaLoader=this.application.find(WWESL.Parameters.loaderElement);this.mediaLoader.source=WWESL.Parameters.wweLoading;this.mediaLoader.addEventListener('MediaEnded',this.handleLoaderEnded.bind(this));},play:function(source){if(source){this.log('Playing video file: '+source);WWESL_STATE.set('moviePlaying',true);this.mediaPlayer.autoPlay=true;this.mediaPlayer.source=source;if(this.playlist&&this.playlist.isAd()){this.broadcast('VideoStarted',this.setData);}
if(this.playlist&&this.playlist.isFeatured()){this.broadcast('ChromeModeChanged',{mode:this.playlist.aspectRatio});}
WWESL_STATE.set('playingStatus','play');this.mediaPlayer.play();this.broadcast('PlaySet',{mode:WWESL_STATE.get('playingStatus')});this.doMediaUpdate();}},doPlaySet:function(setData){if(setData&&setData.video){this.playlist=new WWESL.Playlist(setData);this.setData=setData;WWESL_STATE.set('playingList',true);this.play(this.playlist.getNext());}},stop:function(){if(WWESL_STATE.get('moviePlaying')){WWESL_STATE.set('moviePlaying',false);this.mediaPlayer.stop();this.mediaPlayer.position="00:00:00";this.mediaPlayer.source='';}},doMediaUpdate:function(){var finalProgress=0;try{var currentPosition=this.mediaPlayer.position.seconds;var naturalduration=this.mediaPlayer.naturalDuration.seconds;finalProgress=(1-(naturalduration-currentPosition)/naturalduration);this.broadcast('ScrubSet',{progress:finalProgress});var curMinutes=""+Math.floor(this.mediaPlayer.position.seconds/60);curMinutes=curMinutes.length<2?"0"+curMinutes:curMinutes;var curSeconds=""+Math.floor(this.mediaPlayer.position.seconds%60);curSeconds=curSeconds.length<2?"0"+curSeconds:curSeconds;var finMinutes=""+Math.floor(this.mediaPlayer.naturalDuration.seconds/60);finMinutes=finMinutes.length<2?"0"+finMinutes:finMinutes;var finSeconds=""+Math.floor(this.mediaPlayer.naturalDuration.seconds%60);finSeconds=finSeconds.length<2?"0"+finSeconds:finSeconds;var strProgress=curMinutes+":"+curSeconds+"/"+finMinutes+":"+finSeconds;this.broadcast('DurationSet',{duration:strProgress});}
catch(e){}
if(!this.flagSet&&finalProgress>=WWESL_CONFIG.get('mediaFlagAtProgress')){this.flagSet=true;this.endReached=false;setTimeout(this.handleVideoEnded.bind(this),WWESL_CONFIG.get('mediaFlagInterval'));}
if(finalProgress>=WWESL_CONFIG.get('mediaEndAtProgress')){this.handleVideoEnded();}else if(WWESL_STATE.get('moviePlaying')){setTimeout(this.doMediaUpdate.bind(this),400);}},handlePlay:function(){if(WWESL_STATE.get('moviePlaying')){if(WWESL_STATE.get('playingStatus')){switch(WWESL_STATE.get('playingStatus')){case'play':WWESL_STATE.set('playingStatus','pause');this.mediaPlayer.pause();break;case'pause':WWESL_STATE.set('playingStatus','play');this.mediaPlayer.play();break;}}else{WWESL_STATE.set('playingStatus','play');this.mediaPlayer.play();}
this.broadcast('PlaySet',{mode:WWESL_STATE.get('playingStatus')});}},handleScrub:function(event){if(!this.playlist.isAd()&&event.progress){var mediaDuration=this.mediaPlayer.naturalDuration.seconds;var currentPlayTimeSelected=mediaDuration*event.progress;if(currentPlayTimeSelected>mediaDuration){currentPlayTimeSelected=mediaDuration;}else if(currentPlayTimeSelected<0){currentPlayTimeSelected=0;}
var position=this.mediaPlayer.position;position.seconds=currentPlayTimeSelected;this.mediaPlayer.position=position;this.mediaPlayer.play();var finalProgress=(1-(mediaDuration-position.seconds)/mediaDuration);this.broadcast('ScrubSet',{progress:finalProgress});}},handleVolume:function(){this.mediaPlayer.volume=this.mediaPlayer.volume>0?0:1;var mode=this.mediaPlayer.volume>0?'loud':'mute';this.broadcast('VolumeSet',{mode:mode});},handleFullScreen:function(){this.application.plugin.content.fullScreen=!this.application.plugin.content.fullScreen;},handleVideoClose:function(){this.stop();},handleDigg:function(){if(this.setData&&this.setData.video){var categoryId=WWESL_STATE.get('categoryId');window.open(WWESL.Parameters.diggURL+encodeURIComponent(this.setData.video.shareUrl+'?category='+categoryId));}},handleDelicious:function(){if(this.setData&&this.setData.video){var categoryId=WWESL_STATE.get('categoryId');window.open(WWESL.Parameters.delURL+encodeURIComponent(this.setData.video.shareUrl+'?category='+categoryId));}},handleDownloadProgressChanged:function(){},handleVideoLoaded:function(){if(this.mediaPlayer.currentState=="Playing"&&this.mediaPlayer.bufferingProgress==1){this.mediaLoader.stop();this.broadcast('VideoPlaying');}},handleVideoEnded:function(element){if(!this.endReached&&this.flagSet){this.stop();this.endReached=true;this.flagSet=false;this.stop();var next=this.playlist.getNext();if(next){this.play(next);}
else{this.broadcast("PlaylistEnd");}}},handleLoaderEnded:function(){this.mediaLoader.position="00:00:00";this.mediaLoader.play();}});if(!WWESL){var WWESL={};}
WWESL.VideoControls=Class.create(SL.Partial,{initialize:function(xaml){this.parent(xaml);this.CLASS_NAME='VideoControls';},main:function(){this.setup();this.initEvents();this.initSpecializedEvents();this.setupOverlayClose();},setup:function(){},initEvents:function(){this.subscribe('PlaySet',this.handlePlay.bind(this));this.subscribe('VolumeSet',this.handleVolume.bind(this));},initSpecializedEvents:function(){},hideInfoBox:function(){if(WWESL_STATE.get('overlayInfoDisplayed')){WWESL_STATE.set('overlayInfoDisplayed',false);this.broadcast('OverlayClosed');}},handlePlay:function(event){switch(event.mode){case'play':this.btnPlay.source=WWESL.Parameters.pauseImgPath;break;case'pause':this.btnPlay.source=WWESL.Parameters.playImgPath;break;}},handlePlayHeadPress:function(sender,eventArgs){if(WWESL_STATE.get('moviePlaying')){this.scrub.captureMouse();WWESL_STATE.set('moviePositionEnabled',true);this.handlePlayHeadDrag(sender,eventArgs);}},handlePlayHeadRelease:function(sender,eventArgs){if(WWESL_STATE.get('moviePlaying')){this.scrub.releaseMouseCapture();WWESL_STATE.set('moviePositionEnabled',false);}},handlePlayHeadDrag:function(sender,eventArgs){if(WWESL_STATE.get('moviePositionEnabled')){var mouseX=eventArgs.getPosition(null).x;var absolutePosition=Silverlight.absolute(this.scrub);var globalPosition=absolutePosition.x;var currentPlayTimeSelected=(mouseX-globalPosition-this.scrubBar["Canvas.Left"])/this.scrubBar.width;this.broadcast('ScrubChanged',{progress:currentPlayTimeSelected});}},handleVolume:function(event){switch(event.mode){case'mute':this.btnVolume.source=WWESL.Parameters.muteImgPath;break;case'loud':this.btnVolume.source=WWESL.Parameters.volumeImgPath;break;}},handleScrub:function(event){if(event.progress){this.scrubBox.width=this.scrub.width*event.progress;}},handleDuration:function(event){if(event.duration){this.durationText.text=event.duration;}},onOver:function(control,type){switch(type){case"font":control.foreground=WWESL.Parameters.textHoverColor;break;case"image":control.source=control.source.replace('_on.jpg','_over.jpg');break;}},onOut:function(control,type){switch(type){case"font":control.foreground=WWESL.Parameters.textColor;break;case"image":control.source=control.source.replace('_over.jpg','_on.jpg');break;}},setupOverlayClose:function(){try{var closeButton=document.getElementById('closeButton');closeButton.onclick=function(){this.hideInfoBox();return false;}.bind(this);}catch(e){}}});WWESL.ActiveVideoControls=Class.create(WWESL.VideoControls,{initialize:function(xaml){this.parent(xaml);},setup:function(){this.btnPlay=this.find('player_play_btn');this.btnPlay.cursor='Hand';this.btnPlay.addEventListener("MouseEnter",function(){this.onOver(this.btnPlay,"image");}.bind(this));this.btnPlay.addEventListener("MouseLeave",function(){this.onOut(this.btnPlay,"image");}.bind(this));this.btnPlay.addEventListener("MouseLeftButtonDown",function(){this.broadcast('PlayClicked');}.bind(this));this.durationText=this.find('video_time_txt');this.scrubBar=this.find('scrub_bar');this.scrubBox=this.find('scrub_box');this.scrub=this.find('scrub_mask');this.scrub.cursor="Hand";this.scrub.addEventListener('mouseLeftButtonDown',this.handlePlayHeadPress.bind(this));this.scrub.addEventListener('mouseLeftButtonUp',this.handlePlayHeadRelease.bind(this));this.scrub.addEventListener('mouseMove',this.handlePlayHeadDrag.bind(this));this.btnFullScreen=this.find('player_exp_btn');this.btnFullScreen.cursor='Hand';this.btnFullScreen.addEventListener("MouseEnter",function(){this.onOver(this.btnFullScreen,"image");}.bind(this));this.btnFullScreen.addEventListener("MouseLeave",function(){this.onOut(this.btnFullScreen,"image");}.bind(this));this.btnFullScreen.addEventListener("MouseLeftButtonDown",function(){this.broadcast('FullScreenClicked');}.bind(this));this.btnVolume=this.find('player_vol_btn');this.btnVolume.cursor='Hand';this.btnVolume.addEventListener("MouseEnter",function(){this.onOver(this.btnVolume,"image");}.bind(this));this.btnVolume.addEventListener("MouseLeave",function(){this.onOut(this.btnVolume,"image");}.bind(this));this.btnVolume.addEventListener("MouseLeftButtonDown",function(){this.broadcast('VolumeClicked');}.bind(this));this.btnShare=this.find('share_txt');this.btnShare.cursor='Hand';this.btnShare.addEventListener("MouseEnter",function(){if(!WWESL_STATE.get('overlayInfoDisplayed')||!WWESL_STATE.get('overlayDisplayedType')||WWESL_STATE.get('overlayDisplayedType')!='share'){this.onOver(this.btnShare,"font");}}.bind(this));this.btnShare.addEventListener("MouseLeave",function(){if(!WWESL_STATE.get('overlayInfoDisplayed')||!WWESL_STATE.get('overlayDisplayedType')||WWESL_STATE.get('overlayDisplayedType')!='share'){this.onOut(this.btnShare,"font");}}.bind(this));this.btnShare.addEventListener("MouseLeftButtonDown",function(){this.broadcast('ShareClicked',{mode:'active'});}.bind(this));this.btnInfo=this.find('info_txt');this.btnInfo.cursor='Hand';this.btnInfo.addEventListener("MouseEnter",function(){if(!WWESL_STATE.get('overlayInfoDisplayed')||!WWESL_STATE.get('overlayDisplayedType')||WWESL_STATE.get('overlayDisplayedType')!='info'){this.onOver(this.btnInfo,"font");}}.bind(this));this.btnInfo.addEventListener("MouseLeave",function(){if(!WWESL_STATE.get('overlayInfoDisplayed')||!WWESL_STATE.get('overlayDisplayedType')||WWESL_STATE.get('overlayDisplayedType')!='info'){this.onOut(this.btnInfo,"font");}}.bind(this));this.btnInfo.addEventListener("MouseLeftButtonDown",function(){this.broadcast('InfoClicked',{mode:'active'});}.bind(this));},initSpecializedEvents:function(){this.subscribe('ShareClicked',this.handleShare.bind(this));this.subscribe('InfoClicked',this.handleInfo.bind(this));this.subscribe('OverlayClosed',function(){this.turnShareOff();this.turnInfoOff();}.bind(this));},turnShareOn:function(mode){this.onOver(this.btnShare,"font");var activeFrame=document.getElementById('overlayFrame');activeFrame.style.display='block';if(WWESL_STATE.get('playingMode')){switch(WWESL_STATE.get('playingMode')){case'SD':activeFrame.className='overlayFrameSD';break;case'WD':activeFrame.className='overlayFrameWD';break;}}else{activeFrame.className='overlayFrameSD';}
document.getElementById('closeButton').className=WWESL_STATE.get('playingMode')=='WD'?'wide':'standard';var shareSpan=document.getElementById('share');shareSpan.className='shareOn';},turnShareOff:function(){this.onOut(this.btnShare,"font");var activeFrame=document.getElementById('overlayFrame');activeFrame.className='overlayFrame';activeFrame.style.display='none';var shareSpan=document.getElementById('share');shareSpan.className='shareOff';},turnInfoOn:function(){this.onOver(this.btnInfo,"font");var activeFrame=document.getElementById('overlayFrame');activeFrame.style.display='block';if(WWESL_STATE.get('playingMode')){switch(WWESL_STATE.get('playingMode')){case'SD':activeFrame.className='overlayFrameSD';break;case'WD':activeFrame.className='overlayFrameWD';break;}}else{activeFrame.className='overlayFrameSD';}
document.getElementById('closeButton').className=WWESL_STATE.get('playingMode')=='WD'?'wide':'standard';var infoSpan=document.getElementById('info');infoSpan.className='infoOn';},turnInfoOff:function(){this.onOut(this.btnInfo,"font");var activeFrame=document.getElementById('overlayFrame');activeFrame.className='overlayFrame';activeFrame.style.display='none';var infoSpan=document.getElementById('info');infoSpan.className='infoOff';},handleShare:function(event){if(event.mode&&event.mode=='active'){if(WWESL_STATE.get('overlayInfoDisplayed')){if(WWESL_STATE.get('overlayDisplayedType')&&WWESL_STATE.get('overlayDisplayedType')=='info'){this.turnInfoOff();this.turnShareOn();WWESL_STATE.set('overlayInfoDisplayed',true);WWESL_STATE.set('overlayDisplayedType','share');}else{this.turnShareOff();WWESL_STATE.set('overlayInfoDisplayed',false);}}else{this.turnShareOn();WWESL_STATE.set('overlayInfoDisplayed',true);WWESL_STATE.set('overlayDisplayedType','share');}}},handleInfo:function(event){if(event.mode&&event.mode=='active'){if(WWESL_STATE.get('overlayInfoDisplayed')){if(WWESL_STATE.get('overlayDisplayedType')&&WWESL_STATE.get('overlayDisplayedType')=='share'){this.turnShareOff();this.turnInfoOn();WWESL_STATE.set('overlayInfoDisplayed',true);WWESL_STATE.set('overlayDisplayedType','info');}else{this.turnInfoOff();WWESL_STATE.set('overlayInfoDisplayed',false);}}else{this.turnInfoOn();WWESL_STATE.set('overlayInfoDisplayed',true);WWESL_STATE.set('overlayDisplayedType','info');}}}});WWESL.RecessedVideoControls=Class.create(WWESL.VideoControls,{initialize:function(xaml){this.parent(xaml);},setup:function(){this.btnPlay=this.find('mini_player_play_btn');this.btnPlay.cursor='Hand';this.btnPlay.addEventListener("MouseEnter",function(){this.onOver(this.btnPlay,"image");}.bind(this));this.btnPlay.addEventListener("MouseLeave",function(){this.onOut(this.btnPlay,"image");}.bind(this));this.btnPlay.addEventListener("MouseLeftButtonDown",function(){this.broadcast('PlayClicked');}.bind(this));this.durationText=this.find('mini_video_time_txt');this.scrubBar=this.find('mini_scrub_bar');this.scrubBox=this.find('mini_scrub_box');this.scrub=this.find('mini_scrub_mask');this.scrub.cursor="Hand";this.scrub.addEventListener('mouseLeftButtonDown',this.handlePlayHeadPress.bind(this));this.scrub.addEventListener('mouseLeftButtonUp',this.handlePlayHeadRelease.bind(this));this.scrub.addEventListener('mouseMove',this.handlePlayHeadDrag.bind(this));this.btnVolume=this.find('mini_player_vol_btn');this.btnVolume.cursor='Hand';this.btnVolume.addEventListener("MouseEnter",function(){this.onOver(this.btnVolume,"image");}.bind(this));this.btnVolume.addEventListener("MouseLeave",function(){this.onOut(this.btnVolume,"image");}.bind(this));this.btnVolume.addEventListener("MouseLeftButtonDown",function(){this.broadcast('VolumeClicked');}.bind(this));this.btnShare=this.find('mini_share_txt');this.btnShare.cursor='Hand';this.btnShare.addEventListener("MouseEnter",function(){if(!WWESL_STATE.get('overlayInfoDisplayed')||!WWESL_STATE.get('overlayDisplayedType')||WWESL_STATE.get('overlayDisplayedType')!='share'){this.onOver(this.btnShare,"font");}}.bind(this));this.btnShare.addEventListener("MouseLeave",function(){if(!WWESL_STATE.get('overlayInfoDisplayed')||!WWESL_STATE.get('overlayDisplayedType')||WWESL_STATE.get('overlayDisplayedType')!='share'){this.onOut(this.btnShare,"font");}}.bind(this));this.btnShare.addEventListener("MouseLeftButtonDown",function(){this.broadcast('ShareClicked',{mode:'recessed'});}.bind(this));this.btnInfo=this.find('mini_info_txt');this.btnInfo.cursor='Hand';this.btnInfo.addEventListener("MouseEnter",function(){if(!WWESL_STATE.get('overlayInfoDisplayed')||!WWESL_STATE.get('overlayDisplayedType')||WWESL_STATE.get('overlayDisplayedType')!='info'){this.onOver(this.btnInfo,"font");}}.bind(this));this.btnInfo.addEventListener("MouseLeave",function(){if(!WWESL_STATE.get('overlayInfoDisplayed')||!WWESL_STATE.get('overlayDisplayedType')||WWESL_STATE.get('overlayDisplayedType')!='info'){this.onOut(this.btnInfo,"font");}}.bind(this));this.btnInfo.addEventListener("MouseLeftButtonDown",function(){this.broadcast('InfoClicked',{mode:'recessed'});}.bind(this));},initSpecializedEvents:function(){this.subscribe('ShareClicked',this.handleShare.bind(this));this.subscribe('InfoClicked',this.handleInfo.bind(this));this.subscribe('OverlayClosed',function(){this.turnShareOff();this.turnInfoOff();}.bind(this));},turnInfoOn:function(){this.onOver(this.btnInfo,"font");var activeFrame=document.getElementById('overlayFrame');activeFrame.className='miniOverlayFrame';activeFrame.style.display='block';document.getElementById('closeButton').className='mini';var infoSpan=document.getElementById('info');infoSpan.className='infoOn';},turnInfoOff:function(){this.onOut(this.btnInfo,"font");var activeFrame=document.getElementById('overlayFrame');activeFrame.className='overlayFrame';activeFrame.style.display='none';var infoSpan=document.getElementById('info');infoSpan.className='infoOff';},turnShareOn:function(){this.onOver(this.btnShare,"font");var activeFrame=document.getElementById('overlayFrame');activeFrame.className='miniOverlayFrame';activeFrame.style.display='block';document.getElementById('closeButton').className='mini';var shareSpan=document.getElementById('share');shareSpan.className='shareOn';},turnShareOff:function(){this.onOut(this.btnShare,"font");var activeFrame=document.getElementById('overlayFrame');activeFrame.className='overlayFrame';activeFrame.style.display='none';var shareSpan=document.getElementById('share');shareSpan.className='shareOff';},handleShare:function(event){if(event.mode&&event.mode=='recessed'){if(WWESL_STATE.get('overlayInfoDisplayed')){if(WWESL_STATE.get('overlayDisplayedType')&&WWESL_STATE.get('overlayDisplayedType')=='info'){this.turnInfoOff();this.turnShareOn();WWESL_STATE.set('overlayInfoDisplayed',true);WWESL_STATE.set('overlayDisplayedType','share');}
else{this.turnShareOff();WWESL_STATE.set('overlayInfoDisplayed',false);}}
else{this.turnShareOn();WWESL_STATE.set('overlayInfoDisplayed',true);WWESL_STATE.set('overlayDisplayedType','share');}}},handleInfo:function(event){if(event.mode&&event.mode=='recessed'){if(WWESL_STATE.get('overlayInfoDisplayed')){if(WWESL_STATE.get('overlayDisplayedType')&&WWESL_STATE.get('overlayDisplayedType')=='share'){this.turnShareOff();this.turnInfoOn();WWESL_STATE.set('overlayInfoDisplayed',true);WWESL_STATE.set('overlayDisplayedType','info');}
else{this.turnInfoOff();WWESL_STATE.set('overlayInfoDisplayed',false);}}
else{this.turnInfoOn();WWESL_STATE.set('overlayInfoDisplayed',true);WWESL_STATE.set('overlayDisplayedType','info');}}}});WWESL.FullVideoControls=Class.create(WWESL.VideoControls,{initialize:function(xaml){this.parent(xaml);},setup:function(){this.btnPlay=this.find('full_player_play_btn');this.btnPlay.cursor='Hand';this.btnPlay.addEventListener("MouseEnter",function(){this.onOver(this.btnPlay,"image");}.bind(this));this.btnPlay.addEventListener("MouseLeave",function(){this.onOut(this.btnPlay,"image");}.bind(this));this.btnPlay.addEventListener("MouseLeftButtonDown",function(){this.broadcast('PlayClicked');}.bind(this));this.durationText=this.find('full_video_time_txt');this.scrubBar=this.find('full_scrub_bar');this.scrubBox=this.find('full_scrub_box');this.scrub=this.find('full_scrub_mask');this.scrub.cursor="Hand";this.scrub.addEventListener('mouseLeftButtonDown',this.handlePlayHeadPress.bind(this));this.scrub.addEventListener('mouseLeftButtonUp',this.handlePlayHeadRelease.bind(this));this.scrub.addEventListener('mouseMove',this.handlePlayHeadDrag.bind(this));this.btnFullScreen=this.find('full_player_exp_btn');this.btnFullScreen.cursor='Hand';this.btnFullScreen.addEventListener("MouseEnter",function(){this.onOver(this.btnFullScreen,"image");}.bind(this));this.btnFullScreen.addEventListener("MouseLeave",function(){this.onOut(this.btnFullScreen,"image");}.bind(this));this.btnFullScreen.addEventListener("MouseLeftButtonDown",function(){this.broadcast('FullScreenClicked');}.bind(this));this.btnVolume=this.find('full_player_vol_btn');this.btnVolume.cursor='Hand';this.btnVolume.addEventListener("MouseEnter",function(){this.onOver(this.btnVolume,"image");}.bind(this));this.btnVolume.addEventListener("MouseLeave",function(){this.onOut(this.btnVolume,"image");}.bind(this));this.btnVolume.addEventListener("MouseLeftButtonDown",function(){this.broadcast('VolumeClicked');}.bind(this));}});if(!WWESL){var WWESL={};}
WWESL.VideoModule=Class.create(Base,{initialize:function(application){this.CLASS_NAME='VideoModule';this.application=application;this.application.waitFor(this);this.initEvents();this.setup();},initEvents:function(){this.application.plugin.content.onFullScreenChange=this.initFullScreen.bind(this);this.subscribe('PreRollLoaded',this.handleVideoLoad.bind(this));this.subscribe('ScrubSet',this.handleScrub.bind(this));this.subscribe('DurationSet',this.handleDuration.bind(this));this.subscribe('CarrouselItemOver',this.hideInfoBox.bind(this));},setup:function(){this.application.getZipEmbedded(WWESL_CONFIG.get('xamlPath')+'xaml.zip',function(zip){this.activePlayer=new WWESL.ActiveVideoPlayer(this,this.application.find('activeVideoHolder'),zip.get('videoActive.xaml'),zip.get('controlsActive.xaml'),zip.get('carouselActive.xaml'));this.recessedPlayer=new WWESL.RecessedVideoPlayer(this,this.application.find('recessedVideoHolder'),zip.get('videoRecessed.xaml'),zip.get('controlsRecessed.xaml'),zip.get('carouselRecessed.xaml'));this.fullPlayer=new WWESL.FullVideoPlayer(this,this.application.find('fullVideoHolder'),zip.get('videoFull.xaml'),zip.get('controlsFullScreen.xaml'));this.videoController=new WWESL.VideoController(this.application);zip.destroy();zip=null;this.application.nowReady(this);}.bind(this));},handleVideoLoad:function(event){this.initActive(event);},initActive:function(videoData){if(videoData){this.videoController.doPlaySet(videoData);}},initFullScreen:function(){if(WWESL_STATE.get('fullPlayer')){WWESL_STATE.set('fullPlayer',false);this.broadcast('ExitFullScreen');WWESL_STATE.set('playerMode','Active');this.fullPlayer.hide();}else{WWESL_STATE.set('fullPlayer',true);this.broadcast('EnterFullScreen');this.fullPlayer.show();}},handleScrub:function(event){if(WWESL_STATE.get('playerMode')!=null){switch(WWESL_STATE.get('playerMode')){case'Active':this.activePlayer.controls.handleScrub(event);break;case'Recessed':this.recessedPlayer.controls.handleScrub(event);break;case'FullScreen':this.fullPlayer.controls.handleScrub(event);break;}}},handleDuration:function(event){if(WWESL_STATE.get('playerMode')!=null){switch(WWESL_STATE.get('playerMode')){case'Active':this.activePlayer.controls.handleDuration(event);break;case'Recessed':this.recessedPlayer.controls.handleDuration(event);break;case'FullScreen':this.fullPlayer.controls.handleDuration(event);break;}}},hideInfoBox:function(event){if(WWESL_STATE.get('playerMode')!=null){switch(WWESL_STATE.get('playerMode')){case'Active':this.activePlayer.controls.hideInfoBox(event);break;case'Recessed':this.recessedPlayer.controls.hideInfoBox(event);break;case'FullScreen':this.fullPlayer.controls.hideInfoBox(event);break;}}}});if(!WWESL){var WWESL={};}
WWESL.VideoPlayer=Class.create(Base,{initialize:function(plugin){this.CLASS_NAME='VideoPlayer';this.plugin=plugin;this.initEvents();},initEvents:function(){this.subscribe('VideoLoaded',this.handleVideoLoaded.bind(this));this.subscribe('VideoSelected',this.handleVideoSelected.bind(this));this.subscribe('VideoPlaying',this.handleVideoPlaying.bind(this));},handleVideoPlaying:function(){this.createHideLoader();this.hideLoaderTween.startFromHere();},handleVideoSelected:function(){var activeFrame=document.getElementById('overlayFrame');var lbInfoDate=document.getElementById('infoDate');var lbInfoTitle=document.getElementById('infoTitle');var lbInfoDescription=document.getElementById('infoDescription');var lbInfoFrom=document.getElementById('infoFrom');var lbInfoFeaturing=document.getElementById('infoFeaturing');var lbShareLink=document.getElementById('lbLink');if(lbInfoDate){lbInfoDate.innerHTML='';}
if(this.lbTitle){this.lbTitle.text='Loading video...';}
if(lbInfoTitle){lbInfoTitle.innerHTML='';}
if(lbInfoDescription){lbInfoDescription.innerHTML='';}
if(lbInfoFrom){lbInfoFrom.innerHTML='';}
if(lbInfoFeaturing){lbInfoFeaturing.innerHTML='';}
if(lbShareLink){lbShareLink.value='';}
this.canvasLoader.visibility='Visible';this.createShowLoader();this.showLoaderTween.startFromHere();},handleVideoLoaded:function(event){var activeFrame=document.getElementById('overlayFrame');var lbInfoDate=document.getElementById('infoDate');var lbInfoTitle=document.getElementById('infoTitle');var lbInfoDescription=document.getElementById('infoDescription');var lbInfoFrom=document.getElementById('infoFrom');var lbInfoFeaturing=document.getElementById('infoFeaturing');var lbShareLink=document.getElementById('lbLink');if(event.video){if(lbInfoDate&&event.video.date){lbInfoDate.innerHTML=event.video.date;}
if(this.lbTitle&&event.video.title){this.lbTitle.text=event.video.title;}
if(lbInfoTitle&&event.video.title){lbInfoTitle.innerHTML=event.video.title;}
if(lbInfoDescription&&event.video.description){lbInfoDescription.innerHTML=event.video.description;}
if(lbInfoFrom&&event.video.from){lbInfoFrom.innerHTML='From: '+event.video.from;}
if(lbInfoFeaturing&&event.video.featuring){lbInfoFeaturing.innerHTML='Featuring: '+event.video.featuring;}
if(lbShareLink){var categoryId=WWESL_STATE.get('categoryId');lbShareLink.value=event.video.shareUrl+'?category='+categoryId;}}},createShowLoader:function(){if(this.showLoaderTween){return;}
this.showLoaderTween=new Tween([{obj:this.canvasLoader,prop:'opacity',end:1,func:Tween.easeOutExpo}],1);},createHideLoader:function(){if(this.hideLoaderTween){return;}
this.hideLoaderTween=new Tween([{obj:this.canvasLoader,prop:'opacity',end:0,func:Tween.easeOutExpo}],1);this.hideLoaderTween.addListener('onMotionFinished',function(){this.canvasLoader.visibility='Collapsed';}.bind(this));}});WWESL.ActiveVideoPlayer=Class.create(WWESL.VideoPlayer,{initialize:function(module,container,playerXaml,controlsXaml,carouselXaml){this.module=module;this.application=module.application;this.container=container;this.playerXaml=new SL.Partial(playerXaml);this.controls=new WWESL.ActiveVideoControls(controlsXaml);this.carousel=new WWESL.ActiveCarousel(this,carouselXaml);this.setup();this.parent(this.container.getHost());this.initSpecialEvents();},setup:function(){this.videoCromeSD=this.playerXaml.find('videoChromeSD');this.videoCromeWD=this.playerXaml.find('videoChromeWD');this.cromeScaler=this.playerXaml.find('cromeScaler');this.mediaScaler=this.playerXaml.find('mediaScaler');this.loaderScaler=this.playerXaml.find('loaderScaler');this.videoPlayer=this.playerXaml.find('mediaPlaceholder');this.videoPlayer.fill.setValue('SourceName',WWESL.Parameters.mediaElement);this.videoPlayer.cursor='Hand';this.videoPlayer.addEventListener('MouseLeftButtonDown',function(){this.broadcast('FullScreenClicked');}.bind(this));this.canvasLoader=this.playerXaml.find('loadingCanvas');this.videoLoader=this.playerXaml.find('loaderPlaceholder');this.videoLoader.fill.setValue('SourceName',WWESL.Parameters.loaderElement);this.btnClose=this.playerXaml.find('closeButton');this.btnClose.cursor='Hand';this.btnClose.addEventListener('MouseLeftButtonDown',this.close.bind(this));this.controls.attach(this.playerXaml.find('controlsHolder'));this.carousel.attach(this.playerXaml.find('carouselHolder'));this.playerXaml.attach(this.container);this.lbTitle=this.controls.find('video_name_txt');this.setMode(WWESL.Parameters.defaultVideoMode);},initSpecialEvents:function(){this.subscribe('GridZoomInComplete',this.show.bind(this));this.subscribe('CategoryLoaded',this.hide.bind(this));this.subscribe('ChromeModeChanged',function(event){if(event&&event.mode){this.setMode(event.mode);}}.bind(this));this.subscribe('PlaylistEnd',function(){this.setMode(WWESL.Parameters.defaultVideoMode);}.bind(this));},setMode:function(mode){if(!WWESL_STATE.get('playingMode')!=mode){WWESL_STATE.set('playingMode',mode);if(mode=='WD'){this.createChromeZoomIn();this.chromeZoomIn.startFromHere();}else{this.createChromeZoomOut();this.chromeZoomOut.startFromHere();}}},createChromeZoomIn:function(){if(this.chromeZoomIn){return;}
this.chromeZoomIn=new Tween([{obj:this.cromeScaler,prop:'scaleX',end:1,func:Tween.easeOutExpo},{obj:this.mediaScaler,prop:'scaleX',end:1.33,func:Tween.easeOutExpo},{obj:this.loaderScaler,prop:'scaleX',end:1.33,func:Tween.easeOutExpo},{obj:this.videoCromeWD,prop:'opacity',end:1},{obj:this.videoCromeSD,prop:'opacity',end:0}],1);this.chromeZoomIn.addListener('onMotionFinished',function(){this.btnClose['Canvas.Left']=WWESL.Parameters.videoActiveClosePosWD.x;this.btnClose['Canvas.Top']=WWESL.Parameters.videoActiveClosePosWD.y;}.bind(this));},createChromeZoomOut:function(){if(this.chromeZoomOut){return;}
this.chromeZoomOut=new Tween([{obj:this.cromeScaler,prop:'scaleX',end:0.765,func:Tween.easeOutExpo},{obj:this.mediaScaler,prop:'scaleX',end:1,func:Tween.easeOutExpo},{obj:this.loaderScaler,prop:'scaleX',end:1,func:Tween.easeOutExpo},{obj:this.videoCromeWD,prop:'opacity',end:0},{obj:this.videoCromeSD,prop:'opacity',end:1}],1);this.chromeZoomOut.addListener('onMotionFinished',function(){this.btnClose['Canvas.Left']=WWESL.Parameters.videoActiveClosePosSD.x;this.btnClose['Canvas.Top']=WWESL.Parameters.videoActiveClosePosSD.y;}.bind(this));},show:function(){if(!WWESL_STATE.get('playerActive')){this.createShowTween();this.playerXaml.set('visibility','visible');this.showTween.startFromHere();WWESL_STATE.set('playerActive',true);WWESL_STATE.set('playerMode','Active');this.broadcast('ActivePlayerOpened');}},hide:function(){if(WWESL_STATE.get('playerActive')){this.controls.hideInfoBox();this.createHideTween();this.hideTween.startFromHere();this.broadcast('ActivePlayerHidden');WWESL_STATE.set('playerActive',false);}},close:function(){if(WWESL_STATE.get('playerActive')){this.controls.hideInfoBox();this.createHideTween();this.hideTween.startFromHere();this.setMode('SD');this.broadcast('ActivePlayerClosed');WWESL_STATE.set('playerActive',false);}},createShowTween:function(){if(this.showTween){return;}
this.scaler=this.playerXaml.find('scaler');this.showTween=new Tween([{obj:this.scaler,prop:'scaleX',end:1,func:Tween.easeOutExpo},{prop:'scaleY'},{obj:this.playerXaml.fragment,prop:'opacity',end:1}],1);},createHideTween:function(){if(this.hideTween){return;}
this.hideTween=new Tween([{obj:this.scaler,prop:'scaleX',end:0.5,func:Tween.easeOutExpo},{prop:'scaleY'},{obj:this.playerXaml.fragment,prop:'opacity',end:0}],0.5);this.hideTween.addListener('onMotionFinished',function(){this.playerXaml.set('visibility','collapsed');}.bind(this));}});WWESL.RecessedVideoPlayer=Class.create(WWESL.VideoPlayer,{initialize:function(module,container,playerXaml,controlsXaml,carouselXaml){this.module=module;this.application=module.application;this.container=container;this.playerXaml=new SL.Partial(playerXaml);this.controls=new WWESL.RecessedVideoControls(controlsXaml);this.carousel=new WWESL.RecessedCarousel(this,carouselXaml);this.setup();this.parent(this.container.getHost());this.initEvents();this.initSpecialEvents();},setup:function(){this.videoPlayer=this.playerXaml.find('mini_mediaPlaceholder');this.videoPlayer.fill.setValue('SourceName',WWESL.Parameters.mediaElement);this.videoPlayer.cursor='Hand';this.videoPlayer.addEventListener('MouseLeftButtonDown',function(){this.broadcast('RecessedPlayerClicked');this.broadcast('GridVideoSelected',{position:{x:328,y:243}});}.bind(this));this.canvasLoader=this.playerXaml.find('mini_loadingCanvas');this.videoLoader=this.playerXaml.find('mini_loaderPlaceholder');this.videoLoader.fill.setValue('SourceName',WWESL.Parameters.loaderElement);this.controls.attach(this.playerXaml.find('mini_controlsHolder'));this.carousel.attach(this.playerXaml.find('mini_carouselHolder'));this.playerXaml.attach(this.container);this.lbTitle=this.playerXaml.find('mini_video_name_txt');},initSpecialEvents:function(){this.subscribe('ActivePlayerHidden',this.show.bind(this));this.subscribe('ActivePlayerOpened',this.hide.bind(this));},show:function(){this.createShowTween();this.showTween.startFromHere();WWESL_STATE.set('playerRecessed',true);WWESL_STATE.set('playerMode','Recessed');this.broadcast('RecessedPlayerOpened');},hide:function(){if(WWESL_STATE.get('playerRecessed')){this.controls.hideInfoBox();this.createHideTween();this.hideTween.startFromHere();WWESL_STATE.set('playerRecessed',false);this.broadcast('RecessedPlayerHidden');}},createShowTween:function(){if(this.showTween){return;}
this.showTween=new Tween({obj:this.playerXaml.fragment,prop:'Canvas.Left',end:0,func:Tween.easeOutExpo},1);},createHideTween:function(){if(this.hideTween){return;}
this.hideTween=new Tween({obj:this.playerXaml.fragment,prop:'Canvas.Left',end:WWESL_CONFIG.get('recessedPlayerOrigin').x,func:Tween.easeOutExpo},1);}});WWESL.FullVideoPlayer=Class.create(WWESL.VideoPlayer,{initialize:function(module,container,playerXaml,controlsXaml){this.module=module;this.application=module.application;this.container=container;this.playerXaml=new SL.Partial(playerXaml);this.controls=new WWESL.FullVideoControls(controlsXaml);this.setup();this.parent(this.container.getHost());this.initEvents();},setup:function(){this.videoBackground=this.playerXaml.find('full_mediaBackground');this.loaderBackground=this.playerXaml.find('full_loaderBG');this.videoPlayer=this.playerXaml.find('full_mediaPlaceholder');this.videoPlayer.fill.setValue('SourceName',WWESL.Parameters.mediaElement);this.canvasLoader=this.playerXaml.find('full_loadingCanvas');this.videoLoader=this.playerXaml.find('full_loaderPlaceholder');this.videoLoader.fill.setValue('SourceName',WWESL.Parameters.loaderElement);this.controls.attach(this.playerXaml.find('full_controlsHolder'));this.playerXaml.attach(this.container);this.lbTitle=this.controls.find('full_video_name_txt');},show:function(){var curWidth=this.container.getHost().content.actualWidth;var curHeight=this.container.getHost().content.actualHeight;this.videoBackground.width=curWidth;this.videoBackground.height=curHeight;this.loaderBackground.width=curWidth;this.loaderBackground.height=curHeight;this.videoLoader['Canvas.Top']=(curHeight/2)-50;this.videoLoader['Canvas.Left']=(curWidth/2)-50;this.videoPlayer.width=curWidth;this.videoPlayer.height=curHeight;this.controls.set('Canvas.Top',curHeight-this.controls.get('height'));this.controls.set('Canvas.Left',(curWidth/2)-(this.controls.get('width')/2));this.playerXaml.set('visibility','visible');WWESL_STATE.set('playerMode','FullScreen');this.broadcast('FullPlayerOpened');},hide:function(){this.playerXaml.set('visibility','collapsed');this.videoBackground.width=0;this.videoBackground.height=0;this.videoPlayer.width=0;this.videoPlayer.height=0;this.broadcast('FullPlayerHidden');}});