var url="/dvp/raven/ajax/a-bf.asp";
var http = getHTTPObject();
var LastStatus = 0;

function handleHttpResponse() {
	// 4 is the signal for finished
  if (http.readyState == 4) {


		var results = http.responseText.split(";:;"); 
		var fname=document.getElementById( 'AJUPD' );
		fname.innerHTML = results[0]; 
		statuscheck(results[1])

  }
}

function statuscheck(newstatus){
		//alert(parent.frames['navig'].Menu3[0])

// no change
	if (newstatus == LastStatus){LastStatus = newstatus;}
	//Server goes offline
	if (newstatus == 0 && LastStatus == 1){
		parent.frames['navig'].location.href='/frames/Left-Frame.asp';
		LastStatus = newstatus;
	}
	//Server goes online
	if (newstatus == 1 && LastStatus == 0){
		parent.frames['navig'].location.href='/frames/Left-Frame.asp';
		LastStatus = newstatus;
	}
}


function performLookup()
{
http.open("GET", url , true);

http.onreadystatechange = handleHttpResponse;

http.send(null);
}


function showud() {
//show when uppdating

    var loading = '<div style="position:absolute; right:5px; bottom:5px;"><img src="/loading_pic.gif"></div>'

		var fname=document.getElementById( 'AJUPD' );
		fname.innerHTML = fname.innerHTML+loading


}
/* This method is pretty much standard AJAX, you'll see it 
everywhere. The curious can read into its details, the rest of
you can just know that this gives you a HTTP object */

function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}

var timer1

/* kod för att uppdatera en ram med intervall */
function uppdateraAJ() 
{ 

performLookup();
timer1 = setTimeout("uppdateraAJ()", 5000); 

} 
