//NOTE: If there are problems with the script hanging, may want//      to use XMLHttpRequest asynchronously (the last parameter//      of pageRequest.open would be true)//      This would require using the onreadystatechange event//      e.g. pageRequest.onreadystatechange  = DisplayAd//      where DisplayAd would now handle changing the innerHTML of the divfunction HttpRequest(url){var pageRequest = false //variable to hold ajax object/*@cc_on   @if (@_jscript_version >= 5)      try {      pageRequest = new ActiveXObject("Msxml2.XMLHTTP")      }      catch (e){         try {         pageRequest = new ActiveXObject("Microsoft.XMLHTTP")         }         catch (e2){         pageRequest = false         }      }   @end@*/if (!pageRequest && typeof XMLHttpRequest != 'undefined')   pageRequest = new XMLHttpRequest()if (pageRequest){ //if pageRequest is not false   pageRequest.open('GET', url, false) //get page synchronously    pageRequest.send(null)   if (window.location.href.indexOf("http")==-1 || pageRequest.status==200)     return pageRequest.responseText   }   return 'Failed to retrieve dynamic content';}var intervalID;var adId = 0;var adCount = 0;var divID;var zone="today";function startRotator(adDivID,adZone){  divID = adDivID;  zone = adZone;    RefreshAd(1); //start up ad rotator with a random ad    //cgi page contains two hidden divs so the script knows  //1) the number of ads in the database  //2) the starting ad (that was chosen randomly by the cgi script)  elem = document.getElementById("adCountDiv");  adCount = parseInt(unescape(elem.innerHTML));  elem = document.getElementById("curAdDiv");  adId = parseInt(unescape(elem.innerHTML))+1;    //use setInterval to refresh the ad every 7 seconds  intervalID = setInterval('RefreshAd(0)',7000);}function prevAd(){  clearInterval(intervalID);    //since RefreshAd increments adId after displaying,  //the id of the currently displayed ad is one less than adId  //so we need to decrement adId by two in order to go to the last displayed ad  adId = adId-2;    RefreshAd(0); //do refresh now  intervalID = setInterval('RefreshAd(0)',7000);}function nextAd(){  clearInterval(intervalID);    //no increment needed (already done at the end of RefreshAd)  RefreshAd(0);    intervalID = setInterval('RefreshAd(0)',7000);}function RefreshAd(randAd){  elem = document.getElementById(divID);    //make sure we have the right domain  //HttpRequest won't work for a different domain, and it  //thinks http://www.site.com is different than http://site.com   var mydomain="http://"+window.location.hostname;    if (adId>=adCount)    adId = 0; //start at the first ad  else if (adId<0)    adId = adCount-1; //go to the last ad      if (randAd==0) //get the next ad in sequence  {     elem.innerHTML = HttpRequest(mydomain+"/longviewkelso/cgi-bin/ads/ads-new.cgi?zone="+zone+"&width=170&height=180&ad="+adId+"&action=showsads");  }  else //generate a random ad  {    elem.innerHTML = HttpRequest(mydomain+"/longviewkelso/cgi-bin/ads/ads-new.cgi?zone="+zone+"&width=170&height=180&action=showsads");  }  adId = adId+1; }