
var baseurl = "http://"+top.location.host+"/admin/";
var request = null;

////////////////////////////////////////////////////////////////////////////////
function getBlogInfo(id){
	var fieldval;
	
	// get the date
	var url = baseurl+"/admin.php?func=getbloginfo&id="+id+"&field=entrydate";	
	fieldval = ajaxFunc(url, false, null);
	document.getElementById('blogdate').innerHTML = fieldval;
	
	// get the title
	url = baseurl+"/admin.php?func=getbloginfo&id="+id+"&field=title";	
	fieldval = ajaxFunc(url, false, null);
	document.getElementById('blogtitle').innerHTML = fieldval;
		
	// get the body
	url = baseurl+"/admin.php?func=getbloginfo&id="+id+"&field=body";	
	fieldval = ajaxFunc(url, false, null);
	document.getElementById('blogbody').innerHTML = fieldval;
}


////////////////////////////////////////////////////////////////////////////////
// Generic AJAX function invoker - takes the url of the AJAX function to call 
// and the function to use as a callback when the AJAX call returns
////////////////////////////////////////////////////////////////////////////////
function ajaxFunc(url, async, notifyFunction) {	

  request = createXMLHttp();

  try{
    request.open('GET', url, async);

    // if async is true, register the UI event handler
    if(async == true){
      request.onreadystatechange=notifyFunction;
      request.send(null);    
    }
    // otherwise, await and return the response
    else{
      request.send(null);    
      if(request.readyState == 4 && request.status == 200){
		return request.responseText;
      }
    }
  }
  catch(ex){
    alert(ex);
  }
}


function createXMLHttp() {
  if (typeof XMLHttpRequest != "undefined") {
    return new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    var aVersions = ["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0",
		     "Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0", 
		     "Msxml2.XMLHTTP.2.6","Microsoft.XMLHTTP.1.0", 
		     "Microsoft.XMLHTTP.1","Microsoft.XMLHTTP"];

    for (var i = 0; i < aVersions.length; i++) {
      try {
	var oXmlHttp = new ActiveXObject(aVersions[i]);
	return oXmlHttp;
      } catch (oError) {
	//Do nothing
      }
    }
  }
  throw new Error("XMLHttp object could be created.");
}

