    var tipTimer = 0;
    var tipObject = false;

    $(document).ready(function(){
        $("#reqJS").removeClass("hidden"); // remove the javascript notice

        // Sliding headers
        $(".togglehead").attr("title", "Click to shrink or expand this section.");
        $(".eventcat").attr("title", "Click to shrink or expand this sub-section.");

        //display fix for google chrome
        $(".togglehead").next("span").css("display", "block");
        $(".eventcat").next("span").css("display", "block");

        $(".togglehead").click(function() { $(this).next("span").slideToggle(400); return true; });
        $(".eventcat").click(function() { $(this).next("span").slideToggle(400); return true; });

        $("#helpLink").click(function() { $(this).next("span").toggle(); return false; });

        $(".numbersOnly").keypress(function(e){
            return numbersOnly(this, e);
        });

        $(".selectAll").click(function(){ $(this).focus(); });
        $(".selectAll").focus(function(){ $(this).select(); });

        /* Disapearing/Reapearing Ink */
        $(".magicText").each(function(i){
            $(this).data({
                defaultText: $(this).val()
            });
            $(this).focus(function(){
                if( trim( $(this).val() ) == $(this).data("defaultText") ) { $(this).val(""); }
            });
            $(this).blur(function(){
                if( trim( $(this).val() ) == "") { $(this).val( $(this).data("defaultText") ); }
            });
        });

        $(".tooltip").mouseenter(function(e){ setTip( moveTip(this, e) ); });
        $(".tooltip").mousemove(function(e){ moveTip(this, e); });
        $(".tooltip").mouseout(function(){ clearTip( $(this).children(".tooltipdiv") ); });
        $(".tooltipdiv").mouseover(function(){ clearTip( $(this) ); });
        $(".tooltipdiv").hide();
    });

    function moveTip(o, e)
    {
        var THIS = $(o);
        var TT = THIS.children(".tooltipdiv");
        var P = THIS.position();
        var X = e.pageX + 30; // + P.left;
        var Y = e.pageY + 30;// + P.top;

        var DX = GetWidth(); //$(document).width();
        var DY = GetHeight(); //$(document).height();
        var TX = TT.width();
        var TY = TT.height();
        var ZX = X + TX;
        var ZY = Y + TY;

        if(ZX > DX) { X -= (TX + 30); }
        if(ZY > DY) { Y -= (TY + 30); }

        TT.css({ top: Y, left: X });
        return TT;
    }

    function setTip(o)
    {
        var THIS = $(o);
        clearTip(tipObject);
        tipObject = THIS;
        tipTimer = setTimeout("showTip()", 500);
        return THIS;
    }

    function showTip()
    {
        clearTimeout(tipTimer);
        if(tipObject == false) { return; }
        $(tipObject).show();
    }

    function clearTip(o)
    {
        clearTimeout(tipTimer);
        tipObject = false;
        $(o).hide();
    }

    function GetWidth()
    {
        var x = 0;
        if (self.innerHeight)
        {
            x = self.innerWidth;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
            x = document.documentElement.clientWidth;
        }
        else if (document.body)
        {
            x = document.body.clientWidth;
        }
        return x;
    }

    function GetHeight()
    {
        var y = 0;
        if (self.innerHeight)
        {
            y = self.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
            y = document.documentElement.clientHeight;
        }
        else if (document.body)
        {
            y = document.body.clientHeight;
        }
        return y;
    }

    function trim(str) { return str.replace(/^\s+|\s+$/g,""); }

    function numbersOnly(t, e)
    {
        var keyCode = ((e.which != null) ? e.which : e.keyCodeode );
        var block = false;
        var THIS = $(t);

        switch(keyCode)
        {
            case 13:
                // some browsers (Opera for example) don't fire the onChange event
                // when ENTER is pressed. For that to happen, the field has to
                // loose focus, so we won't block the enter key.
                THIS.blur();
                return true;
                break;

            case 45:
                // Check for negitive numbers, conditionally allow the minus key
                var v = THIS.val();
                var i = THIS.caret().start;
                var j = THIS.caret().end;
                block = ( (i > 0)  || (v.substr(0,1) == "-") ) && (v.length > 0) && ((j-i) == 0);
                break;

            default:
                // block text keys
                block = ( (keyCode > 31) && ((keyCode < 48) || (keyCode > 57)) );
                break;
        }

        if( block ) {
            alert("This field only accepts numbers.");//+ " " + keyCode);
            THIS.blur();
            THIS.focus();
            THIS.select();
        }
        return !block;
    }

//<!-- phpBB javascript -->

function popup(url, width, height, name)
{
    if (!name)
    {
        name = '_popup';
    }

    window.open(url.replace(/&amp;/g, '&'), name, 'height=' + height + ',resizable=yes,scrollbars=yes,width=' + width);
    return false;
}

/**
* Find a member
*/
function find_username(url)
{
    popup(url, 760, 570, '_usersearch');
    return false;
}

/**
* Mark/unmark checklist
* id = ID of parent container, name = name prefix, state = state [true/false]
*/
function marklist(id, name, state)
{
    var parent = document.getElementById(id);
    if (!parent)
    {
        eval('parent = document.' + id);
    }

    if (!parent)
    {
        return false;
    }

    var rb = parent.getElementsByTagName('input');

    for (var r = 0; r < rb.length; r++)
    {
        if (rb[r].name.substr(0, name.length) == name)
        {
            rb[r].checked = ((state == 'invert') ? !rb[r].checked : state);
        }
    }
    return false;
}

