// copyright 2007 Dr. Jon Schuringa



function clearAllWatch(){
   updatingWatch=true;
   ds.removeAll();
   watchList = new Array();
    updatingWatch=false;
}



function IsWhite(ch) // Given : ch is a character // Returns : true if ch is a whitecase letter 
{ var white; white = " \t\n\r"; return (white.indexOf(ch) != -1); } 

function addWatch(expr){
  
 if ((expr.length>0) && IsWhite(expr.charAt(0))) return false;
 if (expr.length==0) return false;
  
  updatingWatch=true;
   watchList.push(expr);
 
       
    addWatchCool(expr);
    state[ds.getCount()-1]='undefined';
    updatingWatch=false;
  
 return;
}

function updateTitle(){
 /* var i
  for (i=0;i<nrVarSpans;i++){
    var v = spanVar[i];
    
    var sub= "state["+findSubstitute(v)+"]";
   // alert(" " + v+ " " + i + " " + sub);
    document.getElementById("vartit"+i).title=v + ": "+eval(sub);
   }*/
}

function updateWatch(){
updatingWatch=true;
if (watchVars){
  var k;
  for (k=0;k<watchVars.length;k++){
   var e=document.getElementsByName("sense"+k);
   var m;
   for (m=0;m<e.length;m++){
     if (stateVars[k]) e[m].title= stateVars[k].toString();
   }
   }
  Ext.QuickTips.interceptTitles = true;
  Ext.QuickTips.init(); // not sure...
}
// update call stack
 delCallAll();
 for (var i=0;i<stack.length;i++){
  addCall(stack[i],stackLine[i]);
  }


   //updateTitle();

 var kkk;
 for (kkk=0;kkk<ds.getCount();kkk++){
  if (state[kkk]!=undefined){
   var txt=state[kkk];
   if (txt==="'undefined'") txt='<i>undefined</i>';
  if (ds.getAt(kkk).get('light')===txt)
  ds.getAt(kkk).commit();
  else ds.getAt(kkk).set('light',txt);
  }else ds.getAt(kkk).set('light',"<i>undefined</i>");
}

updatingWatch=false;

}


