// -- Generic ajax functions --------------------------------------------------
function createXMLHttpRequest( ){
  try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
  try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
  try { return new XMLHttpRequest( ); } catch(e) {}
  alert("XMLHttpRequest not supported");
  return null;
}

function $(id) {
  return document.getElementById(id);
}

function refreshNews( ){
	//alert ("refreshing news");
  var xhr = createXMLHttpRequest( );
  xhr.onreadystatechange = function( ){
    // check for response complete
    if (xhr.readyState==4) { 
      // check status for HTTP OK
      if (xhr.status==200){
      	//alert (xhr.responseText);
        $("zp_news").innerHTML = xhr.responseText;
        //$("zp_news").innerHTML += "ajax<br>" + now.toLocaleString();
        xhr="";
      }
      else{
        alert("Message returned, but with error status.");
      }
    }
  }
  // use POST and not GET to avoid caching of the XMLHttpRequest
  xhr.open("POST", "ynews_ajax.php", true);
  xhr.send(null);
}

function initNews () {
   refreshNews();
   window.setInterval("refreshNews()", 5000); 
}
