window.addEvent("domready",function(){if($("body")&&$("body").hasClass("site")){if($E("#footer .footModeToggle select")){$E("#footer .footModeToggle select").addEvent("change",function(){window.location.href=this.get("value")})}if($E("#header.site h2 a")){var a=$E("#header.site h2 a");a.addEvent("click",POHub.MenuSiteToggle.toggle)}}var b=document.getElements(".tt");b.each(function(d){var c=JSON.decode(d.get("tipdata")||'{"title":"","text":""}');d.store("tip:title",c.title);d.store("tip:text",c.text)});POHub.tips=new Tips(b,{className:"tip-container"})});POHub.Pages={clientLoginPane:{initialize:function(){var a=new POHub.AjaxForm("clientLoginForm",{loadingMsg:"Logging you in",successMsg:"You are logged in. Redirecting you...",delayRedirect:true})}},clientLogin:{initialize:function(){var a=new POHub.AjaxForm("clientLoginForm",{loadingMsg:"Logging you in",successMsg:"You are logged in. Redirecting you...",delayRedirect:true})}},clientSignup:{initialize:function(){var a=new POHub.AjaxForm("clientSignupForm",{loadingMsg:"Creating Publisher account",successMsg:"Account created. Redirecting you...",delayRedirect:true});$("addressCountry").addEvent("change",function(){if(this.get("value")=="US"){$("regionField").hide();$("stateField").show()}else{$("regionField").show();$("stateField").hide()}})}},clientAddApp:{initialize:function(){var a=new POHub.AjaxForm("clientAddAppForm",{loadingMsg:"Creating application"});setCharLimit($("description"),255)}},clientEditApp:{initialize:function(){var a=new POHub.AjaxForm("clientEditAppForm",{loadingMsg:"Editing application"})}},_clientModifyTourney:{formEvents:function(b){var a=function(){var d=(this.get("tag")=="input");if(d&&this.get("value")==""){return false}var e=parseInt(this.get((d)?"value":"text")),c;if(isNaN(e)||e<0){this.set((d)?"value":"text",10)}if(e>25){this.set((d)?"value":"text",25)}e=parseInt(this.get((d)?"value":"text"));$("ourCut").set("text",c=(e<10)?10:e);$("jackpotCut").set("text",100-e-c)};if($("clientCut").get("tag")=="input"){$("clientCut").addEvent("keyup",a).addEvent("blur",function(){if(this.get("value")==""){this.set("value",10);this.fireEvent("keyup")}})}else{a.run(null,$("clientCut"))}$("isRecurring").addEvent("click",function(){if(this.checked){$("recurringOptions").show();if(!b){$("startDateLabel").set("html","Start Date of all Recurrences:");$("endDateLabel").set("html","End Date of all Recurrences:")}}else{$("recurringOptions").hide();if(!b){$("startDateLabel").set("html","Start Date:");$("endDateLabel").set("html","End Date:")}}})}},clientAddTourney:{initialize:function(){var a=POHub.Pages._clientModifyTourney;var b=new POHub.AjaxForm("clientAddTourneyForm",{loadingMsg:"Creating tournament"});a.formEvents();$("numIterations").addEvent("keyup",function(){var h=this.get("value");var d=$("recurringInfo");if(h==""){d.hide();return false}if(isNaN(parseInt(h))||parseInt(h)==0||parseInt(h)<0){this.set("value",2);h=2}if(!$("startDate").get("value").isValidDate()||!$("endDate").get("value").isValidDate()){d.show();d.set("html",'<span class="error">One of the dates entered above does not seem to be valid.</span>');return false}var c=Date.parse($("startDate").get("value")+" "+$("startHour").get("value")+":00"+$("startMeridiem").get("value"));var g=Date.parse($("endDate").get("value")+" "+$("endHour").get("value")+":00"+$("endMeridiem").get("value"));var f=c.diff(g,"hour")/parseInt(h,10);if(parseInt(f)!=f){d.show();d.set("html",'<span class="error">The specified number of iterations gives each tournament a duration with fractional hours. Please choose a number that divides the time range evenly in hours.</span>');return false}var i=Math.floor(f/24);var e=Math.floor(f%24);d.show();d.set("html","Given your time range, each iteration will last "+((i>0)?"<strong>"+i+"</strong> "+((i==1)?"day":"days")+((e==0)?"":" <strong>"+e+"</strong> "+((e==1)?"hr":"hrs")):"<strong>"+e+"</strong> "+((e==1)?"hour":"hours"))+".")})}},clientEditTourney:{initialize:function(e){var l=POHub.Pages._clientModifyTourney;var g=new POHub.AjaxForm("clientEditTourneyForm",{loadingMsg:"Editing tournament"});l.formEvents(true);var n,s=e.isNew,q=e.isRecurring,t=$("parentRecurrence"),j=$("isRecurringTd"),k=$("parentStartDateDisplay"),c=$("parentEndDateDisplay"),f=$("parentStartDate"),d=$("parentEndDate"),m="%m/%d/%Y %I%p";function h(){return Date.parse((s)?$("startDate").get("value")+" "+$("startHour").get("value")+":00"+$("startMeridiem").get("value"):$("startDate").get("text"))}function a(){return Date.parse((s)?$("endDate").get("value")+" "+$("endHour").get("value")+":00"+$("endMeridiem").get("value"):$("endDate").get("text"))}function p(){var v=h(),x=a(),w=v.diff(x,"hour");return{duration:w,days:Math.floor(w/24),hours:Math.floor(w%24)}}function o(){return(isNaN(parseInt($("numIterations").get("value"))))?1:parseInt($("numIterations").get("value"))}function u(){var w=p(),x=w.days,v=w.hours;$("recurringInfo").set("html","Each iteration will last "+((x>0)?"<strong>"+x+"</strong> "+((x==1)?"day":"days")+((v==0)?"":" <strong>"+v+"</strong> "+((v==1)?"hr":"hrs")):"<strong>"+v+"</strong> "+((v==1)?"hour":"hours"))+".")}var n=p();$("isRecurring").addEvent("click",function(){if(!q){if(this.checked){t.show("table-row").addClass("even");j.removeClass("even");u()}else{t.hide().removeClass("even");q.addClass("even")}}if(this.checked){k.set("text",h().format(m));c.set("text",h().increment("hour",p().duration*o()).format(m))}else{k.set("text",h().format(m));c.set("text",a().format(m))}});$("numIterations").addEvent("keyup",function(){var v=this.get("value");if(v==""){return false}if(isNaN(parseInt(v))||parseInt(v)==0||parseInt(v)<0){this.set("value",e.totalIterations);v=e.totalIterations}else{v=parseInt(v)}c.set("text",h().increment("hour",p().duration*v).format(m))}).addEvent("blur",function(){if(this.get("value")==""){this.set("value",e.totalIterations);this.fireEvent("keyup")}});if(s){var b=$("startDate").get("value"),r=$("endDate").get("value");var i=function(){var v=false;$$("#startDate, #endDate").each(function(w){if(!w.get("value").isValidDate()){this.setStyles({color:"#f00","border-color":"#f00"});v=true;return false}if(w.get("id")=="startDate"){if((h().get("time")<(new Date()).get("time"))||(h().get("time")>a().get("time"))){this.setStyles({color:"#f00","border-color":"#f00"});v=true;return false}}else{if(w.get("id")=="endDate"){if(h().get("time")>a().get("time")){this.setStyles({color:"#f00","border-color":"#f00"});v=true;return false}}}this.setStyles({color:"#000","border-color":"#ccc"})});if(v){return false}u();k.set("html",h().format(m));c.set("html",h().increment("hour",p().duration*o()).format(m))};$$("#startMediem, #startHour, #endMeridiem, #endHour").addEvent("change",i);$$("#startDate, #endDate").addEvent("keyup",i);$$("#startDate, #endDate").addEvent("blur",function(){if(!this.get("value").isValidDate()){this.set("value",(this.get("id")=="startDate")?b:r);this.setStyle("color","#000");i()}})}}},clientForgot:{initialize:function(){var a=new POHub.AjaxForm("clientForgotForm",{loadingMsg:"Emailing password reset link",successMsg:"An email to reset your password was sent successfully!"})}},clientEditAccount:{initialize:function(){var b=new POHub.AjaxForm("clientEditAccountForm",{loadingMsg:"Saving account information",successMsg:"Your account information has been updated!"});$("addressCountry").addEvent("change",function(){if(this.get("value")=="US"){$("regionField").hide();$("stateField").show()}else{$("regionField").show();$("stateField").hide()}});var a=new POHub.AjaxForm("clientChangePWForm",{loadingMsg:"Changing password",successMsg:"Your account password has been updated!"})}},clientReset:{initialize:function(){var a=new POHub.AjaxForm("clientResetForm",{loadingMsg:"Resetting your password"})}},userLoginPane:{initialize:function(){var a=new POHub.AjaxForm("userLoginForm",{loadingMsg:"Logging you in",successMsg:"You are logged in. Redirecting you...",delayRedirect:true})}},userLogin:{initialize:function(){var a=new POHub.AjaxForm("userLoginForm",{loadingMsg:"Logging you in",successMsg:"You are logged in. Redirecting you...",delayRedirect:true})}},userSignup:{initialize:function(){var a=new POHub.AjaxForm("userSignupForm",{loadingMsg:"Creating Player account",successMsg:"Account created. Redirecting you...",delayRedirect:true})}},userForgot:{initialize:function(){var a=new POHub.AjaxForm("userForgotForm",{loadingMsg:"Emailing password reset link",successMsg:"An email to reset your password was sent successfully!"})}},userReset:{initialize:function(){var a=new POHub.AjaxForm("userResetForm",{loadingMsg:"Resetting your password"})}},userEditAccount:{initialize:function(){var b=new POHub.AjaxForm("userEditAccountForm",{loadingMsg:"Saving account information",successMsg:"Your account information has been updated!"});$("addressCountry").addEvent("change",function(){if(this.get("value")=="US"){$("regionField").hide();$("stateField").show()}else{$("regionField").show();$("stateField").hide()}});var a=new POHub.AjaxForm("userChangePWForm",{loadingMsg:"Changing password",successMsg:"Your account password has been updated!"})}},userReset:{initialize:function(){var a=new POHub.AjaxForm("userResetForm",{loadingMsg:"Resetting your password"})}},userCashout:{initialize:function(a){if($("userCashoutForm")){var b=new POHub.AjaxForm("userCashoutForm",{loadingMsg:"Processing withdrawal request"});$("amount").addEvent("keyup",function(){var d=parseFloat(this.get("value"));if((!isNaN(d)&&(d>a.withdrawableAmount||d<=a.checkingFee))||isNaN(d)){this.setStyles((this.get("value")!="")?{color:"#f00","border-color":"#f00"}:{color:"#000","border-color":"#ccc"});return false}else{this.setStyles({color:"#000","border-color":"#ccc"});var c=d-a.checkingFee;$("finalTotal").set("html","$"+c.toFixed(2));$("balanceRemaining").set("html","$"+(a.withdrawableAmount-d).toFixed(2));if(a.requireSSN&&!a.hasSSN&&(c+a.YTDWithdrawals>=a.ssnNeededAtYTDCashout)){$("ssnContainer").show()}else{$("ssnContainer").hide()}}});$("paymentMethodCheck").addEvent("change",function(){if(this.checked){$("checkInfo").show();$("paypalInfo").hide()}});$("paymentMethodPaypal").addEvent("change",function(){if(this.checked){$("checkInfo").hide();$("paypalInfo").show()}});$("addressCountry").addEvent("change",function(){if(this.get("value")=="US"){$("regionField").hide();$("stateField").show()}else{$("regionField").show();$("stateField").hide()}})}}},messageUs:{initialize:function(){var a=new POHub.AjaxForm("contactForm",{loadingMsg:"Sending your email",successMsg:"Your message has been sent!",onPassed:function(){this.form.resetForm()}})}},widgetAuth:{initialize:function(a){var b=opener;if(!IE6){window.addEvent("unload",function(){if(b&&!b.closed){b.location.reload()}})}if(a.isLoggedIn){(function(){window.close()}).delay(3000)}var c=new POHub.AjaxForm("widgetAuthForm",{loadingMsg:"Logging you in",successMsg:"You have been logged in successfully! Closing window...",dismissRedirect:true,onPassed:function(){if(IE6){alert("Now that you've logged in, please refresh the game page to view your personal status.");window.close()}else{(function(){window.close()}).delay(1000)}}})}},tournamentEnterAuth:{initialize:function(){if($("enterAuthForm")){$("enterAuthForm").addEvent("submit",function(){if($("returningRadio").checked){$("lname").set("value","");$("dob").set("value","");$("gender").set("value","");$("fname").set("value","")}});$("fname").addEvent("focus",function(){$("firstRadio").checked=true});$("password").addEvent("focus",function(){$("returningRadio").checked=true})}}},tournamentEnterConfirm:{initialize:function(){var a=new POHub.AjaxForm("enterConfirmForm")}},widgetSubmitScore:{initialize:function(a){}},clientTransactions:{initialize:function(){$("showIds").addEvent("change",function(){if(this.checked){$("transactionTable").addClass("showId")}else{$("transactionTable").removeClass("showId")}})}},userTransactions:{initialize:function(){$("showIds").addEvent("change",function(){if(this.checked){$("transactionTable").addClass("showId")}else{$("transactionTable").removeClass("showId")}})}},clientScores:{initialize:function(){var b=new POHub.AjaxForm("clientScoresForm",{loadingMsg:"Deleting selected scores",successMsg:"Selected scores deleted successfully!",reload:true});var a=$("scores");$("selectAll").addEvent("click",function(c){c.stop();selectCheckboxes(a,"all")});$("selectNone").addEvent("click",function(c){c.stop();selectCheckboxes(a,"none")});$("invertSelection").addEvent("click",function(c){c.stop();invertCheckboxes(a)});$$(a).getElements("tr").each(function(c){c.addEvent("click",function(){var d=this.getElement("input[type=checkbox]");if(d){d.checked=!d.checked}})});$$(a).getElements("input[type=checkbox]").each(function(c){c.addEvent("click",function(d){d.stopPropagation()})})}}};