function loadFragmentInToElement(fragment_url, element_id) {
	var element = document.getElementById(element_id);
	//element.innerHTML = '<p><em>Loading ...</em></p>';
	xmlhttp.open("GET", fragment_url);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			element.innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
} 

function addLoadEvent(func) {
/*cribbed from http://simon.incutio.com/archive/2004/05/26/addLoadEvent*/
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function radiobox() {
	if (document.getElementById("radiobox")) {
		setTimeout("setradiobox()",1000);
	}
}

function setradiobox() {
	loadFragmentInToElement("/radio_frame.php", "radiobox_content");
	setTimeout("setradiobox()",10000);
}
 
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  xmlhttp = new XMLHttpRequest();
}

addLoadEvent(radiobox);

/* JavaScript functions for Advent Calendar */

function sndReq(dayno, obj)
{
	xmlhttp.open('get', 'getpoem.php?dayno='+dayno);
	xmlhttp.onreadystatechange = handleResponse;
	xmlhttp.send(null);

	obj.className="seen" + dayno;
	obj.innerHTML = "";
}

function handleResponse()
{
	if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
	{
		var response = xmlhttp.responseText;
		document.getElementById('poemcontent').innerHTML = response;
		document.getElementById('poemcontent').style.visibility = "visible";
	}
}

function hideWork()
{
		document.getElementById('poemcontent').style.visibility = "hidden";
		document.getElementById('calendar').focus();
}	