var xScroll, yScroll, timerPoll, timerRedirect, timerClock;

function hideSuggest()
{
  if(document.getElementById('suggest') != null)
   setelementvisibilitys('suggest',false);
  
  initRedirect();
}

function initRedirect()
{   
  if (typeof document.body.scrollTop != "undefined")
  { //IE,NS7,Moz
    xScroll = document.body.scrollLeft;
    yScroll = document.body.scrollTop;

    clearInterval(timerPoll); //stop polling scroll move
    clearInterval(timerRedirect); //stop timed redirect

    timerPoll = setInterval("pollActivity()",1); //poll scrolling
    //timerRedirect = setInterval("location.href='anotherpage.htm'",10000); //set timed redirect

    //for tracking only
    clearInterval(timerClock);
    document.getElementById("activityclock").innerHTML="0";
    timerClock=setInterval("document.getElementById('activityclock').innerHTML=parseInt(document.getElementById('activityclock').innerHTML,10)+5",5000);
    //end tracking
  }
  else if (typeof window.pageYOffset != "undefined")
  { //other browsers that support pageYOffset/pageXOffset instead
    xScroll = window.pageXOffset;
    yScroll = window.pageYOffset;

    clearInterval(timerPoll); //stop polling scroll move
    clearInterval(timerRedirect); //stop timed redirect

    timerPoll = setInterval("pollActivity()",1); //poll scrolling
    //timerRedirect = setInterval("location.href='anotherpage.htm'",10000); //set timed redirect

    //for tracking only
    clearInterval(timerClock);
    document.getElementById("activityclock").innerHTML="0";
    timerClock=setInterval("document.getElementById('activityclock').innerHTML=parseInt(document.getElementById('activityclock').innerHTML,10)+5",5000);
    //end tracking
  }
  //else do nothing
}

function pollActivity()
{
  if ((typeof document.body.scrollTop != "undefined" && (xScroll!=document.body.scrollLeft || yScroll!=document.body.scrollTop)) //IE/NS7/Moz
   ||
   (typeof window.pageYOffset != "undefined" && (xScroll!=window.pageXOffset || yScroll!=window.pageYOffset))) { //other browsers
      initRedirect(); //reset polling scroll position
  }
}

document.onmousemove=initRedirect;
//document.onclick=initRedirect;
document.onclick=hideSuggest;
document.onkeydown=initRedirect;
window.onload=initRedirect;
window.onresize=initRedirect;

