var loginInfo;$(document).ready(function(){});$(window).resize(function(){centerElement($("#login"));});function getSwf(){return document.getElementById("HBO_GO");}function onAppReady(){setGostCookie();}function createServiceUrl(a){var b=window.location.hostname.match(/^\w+/);var c=window.location.hostname.match(/\w+\.\w+$/);if(!(/(devhbogo|betahbogo|stghbogo|qa|preprd|www|hbogo)/).test(b)){b="devhbogo";}else{if(/^(hbogo|www)$/.test(b)){b=null;}}return"http://"+(b==null?"":b+".")+"profile."+c+"/apps/profile/rest/profileService/"+a+"?jsoncallback=?";}function getLoginInfo(b){var a=createServiceUrl("affiliateLoginInfo");$.getJSON(cacheBust(a),b);}function getLogoutInfo(b){var a=createServiceUrl("affiliateLogoutInfo");$.getJSON(cacheBust(a),b);}function openLogin(b){setGostCookie();var a=getRegData();if(a!=null){openSubAccountRegistration(a.account,a.master,a.affiliate);}else{if(Cookie.get("aff")!=null){handleLoginOrOut(onLogin,b);}else{openLoginSelector();}}}function onLogin(e){var c=cacheBust(loginInfo.affiliateURL);var d=loginInfo.windowWidth;var a=loginInfo.windowHeight;var b=$("#login");b.attr("width",d);b.attr("height",a);b.attr("top",a);var f=$("#login>iframe");f.attr("src",c);f.attr("width",d);f.attr("height",a);var g=getAffName();$("#switch").html(g+' not your television provider? <a href="#">Click here</a>.');$("#switch>a").click(function(){if(e!="signupPage"){closeLogin();openLoginSelector();}else{closeLogin("cancel");}});centerElement($("#login"));$("#login").show();}function logout(){handleLoginOrOut(onLogout,null);}function onLogout(){var a=cacheBust(loginInfo.logoutURL);var b=$("#login>iframe");b.attr("src",a);}function handleLoginOrOut(b,a){if(loginInfo==null||a=="signupPage"){getLoginInfo(function(c){loginInfo=c;b(a);});}else{b(a);}}function cacheBust(b){var a=new Date();var c="nocache="+a.getTime();return((b.indexOf("?")<0)?(b+"?"+c):(b+"&"+c));}function openRegistration(b,c){var a=getSwf();closeLogin();a.registrationSuccess(b,c);}function openSubAccountRegistration(c,a,d){var b=getSwf();closeLogin();b.openSubAccountRegistration(c,a,d);}function openLoginSelector(){var a=getSwf();if(a!=null){loginInfo=null;a.openLoginSelector();}}function centerElement(b){var a=($("body").width()/2)-(b.width()/2);var c=($("body").height()/2)-(b.height()/2);b.css("right",a+"px");b.css("top",c+"px");}function closeLogin(b){$("#login").hide();if(b=="cancel"){var a=getSwf();a.loginCanceled();}}function loginSuccess(){var a=getSwf();a.loginSuccess();}function loginFailure(b){var a=getSwf();a.loginFailure(b);}function setAffCookie(b){var a=new Date();a.setDate(a.getDate()+14);Cookie.set("aff",b,a);}function setGostCookie(){if(!Cookie.has("gost")){var a=getSwf();var b=a.getGost();if(typeof(b)!=="undefined"&&b!=null&&b.length>0){Cookie.set("gost",b);}}}function setGostCookieDirect(a){if(!Cookie.has("gost")){if(typeof(a)!=="undefined"&&a!=null&&a.length>0){Cookie.set("gost",a);}}}function isLoggedIn(){return(Cookie.has("auth"));}function isInternal(){return(Cookie.has("int"));}function getAffName(){var a=null;if((a=Cookie.get("aff"))!=null){if(!(/HBO/.test(a))){a=a.charAt(0)+a.substring(1).toLowerCase();}}return a;}function getRegData(){var a=null;if(Cookie.has("registration")){a={};a.affiliate=Cookie.sub("registration","affiliate");a.account=Cookie.sub("registration","account");a.master=Cookie.sub("registration","master");}return a;}var Cookie={has:function(a){var b=new RegExp(a+"s*=s*(.*?)(;|$)");return b.test(document.cookie);},get:function(b){var c=new RegExp(b+"s*=s*(.*?)(;|$)");var a=document.cookie.match(c);return(a?unescape(a[1]):null);},sub:function(b,c){var a=null;var d=Cookie.get(b);if(d!=null){var e=new RegExp(c+"*:s*(.*?)(\\||$)");a=d.match(e);if(a!=null&&$.isArray(a)&&a.length>1){a=unescape(a[1]);a=$.trim(a);if(a.length<=0){a=null;}}else{a=null;}}return a;},set:function(b,e,a){var d=window.location.hostname.match(/\w+\.\w+$/);var c=b+"="+escape(e)+";path=/;domain="+d;if(typeof(a)!=="undefined"&&a!=null){c+=";expires="+a.toGMTString();}document.cookie=c;},remove:function(b){var a=new Date();a.setTime(a.getTime()-1);var c=window.location.hostname.match(/\w+\.\w+$/);document.cookie=b+"=;path=/;domain="+c+";expires="+a.toGMTString();}};var Browser={supported:function(){var b=false;var a;if(/(Firefox|Minefield)[\/\s](\d+\.\d+)/.test(navigator.userAgent)){a=parseFloat(RegExp.$2);b=(a>=2);}else{if(/Win/.test(navigator.appVersion)&&/MSIE\s(\d+\.\d+);/.test(navigator.userAgent)){a=parseFloat(RegExp.$1);b=(a>=6&&!/Opera/.test(navigator.userAgent));}else{if(/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent)){a=parseFloat(RegExp.$1);b=(a>=3);}else{if(/Safari[\/\s](\d+\.\d+)/.test(navigator.userAgent)){a=parseFloat(RegExp.$1);b=(a>=3&&!/(iPhone|iPod|iPad|Android|webOS)/.test(navigator.userAgent));}}}}return b;},check:function(){if(!Browser.supported()){$("#content").hide();$("#unsupported").show();$("body").css("background-color","#000");}}};var popup;function openPopupVideo(a,b){try{if(popout){popout.close();}}catch(c){}var d="width="+a+",height="+b+",location=no,resizable=yes";popout=window.open("videopopout.html","popout",d);return(popout)?true:false;}function printURL(a){window.open(a,"printWin","width=500,height=500,location=no,scrollbars=yes");}var htmlToPrint;function printHTML(b){htmlToPrint=b;var a=window.open("print.html","printWin","width=500,height=500,location=no,scrollbars=yes");a.opener=this;}function forceRedrawAfterFullscreen(){window.resizeBy(0,0);}function getURL(){return window.location.href;}function FlashScaler(i,b,g){var d=document.getElementById(i);var a=b;var f=g;e("onload",c);e("onresize",c);function e(k,j){var h=window[k];if(typeof window[k]!="function"){window[k]=j;}else{window[k]=function(){if(h){h();}j();};}}function c(){if(self.innerHeight){winW=self.innerWidth;winH=self.innerHeight;}else{if(document.documentElement&&document.documentElement.clientHeight){winW=document.documentElement.clientWidth;winH=document.documentElement.clientHeight;}else{if(document.body){winW=document.body.clientWidth;winH=document.body.clientHeight;}}}if(winH<f){d.style.height=f+"px";}else{d.style.height="100%";}if(winW<a){d.style.width=a+"px";}else{d.style.width="100%";}}}function getWindowHeight(){var a=0;if(typeof(window.innerHeight)=="number"){a=window.innerHeight;}else{if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){a=document.documentElement.clientHeight;}else{if(document.body&&(document.body.clientWidth||document.body.clientHeight)){a=document.body.clientHeight;}}}return a;}