function ajax_connect() {

    var xmlHttp;

	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();

	} catch (e) {    // Internet Explorer
		try
		{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try
	        {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				return false;
			}
		}
	}

	return xmlHttp;

}

function ajax_request(xmlHttp, server_file, function_name) {

	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState  == 4) {
			if(xmlHttp.status  == 200) {

				eval(function_name + "('" + xmlHttp.responseText + "')");

			} else {
				//error
			}
		}
	};


   xmlHttp.open("POST", server_file, true);
   xmlHttp.send(null);

}

function sleep(naptime){

	naptime = naptime * 1000;
	var sleeping = true;
	var now = new Date();
	var alarm;
	var startingMSeconds = now.getTime();
	alert("starting nap at timestamp: " + startingMSeconds + "\nWill sleep for: " + naptime + " ms");

	while(sleeping){

		alarm = new Date();
		alarmMSeconds = alarm.getTime();

		if(alarmMSeconds - startingMSeconds > naptime){

			sleeping = false;

		}

	}

	alert("Wakeup!");

}