function get_url_param(b){b=b.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var a="[\\?&]"+b+"=([^&#]*)";var d=new RegExp(a);var c=d.exec(window.location.href);if(c==null){return"sb_error_code"}else{return c[1]}}function sb_play_video(){if(get_url_param("sb_video_id")!="sb_error_code"&&get_url_param("sb_partner_id")!="sb_error_code"){getVideo(get_url_param("sb_video_id"),get_url_param("sb_partner_id"))}else{}}var globalna;function runHtml5Fallback(a){sbhtml.createSpringboards(a)}if(sbhtml==undefined){var sbhtml={}}if(externalCounter==undefined){var externalCounter=0}if(sbhtml.springboards==undefined){sbhtml.videoObj=null;sbhtml.currentItem=0;sbhtml.springboards={};sbhtml.springboardVideoObjects={};sbhtml.externalCounter=0;sbhtml.sbElementId=null;sbhtml.debug=false;sbhtml.uagent=navigator.userAgent.toLowerCase();sbhtml.detectMobileArray=["iphone","ipad","ipod","android","blackberry"];sbhtml.cookieValue="sbanalytics";sbhtml.createSpringboards=function(d,b){if(sbhtml.detectSmartphone()||sbhtml.debug){var c=[];if(d!=null){sbhtml.sbElementId=d;c.push(document.getElementById(d))}else{c=sbhtml.collectSbObjects()}var e=c.length;for(var a=0;a<e;a++){try{vidObject=c[a];vidObject.itemNumbers=0;if(b!=undefined){vidObject.itemNumbers=b}vidObject.playlist={};vidObject.turns=0;vidObject.playlist.currentItem=0;vidObject.currentItem=externalCounter;vidObject=sbhtml.getValuesForVidObject(vidObject);sbhtml.runHtml5(vidObject);externalCounter++}catch(f){}}}else{return}};sbhtml.collectSbObjects=function(){var c=[];var a=document.getElementsByTagName("object");for(var b=0;b<a.length;b++){if(/\bSpringboardPlayer\b/.test(a[b].className)){c.push(a[b])}}return c};sbhtml.getValuesForVidObject=function(p){var w=p.childNodes;var d;var a=null;if(!p.flashVars){p.flashVars={}}for(var r=0;r<w.length;r++){if(w[r].nodeType!=1){continue}d=w[r].tagName.toLowerCase();if(d=="param"){if(sbhtml.debug){p.flashVars.cmsUrl="beta.cms.springboard.gorillanation.com"}else{p.flashVars.cmsUrl="cms.springboard.gorillanation.com"}if(w[r].name=="movie"){var v=w[r].value;var o=v.split("/");var q=o.length;p.flashVars.xmlUrl=v;if((v.indexOf("playlist")!=-1)&&(v.indexOf("config")!=-1)){var t=/playlist["']:["'](.*)["']/;var s=v.match(t);if(s[1]!=undefined){p.flashVars.externalPlaylist=s[1]}else{throw new Error("[EXTERNAL PLAYLIST][getValuesForVidObject] Playlist not found.")}var b=/superconfig\/(.*).js/;var u=v.match(b);if(u[1]!=undefined){p.flashVars.widgetId=u[1]}else{throw new Error("[EXTERNAL PLAYLIST][getValuesForVidObject] No widget id found.")}}else{if(v.indexOf("clip")!=-1){var r=/url["']:["'](.*)["']/gi;var h=r.exec(v);p.flashVars.clipPath=h[1];if(p.flashVars.xmlUrl.indexOf("title")!=-1){r=/title["']:["'](.*)["']/gi;var g=r.exec(v);p.flashVars.clipTitle=g[1]}if(p.flashVars.xmlUrl.indexOf("video_id")!=-1){r=/video_id["']:["']([0-9]+)["']/gi;var e=r.exec(v);p.flashVars.clipVideoId=e[1]}r=/\/([0-9a-zA-z]+)\.js/gi;var c=r.exec(v);p.flashVars.widgetId=c[1]}else{for(j=2;j<q;j++){if(j==2){p.flashVars.cdnUrl=o[j]}if(j==5){p.flashVars.mode=o[j]}if(j==6){p.flashVars.widgetId=o[j]}if(p.flashVars.mode!="youtube"){if(j==7){p.flashVars.partnerId=o[j]}if(j==8){p.flashVars.contentId=o[j]}}else{if(j==7){p.flashVars.contentId=o[j]}p.flashVars.partnerId=0}}}}}}}return p};sbhtml.ajaxRequest=function(){var c=["Msxml2.XMLHTTP","Microsoft.XMLHTTP"];if(window.ActiveXObject){for(var a=0;a<c.length;a++){try{return new ActiveXObject(c[a])}catch(b){}}}else{if(window.XMLHttpRequest){return new XMLHttpRequest()}else{return false}}};sbhtml.runHtml5=function(d){var b=sbhtml.formVideoTagFromInfo(d);d.videoElement=b;d.videoElement.id=d.id;var a=undefined;for(videoObjectKey in sbhtml.springboardVideoObjects){if(sbhtml.springboardVideoObjects[videoObjectKey].id==d.id){a=videoObjectKey}}if(a==undefined){sbhtml.springboardVideoObjects[d.currentItem]=d}else{d.currentItem=a;sbhtml.springboardVideoObjects[a]=d}sbhtml.springboards[d.id]=d;d.parentNode.replaceChild(b,d);if(d.flashVars.externalPlaylist!=undefined){var c=new sbhtml.ajaxRequest();c.open("GET",d.flashVars.externalPlaylist,false);c.send();c=c.responseXML;if(c!=undefined&&c!=null){sbhtml.springboardVideoObjects[d.currentItem].playlist=sbhtml.createExternalPlaylistFromXML(c);sbhtml.addScriptTag(d,"handleVideoResponse")}else{throw new Error("XML is empty or in wrong format!!!")}}else{if(d.flashVars.clipPath!=undefined){sbhtml.addScriptTag(d,"handleVideoResponseClip")}else{sbhtml.addScriptTag(d,"handleVideoResponse")}}};sbhtml.createExternalPlaylistFromXML=function(g){var e=g.getElementsByTagName("item");var h={};if(e!=undefined&&e.length>0){for(var f in e){if(e[f].hasChildNodes){var c=e[f].childNodes;var d={};d.Video={};for(var b in c){if(h.VideoList==undefined){h.VideoList=[]}d.Video[c[b].tagName]=c[b].textContent;if(c[b].tagName=="media:content"){d.Video.url=c[b].attributes.getNamedItem("url").nodeValue}if(c[b].tagName=="sb:snapshot"){d.Video.snapshot=c[b].attributes.getNamedItem("url").nodeValue}if(c[b].tagName=="siteId"){d.Video.site_id=c[b].textContent}}h.VideoList.push(d)}}}return h};sbhtml.addScriptTag=function(e,d){if(e.flashVars.externalPlaylist!=undefined||e.flashVars.clipPath!=undefined){var a="http://"+e.flashVars.cmsUrl+"/xml_feeds_advanced/html5v2/58/config/0/"+d+"/vid_"+e.id+"/"+e.id+"/"+e.width+"/"+e.height+"/"+e.flashVars.widgetId+"/"+e.currentItem+"/0"}else{var a="http://"+e.flashVars.cmsUrl+"/xml_feeds_advanced/html5v2/"+e.flashVars.partnerId+"/"+e.flashVars.mode+"/"+e.flashVars.contentId+"/"+d+"/vid_"+e.id+"/"+e.id+"/"+e.width+"/"+e.height+"/"+e.flashVars.widgetId+"/"+e.currentItem+"/"+e.itemNumbers}var c=document.createElement("script");c.type="text/javascript";c.src=a;c.async=true;c.charset="utf-8";var b=document.getElementsByTagName("head").item(0);b.appendChild(c)};sbhtml.handleVideoResponse=function(a,c,b){if(a!=""){var d=sbhtml.springboardVideoObjects[c];d.widgetConfig=b;d.videoElement.videoInfo={};if(a.VideoList==undefined){d.jsonResponse=d.playlist;d.playlist.currentItem=0;d.videoElement.videoInfo.partnerId=d.widgetConfig.WidgetPlayer.partner_id;if(d.flashVars.mode!="youtube"){}}else{d.jsonResponse=a}if(d.flashVars.mode!="youtube"){d.playlist.playlistLength=d.jsonResponse.VideoList.length}sbhtml.refreshVideoData(d);if(d.flashVars.mode!="youtube"){sbhtml.attachEvents(d)}}};sbhtml.handleVideoResponseClip=function(a,d,c){if(a!=""){var f=sbhtml.springboardVideoObjects[d];f.widgetConfig=c;var e={};e.VideoList=[];e.currentItem=0;var b={};b.Video={};b.Video.url=f.flashVars.clipPath;b.Video.title=f.flashVars.clipTitle;b.Video.id=f.flashVars.clipVideoId==undefined?0:f.flashVars.clipVideoId;b.Video.site_id=f.widgetConfig.WidgetPlayer.partner_id;b.Video.snapshot="";e.VideoList.push(b);f.playlist=e;f.playlist.playlistLength=f.playlist.VideoList.length;f.jsonResponse=e;f.videoElement.videoInfo={};sbhtml.refreshVideoData(f);sbhtml.attachEvents(f)}};sbhtml.refreshVideoDataWidget=function(b,a){sbhtml.listWidgetCheck=true;for(videoObjectKey in sbhtml.springboardVideoObjects){if(sbhtml.springboardVideoObjects[videoObjectKey].id==b){sbhtml.refreshVideoData(sbhtml.springboardVideoObjects[videoObjectKey],a);sbhtml.removeEvents(sbhtml.springboardVideoObjects[videoObjectKey]);sbhtml.attachEvents(sbhtml.springboardVideoObjects[videoObjectKey]);sbhtml.springboardVideoObjects[videoObjectKey].videoElement.load();break}}};sbhtml.refreshVideoData=function(f,c){if(f!=null){if(f.flashVars.mode=="youtube"){var b=document.getElementById(f.videoElement.id);var e=document.createElement("iframe");e.className="youtube-player";e.width=f.widgetConfig.WidgetPlayer.width;e.height=f.widgetConfig.WidgetPlayer.height;e.frameBorder=0;e.src="http://www.youtube.com/embed/"+f.flashVars.contentId+"?controls=1&enablejsapi=1";b.parentNode.replaceChild(e,b);return false}if(f.jsonResponse!=null&&f.jsonResponse.VideoList!=null&&f.jsonResponse.VideoList!=""){f.videoElement.autoplay=false;if(f.playlist.currentItem==0&&f.widgetConfig.WidgetFeature.autoPlay==1){f.videoElement.autoplay=true}if(f.playlist.playlistLength>1&&f.playlist.currentItem!=0&&f.widgetConfig.WidgetFeature.continousPlay==1){f.videoElement.autoplay=true}f.playlist.currentItem=(c!=null)?c:f.playlist.currentItem;f.videoElement.src=f.jsonResponse.VideoList[f.playlist.currentItem].Video.url;f.videoElement.id=f.id;f.videoElement.setAttribute("items",f.playlist.playlistLength);var a=f.jsonResponse.VideoList[f.playlist.currentItem].Video.url;var d=a.substr(a.lastIndexOf("."));if(d.toLowerCase()==".flv"&&(f.playlist.playlistLength>1&&f.playlist.currentItem<f.playlist.playlistLength-1)){f.playlist.currentItem++;sbhtml.refreshVideoData(f)}else{f.videoElement.title=f.videoElement.videoInfo.videoTitle=f.jsonResponse.VideoList[f.playlist.currentItem].Video.title;f.videoElement.poster=f.jsonResponse.VideoList[f.playlist.currentItem].Video.snapshot;f.videoElement.videoInfo.partnerId=f.jsonResponse.VideoList[f.playlist.currentItem].Video.site_id;f.videoElement.videoInfo.videoId=f.jsonResponse.VideoList[f.playlist.currentItem].Video.id}}}};sbhtml.populateAnalyticsRequest=function(g){var b=new sbhtml.ajaxRequest();var c=window.location.protocol+"//"+window.location.host;var d=g.videoElement.videoInfo;var a=[];a.sbct=sbhtml.time();a.sbvol=d.volume;a.sbva=d.videoAction;a.sbvt=escape(d.videoTitle);a.sbhn=c;a.sbtp=d.timePlayed;a.sbvlen=d.videoLength;a.sbuv=sbhtml.getUnique(g);a.sbpid=((d.partnerId==undefined)?g.siteId:d.partnerId);a.sbvid=((d.videoId==undefined)?0:d.videoId);a.sbpl=g.flashVars.widgetId;a.sbaty="c";a.sbmob=1;var f=[];for(var e in a){f.push(e+"="+a[e])}b.open("GET",g.widgetConfig.WidgetPlayer.analyticsUrl+"?"+f.join("&"),true);b.setRequestHeader("Accept-Sb","sb");b.send(null)};sbhtml.playNext=function(a){if(a.playlist.playlistLength>1&&a.playlist.currentItem<a.playlist.playlistLength-1){a.playlist.currentItem++;sbhtml.refreshVideoData(a)}else{if(a.playlist.playlistLength>1&&a.playlist.currentItem==a.playlist.playlistLength-1){if(a.turns<3){a.playlist.currentItem=0;sbhtml.refreshVideoData(a)}a.turns++}}};sbhtml.failed=function(a,b){if(a.target.error!=null){switch(a.target.error.code){case a.target.error.MEDIA_ERR_ABORTED:sbhtml.playNext(b);break;case a.target.error.MEDIA_ERR_NETWORK:sbhtml.playNext(b);break;case a.target.error.MEDIA_ERR_DECODE:sbhtml.playNext(b);break;case a.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED:sbhtml.playNext(b);break;default:sbhtml.playNext(b);break}}else{sbhtml.playNext(b)}};sbhtml.formVideoTagFromInfo=function(b){var a=document.createElement("video");a.width=b.width;a.height=b.height;a.controls=true;a.onerror=function(c){sbhtml.failed(c,b)};if(sbhtml.detectAndroid()){sbhtml.addClickHandlerToVid(a)}return a};sbhtml.detectSmartphone=function(){var a=false;for(var b=0;b<sbhtml.detectMobileArray.length;b++){if(sbhtml.uagent.search(sbhtml.detectMobileArray[b])!=-1){a=true;break}a=false}if(a){return true}else{return false}};sbhtml.detectAndroid=function(){if(sbhtml.uagent.search("android")>-1){return true}else{return false}};sbhtml.addClickHandlerToVid=function(a){a.addEventListener("click",function(b){return function(){b.play()}}(a))};sbhtml.sbRemoveListeners=function(){document.removeEventListener("load",sbhtml.createSpringboards,false);if(typeof document.addEventListener!="undefined"){document.removeEventListener("DOMContentLoaded",sbhtml.createSpringboard,false);document.removeEventListener("load",sbhtml.createSpringboards,false)}else{if(typeof window.attachEvent!="undefined"){window.detachEvent("onload",sbhtml.createSpringboards)}}};sbhtml.time=function(){var a=new Date();var b=a.getTime();return b};sbhtml.getUnique=function(a){if(sbhtml.readCookie(a)){return 0}else{sbhtml.setCookie(a);if(sbhtml.readCookie(a)){return 1}else{return 0}}},sbhtml.setCookie=function(c){if(c.videoElement.videoInfo.partnerId==undefined){sbhtml.cookieName="sbvideo_"+c.siteId}else{sbhtml.cookieName="sbvideo_"+c.videoElement.videoInfo.partnerId}var b=new Date();var a=new Date();a.setTime(b.getTime()+3600000*24);document.cookie=sbhtml.cookieName+"="+escape(sbhtml.cookieValue)+";expires="+a.toGMTString()};sbhtml.readCookie=function(c){if(c.videoElement.videoInfo.partnerId==undefined){sbhtml.cookieName="sbvideo_"+c.siteId}else{sbhtml.cookieName="sbvideo_"+c.videoElement.videoInfo.partnerId}var a=new RegExp("[; ]"+sbhtml.cookieName+"=([^\\s;]*)");var b=(" "+document.cookie).match(a);if(sbhtml.cookieName&&b){return unescape(b[1])}return""};sbhtml.buildSbPlayersIntoHtml5AfterPageLoad=function(){if(sbhtml.sbElementId==null){sbhtml.sbRemoveListeners();sbhtml.createSpringboards()}};if(typeof document.addEventListener!="undefined"){document.addEventListener("load",sbhtml.buildSbPlayersIntoHtml5AfterPageLoad,false);document.addEventListener("DOMContentLoaded",sbhtml.buildSbPlayersIntoHtml5AfterPageLoad,false)}else{if(typeof window.attachEvent!="undefined"){window.attachEvent("onload",sbhtml.buildSbPlayersIntoHtml5AfterPageLoad)}}sbhtml.bind=function(b,a,c){if(typeof document.addEventListener!="undefined"){b.addEventListener(a,c,false)}else{if(typeof window.attachEvent!="undefined"){b.attachEvent(a,c)}}};sbhtml.unbind=function(c,a,d,b){if(typeof document.addEventListener!="undefined"){c.removeEventListener(a,d,false)}else{if(typeof window.attachEvent!="undefined"){c.detachEvent(a,d)}}};sbhtml.attachEvents=function(b){var a=b.videoElement;a.vidObj=b;sbhtml.bind(a,"loadedmetadata",sbhtml.loadMetaDataEvent);sbhtml.bind(a,"ended",sbhtml.endEvent);sbhtml.bind(a,"timeupdate",sbhtml.trackAnalyticsEvent)};sbhtml.removeEvents=function(b){var a=b.videoElement;sbhtml.unbind(a,"loadedmetadata",sbhtml.loadMetaDataEvent);sbhtml.unbind(a,"ended",sbhtml.endEvent);sbhtml.unbind(a,"timeupdate",sbhtml.trackAnalyticsEvent)};sbhtml.loadMetaDataEvent=function(b){var a=b.target;a.videoInfo.videoLength=a.duration.toFixed();var c=(a.duration/4).toFixed();if(a.type!="ad"){a.analytics={VP_START:{val:false,cue:0},VP_25:{val:false,cue:c},VP_50:{val:false,cue:(c*2)},VP_75:{val:false,cue:(c*3)},VP_END:{val:false,cue:a.videoInfo.videoLength}}}};sbhtml.trackAnalyticsEvent=function(b){var a=b.target;var c=a.vidObj;var d=c.videoElement.currentTime.toFixed();for(var e in c.videoElement.analytics){if(d==c.videoElement.analytics[e].cue&&c.videoElement.analytics[e].val==false){c.videoElement.videoInfo.volume=(a.volume*100).toFixed();c.videoElement.videoInfo.timePlayed=d;c.videoElement.videoInfo.videoAction=e.toString();c.videoElement.analytics[e].val=true;sbhtml.populateAnalyticsRequest(c)}}};sbhtml.endEvent=function(b){try{var a=b.target;var c=a.vidObj;if((c!=null&&c.jsonResponse!=null)&&(c.playlist.currentItem<c.playlist.playlistLength-1)){c.playlist.currentItem++;sbhtml.refreshVideoData(c)}else{if(c.playlist.playlistLength>=0&&c.playlist.currentItem==c.playlist.playlistLength-1&&c.widgetConfig.WidgetFeature.recyclePlaylist==1){c.playlist.currentItem=0;sbhtml.refreshVideoData(c)}}}catch(d){}}};
