/*
 * Adept Mobile - Custom JS for mobile UFC
 */
/**************************** GLOBALS *************************/
const RESULT_SUMMARY_UPDATE_TIME=6e4,RESULT_SUMMARY_TRANSITION_SPEED=5e3;var transitionListInterval;const UNKNOWN_DEVICE=0,ANDROID=1,IOS=2,BERRY=3;var client_device=UNKNOWN_DEVICE,toggleListItem=function(){$(".expanded-result").slideUp(),$(".close").toggleClass("open").toggleClass("close");var a=$("#"+$(this).data("target"));$(this).hasClass("open")&&!a.is(":visible")&&$(this).toggleClass("open").toggleClass("close"),$("#"+$(this).data("target")).stop(!0).slideToggle()},redirectSelect=function(){var a=$(this).find(":selected").data("url");$(location).attr("href",a)},customizeForDevice=function(){var a=navigator.userAgent,b={iphone:a.match(/(iPhone|iPod|iPad)/),blackberry:a.match(/BlackBerry/),android:a.match(/Android/)};b.android?($(".android-only").show(),client_device=ANDROID):b.iphone?($(".idevice-only").show(),client_device=IOS):b.blackberry?($(".berry-only").show(),client_device=BERRY):$(".unknown-device").show()},initTransitionList=function(a,b){b==undefined&&(b=5);const c=Math.ceil($(".trans-row").length/b);if(c>1){var d=1;transitionListInterval=clearInterval(transitionListInterval),transitionListInterval=setInterval(function(){a.find("ul").fadeOut(function(){var b=d+1;c<=d&&(b=1),a.find("li").each(function(){$(this).data("rowset")==d?$(this).hide():$(this).data("rowset")==b&&$(this).show()}),d=b,a.find("ul").fadeIn()})},RESULT_SUMMARY_TRANSITION_SPEED)}},mytimer=new Date,loadHomeResultSummary=function(){$("#home-results-panel").find(".transition-list").animate({opacity:"0"},{duration:300}).delay(300);var a=_HOST_NAME+" #home-results-panel-inner";$("#home-results-panel").load(a,function(){$("#home-results-panel").find(".transition-list").css({opacity:"0"}),initTransitionList($("#home-results-panel").find(".transition-list"),5),$("#home-results-panel").find(".transition-list").animate({opacity:"1"},{duration:300}),setTimeout("loadHomeResultSummary();",RESULT_SUMMARY_UPDATE_TIME)})},initVideoPlayer=function(){var a=$("#video-content").data("image"),b=$("#video-content").data("filename");if($("#video-content").data("path")!=undefined)var c=$("#video-content").data("path");else var c="http://pdvid.ufc.com/mobile/2011/";var d="http://ad.doubleclick.net/pfadx/instream_flash/;sz=320x240;tile=1";IOS==client_device?d="http://ad.doubleclick.net/pfadx/zuffa.ufc/mobile;kw=html5linearnonlinear;sz=1x1000;ord=123456789;dcmt=text/xml":d="http://ad.doubleclick.net/pfadx/zuffa.ufc/mobile;sz=1x1000;ord=123456789?",jwplayer("video-content").setup({file:"mobile/2011/"+b,width:"300",height:"210",volume:"100",image:a,skin:"/skins/newtubedark/newtubedark.zip?cb="+CACHE_BUSTER,controlbar:"bottom",plugins:{googima:{ad:{ufc_preroll:{tag:d,type:"video",position:"pre"}}}},modes:[{type:"flash",src:"/swf/player.swf?cb="+CACHE_BUSTER},{type:"html5",config:{file:c+b,provider:"video"}},{type:"download",config:{file:c+b,provider:"video"}}],provider:"rtmp",streamer:"rtmp://rtmpvid.ufc.com/cfx/st"})},initStreamingPlayer=function(){var a=$("#live-player").data("image");jwplayer("live-player").setup({width:"300",height:"210",volume:"100",image:a,skin:"/skins/newtubedark/newtubedark.zip?cb="+CACHE_BUSTER,controlbar:"bottom",modes:[{type:"flash",src:"/swf/player.swf?cb="+CACHE_BUSTER},{type:"html5",config:{file:"http://ufc.mpl.miisolutions.net:1935/ufc-eclive02/_definst_/mp4:ufc-eclive02/playlist.m3u8",provider:"video"}}],plugins:{googima:{ad:{ufc_preroll:{tag:"http://ad.doubleclick.net/pfadx/zuffa.ufc/mobile;sz=1x1000;ord=123456789?",type:"video",position:"pre"}}}},bitrate:300,provider:"rtmp",file:"ufc-eclive02",streamer:"rtmp://ufc.mpl.miisolutions.net/ufc-eclive02/_definst_"})},alert=function(a){apprise(a)},init=function(){customizeForDevice(),$("#home-results-panel").length&&(initTransitionList($("#home-results-panel").find(".transition-list"),5),setTimeout("loadHomeResultSummary();",RESULT_SUMMARY_UPDATE_TIME));if(typeof USE_TOUCH_GALLERY!="undefined"&&$("#slider").length){var a=$("#slider");reset_slider()}typeof USE_PHOTOSWIPE!="undefined"&&($("#Gallery a").photoSwipe(),$(".gallery-launcher").click(function(a){a.preventDefault(),Code.PhotoSwipe.Current.show(0)})),typeof USE_JWPLAYER!="undefined"&&initVideoPlayer(),typeof USE_LIVE_PLAYER!="undefined"&&initStreamingPlayer(),$(".redirect-selector").change(redirectSelect),$(".touch-row").bind("click",toggleListItem);if($(".no_scroll").length){function b(a){a.preventDefault();var b=a.originalEvent.touches[0]||a.originalEvent.changedTouches[0],c=$(this).offset(),d=b.pageX-c.left,e=b.pageY-c.top;d<$(this).width()&&d>0&&e<$(this).height()&&e>0&&console.log(b.pageY+" "+b.pageX)}document.addEventListener("touchmove",b,!1)}};init()
