public function linkFormFields($opts = null)
 {
     // OPTS:
     // label, header, autoCategoryID, autoTarget, instructions
     if ($opts != null) {
         extract($opts);
     }
     if ($autoCategoryID or $autoTarget) {
         $linkOpts = array('autoCategoryID' => $autoCategoryID, 'autoTarget' => $autoTarget);
     }
     if (isset($moreOptions)) {
         parse_str($moreOptions);
     }
     $numPostLinks = 1;
     if (isset($_POST) && isset($_POST[Link::$tableName])) {
         $numPostLinks = 0;
         foreach ($_POST[Link::$tableName] as $key => $val) {
             $categoryID = isset($categoryID) ? $categoryID : 0;
             $valCatID = isset($val["categoryID"]) ? $val["categoryID"] : 0;
             if ($categoryID == $valCatID) {
                 $numPostLinks++;
             }
         }
     }
     $label = isset($label) ? $label : "Link";
     $this->accelJS()->requireFile('jqueryConfirm');
     $js .= "\$('.delete{$label}').click(function(){\n                var linkID = \$(this).attr('title');\n                \$.ajax({\n                    url: '?ajax=true&adminLayout=empty&ado=linkDeleteLink&linkID=' + linkID,\n                    complete: function(data){\n                        \$('#link_form_' + linkID).hide('slow');\n                    }\n                });\n            });\n            \$('.delete{$label}').confirm();\n\n\n            \$('.dissociate{$label}').click(function(){\n                var linkID = \$(this).attr('title');\n                url = '?ajax=true&adminLayout=empty&ado=linkDissociateLink&linkID=' + linkID + '&recordID=" . $this->obj->id() . "&recordType=" . $this->obj->linkKey() . "';\n                \$.ajax({\n                    url: url,\n                    complete: function(data){\n                        \$('#link_form_' + linkID).hide('slow');\n                    }\n                });\n            });\n            \$('.dissociate{$label}').confirm({\n                msg: 'Dissociating will not delete the file. It will still be available in the Link Manager. <br/>  Continue? ',\n                timeout: 7000\n            });\n/*\n            \$('.sorted_list').sortable({\n                opacity: 0.7,\n                update : function(event,ui){\n\n                    idAttr = \$(this).attr('id').replace('recordID_','').split('_');\n                    id = idAttr[1];\n                    tablename  = idAttr[0];\n                    serial = \$(this).sortable('serialize', {});\n\n                    var url = 'index.php?adminAction=linkRecordDisplayOrder&adminLayout=empty&ajax=true&table='+tablename+'&recordID='+id+'&'+serial;\n\n                    \$.ajax({\n                       url: url,\n                       success: function(msg){\n                          //alert ( msg );\n                       }\n                    });\n\n\n                }\n            })*/\n\n\n\n            ";
     $this->accelJS()->ready($js);
     $headTitle = isset($header) ? $header : "And and Update Links";
     // link
     if ($maxLink = $this->obj->maxLink()) {
         $form .= "<h3>{$headTitle}</h3>";
         if ($instructions) {
             $form .= "<div class='link-form-instructions'>" . $instructions . "</div>";
         }
         $numPostLinks = isset($numPostLinks) ? $numPostLinks : 1;
         $linkLimit = $this->obj->linkCount() ? $this->obj->linkCount() : $numPostLinks;
         $form .= "<div class='sorted_list' id='recordID_{$this->obj->linkKey()}_{$this->obj->id()}'>";
         for ($i = 0; $i < $maxLink && $i < $linkLimit; $i++) {
             $link = $this->obj->getLink($i);
             if (!$link) {
                 $link = new Link();
             }
             if ($formOverride) {
                 list($loc, $file) = explode("/", $formOverride);
                 $snippetOpts['moreOptions'] = $moreOptions;
                 $snippetOpts['count'] = $i;
                 $form .= ThemeHelper::findThis()->snippet($loc, $file, $snippetOpts);
             } else {
                 $form .= $link->extrasForm($i, $linkOpts) . "<br/>";
             }
         }
         $form .= "</div>";
         $opts["label"] = "link";
         $opts["button_label"] = "Add Another Link";
         $opts["formOverride"] = isset($formOverride) ? $formOverride : "";
         $opts["moreOptions"] = $moreOptions;
         if ($i < $maxLink) {
             $form .= $this->addAJAXLink($i, $this->obj->maxLink() - 1, $label, $opts);
         }
         return $form;
     }
 }