// PRELOAD SOME IMAGES
    if (document.images) {
        image1 = new Image();
        image1.src="/images/common/menu_top.gif";
        image2 = new Image();
        image2.src="/images/common/menu_center.gif";
        image3 = new Image();
        image3.src="/images/common/menu_center_hl.gif";
        image4 = new Image();
        image4.src="/images/common/menu_bottom.gif";
        image5 = new Image();
        image5.src="/images/common/tab_left.gif";
        image6 = new Image();
        image6.src="/images/common/tab_right.gif";
    }

// BASE FUNCTIONS
    /**
     * Get the element from the Id
     * @param   string  eltId
     * @return  object
     */
    function elt($eltId)
    {
        return document.getElementById($eltId);
    }

// USER SCRIPTS
    /**
     * Focus a control on page load
     * @return  void
     */
    function focusControl(controlId)
    {
        $obj = elt(controlId);
        if ($obj) {
            $obj.focus();
        }
    }

    // variable to allow user to login
    var $allowLogin = true;

    /**
     * Check if the user can login yet
     * @return  boolean
     */
    function canLogon()
    {
        if (elt("loginp_user").value == "") {
            elt("loginp_user").focus();
            return false;
        }
        if (elt("loginp_pass").value == "") {
            elt("loginp_pass").focus();
            return false;
        }
        return $allowLogin;
    }

    /**
     * when user hits enter focuses empty boxes
     * @return  boolean
     */
    function handleEnter(event)
    {
        var keyCode = event.keyCode ? event.keyCode
            : event.which ? event.which : event.charCode;

        if (keyCode == 13) {
            return canLogon();
        }
        return $allowLogin;
    }

// OBFUSCATE EMAILS
    /**
     * @param   string  $name
     * @param   string  $domain
     * @param   string  $ext
     */
    function obfAddr($name, $domain, $ext)
    {
        $fullAddr = $name + "@" + $domain + "." + $ext;
        document.writeln($fullAddr);
    }

// EDIT IMAGE NAME/DESCRIPTION
    /**
     * Put the content for the image into the edit box
     * @param   int     $imageId
     */
    function editImg($imageId)
    {
        elt('img_id').value    = $imageId;
        elt('img_title').value = elt('img' + $imageId + "_title").value;
        elt('img_desc').value  = elt('img' + $imageId + "_desc").value;
        elt('img_year').value  = elt('img' + $imageId + "_year").value;
    }

    /**
     * Make sure that there is an image selected
     */
    function imgValid()
    {
        if (elt('img_id').value == "") {
            alert("You must choose an image to edit. \n Do this by clicking on the caption");
        }
    }