Date.prototype.addHours=function(a){this.setHours(this.getHours()+a);return this};function VideoCounterController(){this.maxVideos=3;this.resetTime=24;this.canPlay=true;this.joinURL=myJoinUrl;this.joinURL=this.joinURL.replace(/\&amp;/g,"&");var d=(localStorage.initial_date)?localStorage.initial_date:false;if(!d){localStorage.initial_date=new Date()}var b=new Date(localStorage.initial_date);var a=new Date();var c=Math.ceil((a.getTime()-b.getTime())/(1000*60*60));if(c>this.resetTime){if(localStorage.videos_watched){localStorage.removeItem("videos_watched");localStorage.removeItem("initial_date")}}else{if(this.getTotalWatchedVideos()>=this.maxVideos){this.canPlay=false}}}VideoCounterController.prototype={getTotalWatchedVideos:function(){return(localStorage.videos_watched)?localStorage.videos_watched:0},getWaitingTime:function(){if(!localStorage.initial_date){return 0}var a=new Date();var c=new Date(localStorage.initial_date).addHours(this.resetTime);var b=(c.getTime()-a.getTime());return Math.ceil(b/(1000*60*60))},addToWatchedList:function(){var a=(localStorage.videos_watched)?localStorage.videos_watched:0;localStorage.videos_watched=parseInt(a)+1}};function init_video_counter(){if(Utils.isLocalStorageEnabled()==false){return}var f=new VideoCounterController();var a=document.querySelectorAll("a.play_video_trailer");if(a.length==0){return}for(var b=0;b<a.length;b++){a[b].addEventListener("click",function(g){if(f.canPlay){f.addToWatchedList()}else{g.preventDefault();window.location=f.joinURL}},false)}var e=f.maxVideos-f.getTotalWatchedVideos();e=(e>0)?e:0;var d=document.createElement("div");d.className="views_left";if(e==0){d.innerHTML='You have 0 previews left. <br /> <a href="'+f.joinURL+'"><b>Get Unlimited Access Now &raquo;</b></a>';var c=document.querySelector("#video_counter");c.parentNode.insertBefore(d,c.nextSibling)}};
