61b5e11ec9bcc55bf7566ce4d176c7caff2bdf59
tdreszer
  Fri May 16 13:29:22 2014 -0700
Fixed setTimeouts (thanks Angie) and marked some code as possibly DEAD.
diff --git src/hg/js/ajax.js src/hg/js/ajax.js
index 9013df2..3334012 100644
--- src/hg/js/ajax.js
+++ src/hg/js/ajax.js
@@ -25,31 +25,31 @@
 var ajaxWaitCount = 0;
 function ajaxWaitIsDone()     { return ( ajaxWaitCount <= 0 ); }
 function ajaxWaitCountUp()    { ajaxWaitCount++; }
 function ajaxWaitCountReset() { ajaxWaitCount = 0; }
 //function ajaxWaitCountShow()  { warn("ajaxWait calls outstanding:"+ajaxWaitCount); }
 
 // Here is where the "outside callback" gets set up and called
 var ajaxWaitCallbackFunction = null;
 var ajaxWaitCallbackTimeOut = null;
 function ajaxWaitCallbackRegister(func)
 { // register a function to be called when the ajax waiting is done.
     if (ajaxWaitIsDone())
         func();
     else {
         ajaxWaitCallbackFunction = func;
-        ajaxWaitCallbackTimeOut = setTimeout(ajaxWaitCallback(),5000);  // just in case
+        ajaxWaitCallbackTimeOut = setTimeout(ajaxWaitCallback,5000);  // just in case
     }
 }
 
 function ajaxWaitCallback()
 { // Perform the actual function (which could have been because of a callback or a timeout)
     // Clear the timeout if this is not due to ajaxWaitDone
     //warn("ajaxWaitCallback: "+ajaxWaitIsDone());
     if (ajaxWaitCallbackTimeOut) {
         clearTimeout(ajaxWaitCallbackTimeOut);
         ajaxWaitCallbackTimeOut = null;
     }
     // Clear the wait stack incase something failed and we are called by a timeout
     ajaxWaitCountReset();
 
     // Finally do the function
@@ -214,59 +214,59 @@
 function setVarsFromHash(varHash, errFunc, async)
 {
 // Set all vars in a var hash
 // If obj is undefined then obj is document!
     var names = [];
     var values = [];
     for (var aVar in varHash) {
         names.push(aVar);
         values.push(varHash[aVar]);
     }
     if (names.length > 0) {
         setCartVars(names,values, errFunc, async);
     }
 }
 
-function setAllVars(obj,subtrackName)
+function setAllVars(obj,subtrackName) // DEAD CODE ?
 {
 // Set all enabled inputs and selects found as children obj with names to cart with ajax
 // If obj is undefined then obj is document!
     var names = [];
     var values = [];
     if (!obj)
         obj = $('document');
 
     setVarsFromHash(getAllVars(obj,subtrackName));
 }
 
 // Unused but useful
 // function setCartVarFromObjId(obj)
 // {
 //     setCartVar($(obj).attr('id'),$(obj).val());
 // }
 
-function submitMain()
+function submitMain()  // DEAD CODE ?
 {
     $('form[name="mainForm"]').submit();
 }
 
-function setCartVarAndRefresh(name,val)
+function setCartVarAndRefresh(name,val) // DEAD CODE ?
 {
     setCartVar(name,val);
     var main=$('form[name="mainForm"]');
     $(main).attr('action',window.location.href);
-    setTimeout(submitMain(),50);  // Delay helps ensure that cart var has gotten there first.
+    setTimeout(submitMain,50);  // Delay helps ensure that cart var has gotten there first.
 
     return false;
 }
 
 function errorHandler(request, textStatus)
 {
     var str;
     var tryAgain = true;
     if (textStatus && textStatus.length && textStatus !== "error") {
         str = "Encountered network error : '" + textStatus + "'.";
     } else {
         if (request.responseText) {
             tryAgain = false;
             str = "Encountered error: '" + request.responseText + "'";
         } else {