(function(C,B){var A=A||{};
A.Models={};
A.Views={};
A._models={};
A._views={};
A.Router=new C.Router();
A.resultsCollection=new C.Collection();
A.addModel=function(E,D,F){if(E in A._models){if(console&&console.warn){console.warn("model "+E+" already exists.. aborting.");
}return null;
}else{if(!(D instanceof C.Model||D instanceof C.Collection)&&F&&F in A.Models){A._models[E]=new A.Models[F](D);
}else{A._models[E]=D instanceof C.Model||D instanceof C.Collection?D:D instanceof Array?new C.Collection(D):new C.Model(D);
}}return A._models[E];
};
window.Baxster=A;
B.fn.baxster=function(F){var H=this[0],E=this.attr("bax:view").split(" "),I=this.attr("bax:template")&&this.attr("bax:template").split(" "),D=this.attr("bax:model"),G=[];
if(I&&I.length){_.each(I,function(J){var K=B("#"+J);
if(K&&K.length){G.push(K.template());
}},this);
if(1===G.length){G=G[0];
}}else{G=false;
}if(H){_.each(E,function(K){var M={el:H},J;
if(K in A.Views){if(D&&D in A._models){M.model=A._models[D];
if(A._models[D] instanceof C.Collection){M.collection=A._models[D];
}}if(G){M.template=G;
}M.router=A.Router;
var L=_.extend(M,F);
J=new A.Views[K](L);
J.options=L;
J.$el.data("view",J);
if(H.id){A._views[H.id]=A._views[H.id]||[];
A._views[H.id].push(J);
}}},this);
}return this;
};
})(Backbone,jQuery);




Baxster.Views.Search=Backbone.View.extend({events:{"focus [bax\\:sub=query]":"onFocus","blur [bax\\:sub=query]":"onBlur","keyup [bax\\:sub=query]":"onKeyup","keydown [bax\\:sub=query]":"onKeydown","mousedown .result":"onClickResult","mouseenter .result":"selectResult","click [bax\\:sub=viewall]":"submitForm"},initialize:function(A){this._template=A.template;
this._resultsContainer=$(this.el).find("[bax\\:sub=results]");
this._searchButton=$(this.el).find("[bax\\:sub=searchbutton]");
this.model=new Backbone.Model({});
this.model.bind("change:query",$.proxy(this.onQueryChange,this));
this.model.bind("change:results",$.proxy(this.onSearchResults,this));
},onFocus:function(A){$(this.el).addClass("active");
},onBlur:function(A){$(this.el).removeClass("active");
},onClickResult:function(A){this.goToURL($(A.target).closest(".result").data("href"));
},onKeyup:function(A){this.model.set({"query":$.trim($(A.target).val())});
},onKeydown:function(D){var B=$(this.el).find(".searchResults .result");
if(!_.isEmpty(B)&&(38===D.keyCode||40===D.keyCode||13===D.keyCode||27===D.keyCode)){D.preventDefault();
if(38===D.keyCode){if(!this._selectedResult){B.last().mouseenter();
}else{var C=this._selectedResult.prevAll(".result");
if(!_.isEmpty(C)){$(C[0]).mouseenter();
}}}else{if(40===D.keyCode){if(!this._selectedResult){B.first().mouseenter();
}else{var A=this._selectedResult.nextAll(".result");
if(!_.isEmpty(A)){$(A[0]).mouseenter();
}}}else{if(13===D.keyCode){if(this._selectedResult&&!this._selectedResult.hasClass("viewall-btn")){this.goToURL(this._selectedResult.data("href"));
}else{this.submitForm(D);
}}else{if(27===D.keyCode){$(D.target).val("");
}}}}}},onQueryChange:function(A,C){if(this._lastXhr){this._lastXhr.abort();
}this._selectedResult=null;
if(C.length>=3){var B=this;
this._lastXhr=$.getJSON("/api/search/",{q:C,t:"any",count:5},function(F,D,E){F=_.extend(F,{"Date":new Date()});
B.model.set({results:F});
});
}else{this._resultsContainer.empty();
}},onSearchResults:function(B,C){var A=$.tmpl(this._template,C);
this._resultsContainer.html(A);
},selectResult:function(B){var A=this;
var C=$(B.target).closest(".result");
$(this.el).find(".result").each(function(E,F){var D=$(F);
if(C[0]!==D[0]){D.removeClass("selected");
}else{A._selectedResult=D.addClass("selected");
}});
},submitForm:function(A){this.el.submit();
},goToURL:function(A){window.location=A;
}});




Baxster.Views.Hoverable=Backbone.View.extend({events:{"click .hoverable":"onClick"},onClick:function(E){var D=$(E.target);
var A=D.attr("href");
if(!A){var C=D.closest(".hoverable");
var B=C.find("a[href]");
var F=B.attr("target");
if(B&&B.length){B.click();
}}else{var F=D.attr("target");
if(F!="_blank"){window.top.location=A;
}}}});




Baxster.Views.ProfileMenu=Backbone.View.extend({events:{"click [bax\\:sub=logout]":"logout"},initialize:function(A){_.bindAll(this);
this._markup=this.el.innerHTML;
this._loggedIn=$(this.el).data("loggedIn");
this._cancelledFbUser=$(this.el).data("cancelled");
this._fbLoggedIn=false;
FB.Event.subscribe("auth.statusChange",this.onFacebookStatusChange);
},onFacebookStatusChange:function(){var A=FB.getAuthResponse();
if(A&&A.userID){this._fbLoggedIn=true;
if(!this._loggedIn&&!this._cancelledFbUser){var B=$.tmpl(this.options.template,A);
$(this.el).empty().append(B);
this._loggedIn=true;
$.get(window.location.protocol+"//graph.facebook.com/v2.2/"+A.userID,this.onFacebookDetails,"jsonp");
}}},onFacebookDetails:function(A){if(A.first_name){this.$("[bax\\:sub=name]").html(A.first_name);
}},logout:function(A){var B=function(){window.location.href="/logout/?redirect=";
};
return this._fbLoggedIn?FB.logout(B):B();
}});




Baxster.Views.HoverTip=Backbone.View.extend({events:{"mouseenter .tip":"onMouseEnter","mouseleave .tip":"onMouseLeave"},initialize:function(A){var B=document.createElement("span");
B.id="hoverTip";
$(this.el).append(B);
this._tip=this.$("#hoverTip").addClass("ras pas hidden");
},onMouseEnter:function(A){var G=$(A.target).closest(".tip");
var I=G.attr("alt")||G.attr("title")||G.data("tip");
var E=G.data("tipPosition")||"auto";
if(I){var H=G.offset();
var F=$(document).width();
var C=(H.left+(G.outerWidth()/2))>(F/2);
this._tip.html(I).removeClass("hidden");
var B=H.top-this._tip.outerHeight()-4;
var D;
switch(E){case"left":D=H.left;
break;
case"right":D=H.left-(this._tip.outerWidth()-G.outerWidth());
break;
case"center":D=H.left-this._tip.outerWidth()/2;
break;
default:D=H.left-(C?(this._tip.outerWidth()-G.outerWidth()):0);
break;
}this._tip.css("left",D).css("top",B);
if("center"===E){this._tip.addClass("tipCenter");
}else{this._tip.addClass(C?"tipRight":"tipLeft");
}}},onMouseLeave:function(A){this._tip.addClass("hidden").removeClass("tipLeft tipRight tipCenter").empty();
}});




Baxster.Views.GAEvents=Backbone.View.extend({events:{"mousedown [data-ga-event]":"trackEvent"},trackEvent:function(D){var A=$(D.currentTarget).data("gaEvent").split("/");
var C=["_trackEvent"],B;
while(A.length){B=A.shift();
if(!!B){C.push(B);
}}if(C.length>=3){_gaq.push(C);
}}});




Baxster.Views.NavBar=Backbone.View.extend({events:{"click [bax\\:sub~=nav]":"onNavClick"},initialize:function(A){this._originalId=document.body.id;
},onNavClick:function(B){if(this._originalId){this.$("."+this._originalId).addClass("hover");
}var A=$(B.target).closest("[bax\\:sub~=nav]").removeClass("hover").attr("class");
document.body.id=A;
}});




Baxster.Views.Ads=Backbone.View.extend({initialize:function(A){_.bindAll(this);
},onInterval:function(B){var A=false;
this.$("[bax\\:sub~=ad]:not(.page_ad)").each(function(D,E){var C=$(E).height();
if(C>1){$(E).addClass("page_ad");
}A=true;
});
if(!A){clearInterval(this._interval);
}}});




Baxster.Views.MoviePopover=Backbone.View.extend({events:{"removePopover":"removePopover","posterEnterTrigger":"onMouseEnterTrigger","posterLeaveTrigger":"onMouseLeave","mouseenter [bax\\:sub=popoverBox]":"onMouseEnterPopover","mouseleave [bax\\:sub=popoverBox]":"onMouseLeave","mousemove #starsbutton":"onStarsMove","mouseleave #starsbutton":"onStarsLeave","click #starsbutton":"onRateClick","click #wtsbutton":"onRateClick","click #nibutton":"onRateClick","bax:close":"onClose","click [bax\\:sub=showtimes]":"onClickShowtimes","click #summarymorelink":"onSynopsisMoreClick","click [bax\\:sub=switch-hd]":"setHd","click [bax\\:sub=switch-sd]":"setSd"},initialize:function(A){this._template=A.template;
this._timer=null;
this._popover=null;
this._delay=300;
this._grace=300;
this._videoLauncherView=null;
this._starClasses="score00 score05 score10 score15 score20 score25 score30 score35 score40 score45 score50";
this._xhrSynopsis=null;
this._hdSdState="sd";
},onSynopsisMoreClick:function(B){var A=this;
this._xhrSynopsis.done(function(){A.$("[bax\\:sub=synopsisShort]").hide();
A.$("[bax\\:sub=synopsisLong]").show();
});
},onClickShowtimes:function(C){C.preventDefault();
var A=$("#showtimesModalContainer");
var B=$("#showtimesModal");
B.attr("src",$(C.currentTarget).attr("href"));
B[0].onload=(function(){var F=$(window).height()-200;
if(F<500){F=500;
}A.height(this.contentWindow.document.body.offsetHeight);
if(this.contentWindow.document.body.offsetHeight>F){A.height(F);
}var D=($(window).width()/2)-(A.width()/2);
var E=($(window).height()/2)-(A.height()/2);
A.css({"position":"fixed","left":D+"px","top":E+"px"});
A.css("opacity","1");
});
A.trigger("bax:modalLong",{el:A,closeButton:true,closeOnClick:true});
},onMouseEnterTrigger:function(B,C){var A=this;
clearTimeout(this._timer);
this._timer=setTimeout(function(){A.renderPopover(C);
},this._delay);
},onMouseLeave:function(B,C){var A=this;
clearTimeout(this._timer);
if(this._popover){A._timer=setTimeout(function(){A.removePopover();
},this._grace);
}},onMouseEnterPopover:function(A){clearTimeout(this._timer);
},onStarsMove:function(B){var A=this.$("#starsbutton");
var C=this.computeStarsScore(B,A);
A.removeClass(this._starClasses).addClass("score"+C.replace(".",""));
},onStarsLeave:function(B){var A=this.$("#starsbutton");
var C="current";
var E=this.movieId;
var D=this.rating;
var F="";
if(D){D=D.attributes;
F=D.score;
}A.removeClass(this._starClasses);
var G="score";
if(F){G+=F.replace(".","");
}if(this._starClasses.search(G)>0){A.addClass(G);
}else{A.addClass("score00");
}},onRateClick:function(B){var F="";
var L="";
var G=$(B.target).data("scoretype");
var J="current";
var K=this.popoverId;
var H=this.rating;
var E=this.$("#starsbutton");
var I=this.$("#wtsbutton");
var D=this.$("#nibutton");
var A=false;
var C="";
if(H){L=H.attributes.score;
if(G==L||(G==="*"&&this.computeStarsScore(B,E)==L)){A=true;
I.removeClass("on");
D.removeClass("on");
E.removeClass(this._starClasses);
E.addClass("score00");
C="-undo";
}}if(G==="+"){F="+";
_gaq.push(["_trackEvent","Movie Rating Widget","Homepage","WTS"+C]);
}else{if(G==="-"){F="-";
_gaq.push(["_trackEvent","Movie Rating Widget","Homepage","NI"+C]);
}else{if(G==="*"){F=this.computeStarsScore(B,E);
_gaq.push(["_trackEvent","Movie Rating Widget","Homepage","Stars"+F+C]);
}}}if(A){F="";
}this.updateCountsModel(L,F);
H.set({"score":F,"source":"HOM"});
},onClose:function(B){var A=this;
clearTimeout(this._timer);
if(this._popover){this._timer=setTimeout(function(){A.removePopover();
},this._grace);
}},contentLoaded:function(A){if(this._popover){this.renderPopover(this._trigger);
}},computeStarsScore:function(E,A){var C=E.currentTarget.clientWidth;
var B=E.pageX-A.offset().left;
var D=100*(B/C);
var F="0.0";
if(90<D){F="5.0";
}else{if(80<D){F="4.5";
}else{if(70<D){F="4.0";
}else{if(60<D){F="3.5";
}else{if(50<D){F="3.0";
}else{if(40<D){F="2.5";
}else{if(30<D){F="2.0";
}else{if(20<D){F="1.5";
}else{if(10<D){F="1.0";
}else{if(5<D){F="0.5";
}}}}}}}}}}return F;
},removePopover:function(){if(this._videoLauncherView){var A=Baxster._views[this._videoLauncherView];
if((A instanceof Array)&&(A.length>0)&&A[0].isShowingVideo()){return ;
}else{delete Baxster._views[this._videoLauncherView];
this._videoLauncherView=null;
}}if(this._popover){this._popover.fadeOut();
this._popover.remove();
this._popover=null;
}if(this._arrow){this._arrow.fadeOut();
this._arrow.remove();
this._arrow=null;
}},renderPopover:function(R){R=$(R);
this._trigger=R;
var D=R.data("model");
var Q=R.find("img");
var a=D.get("id");
var C="current";
var Z=D.get("contentType")||"movie";
var P=D.get("userRating");
this.movieModel=D;
this.popoverId=a;
this.rating=P;
var E=true;
var N=null,L=null;
var X=D.toJSON();
if(P){N=P.attributes;
}if(D.attributes.lockerRight){L=D.attributes.lockerRight;
}else{if(D.attributes.lockerRights){L=D.attributes.lockerRights[0];
}else{L={};
}}var O=R.data("displaytype")||"contentNotOwned";
var H,V,J,U;
H="trailer";
V=false;
if((O==="contentOwned")||(L&&(L.streamable==="true"))){J=false;
U="watchButtonTable";
}else{if("inTheaters"===O){J=false;
U="showtimesButton";
}else{J=true;
U="affliateTable";
}}var b=R.data("rightid")||null;
if(!X.rightId&&b){X.rightId=b;
}var W=D.toJSON();
var F={"m":W,"rating":P?P.toJSON():"","lockerRight":L,"contentLoaded":E,"contentType":Z,"displayType":O,"headerDisplay":H,"contentRating":V,"contentPurchase":J,"contentControl":U,"isAvailableFromSomeRetailerInSd":W.affiliate.flixBuyUrl||W.affiliate.flixRentUrl||W.affiliate.iTunesBuyUrl||W.affiliate.iTunesRentUrl||W.affiliate.vuduBuyUrl||W.affiliate.vuduRentUrl||W.affiliate.amazonBuyUrl||W.affiliate.amazonRentUrl||W.affiliate.targetBuyUrl||W.affiliate.targetRentUrl,"isAvailableFromSomeRetailerInHd":W.affiliate.flixBuyHdUrl||W.affiliate.flixRentHdUrl||W.affiliate.iTunesBuyHdUrl||W.affiliate.iTunesRentHdUrl||W.affiliate.vuduBuyHdUrl||W.affiliate.vuduRentHdUrl||W.affiliate.amazonBuyHdUrl||W.affiliate.amazonRentHdUrl||W.affiliate.targetBuyHdUrl||W.affiliate.targetRentHdUrl,};
F.isAvailableFromSomeRetailer=F.isAvailableFromSomeRetailerInSd||F.isAvailableFromSomeRetailerInHd;
if(W.affiliate.iTunesBuyUrl){W.affiliate.iTunesBuyUrl+=(W.affiliate.iTunesBuyUrl.indexOf("?")==-1?"?":"&")+"at=10l9IP&ct=Flixster.com";
}if(W.affiliate.iTunesRentUrl){W.affiliate.iTunesRentUrl+=(W.affiliate.iTunesRentUrl.indexOf("?")==-1?"?":"&")+"at=10l9IP&ct=Flixster.com";
}var Y=$.tmpl(this._template,F);
if(E&&this._popover&&this._popover.hasClass("loading")){var M=$.tmpl(this._template,F);
M.css("display","none");
$(this.el).append(M);
var T=M.height();
M.remove();
this._popover.css("height",T);
var S=this;
setTimeout(function(){S._popover=S.$(".popover#bubble");
S._popover.removeClass("loading");
S._popover.children().remove();
S._popover.append(Y.children());
S._title=S.$("#popoverTitle");
S._arrow=S.$(".popover#arrow");
S.renderRatingData();
S.insertPopoverAnalyticTracking(X,E,O);
},100);
}else{this.removePopover();
$(this.el).append($.tmpl(this._template,F));
this.insertPopoverAnalyticTracking(X,E,O);
}var S=this;
this._xhrSynopsis=$.getJSON("http://api.flixster.com/iphone/api/v1/movies/"+a+".json",function(c,e,d){S.$("[bax\\:sub=synopsisLong]").text(c.synopsis);
});
if(J){if(this._hdSdState==="hd"&&F.isAvailableFromSomeRetailerInHd){this.renderHdSd("hd");
}else{if(this._hdSdState==="sd"&&F.isAvailableFromSomeRetailerInSd){this.renderHdSd("sd");
}else{this.renderHdSd("sd");
}}}this._popover=this.$(".popover#bubble");
this._title=this.$("#popoverTitle");
this._arrow=this.$(".popover#arrow");
if(P){P.bind("change:score",this.renderRatingData,this);
}this.renderRatingData();
if(H==="trailer"){if(!this._videoLauncherView&&this._popover){if(this._popover.attr("bax:view")){this._popover.baxster();
this._videoLauncherView=this._popover.attr("id");
}}}var I=Q.offset();
var G=$(document).width();
var A=(G-I.left)<(Q.outerWidth()+this._popover.outerWidth()+18);
var K=(I.top-$(this.el).offset().top)+(Q.outerHeight()*0.2);
var B=(I.left-$(this.el).offset().left)+(A?(-this._popover.outerWidth()):Q.outerWidth());
this._popover.css("left",B).css("top",K).addClass(A?"popLeft":"popRight");
this._popover.fadeIn({duration:200});
},renderHdSd:function(C){var D=this.$("[data-hdsd-type=hd]");
var B=this.$("[data-hdsd-type=sd]");
var A=this.$("[bax\\:sub=switch-hd]");
var E=this.$("[bax\\:sub=switch-sd]");
if(C==="hd"){B.hide();
D.show();
E.removeClass("selected");
A.addClass("selected");
}else{D.hide();
B.show();
A.removeClass("selected");
E.addClass("selected");
}},renderRatingData:function(){var D="current";
var F=this.popoverId;
var E=this.rating;
if(E){E=E.attributes;
}var A=this.$("#starsbutton");
var B=this.$("#wtsbutton");
var C=this.$("#nibutton");
if(E){var G=E.score;
B.removeClass("on");
C.removeClass("on");
A.removeClass(this._starClasses);
A.addClass("score00");
if(G){if(G=="+"){B.addClass("on");
}else{if(G=="-"){C.addClass("on");
}else{A.addClass("score"+G.replace(".",""));
}}}}},updateCountsModel:function(I,F){var B=Baxster._models["usercounts"];
if(B){var D=B.get("wtscount");
var H=B.get("ratingcount");
var C=D,A=H;
var G=I&&I!=="+"&&I!=="-";
var E=F&&F!=="+"&&F!=="-";
if((I===F)||(G&&E)){}else{if(F==="+"){C=D+1;
if(G){A=H-1;
}}else{if(E){A=H+1;
if(I==="+"){C=D-1;
}}else{if(I==="+"){C=D-1;
}if(G){A=H-1;
}}}}if(D!==C){B.set({wtscount:C});
}if(H!==A){B.set({ratingcount:A});
}}},setHd:function(){if(this._hdSdState==="hd"){return ;
}this._hdSdState="hd";
this.renderHdSd(this._hdSdState);
},setSd:function(){if(this._hdSdState==="sd"){return ;
}this._hdSdState="sd";
this.renderHdSd(this._hdSdState);
},insertPopoverAnalyticTracking:function(D,A,B){if(D&&A){$(".actorlinkclass").off("mousedown");
$("#summarymorelink").off("mousedown");
$("#trailerlink").off("mousedown");
$("[bax\\:sub=flixbuylink]").off("mousedown");
$("[bax\\:sub=flixrentlink]").off("mousedown");
$("#watchnowlink").off("mousedown");
$("#downloadlink").off("mousedown");
$("#showtimeslink").off("mousedown");
$(".netflixpopoverunit a").off("mousedown");
$(".amazonprimepopoverunit a").off("mousedown");
$(".hbogopopoverunit a").off("mousedown");
$(".itunespopoverunit a").off("mousedown");
$(".vudupopoverunit a").off("mousedown");
$(".amazonpopoverunit a").off("mousedown");
var C=(B==="contentOwned")?"CollectionHover":"WatchNowHover";
$(".actorlinkclass").on("mousedown",function(E){_gaq.push(["_trackEvent",C,"ActorClick",$(E.target).text()+"|"+D.title]);
});
$("#summarymorelink").on("mousedown",function(E){_gaq.push(["_trackEvent",C,"MoreClick",D.title]);
});
$("#trailerlink").on("mousedown",function(E){_gaq.push(["_trackEvent",C,"TrailerClick",D.title]);
});
$("[bax\\:sub=flixbuylink]").on("mousedown",function(E){_gaq.push(["_trackEvent",C,"BuyClick",D.title]);
});
$("[bax\\:sub=flixrentlink]").on("mousedown",function(E){_gaq.push(["_trackEvent",C,"RentClick",D.title]);
});
$("#watchnowlink").on("mousedown",function(E){_gaq.push(["_trackEvent",C,"WatchClick",D.title]);
});
$("#downloadlink").on("mousedown",function(E){_gaq.push(["_trackEvent",C,"DownloadClick",D.title]);
});
$("#showtimeslink").on("mousedown",function(E){_gaq.push(["_trackEvent","Showtimes","Home",D.title]);
});
$(".netflixpopoverunit a").on("mousedown",function(E){_gaq.push(["_trackEvent","Affiliates",C,"Netflix - Stream"]);
});
$(".amazonprimepopoverunit a").on("mousedown",function(E){_gaq.push(["_trackEvent","Affiliates",C,"AmazonPrime - Stream"]);
});
$(".hbogopopoverunit a").on("mousedown",function(E){_gaq.push(["_trackEvent","Affiliates",C,"HBO Go - Stream"]);
});
$(".itunespopoverunit a").on("mousedown",function(F){var E=$(this).hasClass("itunesbuy");
_gaq.push(["_trackEvent","Affiliates",C,"iTunes - "+(E?"Buy":"Rent")]);
});
$(".vudupopoverunit a").on("mousedown",function(F){var E=$(this).hasClass("vudubuy");
_gaq.push(["_trackEvent","Affiliates",C,"Vudu - "+(E?"Buy":"Rent")]);
});
$(".amazonpopoverunit a").on("mousedown",function(F){var E=$(this).hasClass("amazonbuy");
_gaq.push(["_trackEvent","Affiliates",C,"AmazonInstant - "+(E?"Buy":"Rent")]);
});
}}});




Baxster.Views.GooglePlusLoginForm=Backbone.View.extend({initialize:function(){_.bindAll(this);
if(!FLX.userLoggedIn){FLX.gplusSignedIn.done(this.onGplusSignin);
}},onGplusSignin:function(A){var C,D=this.$el,E;
_.each(D.find("[name]"),function B(F){E=F.name;
if(!!A[E]){$(F).val(A[E]);
}});
D.submit();
}});




function scrollFunc(H,C,E){var G=H+">#medrec_top_ad";
var F=$(this).scrollTop();
var I=$(G).height()+"px";
var A=$(C?C:H).offset().top+(E?$(C).height():0);
var B=$(H).height()-$(G).height()+A;
var D=E?"auto":"0";
if($(H).height()-$(G).height()>50){if(F<A){$(G).css({"position":"absolute","top":D});
}else{if(F>B){$(G).css({"position":"absolute","bottom":"0","top":"auto"});
}else{$(G).css({"position":"fixed","top":"10px","height":I});
}}}}



(function(E){var I=false;
FLX.gplusSdkLoaded=FLX.gplusSdkLoaded||E.Deferred();
FLX.gplusSignedIn=FLX.gplusSignedIn||E.Deferred();
window.googlePlusSigninCallback=function(K){if(!getCookie("session_id")){if(!FLX.gplusBtnPressed){return ;
}FLX.gplusBtnPressed=false;
}I=false;
D(K);
};
window.googleApiLoadedCallback=function(){gapi.client.setApiKey(FLX.gplusApiKey);
FLX.gplusSdkLoaded.resolve();
var K=document.createElement("script");
K.type="text/javascript";
K.async=true;
K.src="https://apis.google.com/js/client:plusone.js?enable_cooper=1&onload=plusoneApiLoadedCallback";
var L=document.getElementsByTagName("script")[0];
L.parentNode.insertBefore(K,L);
};
window.plusoneApiLoadedCallback=function(){E(".gglLogin").each(function(K,L){if(gapi.signin){gapi.signin.render(L.id,E(L).data());
}});
};
window.googleApiLoadFailedCallback=function(){FLX.gplusSdkLoaded.reject();
};
window.googlePlusSignin=function(K){if(!A(FLX.gplusSignedIn.state())){if(K){J(false);
}}else{return true;
}return false;
};
window.googlePlusDisconnectUser=function(L){var K=getCookie("platform_token");
if(K){F(K,L);
}};
window.googlePlusSignOut=function(){gapi.auth.signOut();
};
var F=function(M,L){var K="https://accounts.google.com/o/oauth2/revoke?token="+M;
E.ajax({type:"GET",url:K,async:false,contentType:"application/json",dataType:"jsonp",success:function(N){L(true);
},error:function(N){L(false);
}});
};
var G=function(){J(true);
};
var J=function(K){var L=["https://www.googleapis.com/auth/userinfo.email","https://www.googleapis.com/auth/plus.login"];
if(K){I=true;
}gapi.auth.authorize({"client_id":FLX.gplusClientId,"scope":L,"immediate":K},D);
};
var B=function(K){if(getCookie("platform")==="GGL"){deleteCookie("platform_token","/",FLX.gplusDomain);
deleteCookie("platform_user","/",FLX.gplusDomain);
deleteCookie("platform","/",FLX.gplusDomain);
location.reload();
}};
var D=function(K){var M=((K!==null)&&!K.error);
if(M||!I){if(M){gapi.auth.setToken(K);
}if(null!==K&&!K.error&&(K.code||(K.access_token&&(K.id_token||getCookie("platform_user"))))){var L=A(FLX.gplusSignedIn.state());
FLX.gplusSignedIn.resolve(K);
setCookie("platform_token",K.access_token,Number(K.expires_in)/60/60/24,"/",FLX.gplusDomain);
if(L){E("body").trigger("bax:gglReauth");
}}}if(K){I=false;
if(K.error==="immediate_failed"){B(K);
}}else{if(I){B(K);
}}FLX.gplusSignedIn.notify(A(FLX.gplusSignedIn.state()));
};
var A=function(K){return K==="resolved";
};
var C=document.createElement("script");
C.type="text/javascript";
C.async=true;
C.src="https://apis.google.com/js/client.js?onload=googleApiLoadedCallback&enable_cooper=1";
C.onerror=window.googleApiLoadFailedCallback;
var H=document.getElementsByTagName("script")[0];
H.parentNode.insertBefore(C,H);
})(window.jQuery);




