
var xScroll, yScroll, timerPoll, timerRedirect, timerClock;
var idletime=30*60*1000;
var loadPath;
var times=1;

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("postIdleAction()",idletime); //set timed redirect

    //for tracking only
    //clearInterval(timerClock);
    //document.getElementById("clock").innerHTML="0";
    //timerClock=setInterval("document.getElementById('clock').innerHTML=parseInt(document.getElementById('clock').innerHTML,10)+1",1000);
    //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'",idletime); //set timed redirect

    //for tracking only
    //clearInterval(timerClock);
    //document.getElementById("clock").innerHTML="0";
    //timerClock=setInterval("document.getElementById('clock').innerHTML=parseInt(document.getElementById('clock').innerHTML,10)+1",1000);
    //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
  }
}

function postIdleAction(){
  // var path="http://www.sina.com.cn";
  // window.open(path,'ResetPassword','width=0,height=0,menubar=no,status=no,scrollbars=no,toolbar=no,location=no,directories=no,resizable=no,titlebar=no,top=50,left=140,alwaysRaised=yes'); 
  //location.href='www.sina.com.cn';   
  if(times>0){  
  }else{
   document.getElementById("backendcontainer").src=loadPath;
   times=times+1;
  }
    
}

document.onmousemove=initRedirect;
document.onclick=initRedirect;
document.onkeydown=initRedirect;
window.onload=initRedirect;
window.onresize=initRedirect;