ea95f05b7db51e240111a8d6d4ba7bb1895c9ade
larrym
  Fri Jun 29 10:41:35 2012 -0700
code cleanup
diff --git src/hg/js/hgGateway.js src/hg/js/hgGateway.js
index 308226a..c57baf1 100644
--- src/hg/js/hgGateway.js
+++ src/hg/js/hgGateway.js
@@ -1,30 +1,32 @@
 $(document).ready(function()
 {
     suggestBox.init(document.orgForm.db.value, $('#suggestTrack').length > 0,
                       function(item) {
                           $('#positionDisplay').text(item.id);
                           $('#position').val(item.id);
                       },
                       function(position) {
                           $('#positionDisplay').text(position);
                           $('#position').val(position);
                       }
                    );
-    // default the image width to current browser window width
+
+    // Default the image width to current browser window width (#2633).
     var ele = $('input[name=pix]');
     if(ele.length && (!ele.val() || ele.val().length == 0)) {
         ele.val(calculateHgTracksWidth());
     }
 
-    // Make sure suggestTrack is visible if user has choosen soemting via gene select.
-    $(document.mainForm).submit(function(event)
-                                {
+    if($("#suggestTrack").length) {
+        // Make sure suggestTrack is visible when user chooses something via gene select (#3484).
+        $(document.mainForm).submit(function(event) {
                                     if($('#hgFindMatches').length) {
                                         var track = $("#suggestTrack").val();
                                         if(track) {
                                             $("<input type='hidden' name='" + track + "'value='pack'>").appendTo($(event.currentTarget));
                                         }
                                     }
                                 });
+    }
 });