var secDelay=10;
var secToShowMsg=tSec+secDelay;
var secToAutoLoad=tNoClickSec-secToShowMsg;

function stopError() { return true; }
window.onerror=stopError;

if (secToAutoLoad<0) secToAutoLoad=30;

var timerID = null;
var timerID2= null;
function stopclock() {
   clearTimeout(timerID); 
   clearTimeout(timerID2);
   return true;
   }

var tmpAL="or \"Turn on Auto-Load Next Website\"";
var maxMSG="Auto-load next Website: "+maxAutoLoad+" times max reached.";
var viewNEXT;
function secLeft() {

 if (curMaxAutoLoad>=maxAutoLoad) { 
     // window.status=maxMSG;
     parent.topframe.document.tfmsg.msg.value=maxMSG;
    }
 else {
	 if (tSec==0) {
	    if (autoLoadOn.indexOf("on") != -1) 
	       {
	       tmpAL="or let it auto-load";   
	       }
	    viewNEXT="Now click on \"View Next Website\" "+tmpAL+ " to earn Website hits.";
	    // window.status=viewNEXT;
	    parent.topframe.document.tfmsg.msg.value=viewNEXT;
	    }
	 else{ 
	     tSec-=1;
	     rTime=tSec+" seconds to earn Website hits.";
	     // window.status=rTime;
	     parent.topframe.document.tfmsg.msg.value=rTime;
	     }
    }
 timerID=setTimeout("secLeft()",1000);
 return true;
 }

var noClickCount=0;
var autoMSG;
function autoLoadIt() {
  if (curMaxAutoLoad>=maxAutoLoad) { 
     // window.status=maxMSG;
     parent.topframe.document.tfmsg.msg.value=maxMSG;
     }
  else { 
	 if (autoLoadOn.indexOf("on") != -1) {
	    noClickCount+=1;
	    
	    if (noClickCount>=secToShowMsg && noClickCount<tNoClickSec) {
	       clearTimeout(timerID);
	       autoMSG="Next Website will be auto-loaded in "+secToAutoLoad+" seconds. Click here to reset the timer.";
	       // window.status=autoMSG;
	       parent.topframe.document.tfmsg.msg.value=autoMSG;
	       secToAutoLoad-=1;
	       }
	    if (noClickCount>=tNoClickSec && curMaxAutoLoad<maxAutoLoad) {
	       // window.location.reload();
	       curMaxAutoLoad+=1;
	       window.location="hits.cgi?mid="+memberID+"&mAutoLoad="+curMaxAutoLoad;
	       return true;
	       }
	
	    }
    }
 timerID2=setTimeout("autoLoadIt()",1000);
 return true;
 }



function reSetIt() { 
 if (noClickCount>=secToShowMsg && noClickCount<tNoClickSec) {
  noClickCount=0;
  secToShowMsg=0;
  secToAutoLoad=tNoClickSec;
  //parent.topframe.document.tfmsg.msg.focus();
  }
 }

function loadAll() { 
 secLeft();
 autoLoadIt();
 return true;
 }

window.onload=loadAll;
window.onUnload=stopclock;