var timerID = 0;
var tStart  = null;
var storesecs = 0;


function UpdateTimer()
 {
  if(timerID) 
   {
    clearTimeout(timerID);
    clockID  = 0;
   }

  if(!tStart)
   tStart   = new Date();

  var   tDate = new Date();
  var   tDiff = tDate.getTime() - tStart.getTime();

  tDate.setTime(tDiff);
  storesecs = tDate.getSeconds();
  timerID = setTimeout("UpdateTimer()", 1000);
  mycounter = storesecs;
  
  if(mycounter==time_change)
   {
    Stop();
    Reset();
    change_url(); 
   }
 }

function Start()
 {
  tStart   = new Date();
  timerID  = setTimeout("UpdateTimer()", 1000);
 }

function Stop() 
 {
  if(timerID) 
   {
    clearTimeout(timerID);
    timerID  = 0;
   }
  tStart = null;
 }

function Reset()
 {
  tStart = null;
 }

function change_url()
 {
  remote.location.href = url_to_go_to;
 }


var remote = null;

function run(url1,url2)
 {
  url_to_go_to = "http://www.gogoshopper.com/search1.shtml?db=default&uid=default&PID=*&Category=---&Company=" + url1 + "&URL=&ShortDescription=&LongDescription=&AddDate=&ExpDate=&keyword=&mh=20&sb=6&so=descend&ww=on&view_records=View+Records";
  time_change = 6;
  remote = window.open('', 'TheRemote');
  if (remote != null)
   {
    if (remote.opener == null)
     {
      remote.opener = self;
     }
    remote.location.href = url2;
	Start(url_to_go_to);
   }
   else
	 {
	   alert("You HAVE A POPUP BLOCKER! To see more coupons, please turn off the Popup Blocker.");
	 }
 }

