function createXHR( )
{
    try { return new XMLHttpRequest( ); } catch(e) {}
    try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e) {}
    try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (e) {}
    try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
    try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
    return null; // no XHR support
}

function addEvent(elem, evt, func, cap)
{

	if(elem.attachEvent)
	{
		//if this evaluates to true, we are working with IE so we use IE's code.
		elem.attachEvent('on'+evt, func);
	} else {
		//the statement has evaluated to false, so we are not in IE/
		//the capture argument is optional. If it's left out, we set it to false:
		if(!cap) cap = false;
		//and use the normal code to add our event.
		elem.addEventListener(evt, func, cap);
	}
}

var xhr = null;

function handleOptions(){
	if(xhr.readyState != 4){return;}
	var response = xhr.responseText;
	var selectEl = document.getElementById("day-select");
	selectEl.innerHTML = response;
}

function loadOptions(){
	xhr = createXHR();
	xhr.open('GET','home_times.php',true);
	xhr.onreadystatechange = handleOptions; 
	xhr.send(null);
}

addEvent(window,'load',loadOptions);

