/* (c) 2009 PayoutHub */
 
var POHub = {
    config: {
        isToggleMenuOpen: false,
        Forms: {
            resultsContainer: "resultsContainer",
            successBox: {
                className: "formSuccess",
                html: '<div class="formSuccess">                    <a href="#" onclick="this.getParent(\'.formSuccess\').dissolve(); return false;" class="ex" title="Hide this message"><img src="' + IMG_URL + 'close.png" alt="" /></a>                    <ul><li>{message}</li></ul>                </div>'
            },
            errorsBox: {
                className: "formErrors",
                html: '<div class="formErrors">                    <a href="#" onclick="this.getParent(\'.formErrors\').dissolve(); return false;" class="ex" title="Hide this message"><img src="' + IMG_URL + 'close.png" alt="" /></a>                    <ul>{errors}</ul>                </div>'
            },
            loadingBox: {
                className: "formLoading",
                html: '<div class="formLoading">                    <div class="text">{message}</div>                    <img src="' + IMG_URL + 'loader.gif" alt="" />                </div>'
            }
        },
        Request: {
            Hajax: {
                errorsClass: "errors"
            }
        }
    }
};

/* (c) 2009 PayoutHub */

var WEBKIT = Browser.Engine.webkit;
var GECKO = Browser.Engine.gecko;
var OPERA = Browser.Engine.presto;
var IE = Browser.Engine.trident;
var IE6 = (navigator.userAgent.toLowerCase().indexOf("msie 6") != -1) && (navigator.userAgent.toLowerCase().indexOf("msie 7") == -1);
var $E = function (a, b) {
    return ($(b) || document).getElement(a)
};
var $ES = function (a, b) {
    return ($(b) || document).getElements(a)
};
Array.implement({
    isEmpty: function () {
        return (this.length == 0)
    }
});
Element.implement({
    injectHTML: function (e, b, a) {
        var c = new Element("div").set("html", e).getChildren();
        if (a) {
            c.reverse()
        }
        c.inject(this, b);
        return this
    },
    selectedOption: function () {
        if (this.get("tag") != "select") {
            return this
        }
        return $(this.options[this.selectedIndex])
    },
    isScrollVisible: function () {
        if (!this.isDisplayed()) {
            return false
        }
        var b = window.getSize(),
            e = window.getCoordinates(),
            a = window.getScroll(),
            c = this.getCoordinates();
        return ((c.top >= a.y) && (c.left >= a.x) && ((c.left + c.width / 2) <= (a.x + b.x)) && ((c.top + c.height / 2) <= (a.y + b.y)))
    },
    resetForm: function () {
        this.getElements("input[type=text],input[type=password], textarea").each(function (a) {
            a.set("value", a.defaultValue)
        });
        this.getElements("select").each(function (a) {
            a.selectedIndex = a.defaultIndex
        });
        this.getElements("input[type=checkbox],input[type=radio]").each(function (a) {
            a.checked = false
        })
    }
});
String.implement({
    isValidDate: function () {
        var a = /^(\d{2})\/(\d{2})\/(\d{4})$/;
        if (!a.test(this)) {
            return false
        }
        d = new Date(this.replace(a, "$1/$2/$3"));
        return (parseInt(RegExp.$1, 10) == (1 + d.getMonth())) && (parseInt(RegExp.$2, 10) == d.getDate()) && (parseInt(RegExp.$3, 10) == d.getFullYear())
    },
    truncate: function (b, a) {
        b = b || 30;
        a = (!$defined(a)) ? "..." : a;
        return (this.length > b) ? this.slice(0, b - a.length) + a : this
    }
});

function selectCheckboxes(a, b) {
    b = b || "all";
    $(a).getElements("input[type=checkbox]").each(function (c) {
        c.checked = (b == "all")
    })
}
function disableInputs(a, b) {
    b = b || "disable";
    $(a).getElements("input").each(function (c) {
        c.disabled = (b != "enable")
    })
}
function invertCheckboxes(a) {
    $(a).getElements("input[type=checkbox]").each(function (b) {
        b.checked = !b.checked
    })
}
function setCharLimit(c, f) {
    f = f || 400;
    var b = new Element("div", {
        "class": "charlimit"
    }).set("html", '<span class="count">' + c.value.length + '</span> of <span class="total">' + f + "</span> characters used.");
    var e = b.inject(c, "after").getElement("span.count");
    var a = function () {
        e.set("text", c.value.length)
    };
    c.addEvents({
        keypress: function (g) {
            if (c.value.length >= f) {
                if (g.key != "backspace" && g.key != "delete" && g.key != "left" && g.key != "right" && g.key != "up" && g.key != "down" && g.code != 33 && g.code != 34 && g.code != 35 && g.code != 36) {
                    g.stop()
                }
            }
            a.delay(1)
        },
        keyup: function (g) {
            if (c.value.length > f) {
                c.value = c.value.truncate(f, "")
            }
            a.delay(1)
        },
        blur: function (g) {
            a.delay(1)
        },
        focus: function (g) {
            a.delay(1)
        }
    });
    return {
        charlimit: b,
        textarea: c
    }
}
if (console && console.log) {
    $log = console.log
} else {
    var console = {};
    console.log = $empty
}
POHub.initPage = function (b, a) {
    if (POHub.Pages[b]) {
        window.addEvent("domready", POHub.Pages[b].initialize.pass(a))
    }
};
var $wopen = function (g, b, a, c) {
    c = c || true;
    b = b.replace(/\-/g, "_") || "";
    a = $merge({
        status: 1,
        toolbar: 0,
        location: 0,
        menubar: 0,
        directories: 0,
        resizable: 1,
        scrollbars: 1,
        height: 500,
        width: 800,
        fullWindow: false
    }, (a || {}));
    var f, e;
    if ($type(g) == "element") {
        e = $(g);
        g = e.get("href")
    }
    if (navigator.userAgent.indexOf("Chrome/") > 0) {
        window.open("", b, "height=1,width=1,scrollbars=0").close()
    }
    f = window.open(g, b, (a.fullWindow) ? "" : ("status={status},toolbar={toolbar},location={location},menubar={menubar},directories={directories},resizable={resizable},scrollbars={scrollbars},height={height},width={width}").substitute(a));
    (function () {
        if (!f || f.closed) {
            top.location.href = g
        }
    }).delay(200);
    if (c) {
        f.focus()
    }
    return f
};
POHub.MenuSiteToggle = {
    fx: null,
    toggle: function () {
        var b = POHub.config,
            a = $E("#header.site h2 a"),
            c = $E("#header.site #menuSiteToggle");
        POHub.MenuSiteToggle.fx = new Fx.Reveal(c, {
            duration: 200
        });
        if (b.isToggleMenuOpen) {
            POHub.MenuSiteToggle.hide()
        } else {
            a.addClass("active");
            POHub.MenuSiteToggle.fx.reveal();
            b.isToggleMenuOpen = true
        }
    },
    hide: function () {
        var b = POHub.config,
            a = $E("#header.site h2 a"),
            c = $E("#header.site #menuSiteToggle");
        a.removeClass("active");
        POHub.MenuSiteToggle.fx.dissolve();
        b.isToggleMenuOpen = false
    }
};
POHub.Hajax = new Class({
    Extends: Request.HTML,
    options: {
        responseContentID: null
    },
    initialize: function (a) {
        this.parent(a);
        this.addEvent("success", function (j, i, k, c) {
            var n = this.options.responseContentID,
                h = k.toElements(),
                m = h.length == 0,
                o = !h.filter("ul." + POHub.config.Request.Hajax.errorsClass).isEmpty(),
                b = h.filter("#" + n).isEmpty(),
                e = {
                html: k,
                nodes: j,
                elements: i,
                script: c
            };
            if (m || o || (n && !b)) {
                if (o) {
                    var g = h.filter("ul." + POHub.config.Request.Hajax.errorsClass).getLast(),
                        f = g.getElements("li"),
                        l = [];
                    l = f.map(function (p) {
                        return p.get("text")
                    });
                    this.fireEvent("failed", l)
                } else {
                    this.fireEvent("failed")
                }
            } else {
                this.fireEvent("passed", arguments)
            }
        });
        this.addEvent("failure", function (b) {
            this.fireEvent("failed")
        });
        ["complete", "exception", "cancel"].each(function (b) {
            this.addEvent(b, function () {
                this.fireEvent("finished")
            })
        }, this)
    }
});
POHub.Ajax = new Class({
    Extends: Request.JSON,
    options: {},
    initialize: function (a) {
        this.parent(a);
        this.addEvent("success", function (e, c) {
            var b = e;
            if (!b) {
                this.fireEvent("failed")
            } else {
                if (b.errors && b.errors.length > 0) {
                    this.fireEvent("failed", [b.errors])
                } else {
                    if (!b.success) {
                        this.fireEvent("failed")
                    } else {
                        this.fireEvent("passed", b)
                    }
                }
            }
        });
        this.addEvent("failure", function (b) {
            this.fireEvent("failed")
        });
        ["complete", "exception", "cancel"].each(function (b) {
            this.addEvent(b, function () {
                this.fireEvent("finished")
            })
        }, this)
    }
});
POHub.AjaxForm = new Class({
    Implements: [Options, Events],
    form: null,
    submitButton: null,
    xhr: null,
    results: null,
    submitFunc: null,
    options: {
        submitButton: "input[type=submit]",
        resultsContainer: ".resultsContainer",
        loadingContainer: ".loadingContainer",
        delayRedirect: false,
        reload: false,
        dismissRedirect: false,
        delay: 1000,
        loadingMsg: "Submitting",
        successMsg: "Your information submitted successfully!",
        errorMsg: "The request failed. There was either an error or our servers could not be reached. Please check your internet connection or try again later."
    },
    initialize: function (b, a) {
        if (!$(b)) {
            return false
        }
        var e = this,
            c = POHub.config.Forms;
        this.setOptions(a);
        this.form = $(b);
        this.submitButton = this.form.getElement(this.options.submitButton);
        this.addSubmit();
        if (!this.results) {
            this.results = this.form.getElement("." + c.resultsContainer) || new Element("div", {
                "class": c.resultsContainer
            }).inject(this.form, "top")
        }
        this.xhr = new POHub.Ajax({
            method: this.form.get("method"),
            url: this.form.get("action"),
            link: "cancel",
            onRequest: function () {
                e.results.empty();
                e.submitButton.hide().disabled = true;
                var f = c.loadingBox.html.substitute({
                    message: e.options.loadingMsg + "..."
                });
                if (e.form.getElement(e.options.loadingContainer)) {
                    e.form.getElement(e.options.loadingContainer).set("html", f)
                } else {
                    e.submitButton.injectHTML(f, "before")
                }
                e.fireEvent("request")
            },
            onFinished: function () {
                e.submitButton.show("inline").disabled = false;
                var f = e.submitButton.getParent().getElement("." + c.loadingBox.className);
                if (f) {
                    f.destroy()
                }
                e.fireEvent("finished")
            },
            onPassed: function (g) {
				//alert('yeh');				
                if (!g.nextUrl || g.nextUrl == "" || e.options.delayRedirect) {
                    e.results.set("html", c.successBox.html.substitute({
                        message: e.options.successMsg
                    }));
                    if (!e.results.isScrollVisible()) {
                        var f = new Fx.Scroll(window).toElement(e.results)
                    }
                }
                if (((g.nextUrl && g.nextUrl != "") || e.options.reload) && !e.options.dismissRedirect) {
                    (function () {
                        if (e.options.reload) {
                            window.location.reload()
                        } else {
                            self.location.href = g.nextUrl
                        }
                    }).delay((e.options.delayRedirect) ? e.options.delay : 0)
                }
                e.fireEvent("passed")
            },
            onFailed: function (h) {
				//alert('why');
                h = (h) ? h : [e.options.errorMsg];
                var g = h.map(function (i, j) {
                    return ((j == 0) ? '<li style="margin-top:0;">' : "<li>") + i + "</li>"
                }).join("");
                e.results.set("html", c.errorsBox.html.substitute({
                    errors: g
                }));
                if (!e.results.isScrollVisible()) {
                    var f = new Fx.Scroll(window).toElement(e.results)
                }
                e.fireEvent("failed")
            }
        })
    },
    addSubmit: function () {
        this.form.addEvent("submit", this.submitFunc = this.submit.bindWithEvent(this))
    },
    removeSubmit: function () {
        this.form.removeEvent("submit", this.submitFunc)
    },
    submit: function (a) {
        a.stop();
        this.xhr.send({
            data: this.form.toQueryString()
        })
    }
});

/* (c) 2009 PayoutHub */

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 = {
    playerJoinTournament: {
        initialize: function () {
			$('anc_rules').addEvent('click', function(e) {								  
				e = new Event(e).stop();
				
				$("resultContainer").set("src", $("anc_rules").get("href"));
				$("resultContainer").set("height", "550");
				$("resultContainer").set("width", "100%");
				//Toggle();
			});
			if($('anc_paypal')!='undefined'){
				$('anc_paypal').addEvent('click', function(e) {								  
					e = new Event(e).stop();
					
					$("resultContainer").set("src", $("anc_rules").get("href"));
					$("resultContainer").set("height", "550");
					$("resultContainer").set("width", "100%");
					//Toggle();
				});
			}
			$('anc_leaderboard').addEvent('click', function(e) {								  
				e = new Event(e).stop();
				//alert($("anc_leaderboard").get("href"));
				
				$("resultContainer").set("src", $("anc_leaderboard").get("href"));
				$("resultContainer").set("height", "550");
				$("resultContainer").set("width", "100%");
				//Toggle();
			});
			$('anc_join').addEvent('click', function(e) {								  
				e = new Event(e).stop();
				
				$("resultContainer").set("src", $("anc_join").get("href"));
				$("resultContainer").set("height", "550");
				$("resultContainer").set("width", "100%");		
			    //Toggle();
			});	
			
			$('anc_login').addEvent('click', function(e) {								  
				e = new Event(e).stop();
				
				$("resultContainer").set("src", $("anc_login").get("href"));
				$("resultContainer").set("height", "550");
				$("resultContainer").set("width", "100%");		
				//Toggle();
			});	
			/*if($('anc_reset')!="undefined" || $('anc_reset')!=null){
				$('anc_reset').addEvent('click', function(e) {								  
					e = new Event(e).stop();
					
					$("resultContainer").set("src", $("anc_reset").get("href"));
					$("resultContainer").set("height", "550");
					$("resultContainer").set("width", "100%");		
					//Toggle();
				});
			}*/
			$('anc_auth_signup').addEvent('click', function(e) {								  
				e = new Event(e).stop();
				
				$("resultContainer").set("src", $("anc_auth_signup").get("href"));
				$("resultContainer").set("height", "550");
				$("resultContainer").set("width", "100%");		
				//Toggle();
			});
			$('anc_dont').addEvent('click', function(e) {								  
				e = new Event(e).stop();
				$("resultContainer").set("src", $("anc_dont").get("href"));
				$("resultContainer").set("height", "550");
				$("resultContainer").set("width", "100%");		
				//Toggle();
			});
			$('anc_remember').addEvent('click', function(e) {								  
				e = new Event(e).stop();
				$("resultContainer").set("src", $("anc_remember").get("href"));
				$("resultContainer").set("height", "550");
				$("resultContainer").set("width", "100%");		
			
			});
			$('anc_forgot_login').addEvent('click', function(e) {								  
				e = new Event(e).stop();
				$("resultContainer").set("src", $("anc_forgot_login").get("href"));
				$("resultContainer").set("height", "550");
				$("resultContainer").set("width", "100%");		
			
			});
        }
    },
    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)
            };
			//alert(a);
			
            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:")
                    }
                }
            })
			$("progressive").addEvent("click", function () {
                if (this.checked) {                    
                    //alert('progressive');
					$("clientCut").set('value',10).fireEvent('keyup');
					//a.run(null, $("clientCut"))
                } 
            })
			$("nonprogressive").addEvent("click", function () {
                if (this.checked) {                    
                    //alert('nonprogressive');
					$("ourCut").set("text",10);
					$("clientCut").set("value",90);
                	$("jackpotCut").set("text", 0)
                } 
            })
			
        }
    },
    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!"
            })
        }
    },
	adminclientEditAccount: {
        initialize: function () {
            var b = new POHub.AjaxForm("adminclientEditAccountForm", {
                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("adminclientChangePWForm", {
                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()
                })
            })
        }
    }
};