
(function(window,undefined){if(window.WM&&window.WM.PlayerManager){return;}
var Env={};Env.defaultEnvironment="prod";var Builder={};var Ajax={};var Util={};var Effect={};var Event={};var Data={};var Auth={};var Signer={};var QueryString={};var Playlist={};var PlayerHtml5={};var WMClass=function(){};(function(Class){var initializing=false,xyz=true,fnTest=/xyz/.test(function(){return xyz;})?/\b_super\b/:/.*/;Class.extend=function(prop){var _super=this.prototype;initializing=true;var prototype=new this();initializing=false;for(var name in prop){prototype[name]=typeof prop[name]=="function"&&typeof _super[name]=="function"&&fnTest.test(prop[name])?(function(name,fn){return function(){var tmp=this._super;this._super=_super[name];var ret=fn.apply(this,arguments);this._super=tmp;return ret;};})(name,prop[name]):prop[name];}
function Class(){if(!initializing&&this.init)
this.init.apply(this,arguments);}
Class.prototype=prototype;Class.prototype.constructor=Class;Class.extend=arguments.callee;return Class;};})(WMClass);Env.environment=Env.defaultEnvironment;Env.hostForEnvironment=function(hosts,replaceParams){if(Env.environment==="qa1"){return Util.replace(hosts.qa1,replaceParams);}else if(Env.isInternal()){return Util.replace(hosts.internal,replaceParams);}else{return Util.replace(hosts.live,replaceParams);}};Env.isTest=function(){return false;};Env.isInternal=function(){return(/\.globoi\.com$/).test(Util.getHostname());};Env.isGloboDomain=function(){return(Env.isInternal()&&Env.environment==="qa1")||(/\.globo\.com$/).test(Util.getHostname());};Env.HOSTS={API:{qa1:"api.video.qa01.globoi.com",internal:"api.video.globoi.com",live:"api.globovideos.com"},SECURITY:{qa1:"security.video.qa01.globoi.com",internal:"security.video.globo.com",live:"security.video.globo.com"},PLAYER:{qa1:"s.videos.cma.qa01.globoi.com",internal:"s.videos.globo.com",live:"s.videos.globo.com"},CADUN:{qa1:"login.qa01.globoi.com",internal:"login.globo.com",live:"login.globo.com"},THUMB:{qa1:"img.video.qa01.globoi.com",internal:"s0{index}.video.glbimg.com",live:"s0{index}.video.glbimg.com"}};Env.apiHostname=function(){return Env.hostForEnvironment(Env.HOSTS.API);};Env.securityHostname=function(){return Env.hostForEnvironment(Env.HOSTS.SECURITY);};Env.playerHostname=function(){return Env.hostForEnvironment(Env.HOSTS.PLAYER);};Env.cadunHostname=function(){return Env.hostForEnvironment(Env.HOSTS.CADUN);};Env.thumbHostname=function(settings){return Env.hostForEnvironment(Env.HOSTS.THUMB,{index:(settings.videoID%4)+1});};RegExp.escape=function(str){var specials=new RegExp("[.*+?|()\\[\\]{}\\\\]","g");return str.replace(specials,"\\$&");}
if(!Array.prototype.indexOf){Array.prototype.indexOf=function(obj,start){for(var i=(start||0),j=this.length;i<j;i++){if(this[i]===obj){return i;}}
return-1;}}
QueryString.PLAYER_PARAMS_PREFIX="wmp_";QueryString.parse=function(url,prefix){prefix=(prefix!==undefined)?prefix:'';var parameters={};if(url){var queryString=url.split('?')[1];if(queryString){var allParams=queryString.split('&');for(var i=0;i<allParams.length;i++){var keyValuePair=allParams[i].split('=');var paramKey=keyValuePair[0].toLowerCase();if((prefix.length===0)||(paramKey.indexOf(prefix)>=0)){parameters[QueryString.removePrefix(paramKey,prefix)]=QueryString._parseValue(keyValuePair[1]);}}}}
return parameters;}
QueryString.removePrefix=function(key,prefix){prefix=(prefix!==undefined)?prefix:'';return((prefix.length>0)&&(key.indexOf(prefix)===0))?key.substring(prefix.length,key.length):key;}
QueryString._parseValue=function(value){if(value===undefined||value=='true'){return true;}else if(value=='false'){return false;}else{return value;}}
Ajax.jsonp=function(settings){settings.callbackName=settings.callbackName||"json_callback";settings.timeout=settings.timeout||10000;window[settings.callbackName]=function(data){if(!Ajax.isErrorObject(data)){settings.success(data);}else{settings.error(data);}}
var head=Util.head();var script=document.createElement("script");script.setAttribute("src",settings.url);script.setAttribute("async","async");script.onload=script.onreadystatechange=function(eventLoad){if(!script.readyState||/loaded|complete/.test(script.readyState)){if(settings.timeoutId){window.clearTimeout(settings.timeoutId);}
script.onload=script.onreadystatechange=null;if(head&&script.parentNode)head.removeChild(script);script=undefined;}};head.insertBefore(script,head.firstChild);if(settings.error){settings.timeoutId=window.setTimeout(settings.error,settings.timeout);}};Ajax.isErrorObject=function(data){return data&&data.http_status_code&&data.http_status_code!=200;}
Util.Exception=function(message){this.message=message;};Util.notWhite=/\S/.test("\xA0");Util.TrimRegex={trimLeft:Util.notWhite?/^[\s\xA0]+/:/^\s+/,trimRight:Util.notWhite?/[\s\xA0]+$/:/\s+$/};Util.nativeTrim=function(text){return text==null?"":String.prototype.trim.call(text);};Util.customTrim=function(text){var trimLeft=Util.TrimRegex.trimLeft;var trimRight=Util.TrimRegex.trimRight;return text==null?"":text.toString().replace(trimLeft,"").replace(trimRight,"");};Util.trim=String.prototype.trim?Util.nativeTrim:Util.customTrim;Util.findFirst=function(collection,callback){for(var index=0;index<collection.length;index++){if(callback(collection[index],index)){return collection[index];}}
return null;}
Util.each=function(collection,callback){var index;if(collection instanceof Array){for(index=0;index<collection.length;index++){callback(collection[index],index);}}else{for(index in collection){if(!collection.hasOwnProperty||collection.hasOwnProperty(index)){callback(collection[index],index);}}}};Util.eachObject=function(collection,callback){Util.each(collection,function(value,index){if(Util.isObject(value)){callback(value,index);}});};Util.map=function(array,callback){var result=[];Util.each(array,function(value,index){result.push(callback(value,index));});return result;};Util.joinWithCamelCase=function(array){var first=array.splice(0,1);var joined="";Util.each(array,function(value){if(value){joined+=Util.capitalize(value);}});return first+joined;};Util.capitalize=function(value){return value.replace(value.charAt(0),value.charAt(0).toUpperCase());};Util.uncapitalize=function(value){return value.replace(value.charAt(0),value.charAt(0).toLowerCase());};Util.replace=function(template,params){var result=template;Util.each(params,function(value,key){result=result.replace(new RegExp("{"+key+"}","g"),value);});return result;};Util.JSONRegex={validChars:/^[\],:{}\s]*$/,validEscape:/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,validTokens:/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,validBraces:/(?:^|:|,)(?:\s*\[)+/g};Util.parseJSON=function(data){if(typeof data!=="string"||!data){return null;}
data=Util.trim(data);if(window.JSON&&window.JSON.parse){try{return window.JSON.parse(data);}catch(e){throw new Util.Exception("Invalid JSON: "+data);}}
var rvalidchars=Util.JSONRegex.validChars;var rvalidescape=Util.JSONRegex.validEscape;var rvalidtokens=Util.JSONRegex.validTokens;var rvalidbraces=Util.JSONRegex.validBraces;if(rvalidchars.test(data.replace(rvalidescape,"@").replace(rvalidtokens,"]").replace(rvalidbraces,""))){return(new Function("return "+data))();}
throw new Util.Exception("Invalid JSON: "+data);};Util.getUserAgent=function(){return navigator.userAgent;};Util.getHostname=function(){return location.hostname;};Util.getCurrentUrl=function(){return location.href;};Util.isIPhone=function(){var userAgent=Util.getUserAgent();return(/iPhone/i).test(userAgent)||(/iPod/i).test(userAgent);};Util.isIPad=function(){return(/iPad/i).test(Util.getUserAgent());};Util.isAndroid=function(){return(/Android/i).test(Util.getUserAgent());};Util.isMobileBrowser=function(){return(Util.isIPhone()||Util.isIPad()||Util.isAndroid());};Util.canUseFlashPlayer=function(){return!Util.isMobileBrowser();};Util.canPlayType=function(src){var video=document.createElement('video');return(video.canPlayType('video/'+src.split('?')[0].split('.').pop())!=="");};Util.navigateTo=function(uri){window.location.href=uri;}
Util.isPrivate=function(attribute){return attribute.indexOf('_')===0;};Util.isPrimitive=function(value){return!(Util.isUndefined(value)||Util.isFunction(value)||Util.isObject(value));};Util.isFunction=function(value){return(typeof value==="function");};Util.isObject=function(value){return(typeof value==="object");};Util.isUndefined=function(value){return(typeof value==="undefined");};Util.createElement=function(tagName,id,backgroundColor,opacity,width,height,position,top,left,zIndex){var element=document.createElement(tagName);element.setAttribute('id',id);if(arguments.length>2){element.style.display='none';element.style.backgroundColor=backgroundColor;element.style.opacity=opacity;element.style.filter='alpha(opacity='+(opacity*100)+')';element.style.width=width;element.style.height=height;element.style.position=position;element.style.top=top;element.style.left=left;element.style.zIndex=zIndex;}
return element;};Util.customGetElementsByClassName=function(element,tagName,className){var elements=(tagName=="*"&&element.all)?element.all:element.getElementsByTagName(tagName),elementsToReturn=[],classNamePattern=new RegExp("(^|\\s)"+className.replace(/\-/g,"\\-")+"(\\s|$)");for(var i=0;i<elements.length;i++){element=elements[i];if(classNamePattern.test(element.className)){elementsToReturn.push(element);}}
return elementsToReturn;}
if(document.getElementsByClassName){Util.getElementsByClassName=function(element,tagName,className){return element.getElementsByClassName(className);}}else{Util.getElementsByClassName=Util.customGetElementsByClassName;}
Util.getFirstElementByClassName=function(element,className){var elements=Util.getElementsByClassName(element,"*",className);return elements.length>0?elements[0]:null;};Util.getStyle=function(element,property){if(element.currentStyle){return element.currentStyle[property];}else if(window.getComputedStyle){return document.defaultView.getComputedStyle(element,null).getPropertyValue(property);}
return null;};Util.getDefaultDisplay=function(element){var newElement=document.createElement(element.nodeName);var body=Util.body();body.appendChild(newElement);var defaultDisplay=Util.getStyle(newElement,"display");body.removeChild(newElement);return defaultDisplay;};Util.log=function(){if(window.console&&window.console.log&&window.console.log.apply){window.console.log.apply(window.console,arguments);}};Util.getCookie=function(cookieName){var results=document.cookie.match('(^|;) ?'+cookieName+'=([^;]*)(;|$)');if(results){return(window.unescape(results[2]));}
return null;};Util.head=function(){return document.head||document.getElementsByTagName("head")[0];};Util.body=function(){return document.body||document.getElementsByTagName('body')[0];};Util.checkExistenceOfPushedStyle=function(pushedName){if(pushedName){var styles=document.getElementsByTagName("style");for(var i=0;i<styles.length;i++){if(styles[i].pushName&&styles[i].pushName==pushedName)return true;}}
return false;};Util.pushCss=function(arrayWithCss,pushName,paramsToReplace){if(Util.checkExistenceOfPushedStyle(pushName))return;var head=Util.head();var style=document.createElement('style');style.type="text/css";style.media="all";style.rel="stylesheet";if(pushName){style.pushName=pushName;}
var rules=document.createTextNode(Util.replace(arrayWithCss.join("\n"),paramsToReplace||{}));if(style.styleSheet){style.styleSheet.cssText=rules.nodeValue;}else{style.appendChild(rules);}
head.appendChild(style);};Util.getCurrentDate=function(){return new Date();};Util.getCurrentTime=function(){return Util.getCurrentDate().getTime();};Util.mergeObjects=function(object,settings){var existingKeys={};Util.each(object,function(value,key){var keyLower=key.toLowerCase();existingKeys[keyLower]=1;object[key]=settings[keyLower]!==undefined?settings[keyLower]:object[key];});Util.each(settings,function(value,key){if(!existingKeys[key]){object[key]=settings[key];}});};Util.getUrlParameters=function(prefix){return QueryString.parse(Util.getCurrentUrl(),prefix);};Util.hasFlashInstalled=function(){try{return!!new ActiveXObject('ShockwaveFlash.ShockwaveFlash');}catch(e1){}
var mimeType=Util.getMimeType("application/x-shockwave-flash");return!!(mimeType&&mimeType.enabledPlugin);};Util.getMimeType=function(type){return navigator.mimeTypes[type];};Util.clearElement=function(element){try{if(element.hasChildNodes()){while(element.childNodes.length>=1){element.removeChild(element.firstChild);}}}catch(e){Util.log(e);}
element.innerHTML='';};var Metrics=WMClass.extend({_account:'UA-296593-12',_trackerName:'WMPlayer',init:function(settings){settings=settings||{};this._account=settings.account||this._account;this._trackerName=(settings.trackerName===undefined)?this._trackerName:settings.trackerName;this._formatTrackerName();this._initializeGAQ();this.push([this._trackerName+'_setAccount',this._account]);this.push([this._trackerName+'_trackPageview']);this._loadScript();},push:function(array){window._gaq.push(array);},play:function(settings){settings.category=settings.category.substr(0,3).toUpperCase();var _playUrl=Util.replace(Metrics.PLAY_TEMPLATE_URL,settings);this.push([this._trackerName+'_trackPageview',_playUrl]);this.push([this._trackerName+'_trackEvent','Videos',"Play",settings.videoID+" - "+settings.title]);},end:function(settings){settings.category=settings.category.substr(0,3).toUpperCase();var _endUrl=Util.replace(Metrics.END_TEMPLATE_URL,settings);this.push([this._trackerName+'_trackPageview',_endUrl]);this.push([this._trackerName+'_trackEvent','Videos',"End Of The Video",settings.videoID+" - "+settings.title]);},_formatTrackerName:function(){this._trackerName=(this._trackerName.length>0)?this._trackerName+'.':this._trackerName;},_initializeGAQ:function(){window._gaq=window._gaq||[];},_loadScript:function(){if(!window._gat){var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;ga.src=('https:'==document.location.protocol?'https://ssl':'http://www')+'.google-analytics.com/ga.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);}}});Metrics.getDefaultInstance=function(){return(Metrics._defaultInstance=Metrics._defaultInstance||new Metrics());};Metrics.PLAY_TEMPLATE_URL='/use/play/{channel}/{program}/{category}/{videoID}';Metrics.END_TEMPLATE_URL='/use/end/{channel}/{program}/{category}/{videoID}';Playlist.CALLBACK_TEMPLATE="wmPlayerPlaylistLoaded{playerId}";Playlist.urlFor=function(videoID,callbackName){return"http://"+Env.apiHostname()+"/videos/"+videoID+"/playlist/callback/"+callbackName;}
Playlist.load=function(settings){var callbackName=Playlist._callbackNameFor(settings.playerId);Ajax.jsonp({url:Playlist.urlFor(settings.videoID,callbackName),callbackName:callbackName,success:settings.success,error:settings.error});}
Playlist._callbackNameFor=function(playerId){var params={playerId:playerId>0?playerId:""};return Util.replace(Playlist.CALLBACK_TEMPLATE,params);}
Playlist._isTargetDeviceEqual=function(resource,targetDevice){return resource.target_device&&(resource.target_device.indexOf(targetDevice)>=0);}
Playlist._isPlayerTypeEqual=function(resource,playerType){return resource.player_type&&(resource.player_type.indexOf(playerType)>=0);}
Playlist._findResource=function(video,targetDevice,playerType,kind){var resource={};Util.each(video.resources,function(_resource){if(Playlist._isTargetDeviceEqual(_resource,targetDevice)&&Playlist._isPlayerTypeEqual(_resource,playerType)){return(resource=_resource);}});if(!resource.url){Util.each(video.resources,function(_resource){if(kind===_resource.kind){return(resource=_resource);}});}
resource.id=resource._id;if(resource.target_device){resource.targetDevice=resource.target_device;}
if(resource.player_type){resource.playerType=resource.player_type;}
return resource;}
Playlist._isVideoIndexAvailable=function(playlist,videoIndex){return playlist&&playlist.videos&&playlist.videos.length>videoIndex;}
Playlist._isChildrenIndexAvailable=function(video,childrenIndex){return!!(video.children&&video.children.length>childrenIndex);}
Playlist.isGalleryOrFullEpisode=function(video){return Playlist._isChildrenIndexAvailable(video,0);}
Playlist._getVideo=function(playlist,videoIndex,childrenIndex){var video=playlist.videos[videoIndex];return Playlist._isChildrenIndexAvailable(video,childrenIndex)?video.children[childrenIndex]:video;}
Playlist.getResource=function(playlist,videoIndex,childrenIndex){var resource={};videoIndex=videoIndex||0;childrenIndex=childrenIndex||0;if(Playlist._isVideoIndexAvailable(playlist,videoIndex)){var video=Playlist._getVideo(playlist,videoIndex,childrenIndex);if(Util.isIPhone()){resource=Playlist._findResource(video,"iphone","html5","M4");}else if(Util.isIPad()){resource=Playlist._findResource(video,"ipad","html5","H4");if(resource.url.indexOf('rtmp')===0){resource=Playlist._findResource(video,"iphone","html5","M4");}else if(resource.url){resource.url=resource.url.replace("flashvideo","ipadvideo");}}else if(Util.isAndroid()){resource=Playlist._findResource(video,"android","html5","M4");}else{resource=Playlist._findResource(video,"web","flash","H4");if(!resource.url){resource=Playlist._findResource(video,"web","flash","FS");}}}
return resource;};Playlist.totalChildren=function(playlist,videoIndex){if(Playlist._isVideoIndexAvailable(playlist,videoIndex)){var video=playlist.videos[videoIndex];return video.children?video.children.length:1;}
return 1;};Playlist.getServiceId=function(playlist){if(Playlist._isVideoIndexAvailable(playlist,0)){return playlist.videos[0].service_id;}};Playlist.parametersForMetrics=function(playlist,videoIndex){if(Playlist._isVideoIndexAvailable(playlist,videoIndex)){var video=playlist.videos[videoIndex];return{channel:video.channel,program:video.program,category:video.category,title:video.title,videoID:video.id}}
return{};};Playlist.hasSubscriberOnly=function(playlist){if(Playlist._isVideoIndexAvailable(playlist,0)){var subscribers_only=false;Util.each(playlist.videos,function(video){if(video.subscriber_only){subscribers_only=true;}});return subscribers_only;}
return true;};Event.Exception=function(message){this.message=message;};Event.linker=function(method,instance){return function(){return method.apply(instance,arguments);};}
Event.createLinkedMethodsFor=function(instance,methods){Util.each(methods,function(method){var methodName=/^_/.test(method)?method.replace("_",""):method;var prefix=/^_/.test(method)?"_linked":"linked";var name=prefix+Util.capitalize(methodName);instance[name]=Event.linker(instance[method],instance);});}
Event.bind=function(element,eventType,handler){var listenerMethod=element.addEventListener||element.attachEvent;Event._bindOrUnbind(listenerMethod,element,eventType,handler);};Event.unbind=function(element,eventType,handler){var listenerMethod=element.removeEventListener||element.detachEvent;Event._bindOrUnbind(listenerMethod,element,eventType,handler);};Event._bindOrUnbind=function(listenerMethod,element,eventType,handler){if(element.nodeType===3||element.nodeType===8){throw new Event.Exception("It is not possible to attach events to text or comment nodes");}
if(element.addEventListener||element.removeEventListener){listenerMethod.call(element,eventType,handler,false);}else if(element.attachEvent||element.detachEvent){listenerMethod("on"+eventType,handler);}};var ErrorPage=WMClass.extend({init:function(settings){this.rendered=false;this.width=settings.width;this.height=settings.height;this.element=settings.element;this.errorMessages=[ErrorPage.DEFAULT_MESSAGE,ErrorPage.GEO_BLOCKED,ErrorPage.NOT_FOUND,ErrorPage.DEVICE_NOT_SUPPORTED];this._mergeWithErrorMessages(settings.errorMessages);this.ops_url="http://"+Env.playerHostname()+"/p2/i/ops.png";},render:function(code){var codeToRender=code?code:ErrorPage.DEFAULT_MESSAGE.code;var error=this.messageFor(codeToRender);this._applyCss();Util.clearElement(this.element);this.element.innerHTML=Util.replace(ErrorPage.TEMPLATE,{ops_url:this.ops_url,title:error.title,description:error.description,code:error.code});this.rendered=true;this.resize();},isNotFound:function(errorObject){return errorObject&&errorObject.http_status_code==404;},isGeoBlocked:function(errorObject){return errorObject&&errorObject.http_status_code==403&&errorObject.code=='GB';},isNotAuthorized:function(errorObject){return errorObject&&errorObject.http_status_code==403&&errorObject.code=='AUT';},messageFor:function(code){return Util.findFirst(this.errorMessages,function(error){return error.code.toLowerCase()==code.toLowerCase();});},_mergeWithErrorMessages:function(errorObjects){var self=this;Util.each(errorObjects,function(obj){var message=self.messageFor(obj.code);if(message){self.errorMessages.splice(self.errorMessages.indexOf(message),1);}
self.errorMessages.push(obj);});},_applyCss:function(){Util.pushCss(this._cssRules(),"wm-error");},resize:function(settings){settings=settings||{};this.width=settings.width||this.width;this.height=settings.height||this.height;if(this.element&&this.rendered){var wmError=Util.getFirstElementByClassName(this.element,"wm-error");if(wmError){var sizeClass=this._getSizeClass();wmError.className=wmError.className.replace(/(\s?wm-error-small)+/,"").replace(/(\s?wm-error-big)+/,"");wmError.className+=(" "+sizeClass);}}},_getSizeClass:function(){return(this.height===undefined||this.height>240)?"wm-error-big":"wm-error-small";},_cssRules:function(){var rules=[];rules.push(".wm-error { background-color: #2C2C2C; font-family: Arial; width: 100%; height: 100%; position: relative; }");rules.push(".wm-error img { border: 0; }");rules.push(".wm-error-title { color: #999999; }");rules.push(".wm-error-description { color: #838383; }");rules.push(".wm-error-code { color: #838383; position: absolute; }");rules.push(".wm-error-code-number { color: #D5D5D5; }");rules.push(".wm-error a, a:visited { text-decoration: underline; color: #B6B6B6; }");rules.push(".wm-error a:hover { color: #ECECEC; }");rules.push(".wm-error-big img { height: 73; margin: 38px 0 0 38px; }");rules.push(".wm-error-big .wm-error-title { font-size: 22px; margin: 30px 38px 0 38px; }");rules.push(".wm-error-big .wm-error-description { font-size: 12px; margin: 24px 38px 0 38px; }");rules.push(".wm-error-big .wm-error-code { font-size: 10px; margin: 0 38px; bottom: 38px}");rules.push(".wm-error-small img { height: 54; margin: 20px 0 0 20px; }");rules.push(".wm-error-small .wm-error-title { font-size: 18px; margin: 20px 20px 0 20px; }");rules.push(".wm-error-small .wm-error-description { font-size: 10px; margin: 18px 20px 0 20px; }");rules.push(".wm-error-small .wm-error-code { font-size: 8px; margin: 0 20px; bottom: 20px}");return rules;}});ErrorPage.TEMPLATE='<div class="wm-error">'+'<img src="{ops_url}" />'+'<div class="wm-error-title">{title}</div>'+'<div class="wm-error-description">{description}</div>'+'<div class="wm-error-code">Código do Erro - <span class="wm-error-code-number">{code}</span></div>'+'</div>';ErrorPage.DEFAULT_MESSAGE={title:"Não foi possível exibir o vídeo!",description:'Ocorreu um problema ao tentar carregar o vídeo. '+'Tente <a href="" onclick="window.location.reload(); return false;">recarregar</a> a sua página.',code:"load-error"}
ErrorPage.GEO_BLOCKED={title:"O vídeo não pode ser exibido nessa região",description:"Infelizmente este vídeo não está disponível para ser exibido na sua região ou país. Desculpe-nos pelo inconveniente.",code:"GB"}
ErrorPage.NOT_FOUND={title:"Conteúdo não disponível.",description:"Infelizmente este vídeo não está disponível. Desculpe-nos pelo inconveniente.",code:"NF"}
ErrorPage.DEVICE_NOT_SUPPORTED={title:"Dispositivo não suportado.",description:"Infelizmente o seu dispositivo não possui os requisitos mínimos para exibir esse vídeo.",code:"DNS"}
var Message={interval_id:null,last_hash:null,cache_bust:1,has_postMessage:window.postMessage,rm_callback:null,post:function(message,target_url,target){if(!target_url){return;}
if(typeof message!=='string'){return;}
target=target||parent;if(Message.has_postMessage){target.postMessage(message,target_url.replace(/([^:]+:\/\/[^\/]+).*/,'$1'));}else if(target_url){target.location=target_url.replace(/#.*$/,'')+'#'+(+new Date())+(Message.cache_bust++)+'&'+message;}},receive:function(callback,source_origin,delay){if(Message.has_postMessage){if(callback){if(Message.rm_callback){Message.receive();}
Message.rm_callback=function(e){if((typeof source_origin==='string'&&e.origin!==source_origin)||(Util.isFunction(source_origin)&&source_origin(e.origin)===false)){return false;}
callback(e);};Event.bind(window,'message',Message.rm_callback);}else{Event.unbind(window,'message',Message.rm_callback);}}else{if(Message.interval_id){clearInterval(Message.interval_id);}
Message.interval_id=null;if(callback){delay=(typeof source_origin==='number')?source_origin:((typeof delay==='number')?delay:100);Message.interval_id=setInterval(function(){var hash=document.location.hash,re=/^#?\d+&/;if(hash!==Message.last_hash&&re.test(hash)){document.location.hash=null;Message.last_hash=hash;callback({data:hash.replace(re,'')});}},delay);}}}}
Effect._resizeAndPositioningShadowTimer=null;Effect.FADE_TICK=10;Effect.Fade=function(options){this.elements=[].concat(options.element||[]).concat(options.elements||[]);this.instances={};this._init(options);};Effect.Fade.prototype={fadeIn:function(maxFade){this._eachInstance(function(){if(!this.isVisible()){this.fadeState='visible';this.maxFade=maxFade||this.maxFade;this._start();}});},fadeOut:function(maxFadeOut){this._eachInstance(function(){if(this.isVisible()){this.fadeState='invisible';this.maxFadeOut=maxFadeOut||this.maxFadeOut;this._start();}});},_init:function(options){this.duration=options.duration;var self=this;Util.each(this.elements,function(value,key){self.instances[key]=self._newInstance(value,options.maxFade,options.maxFadeOut);});},_newInstance:function(element,maxFade,maxFadeOut){var obj={};obj.element=element;obj.duration=this.duration;if(!maxFade){var opacity=element.style.opacity;obj.maxFade=(!this._isWithoutOpacity(element)&&opacity!=='0')?parseFloat(opacity):1;}else{obj.maxFade=maxFade;}
obj.maxFadeOut=maxFadeOut||0;obj.defaultDisplay=Util.getDefaultDisplay(element);if(this._isDisplayed(element)&&(this._isWithoutOpacity(element)||this._isOpaque(element,obj.maxFade))&&parseFloat(element.style.opacity)!==maxFadeOut){obj.fadeState='visible';}else{obj.fadeState='invisible';}
var self=this;obj._start=function(){self._start.call(obj);};obj.isVisible=function(){return self._isVisible.call(obj);}
return obj;},_isVisible:function(){return this.fadeState==='visible';},_eachInstance:function(block){Util.each(this.instances,function(value){block.call(value);});},_isDisplayed:function(element){return Util.getStyle(element,"display")!=="none";},_isWithoutOpacity:function(element){var opacity=element.style.opacity;return opacity===null||opacity===undefined||opacity==='';},_isOpaque:function(element,maxFade){return element.style.opacity===''+maxFade;},_start:function(){this.fadeTimeLeft=this.duration;var currentTick=new Date().getTime();var self=this;setTimeout(function(){Effect._animateFade(currentTick,self)},Effect.FADE_TICK);}};Effect._animateFade=function(lastTick,fadeObj){var duration=fadeObj.duration;var maxFade=fadeObj.maxFade;var maxFadeOut=fadeObj.maxFadeOut;var style=fadeObj.element.style;var currentTick=new Date().getTime();var elapsedTicks=currentTick-lastTick;if(fadeObj.fadeTimeLeft<=elapsedTicks){style.opacity=fadeObj.isVisible()?''+maxFade:''+maxFadeOut;style.filter='alpha(opacity = '+(fadeObj.isVisible()?''+(maxFade*100):''+(maxFadeOut*100))+')';if(fadeObj.isVisible()||maxFadeOut>0){style.display=fadeObj.defaultDisplay;}else{style.display='none';}
return;}
fadeObj.fadeTimeLeft-=elapsedTicks;var newOpacityValue=(fadeObj.fadeTimeLeft/duration)*maxFade;if(fadeObj.isVisible()){newOpacityValue=maxFade-newOpacityValue;if(maxFadeOut===0||(newOpacityValue>maxFadeOut&&maxFadeOut>0)){style.opacity=newOpacityValue;style.filter='alpha(opacity = '+(newOpacityValue*100)+')';}}else if(maxFadeOut===0||newOpacityValue>maxFadeOut){style.opacity=newOpacityValue;style.filter='alpha(opacity = '+(newOpacityValue*100)+')';}
if(Util.getStyle(fadeObj.element,"display")=="none"){style.display=fadeObj.defaultDisplay;}
setTimeout(function(){Effect._animateFade(currentTick,fadeObj)},Effect.FADE_TICK);};Effect.createShadow=function(zIndex,duration,maxFade){var wmPlayerShadow=document.getElementById('wmPlayerShadow');if(wmPlayerShadow===undefined||wmPlayerShadow==null){zIndex=zIndex||100000;wmPlayerShadow=Util.createElement('div','wmPlayerShadow');Util.body().appendChild(wmPlayerShadow);var left=Effect._newShadowDiv('wmPlayerShadowLeft',zIndex);var top=Effect._newShadowDiv('wmPlayerShadowTop',zIndex);var right=Effect._newShadowDiv('wmPlayerShadowRight',zIndex);var bottom=Effect._newShadowDiv('wmPlayerShadowBottom',zIndex);wmPlayerShadow.appendChild(left);wmPlayerShadow.appendChild(top);wmPlayerShadow.appendChild(right);wmPlayerShadow.appendChild(bottom);wmPlayerShadow.wmFade=new Effect.Fade({duration:duration||500,maxFade:maxFade||0.8,elements:[left,top,right,bottom]});}};Effect._newShadowDiv=function(id,zIndex){return Util.createElement('div',id,'black',0.8,0,0,'absolute',0,0,zIndex);};Effect.showShadow=function(){Effect._animateShadow("fadeIn");};Effect.hideShadow=function(){Effect._animateShadow("fadeOut");};Effect._animateShadow=function(animation){var wmPlayerShadow=document.getElementById('wmPlayerShadow');if((wmPlayerShadow!==undefined)&&(wmPlayerShadow!=null)&&(wmPlayerShadow.wmFade!=null)){wmPlayerShadow.wmFade[animation]();}};Effect._clientHeight=function(){var n_win=window.innerHeight?window.innerHeight:0;var n_docel=document.documentElement?document.documentElement.clientHeight:0;var n_scroll=document.documentElement?document.documentElement.scrollHeight:0;var n_body=Util.body()?Util.body().clientHeight:0;return Math.max(n_win,Math.max(n_docel,Math.max(n_scroll,n_body)));};Effect._clientWidth=function(){var n_win=window.innerWidth?window.innerWidth:Number.MAX_VALUE;var n_docel=document.documentElement?document.documentElement.clientWidth:Number.MAX_VALUE;var n_body=Util.body()?Util.body().clientWidth:Number.MAX_VALUE;return Math.min(n_win,Math.min(n_docel,n_body));};Effect.findCoordinates=function(element){var leftSide=0,topSide=0,rightSide=0,bottomSide=0,obj=element;if(obj.offsetParent){do{topSide+=obj.offsetTop;leftSide+=obj.offsetLeft;}while(obj=obj.offsetParent);rightSide=element.offsetWidth+leftSide;bottomSide=element.offsetHeight+topSide;}
return[leftSide,topSide,rightSide,bottomSide];};Effect.resizeAndPositioningShadow=function(element){if((element!==undefined)&&(element!=null)){var coords=Effect.findCoordinates(element);var clientWidth=Math.max(document.documentElement.scrollLeft,Util.body().scrollLeft)+Effect._clientWidth();var clientHeight=Effect._clientHeight();Effect._updatePosition('wmPlayerShadowTop',0,0,clientWidth,coords[1]);Effect._updatePosition('wmPlayerShadowLeft',coords[1],0,coords[0],(coords[3]-coords[1]));Effect._updatePosition('wmPlayerShadowRight',coords[1],coords[2],(clientWidth-coords[2]),(coords[3]-coords[1]));Effect._updatePosition('wmPlayerShadowBottom',coords[3],0,clientWidth,(clientHeight-coords[3]));}};Effect._updatePosition=function(id,top,left,width,height){var style=document.getElementById(id).style;style.top=top+'px';style.left=left+'px';style.width=width+'px';style.height=height+'px';};Effect._onResizeOrScroll=function(){clearTimeout(Effect._resizeAndPositioningShadowTimer);Effect._resizeAndPositioningShadowTimer=setTimeout(this.wmResizeAndPositioningShadow,10);};Effect._onResizeAndPositioningShadow=function(){Effect.resizeAndPositioningShadow(this);};Effect.onLightOff=function(element,zIndex){element.wmResizeOrScroll=Event.linker(Effect._onResizeOrScroll,element);element.wmResizeAndPositioningShadow=Event.linker(Effect._onResizeAndPositioningShadow,element);Effect.createShadow(zIndex);Effect.resizeAndPositioningShadow(element);Effect.showShadow();Event.bind(window,'resize',element.wmResizeOrScroll);Event.bind(window,'scroll',element.wmResizeOrScroll);};Effect.onLightOn=function(element){Effect.hideShadow();Event.unbind(window,'resize',element.wmResizeOrScroll);Event.unbind(window,'scroll',element.wmResizeOrScroll);};Effect.Lightbox=WMClass.extend({init:function(settings){Event.createLinkedMethodsFor(this,['_closedByUser','_alignLightbox','_resizeIframe']);this.firstLoad=true;this.body=Util.body();this.element=settings.element;this.modal=settings.modal||false;this.onCloseCallback=settings.onClose;this._applyCss();this._createElements();this._bindEvents();this._bindIframeOnloadEvent();this._appendElements();this._alignLightbox();this.fadeOverlay=new Effect.Fade({element:this.overlay,duration:settings.overlayFadeDuration||300,maxFade:settings.overlayMaxFade||0.6});this.fadeInnerWrapper=new Effect.Fade({element:this.innerWrapper,duration:settings.boxFadeDuration||200});},open:function(){this.wrapper.style.display="block";this.fadeOverlay.fadeIn();this.fadeInnerWrapper.fadeIn();},close:function(){this.fadeInnerWrapper.fadeOut();this.fadeOverlay.fadeOut();this.wrapper.style.display="none";},_closedByUser:function(){if(this.onCloseCallback){this.onCloseCallback();}
this.close();},_bindEvents:function(){var self=this;this.closeButton.onclick=this._linkedClosedByUser;if(!this.modal){this.outerWrapper.style.cursor="pointer";this.outerWrapper.onclick=this._linkedClosedByUser;this.innerWrapper.onclick=function(event){var e=event||window.event;e.cancelBubble=true;if(e.stopPropagation){e.stopPropagation();}};}
Event.bind(window,'resize',this._linkedAlignLightbox);Event.bind(window,'scroll',this._linkedAlignLightbox);},_bindIframeOnloadEvent:function(){this.iframe=this.element.getElementsByTagName("iframe")[0];if(this.iframe){Event.bind(this.iframe,'load',this._linkedResizeIframe);}},_resizeIframe:function(){if(!this.firstLoad){this.iframe.width="100%";this.iframe.height="100%";this.element.style.width="980px";this._alignLightbox();}
this.firstLoad=false;},_getViewPort:function(){this.viewPortWidth=window.innerWidth||document.documentElement.clientWidth||this.body.clientWidth;this.viewPortHeight=window.innerHeight||document.documentElement.clientHeight||this.body.clientHeight;},_alignLightbox:function(){this._getViewPort();var width=parseInt(Util.getStyle(this.element,"width").replace(/\D+/,''),10);var height=parseInt(Util.getStyle(this.element,"height").replace(/\D+/,''),10);if(width&&height){var innerLeft=(Effect._clientWidth()/2)-(width/2);var innerTop=(this.viewPortHeight/2)-(height/2);this.innerWrapper.style.left=innerLeft+"px";this.innerWrapper.style.top=innerTop+"px";}},_createElements:function(){this.overlay=this._createElementWithClass("div","wm-lightbox-black-overlay");this.outerWrapper=this._createElementWithClass("div","wm-lightbox-outer-wrapper");this.innerWrapper=this._createElementWithClass("div","wm-lightbox-inner-wrapper");this.content=this._createElementWithClass("div","wm-lightbox-content");this.closeButton=this._createElementWithClass("div","wm-lightbox-close");this.wrapper=this._createElementWithClass("div","wm-lightbox-wrapper");this.wrapper.style.display="none";},_createElementWithClass:function(nodeType,className){var node=document.createElement(nodeType);node.className=className;return node;},_appendElements:function(){this.content.appendChild(this.element);this.innerWrapper.appendChild(this.content);this.innerWrapper.appendChild(this.closeButton);this.outerWrapper.appendChild(this.innerWrapper);this.wrapper.appendChild(this.outerWrapper);this.element.style.display=Util.getDefaultDisplay(this.element);this.element.style.visibility="visible";this.body.appendChild(this.overlay);this.body.appendChild(this.wrapper);},_applyCss:function(){var closeUrl="http://"+Env.playerHostname()+"/p2/i/close.png";var rules=[];rules.push(".wm-lightbox-black-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: black; z-index: 10000; }");rules.push(".wm-lightbox-wrapper { z-index: 10001; position: fixed; top: 0; left: 0; width: 100%; height: 100%; }");rules.push(".wm-lightbox-outer-wrapper { position: relative; width: 100%; height: 100%; }");rules.push(".wm-lightbox-inner-wrapper { position: absolute; z-index: 10002; cursor: default; min-width: "+this.scrollWidth+"px; min-height: "+this.scrollHeight+"px; }");rules.push(".wm-lightbox-content { float: left; } ");rules.push(".wm-lightbox-close { z-index: 10003; cursor: pointer; width: 24px; height: 24px; float: left; background:url('"+closeUrl+"') no-repeat transparent; margin-left: -12px; margin-top: -10px; position: relative; }");Util.pushCss(rules,"wm-lightbox",{scrollWidth:this.scrollWidth,scrollHeight:this.scrollHeight,closeUrl:closeUrl});}});var Poster=WMClass.extend({init:function(){Event.createLinkedMethodsFor(this,['_showImage','_onClick']);},render:function(settings){if(this._hasChanged(settings)){this._settings=settings;this._create();this.enable();}
if(settings.callback){this._settings.callback=settings.callback;}},resize:function(settings){if(!this._settings){return;}
this._settings.width=settings.width;this._settings.height=settings.height;var playWidth=(this._settings.width/2)-(117/2);var playHeight=(this._settings.height/2)-(98/2);this.play.style.top=playHeight+"px";this.play.style.left=playWidth+"px";this.wrapper.style.width=this._settings.width+"px";this.wrapper.style.height=this._settings.height+"px";this.image.src=Poster._thumbUrl({height:this._settings.height,videoID:this._settings.videoID});this._applyLetterbox();},disable:function(){this._disabled=true;this._disableEffects();this.play.style.display='none';this.innerWrapper.style.cursor='default';},enable:function(){this._disabled=false;this.play.style.display='';this.innerWrapper.style.cursor='pointer';this._enableEffects();},_onClick:function(){if(!this._disabled){this.disable();this._settings.callback();}},_create:function(){this._applyCss();this._createImage();this._createPlayIcon();this._createInnerWrapper();this._createWrapper();this.resize(this._settings);this._settings.element.appendChild(this.wrapper);},_hasChanged:function(settings){return this._settings===undefined||this._settings.videoID!==settings.videoID||this._settings.width!==settings.width||this._settings.height!==settings.height;},_applyCss:function(settings){var playUrl="http://"+Env.playerHostname()+"/p2/i/play.png";var allRules=[];allRules.push(".wm-poster-wrapper { background: black; }");allRules.push(".wm-poster-inner-wrapper { position: relative; width: 100%; height: 100%; text-align: center;}");allRules.push(".wm-poster-inner-wrapper img { visibility:hidden; } ");allRules.push(".wm-poster-inner-wrapper:hover { cursor: pointer; }");allRules.push(".wm-poster-play { background:url('"+playUrl+"') no-repeat transparent; } ");allRules.push(".wm-poster-play { width:117px; height:98px; position:absolute; }");if(Poster.isIE()){allRules.push(".wm-poster-play { opacity:"+Poster.MAX_FADE_OUT+"; background-position: 0px -97px; }");allRules.push(".wm-poster-inner-wrapper:hover .wm-poster-play { background-position: 0px 0px; }");}
Util.pushCss(allRules,"wm-poster");},_enableEffects:function(){if(!Poster.isIE()){var fade=new Effect.Fade({element:this.play,duration:300,maxFadeOut:Poster.MAX_FADE_OUT});this.innerWrapper.onmouseover=function(event){fade.fadeIn(1);}
this.innerWrapper.onmouseout=function(event){var toElement=event.toElement||event.relatedTarget||null;if(toElement&&Poster.CLASSES.indexOf(toElement.getAttribute("class"))==-1){fade.fadeOut();}}
fade.fadeOut();}},_disableEffects:function(){this.innerWrapper.onmouseover=function(event){};this.innerWrapper.onmouseout=function(event){};},_createImage:function(){var img=this.image=new Image();this.image.className="wm-poster-image";this.image.onload=this._linkedShowImage;},_createPlayIcon:function(){this.play=document.createElement("div");this.play.className="wm-poster-play";if(!Poster.isIE()){this.play.style.opacity=""+Poster.MAX_FADE_OUT;this.play.style.filter="alpha(opacity="+(Poster.MAX_FADE_OUT*100)+")";}},_createInnerWrapper:function(){this.innerWrapper=document.createElement("div");this.innerWrapper.className="wm-poster-inner-wrapper";this.innerWrapper.appendChild(this.play);this.innerWrapper.appendChild(this.image);this.innerWrapper.onclick=this._linkedOnClick;},_createWrapper:function(){Util.clearElement(this._settings.element);this.wrapper=document.createElement("div");this.wrapper.className="wm-poster-wrapper";this.wrapper.appendChild(this.innerWrapper);},_applyLetterbox:function(){var ratioPlayer=this._settings.width/this._settings.height;var ratioImg=this.imageWidth/this.imageHeight;if(isNaN(this.imageWidth)||isNaN(this.imageHeight)||isNaN(ratioPlayer)||isNaN(ratioImg)){return;}
var width,height;if(ratioPlayer>ratioImg){width=Math.round(this._settings.height*ratioImg);}else if(ratioPlayer<ratioImg){height=Math.round(this._settings.width/ratioImg);}
height=height||this._settings.height;var style=this.image.style;style.width=(width||this._settings.width)+"px";style.height=(height)+"px";this._centerImage(height);},_centerImage:function(height){this.image.style.marginTop=((this._settings.height-height)/2)+"px";},_showImage:function(){this._measureImage();this._applyLetterbox();this.image.style.visibility='visible';},_getImageSize:function(){this.imageWidth=parseInt(Util.getStyle(this.image,"width").replace(/\D+/,''),10);this.imageHeight=parseInt(Util.getStyle(this.image,"height").replace(/\D+/,''),10);},_measureImage:function(){this._getImageSize();if(isNaN(this.imageWidth)||isNaN(this.imageHeight)){var body=Util.body();var newElement=document.createElement('div');newElement.style.width='1px';newElement.style.height='1px';body.appendChild(newElement);newElement.appendChild(this.image);this._getImageSize();body.removeChild(newElement);this.innerWrapper.appendChild(this.image);}}});Poster.MAX_FADE_OUT=0.6;Poster.AVAILABLE_HEIGHTS=[216,240,360];Poster.CLASSES=["wm-poster-image","wm-poster-play","wm-poster-inner-wrapper","wm-poster-wrapper"];Poster._thumbUrl=function(settings){var height=Poster._fixHeight(settings.height);var hostname=Env.thumbHostname(settings);return"http://"+hostname+"/x"+height+"/"+settings.videoID+".jpg";}
Poster._fixHeight=function(height){height=parseInt(height,10);for(var i=0;i<Poster.AVAILABLE_HEIGHTS.length;i++){if(Poster.AVAILABLE_HEIGHTS[i]>=height){return Poster.AVAILABLE_HEIGHTS[i];}}
return Poster.AVAILABLE_HEIGHTS[Poster.AVAILABLE_HEIGHTS.length-1];}
Poster.isIE=function(){return window.ActiveXObject;}
Data.all=function(element,removePrefix){var prefix=removePrefix||"player";var dataSet=Data._getDataSet(element);var result={};Util.each(dataSet,function(value,key){var formattedKey=Util.uncapitalize(key.replace(prefix,""));result[formattedKey]=value;});return result;};Data._getDataSet=function(element){var dataSet={};var attributes=element.attributes;Util.eachObject(element.attributes,function(value){var name=value.name;if(typeof name==="string"&&name.match(/^data-/)){var newKey=Util.joinWithCamelCase(name.toLowerCase().replace("data-","").split("-"));dataSet[newKey]=QueryString._parseValue(element.getAttribute(name));}});return dataSet;};Auth._lightbox=null;Auth.hasGlbId=function(){var glbid=Util.getCookie('GLBID');return(typeof glbid==='string')&&glbid.length>10;};Auth.getHash=function(settings){var callbackName='getHash_'+Util.getCurrentTime();var hashPath="/videos/"+settings.videosIDs+"/hash?resource_id="+settings.resourceId+"&callback="+callbackName;var hashUrl="http://"+Env.securityHostname()+hashPath;var callbackWrapper=Auth._getHashCallbackWrapper(settings.success,settings.error);Ajax.jsonp({url:hashUrl,callbackName:callbackName,success:callbackWrapper,error:callbackWrapper});};Auth._getHashCallbackWrapper=function(success,error){return function(hash){if(Auth._isValidHash(hash)){if(success){success(hash);}}else{if(error){error(Util.isObject(hash)?hash:{});}}}};Auth.isAuthenticationRequired=function(playlist){return Playlist.hasSubscriberOnly(playlist);};Auth._isValidHash=function(hash){return(hash!==undefined)&&(hash!=null)&&(hash.hash!==undefined)&&(hash.hash!=null)&&(hash.hash!=='');};Auth.checkAuthorized=function(settings){if(Env.isGloboDomain()&&!Auth.hasGlbId()){settings.callback(false);}else{var callbackSuccessWrapper=function(hash){if(settings.callback){settings.callback(true,hash);}}
var callbackErrorWrapper=function(hash){if(settings.callback){settings.callback(false,hash);}}
Auth.getHash({videosIDs:settings.videosIDs,resourceId:settings.resourceId,success:callbackSuccessWrapper,error:callbackErrorWrapper});}};Auth._loginIframeUrl=function(serviceId,lightbox,size){size=size||"widget";var siteUrl=encodeURIComponent(Util.getCurrentUrl());var returnUrl=(lightbox)?encodeURIComponent('http://'+Env.playerHostname()+'/p2/close_box_login.html?url='+siteUrl):siteUrl;var protocol=Env.isTest()?'http':'https';var loginIframeUrl=protocol+"://"+Env.cadunHostname()+"/login/"+serviceId+"?tam="+size+"&url="+returnUrl;return loginIframeUrl;};Auth.redirectToAuthenticationScreen=function(settings){location.href=Auth._loginIframeUrl(settings.serviceId,false);};Auth.showAuthenticationScreen=function(settings){var callbackWrapper=function(){Auth._authenticationScreenCallback(settings.callback);}
Message.receive(callbackWrapper,'http://'+Env.playerHostname());var loginWrapper=document.getElementById('wmPlayerBoxLogin');if(loginWrapper){Util.clearElement(loginWrapper);}else{loginWrapper=Util.createElement('div','wmPlayerBoxLogin','#FFFFFF',1,'350px','520px','relative','0px','0px',1);Util.body().appendChild(loginWrapper);}
var iframe=Util.createElement('iframe','','#FFFFFF',1,'100%','100%','relative','0px','0px',1);iframe.setAttribute('src',Auth._loginIframeUrl(settings.serviceId,true));iframe.style.display='block';iframe.style.border='none';loginWrapper.appendChild(iframe);if(!Auth._lightbox){Auth._lightbox=new Effect.Lightbox({element:loginWrapper,modal:true,onClose:settings.onClose});}
Auth._openLightbox();};Auth._openLightbox=function(){if(Auth._lightbox){Auth._lightbox.open();}};Auth.closeAuthenticationScreen=function(){if(Auth._lightbox){Auth._lightbox.close();}};Auth._authenticationScreenCallback=function(callback){Message.receive();Auth.closeAuthenticationScreen();if(callback){callback();}};Auth.closeBoxLoginScreen=function(){var queryStringParams=Util.getUrlParameters();Message.post('{"operation":"close"}',window.unescape(queryStringParams.url));}
Signer._random=function(){var rand=(Math.round(Math.random()*10000000000)).toString();while(rand.length<10){rand="0"+rand;}
return rand;};Signer.getCurrentTime=function(){return Util.getCurrentTime().toString().substr(0,10);};Signer.sign=function(receivedHash){var version=receivedHash.substr(0,2);var receivedTime=receivedHash.substr(2,10);var receivedRandom=receivedHash.substr(12,10);var receivedGrf=receivedHash.substr(22,22);var currentTime=Signer.getCurrentTime();var randomNumber=Signer._random();var grf=Signer.Encryptor.b64_grf(receivedGrf+currentTime+randomNumber);return version+receivedTime+receivedRandom+currentTime+randomNumber+grf;};Signer.Encryptor={hexcase:0,b64pad:"",PADDINGgrf:"=0xAC10FD",b64_grf:function(s){return this.rstr2b64(this.rstr_grf(this.str2rstr_utf8(s)));},rstr_grf:function(s){return this.binl2rstr(this.binl_grf(this.rstr2binl(s),s.length*8));},rstr2b64:function(input){var output="";var len=input.length;for(var i=0;i<len;i+=3){var triplet=(input.charCodeAt(i)<<16)|(i+1<len?input.charCodeAt(i+1)<<8:0)|(i+2<len?input.charCodeAt(i+2):0);for(var j=0;j<4;j++){if(i*8+j*6>input.length*8)output+=this.b64pad;else output+=Signer.Encryptor.B64_TAB.charAt((triplet>>>6*(3-j))&0x3F);}}
return output;},str2rstr_utf8:function(input){var output="";var i=-1;var x,y;var padding=this.PADDINGgrf;input=input+padding.substr(1,8);while(++i<input.length){x=input.charCodeAt(i);y=i+1<input.length?input.charCodeAt(i+1):0;if(0xD800<=x&&x<=0xDBFF&&0xDC00<=y&&y<=0xDFFF){x=0x10000+((x&0x03FF)<<10)+(y&0x03FF);i++;}
if(x<=0x7F){output+=String.fromCharCode(x);}else if(x<=0x7FF){output+=String.fromCharCode(0xC0|((x>>>6)&0x1F),0x80|(x&0x3F));}else if(x<=0xFFFF){output+=String.fromCharCode(0xE0|((x>>>12)&0x0F),0x80|((x>>>6)&0x3F),0x80|(x&0x3F));}else if(x<=0x1FFFFF){output+=String.fromCharCode(0xF0|((x>>>18)&0x07),0x80|((x>>>12)&0x3F),0x80|((x>>>6)&0x3F),0x80|(x&0x3F));}}
return output;},rstr2binl:function(input){var output=new Array(input.length>>2);for(var i=0;i<output.length;i++){output[i]=0;}
for(i=0;i<input.length*8;i+=8){output[i>>5]|=(input.charCodeAt(i/8)&0xFF)<<(i%32);}
return output;},binl2rstr:function(input){var output="";for(var i=0;i<input.length*32;i+=8){output+=String.fromCharCode((input[i>>5]>>>(i%32))&0xFF);}
return output;},binl_grf:function(x,len){x[len>>5]|=0x80<<((len)%32);x[(((len+64)>>>9)<<4)+14]=len;var a=1732584193;var b=-271733879;var c=-1732584194;var d=271733878;for(var i=0;i<x.length;i+=16){var olda=a;var oldb=b;var oldc=c;var oldd=d;a=this.grf_ff(a,b,c,d,x[i+0],7,-680876936);d=this.grf_ff(d,a,b,c,x[i+1],12,-389564586);c=this.grf_ff(c,d,a,b,x[i+2],17,606105819);b=this.grf_ff(b,c,d,a,x[i+3],22,-1044525330);a=this.grf_ff(a,b,c,d,x[i+4],7,-176418897);d=this.grf_ff(d,a,b,c,x[i+5],12,1200080426);c=this.grf_ff(c,d,a,b,x[i+6],17,-1473231341);b=this.grf_ff(b,c,d,a,x[i+7],22,-45705983);a=this.grf_ff(a,b,c,d,x[i+8],7,1770035416);d=this.grf_ff(d,a,b,c,x[i+9],12,-1958414417);c=this.grf_ff(c,d,a,b,x[i+10],17,-42063);b=this.grf_ff(b,c,d,a,x[i+11],22,-1990404162);a=this.grf_ff(a,b,c,d,x[i+12],7,1804603682);d=this.grf_ff(d,a,b,c,x[i+13],12,-40341101);c=this.grf_ff(c,d,a,b,x[i+14],17,-1502002290);b=this.grf_ff(b,c,d,a,x[i+15],22,1236535329);a=this.grf_gg(a,b,c,d,x[i+1],5,-165796510);d=this.grf_gg(d,a,b,c,x[i+6],9,-1069501632);c=this.grf_gg(c,d,a,b,x[i+11],14,643717713);b=this.grf_gg(b,c,d,a,x[i+0],20,-373897302);a=this.grf_gg(a,b,c,d,x[i+5],5,-701558691);d=this.grf_gg(d,a,b,c,x[i+10],9,38016083);c=this.grf_gg(c,d,a,b,x[i+15],14,-660478335);b=this.grf_gg(b,c,d,a,x[i+4],20,-405537848);a=this.grf_gg(a,b,c,d,x[i+9],5,568446438);d=this.grf_gg(d,a,b,c,x[i+14],9,-1019803690);c=this.grf_gg(c,d,a,b,x[i+3],14,-187363961);b=this.grf_gg(b,c,d,a,x[i+8],20,1163531501);a=this.grf_gg(a,b,c,d,x[i+13],5,-1444681467);d=this.grf_gg(d,a,b,c,x[i+2],9,-51403784);c=this.grf_gg(c,d,a,b,x[i+7],14,1735328473);b=this.grf_gg(b,c,d,a,x[i+12],20,-1926607734);a=this.grf_hh(a,b,c,d,x[i+5],4,-378558);d=this.grf_hh(d,a,b,c,x[i+8],11,-2022574463);c=this.grf_hh(c,d,a,b,x[i+11],16,1839030562);b=this.grf_hh(b,c,d,a,x[i+14],23,-35309556);a=this.grf_hh(a,b,c,d,x[i+1],4,-1530992060);d=this.grf_hh(d,a,b,c,x[i+4],11,1272893353);c=this.grf_hh(c,d,a,b,x[i+7],16,-155497632);b=this.grf_hh(b,c,d,a,x[i+10],23,-1094730640);a=this.grf_hh(a,b,c,d,x[i+13],4,681279174);d=this.grf_hh(d,a,b,c,x[i+0],11,-358537222);c=this.grf_hh(c,d,a,b,x[i+3],16,-722521979);b=this.grf_hh(b,c,d,a,x[i+6],23,76029189);a=this.grf_hh(a,b,c,d,x[i+9],4,-640364487);d=this.grf_hh(d,a,b,c,x[i+12],11,-421815835);c=this.grf_hh(c,d,a,b,x[i+15],16,530742520);b=this.grf_hh(b,c,d,a,x[i+2],23,-995338651);a=this.grf_ii(a,b,c,d,x[i+0],6,-198630844);d=this.grf_ii(d,a,b,c,x[i+7],10,1126891415);c=this.grf_ii(c,d,a,b,x[i+14],15,-1416354905);b=this.grf_ii(b,c,d,a,x[i+5],21,-57434055);a=this.grf_ii(a,b,c,d,x[i+12],6,1700485571);d=this.grf_ii(d,a,b,c,x[i+3],10,-1894986606);c=this.grf_ii(c,d,a,b,x[i+10],15,-1051523);b=this.grf_ii(b,c,d,a,x[i+1],21,-2054922799);a=this.grf_ii(a,b,c,d,x[i+8],6,1873313359);d=this.grf_ii(d,a,b,c,x[i+15],10,-30611744);c=this.grf_ii(c,d,a,b,x[i+6],15,-1560198380);b=this.grf_ii(b,c,d,a,x[i+13],21,1309151649);a=this.grf_ii(a,b,c,d,x[i+4],6,-145523070);d=this.grf_ii(d,a,b,c,x[i+11],10,-1120210379);c=this.grf_ii(c,d,a,b,x[i+2],15,718787259);b=this.grf_ii(b,c,d,a,x[i+9],21,-343485551);a=this.safe_add(a,olda);b=this.safe_add(b,oldb);c=this.safe_add(c,oldc);d=this.safe_add(d,oldd);}
return[a,b,c,d];},grf_cmn:function(q,a,b,x,s,t){return this.safe_add(this.bit_rol(this.safe_add(this.safe_add(a,q),this.safe_add(x,t)),s),b);},grf_ff:function(a,b,c,d,x,s,t){return this.grf_cmn((b&c)|((~b)&d),a,b,x,s,t);},grf_gg:function(a,b,c,d,x,s,t){return this.grf_cmn((b&d)|(c&(~d)),a,b,x,s,t);},grf_hh:function(a,b,c,d,x,s,t){return this.grf_cmn(b^c^d,a,b,x,s,t);},grf_ii:function(a,b,c,d,x,s,t){return this.grf_cmn(c^(b|(~d)),a,b,x,s,t);},safe_add:function(x,y){var lsw=(x&0xFFFF)+(y&0xFFFF);var msw=(x>>16)+(y>>16)+(lsw>>16);return(msw<<16)|(lsw&0xFFFF);},bit_rol:function(num,cnt){return(num<<cnt)|(num>>>(32-cnt));}};Signer.Encryptor.B64_TAB="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";Builder.toObjectTag=function(player){player.channel=player.playlist.videos[0].channel;var lines=[];lines.push('<object id="'+player.objectId+'" width="100%" height="100%" ');lines.push('data="'+Builder.swfUrl(player)+'" type="application/x-shockwave-flash">');lines.push('<param value="true" name="allowFullScreen">');lines.push('<param value="always" name="allowScriptAccess" />');lines.push('<param value="high" name="quality" />');lines.push('<param value="opaque" name="wmode" />');lines.push('<param value="#000000" name="bgcolor" />');lines.push('<param value="'+Builder.swfUrl(player)+'" name="movie" />');lines.push('<param value="videosIDs='+player.videosIDs+Builder._toFlashVars(player)+'" name="flashvars" />');lines.push('</object>');return lines.join('');};Builder.toVideoTag=function(params){return Util.replace(Builder.videoTagTemplate,params);};Builder.videoTagTemplate='<video width="100%" height="100%" src="{src}" controls="controls"'+' style="background-color: black;" poster="{poster}"></video>';Builder._toFlashVars=function(player){var flashvars='';Util.each(player,function(value,key){if((key.toLowerCase()!=='videosids')&&!Util.isPrivate(key)&&Util.isPrimitive(player[key])){flashvars+='&'+key+'='+player[key];}});return flashvars;};Builder.swfUrl=function(player){if(player.swf){return player.swf;}
return"http://"+Env.playerHostname()+"/p2/player.swf";};Builder.convertSizeToBanda=function(width,height){var size=width+'x'+height;var banda=null;switch(size){case"288x216":banda="I";break;case"320x240":banda="N";break;case"480x360":banda="L";break;case"640x360":banda="X";break;}
return banda;};var PlayerFactory={create:function(settings){if(Util.canUseFlashPlayer()){return new PlayerFlash(settings);}else{if(Util.isIPad()){return new PlayerHtml5.IPad(settings);}else if(Util.isIPhone()){return new PlayerHtml5.IPhone(settings);}else{return new PlayerHtml5.Android(settings);}}}}
var PlayerManager=[];var Player=function(options){if(Util.isObject(options)){var self=this;Util.each(options,function(value,key){if(Util.isPrivate(key)||Player.PROTECTED_ATTRIBUTES.indexOf(key)!=-1){throw new Player.Exception(key+" should not be overrided");}
self[key]=value;});}
this.errorMessages=this.errorMessages||[];this._definedProperties();this._defaultValues();Util.mergeObjects(this,Util.getUrlParameters(QueryString.PLAYER_PARAMS_PREFIX));Env.environment=this.environment;};Player.prototype={attachTo:function(element){this._element=element;this._element.style.background='black';this._setElementSize();this._createAndStart();},playVideo:function(){if(this._hasPlayerImpl())this._playerImpl.playVideo();},seek:function(settings){if(this._hasPlayerImpl())this._playerImpl.seek(settings);},pauseVideo:function(){if(this._hasPlayerImpl())this._playerImpl.pauseVideo();},stopVideo:function(){if(this._hasPlayerImpl())this._playerImpl.stopVideo();},mute:function(){if(this._hasPlayerImpl())this._playerImpl.mute();},unmute:function(){if(this._hasPlayerImpl())this._playerImpl.unmute();},volume:function(settings){if(this._hasPlayerImpl())this._playerImpl.volume(settings);},lightOn:function(){if(this._hasPlayerImpl())this._playerImpl.lightOn();},lightOff:function(){if(this._hasPlayerImpl())this._playerImpl.lightOff();},load:function(settings){this.videosIDs=settings.videosIDs;this.autoPlay=((settings.autoPlay===undefined)||(settings.autoPlay));if((this.autoPlay)&&(this._hasPlayerImpl())){this._playerImpl.load(settings);}else{this._createAndStart();}},loadSecondary:function(settings){if(this._hasPlayerImpl())this._playerImpl.loadSecondary(settings);},hideSecondary:function(){if(this._hasPlayerImpl())this._playerImpl.hideSecondary();},dynamicStream:function(settings){if(this._hasPlayerImpl())this._playerImpl.dynamicStream(settings);},isStopped:function(){if(this._hasPlayerImpl())return this._playerImpl.isStopped();},isPlaying:function(){if(this._hasPlayerImpl())return this._playerImpl.isPlaying();},isPaused:function(){if(this._hasPlayerImpl())return this._playerImpl.isPaused();},resize:function(settings){this.width=settings.width||this.width;this.height=settings.height||this.height;this._setElementSize();if(this._hasPlayerImpl()){this._playerImpl.resize({width:this.width,height:this.height});}},authenticationRequired:function(){if(this._hasPlayerImpl()){this._playerImpl.loadPlaylist();}else{this._createAndStart();}},getErrorMessageFor:function(code){if(this._hasPlayerImpl()){return this._playerImpl.getErrorMessageFor(code);}},getUserId:function(){return Util.getCookie("__utma");},_setElementSize:function(){this._element.style.width=this.width+'px';this._element.style.height=this.height+'px';},_hasPlayerImpl:function(){return(this._playerImpl!==undefined);},_createAndStart:function(){this._create();this._start();},_create:function(){this._playerImpl=PlayerFactory.create({playerId:this.id,width:this.width,height:this.height,autoPlay:this.autoPlay,element:this._element,player:this});},_start:function(){if(this.autoPlay){this._playerImpl.loadPlaylist();}else{this._playerImpl.showPoster();}},_definedProperties:function(){this.id=PlayerManager.push(this)-1;this.objectId="wmPlayer-"+this.id;this.playerNamespace="WM.PlayerManager["+this.id+"]";},_defaultValues:function(){this.autoPlay=this.autoPlay||this.autoplay||false;this.videosIDs=String(this.videosIDs||this.videosids||'');this.width=this.width||320;this.height=this.height||240;this.stretchWidth=this.stretchWidth||this.stretchwidth||this.width;this.stretchHeight=this.stretchHeight||this.stretchheight||this.height;this.environment=this.environment||Env.defaultEnvironment;this.simulateAutoPlay=this.simulateAutoPlay||!this.autoPlay;this.onLightOn=this.onLightOn||this.playerNamespace+'._onLightOn';this.onLightOff=this.onLightOff||this.playerNamespace+'._onLightOff';this.onStretch=this.onStretch||this.playerNamespace+'._onStretch';this.onShrink=this.onShrink||this.playerNamespace+'._onShrink';this.playRelated=(this.onPlayRelatedClick&&Util.isFunction(this.onPlayRelatedClick)?this.onPlayRelatedClick:window[this.onPlayRelatedClick]);this.playRelated=this.playRelated||this._onPlayRelatedClick;},_interfaceReady:function(){if(this._hasPlayerImpl())this._playerImpl.setCallbacks();},_onShrink:function(){this.resize({width:this._beforeStretchWidth||this.width,height:this._beforeStretchHeight||this.height});},_onStretch:function(){this._beforeStretchWidth=this.width;this._beforeStretchHeight=this.height;this.resize({width:this.stretchWidth,height:this.stretchHeight});},_onLightOn:function(){Effect.onLightOn(document.getElementById(this.objectId));},_onLightOff:function(){Effect.onLightOff(document.getElementById(this.objectId),this.zIndex);},_onPlayRelatedClick:function(){return false;}};Player.Exception=function(message){this.message=message;};Player.PROTECTED_ATTRIBUTES=["id","attachTo","objectId","playerNamespace","playVideo","seek","pauseVideo","stopVideo","mute","unmute","volume","lightOn","lightOff","load","loadSecondary","hideSecondary","authenticationRequired","dynamicStream","resize","getErrorMessageFor","isStopped","isPlaying","isPaused","playRelated","getUserId"];var PlayerFlash=WMClass.extend({_videoIndex:0,_totalChildren:1,_hasRenderedPlayer:false,init:function(settings){this.settings=settings;this._setup();},showPoster:function(){this._renderPoster();this._getPoster().enable();},loadPlaylist:function(){Playlist.load({playerId:this.settings.playerId,videoID:this._mainVideoID(),success:this._linkedPlaylistLoaded,error:this._linkedPlaylistLoadError});},posterClicked:function(){if(Util.isFunction(this.player.onPlay)){this.player.onPlay();}
this.loadPlaylist();},playVideo:function(){if(this._hasRenderedPlayer){this._getObject().playVideo();}else{this.posterClicked();}},seek:function(settings){if(this._hasRenderedPlayer)this._getObject().seek(settings);},pauseVideo:function(){if(this._hasRenderedPlayer)this._getObject().pauseVideo();},stopVideo:function(){if(this._hasRenderedPlayer)this._getObject().stopVideo();},mute:function(){if(this._hasRenderedPlayer)this._getObject().mute();},unmute:function(){if(this._hasRenderedPlayer)this._getObject().unmute();},volume:function(settings){if(this._hasRenderedPlayer)this._getObject().volume(settings);},lightOn:function(){if(this._hasRenderedPlayer)this._getObject().lightOn();},lightOff:function(){if(this._hasRenderedPlayer)this._getObject().lightOff();},load:function(settings){if(this._hasRenderedPlayer){this._getObject().load(settings);}else{this.loadPlaylist();}},loadSecondary:function(settings){if(this._hasRenderedPlayer)this._getObject().loadSecondary(settings);},hideSecondary:function(){if(this._hasRenderedPlayer)this._getObject().hideSecondary();},dynamicStream:function(settings){if(this._hasRenderedPlayer)this._getObject().dynamicStream(settings);},isStopped:function(){if(this._hasRenderedPlayer){return this._getObject().isVideoStopped();}
return true;},isPlaying:function(){if(this._hasRenderedPlayer){return this._getObject().isVideoPlaying();}
return false;},isPaused:function(){if(this._hasRenderedPlayer){return this._getObject().isVideoPaused();}
return false;},resize:function(settings){if(this._getPoster()){this._getPoster().resize(settings);}
this.error.resize(settings);},setCallbacks:function(){if(this._hasRenderedPlayer){var object=this._getObject();if(object){this._setCallbacks(object,object.addListener,PlayerFlash.CALLBACKS);this._setCallbacks(object,object.addInputListener,PlayerFlash.INPUTCALLBACKS);}else{Util.log("Object tag not found");}}},getErrorMessageFor:function(code){return this.error.messageFor(code);},_setup:function(){this.player=this.settings.player;this.error=new ErrorPage({element:this.settings.element,errorMessages:this.player.errorMessages,width:this.settings.width,height:this.settings.height});Event.createLinkedMethodsFor(this,this._methodsToLink());},_getObject:function(){return document.getElementById(this.player.objectId);},_mainVideoID:function(){return this.player.videosIDs.split('|')[0];},_setCallbacks:function(object,listener,callbacks){var self=this;Util.each(callbacks,function(callbackName){var callback=self.player[callbackName.toLowerCase()]||self.player[callbackName];if(callback){if(Util.isFunction(callback)){self.player[callbackName]=callback;callback=self.player.playerNamespace+'.'+callbackName;}
try{listener.call(object,callbackName,callback);}catch(e){Util.log(e);}}});},_playlistLoaded:function(playlist){this._setPlaylist(playlist);this._getResource();this._getTotalChildren();if(this._isAuthenticationRequired()){this._checkAuthorized();}else{this._authorized();}},_setPlaylist:function(playlist){this.playlist=this.player.playlist=playlist;},_isAuthenticationRequired:function(){return Auth.isAuthenticationRequired(this.playlist)},_playlistLoadError:function(errorData){this._renderError(errorData);},_getResource:function(){this.resource=Playlist.getResource(this.playlist,this._videoIndex,this._childrenIndex);},_checkAuthorized:function(){Auth.checkAuthorized({videosIDs:this._mainVideoID(),resourceId:this._getResourcesIds(),callback:this._linkedAuthorizationChecked});},_authorizationChecked:function(authorized,errorObject){if(authorized){this._authorized();}else if(this._isNotAuthorized(errorObject)){this._handleAuthentication();}else{this._renderError(errorObject);}},_isNotAuthorized:function(errorObject){return errorObject===undefined||this.error.isNotAuthorized(errorObject);},_authorized:function(){this._render();},_handleAuthentication:function(){this._renderPoster();this._getPoster().disable();this._showAuthenticationScreen();},_showAuthenticationScreen:function(){Auth.showAuthenticationScreen({serviceId:Playlist.getServiceId(this.playlist),element:this.settings.element,callback:this._linkedAuthorized,onClose:this.linkedShowPoster});},_renderError:function(errorObject){var code;if(this.error.isNotFound(errorObject)){code=ErrorPage.NOT_FOUND.code;}else if(this.error.isGeoBlocked(errorObject)){code=ErrorPage.GEO_BLOCKED.code;}
this.error.render(code);},_renderFlashErrorPage:function(){this.error.render(ErrorPage.DEVICE_NOT_SUPPORTED.code);},_getPoster:function(){if(this._poster===undefined){this._poster=new Poster();}
return this._poster;},_renderPoster:function(){this._getPoster().render({element:this.settings.element,videoID:this._mainVideoID(),width:this.settings.width,height:this.settings.height,callback:this.linkedPosterClicked});this._hasRenderedPlayer=false;},_render:function(){Util.clearElement(this.settings.element);if(Util.hasFlashInstalled()){this._hasRenderedPlayer=true;this.settings.element.innerHTML=Builder.toObjectTag(this.player);}else{this._renderFlashErrorPage();}},_getResourcesIds:function(){var resourcesIds=[];for(var index=0;index<this._totalChildren;index++){resourcesIds.push(Playlist.getResource(this.playlist,this._videoIndex,index).id);}
return resourcesIds.join('|');},_getTotalChildren:function(){this._totalChildren=Playlist.totalChildren(this.playlist,this._videoIndex);},_methodsToLink:function(){return['showPoster','posterClicked','_playlistLoaded','_playlistLoadError','_authorizationChecked','_authorized'];}});PlayerFlash.CALLBACKS=["onLightOn","onLightOff","complete"];PlayerFlash.INPUTCALLBACKS=["onPlay","onPause","onStop","onSeek","onVolumeChange","onMute","onUnmute","onEnterFullScreen","onExitFullScreen","onShrink","onStretch","onDynamicStream"];PlayerHtml5.BLACK_VIDEO="http://flashvideo.globo.com/entretenimento/1/propaganda/black.mp4";PlayerHtml5.IPad=PlayerFlash.extend({_childrenIndex:0,_eventsRegistered:false,_hasTrackedPlay:false,_signedHashes:[],playVideo:function(){if(this._isRendered()){this._video.play();}else{this.posterClicked();}},seek:function(settings){if(this._isRendered()){var duration=this._video.duration;if(!isNaN(duration)){var percentage=parseFloat(settings.seekPercentage);this._video.currentTime=duration*percentage;}}},pauseVideo:function(){if(this._isRendered())this._video.pause();},stopVideo:function(){if(this._isRendered()){this._video.pause();this._video.currentTime=0;var callbackFunction=this._callbackFunction("onStop");if(callbackFunction){callbackFunction();}}},mute:function(){if(this._isRendered())this._video.muted=true;},unmute:function(){if(this._isRendered())this._video.muted=false;},volume:function(settings){if(this._isRendered())this._video.volume=parseFloat(settings.value);},load:function(settings){Util.clearElement(this.settings.element);this._video=undefined;this.loadPlaylist();},isStopped:function(){if(this._isRendered()){return this._video.ended||(this._video.paused&&this._video.currentTime===0);}},isPlaying:function(){if(this._isRendered()){return!this._video.paused&&!this._video.ended;}},isPaused:function(){if(this._isRendered()){return this._video.paused&&this._video.currentTime!==0;}},setCallbacks:function(){this._setCallbacks("onPlay","play");this._setCallbacks("onPause","pause");this._setCallbacks("onStop","ended");this._setCallbacks("complete","ended");this._setCallbacks("onSeek","seeked");},_callbackFunction:function(callbackName){var callback=this.player[callbackName.toLowerCase()]||this.player[callbackName];var callbackFunction=null;if(callback){if(Util.isFunction(callback)){this.player[callbackName]=callback;callbackFunction=Event.linker(this.player[callbackName],this.player);}else{callbackFunction=new Function('return '+callback)();}}
return callbackFunction;},_setCallbacks:function(callbackName,eventName){var callbackFunction=this._callbackFunction(callbackName);if(callbackFunction){Event.bind(this._video,eventName,callbackFunction);}},showPoster:function(){this._render();this._setupFirstPlay();},_setup:function(){this._super();this._metrics=Metrics.getDefaultInstance();},_playlistLoaded:function(playlist){this._getResource();this._super(playlist);},_playlistLoadError:function(errorData){this._renderError(errorData);},_authorized:function(){this._loadHash();},_handleAuthentication:function(){if(this.settings.autoPlay){this.showPoster();this._hideVideo();}
this._showAuthenticationScreen();},_loadHash:function(){Auth.getHash({videosIDs:this._mainVideoID(),resourceId:this._getResourcesIds(),success:this._linkedHashLoaded,error:this._linkedHashError});},_hashLoaded:function(hashData){this._signHashes(hashData);this._play();},_signHashes:function(hashData){var hashes=hashData.hash instanceof Array?hashData.hash:[hashData.hash];this._signedHashes=Util.map(hashes,function(hash){return Signer.sign(hash);});},_play:function(){var videoUrl=this.resource.url+'?'+this._signedHashes[this._childrenIndex];if(this._isRendered()){this._showVideo();this._loadAndPlay(videoUrl);}else{this._render(videoUrl);}},_hashError:function(errorData){this._renderError(errorData);},_isRendered:function(){return this._video!==undefined;},_loadAndPlay:function(src){this._video.src=src;if(!this._eventsRegistered){this._setupEventListeners();}
this._video.load();this._video.play();},_showVideo:function(){this._video.style.display='block';},_hideVideo:function(){this._video.style.display='none';},_render:function(src){Util.clearElement(this.settings.element);this.settings.element.innerHTML=Builder.toVideoTag({width:this.settings.width,height:this.settings.height,src:src||PlayerHtml5.BLACK_VIDEO,poster:this._getPosterUrl()});this._video=this.settings.element.getElementsByTagName('video')[0];if(src){this._setupEventListeners();}},_getPosterUrl:function(){return Poster._thumbUrl({videoID:this._mainVideoID(),height:this.settings.height});},_setupFirstPlay:function(){Event.bind(this._video,'play',this._linkedOnFirstPlay);},_onFirstPlay:function(){Event.unbind(this._video,'play',this._linkedOnFirstPlay);this._hideVideo();this.loadPlaylist();},_setupEventListeners:function(){Event.bind(this._video,'play',this._linkedOnPlay);Event.bind(this._video,'ended',this._linkedOnEnded);this.setCallbacks();this._eventsRegistered=true;},_onPlay:function(){if(this._isFirstChild()&&!this._hasTrackedPlay){this._metrics.play(Playlist.parametersForMetrics(this.playlist,this._videoIndex));this._hasTrackedPlay=true;}},_onEnded:function(){if(this._isLastChild()){this._metrics.end(Playlist.parametersForMetrics(this.playlist,this._videoIndex));}
this._next();},_isFirstChild:function(){return this._childrenIndex===0;},_isLastChild:function(){return this._childrenIndex==(this._totalChildren-1);},_next:function(){if(!this._isLastChild()){this._childrenIndex++;this._getResource();this._play();}},_getResource:function(){this.resource=Playlist.getResource(this.playlist,this._videoIndex,this._childrenIndex);},_methodsToLink:function(){return this._super().concat(["_loadHash","_hashLoaded","_hashError","_onFirstPlay","_onPlay","_onEnded","_volumeChanged"]);}});PlayerHtml5.IPhone=PlayerHtml5.IPad.extend({showPoster:function(){this.loadPlaylist();},posterClicked:function(){this._redirectToAuthenticationPage();},_handleAuthentication:function(){if(this.settings.autoPlay){this._redirectToAuthenticationPage();}else{this._renderPoster();}},_redirectToAuthenticationPage:function(){Auth.redirectToAuthenticationScreen({serviceId:Playlist.getServiceId(this.playlist)});}});PlayerHtml5.Android=PlayerHtml5.IPhone.extend({_getVideoFromPlaylist:function(){return this.playlist.videos[this._videoIndex];},posterClicked:function(){if(this._src){Util.navigateTo(this._src);}else{this._super();}},_render:function(src){if(Playlist.isGalleryOrFullEpisode(this._getVideoFromPlaylist())){if(Util.hasFlashInstalled()){this._fallbackToFlashPlayer();}else{this._renderFlashErrorPage();}}else{if(Util.canPlayType(src||PlayerHtml5.BLACK_VIDEO)){this._super(src);}else{this._src=(src||PlayerHtml5.BLACK_VIDEO);this._renderPoster();}}},_fallbackToFlashPlayer:function(){Util.clearElement(this.settings.element);this.settings.element.innerHTML=Builder.toObjectTag(this.player);}});window.WM={Player:Player,PlayerManager:PlayerManager,closeBoxLoginScreen:Auth.closeBoxLoginScreen,getUrlParameters:Util.getUrlParameters,getDataAttributes:Data.all,convertSizeToBanda:Builder.convertSizeToBanda};if((window.jQuery!==undefined)&&(window.jQuery!=null)){(function($){$.fn.playerInstance=function(){var playerInstances=[];this.each(function(){if(this.wmPlayer){playerInstances.push(this.wmPlayer);}});return playerInstances;};$.fn.playerApiCaller=function(method,params){return this.each(function(){if(this.wmPlayer){this.wmPlayer[method](params);}});};$.fn.player=function(options){var settings={};$.each(options||{},function(key,value){settings[key.toLowerCase()]=value;});return this.each(function(){var _options={videosIDs:'',autoPlay:false,width:320,height:240};Util.mergeObjects(_options,Data.all(this,"player"));Util.mergeObjects(_options,settings);if((_options.autoPlay===false)||(_options.autoPlay==='false')){delete _options.autoPlay;}
var resultSettings=$.extend({},_options);var banda=Builder.convertSizeToBanda(resultSettings.width,resultSettings.height);if((resultSettings.videosIDs==='')||(!banda)){$(this).html('Não foi possível exibir o player');var message='Parâmetro videosIDs inválido: '+resultSettings.videosIDs;if(!banda){message='Parâmetro width ou height inválidos. Tamanhos válidos: 288x216, 320x240, 480x360, 640x360';}
Util.log(message);}else{var player=new Player(resultSettings);this.wmPlayer=player;player.attachTo(this);}});};})(window.jQuery);}})(window);if((window.jQuery!==undefined)&&(window.jQuery!=null)){(function($){$(document).ready(function(){$('.player').player();});})(window.jQuery);}
