var Vevo=window.Vevo||{};Vevo.Proxy=function(){var PROXY_HOST="/Proxy/";function call(api,data,callback,params){var url=PROXY_HOST+api;if($.isFunction(data)){params=callback;
callback=data;data=null}params=params?params:{};var type=(params.type)?params.type:"POST";var dataType=(params.dataType)?params.dataType:"json";return $.ajax({url:url,type:type,data:data,cache:params.cache||false,dataType:dataType,success:callback,error:function(XMLHttpRequest,textStatus,errorThrown){if(window.console&&console.error){console.error("Error occurred during XHR to proxy. \n XHR: %o, Status: %o, Error: %o",XMLHttpRequest,textStatus,errorThrown)
}}})}function handleApiResponse(data,textstatus){return((textstatus=="success")&&(typeof data.error_code==="undefined"||data.error_code===0))}function handleError(error){var errorString="Error "+error.error_code+": "+error.error_detail;
return errorString}return{Favorites:function(){var FAVORITES={actions:["User/Favorite/Add.ashx","User/Favorite/Remove.ashx","User/Favorite/IsFavorite.ashx"],types:{video:"Video",artist:"Artist",playlist:"Playlist",channel:"Channel"}};
return{toggleFavorite:function(node){var $node=$(node),$changeThese=$("a.favoritable[rel='"+$node.attr("rel")+"']");var rel=$node.attr("rel").split(":");var ACTION=FAVORITES.actions[Number($node.hasClass("un-favoritable"))];
var data={};data.id=rel[1];data.t=FAVORITES.types[rel[0]];call(ACTION,data,function(result,textstatus){if(handleApiResponse(result,textstatus)){var status=("undefined"!==typeof result.favorite_count);
$(Vevo).trigger("updatedFavorite",{status:status,$node:$changeThese})}else{}})},getFavorites:function(nodes,type){var ACTION=FAVORITES.actions[2];var type=FAVORITES.types[type];
var typeLc=type.toLowerCase();call(ACTION,"t="+type+"&q="+nodes.join(","),function(result,textstatus){if(handleApiResponse(result,textstatus)){$.each(result,function(i,aResult){$(Vevo).trigger("updatedFavorite",{$node:$('.favoritable[rel="'+typeLc+":"+aResult.Id+'"]')})
})}else{}})}}}(),Comments:function(){function getComments(e,data,type,cache){cache=(cache!=null&&cache!=undefined)?false:true;var getData={pageSize:(data.pageSize)?data.pageSize:e.data.pageSize,pageStart:(data.commentIndex)?data.commentIndex:"0",direction:(data.sort)?data.sort:"desc"};
var GET_COMMENTS;switch(type){case"video":GET_COMMENTS="Video/Comment/Get.ashx";getData.isrc=data.isrc;break;case"playlist":GET_COMMENTS="Playlist/Comment/Get.ashx";
getData.playlistID=data.playlistID;break}return call(GET_COMMENTS,getData,function(result,textresult){if(handleApiResponse(result,textresult)){result.type=type;$(Vevo).trigger("commentDataReady",[result])
}else{$(Vevo).trigger("commentDataError",[result])}},{type:"GET",cache:cache})}return{getVideoComments:function(e,data,cache){return getComments(e,data,"video",cache)
},getPlaylistComments:function(e,data,cache){return getComments(e,data,"playlist",cache)}}}(),Watched:function(){var Watched={markWatched:"analytics/userevents/WatchVideo.ashx ",isWatched:"Analytics/UserEvents/isWatched.ashx",query:"isrc"};
return{markWatched:function(node,id){var $node=$(node);var rel=$node.attr("rel").split(":");var contentType=rel[0];var ACTION=Watched[Number($node.hasClass("on"))];
var data={};data[Watched.query]=rel[1];call(ACTION,data,function(result,textstatus){if(handleApiResponse(result,textstatus)){var status=("undefined"!==typeof result.Watched_count);
$(Vevo).trigger("updatedWatched",{status:status,$node:$node})}else{}})},getWatched:function(nodes){var ACTION=Watched.isWatched;var data=[];for(var i=0;i<nodes.length;
i++){data.push(nodes[i])}call(ACTION,Watched.query+"="+data.join(","),function(result,textstatus){if(handleApiResponse(result,textstatus)){for(var i=0;i<result.result.length;
i++){var a=result.result[i];var type="video";if(typeof(a)=="string"&&a.length>0){$('.playOverlay[rel="'+type+":"+a+'"]').parent(".listThumb").fadeTo("slow",0.05)
}}}else{}})}}}()}}();