  /*
    Code to keep the auction boards up to date
  */
  var hdoc = new openDom();
  var xdoc = hdoc.newXMLHttpRequest();
  var interval=5000;
  function newBoard()
  {
    document.location.href = document.location.href;
  }
  function checkBoard()
  { 
    var bn_element = hdoc.getElementById("boardid");   
    if( bn_element )
    {
      /* Call the web service */
      var xmlURL = "boardstate.cgi?Board=";    
      xmlURL += bn_element.innerHTML;
      xdoc.open( "POST", xmlURL, true ); 
      if(hdoc.isIE)
      {      
        xdoc.onreadystatechange=changeBoard;
        xdoc.send();
      }  
      else
      { 
        xdoc.onload=nchangeBoard;
        xdoc.send(null);        
      }
    }   
  }
  function nchangeBoard()
  {  
    if(xdoc && xdoc.responseXML)
    { // server relief spread - 
      // vary when everbody refreshes - 
      var newtime = Math.round(Math.random()*5000);  
      var nodes = xdoc.responseXML.getElementsByTagName("board");
      var node = nodes[0];
      var progStat = hdoc.XMLAttribute(node,"progStatus").value;
      var stat = hdoc.XMLAttribute(node,"status").value;
      if( progStat=="30" ) // Auction_Board_Bid_War
      {
        stat += "&nbsp; Time Left: ";
        stat += hdoc.XMLAttribute(node,"timeleft").value; 
      }
      else if( progStat=="40") // Auction_Board_Sold
      {
        // refresh with random time spread for server relief
        window.setTimeout("newBoard()",newtime);
        hdoc.getElementById("status").innerHTML="<span style='color:red;'>SOLD</span>";
        return;        
      }    
      if(hdoc.getElementById("status").innerHTML!=stat)
      {
        // The status just changed, if it went to Active, we want to refresh
        if( progStat=="10") // Auction_Board_Set (Active)
        {
          // simply refresh
          window.setTimeout("newBoard()",newtime);
          return;          
        }  
        hdoc.getElementById("status").innerHTML=stat;
      }  
      changeBids();
    }
    window.setTimeout("checkBoard()",interval);     
  } 
  function changeBoard()
  { // MSIE only logic   
    if(xdoc && xdoc.readyState == 4) 
    {     
      nchangeBoard();
    }    
  }  
  function changeBids()
  {
    var nodes = xdoc.responseXML.getElementsByTagName("item");    
    var newBids = false;
    for(i=0;i<nodes.length;i++) // > fool kate
    {
      var node = nodes[i];
      var id = "amt" + hdoc.XMLAttribute(node,"id").value;                 
      var item = hdoc.getElementById(id);      
      if( item )
      {
        var nprice = hdoc.XMLAttribute(node,"value").value;
        if( item.innerHTML!=nprice )
        { item.innerHTML=nprice;
          newBids = true;
          item.style.fontWeight="bolder";
          showImage( item );
        }
        else
        {
          item.style.fontWeight="normal";
        }
      }
    }
    if( newBids == true )
    {
      //  set the timer for ? seconds
      interval=6000; 
      hdoc.getElementById("itm_bidded").style.display="block";    
    }
    else
    {
      interval=5000;
      hideImage();
    }
  }
  function startRefresh()
  {
    if( ! allDone ) // global indicator for SOLD board
    { // once per second...
      window.setTimeout("checkBoard()",interval);       
    }
    else
    { // show sold board for 3 seconds
      window.setTimeout("newBoard()",6000);
    }  
  }
  function hideImage()
  { var imgNode = hdoc.getElementById("itm_bidded");
    if( imgNode )
    {
      imgNode.style.display="none";
    }
  }
  function showImage( node )
  { var imgNode = hdoc.getElementById("itm_bidded");
    if( imgNode && node )
    { var top=hdoc.getY(node)-50;
      var left=hdoc.getX(node)+20;
      hdoc.setPosition( "itm_bidded", left, top );
      imgNode.style.display="block";
    }
  }
