function whenReady() {
   var wait= [10, 20];
   var timeoutFn= function() {
     if (self.document)
       if (self.usatAj) {
         loadPages(defaultstate);
       } else {
         wait[2]= wait[0]+wait[1];
         setTimeout(timeoutFn, wait.shift());
     }
   };
   timeoutFn();
};
setTimeout(whenReady,1);