// Standard AJAX lib

function getXMLHTTPRequest () {
	try {
		req = new XMLHttpRequest ();
	} catch (err1) {
		try {
			req = new ActiveXObject ("Msxml2.XMLHTTP");
		} catch (err2) {
			try {
				req = new ActiveXObject ("Microsoft.XMLHTTP");
			} catch (err3) {
				req = false;
			} 
		} 
	}
	return req;
}

function useHttpResponse (http, divid) {
	if (http.readyState == 4) {
		if (http.status == 200) {
			document.getElementById (divid).innerHTML = http.responseText;
		} else {
			document.getElementById (divid).innerHTML = '<p>useHttpResponse: AJAX request fatal error: ' + http.status + ' updating ' + divid + '</p>';
		}
	}
}

// Site-specific functions

function reloadMyday (action, id) {
	var http = getXMLHTTPRequest ();
	var actionurl = 'components/content_planyourday_myday.php?act=' + action + '&ev=' + id;
	randno = parseInt (Math.random () * 999999999999999);
	var modurl = actionurl + "&rand=" + randno;
	http.open ("GET", modurl, true);
	http.onreadystatechange = function () {
			useHttpResponse (http, 'myday');
		}
	http.send (null);
}
function photoVote (photoid) {
	var http = getXMLHTTPRequest ();
	var actionurl = 'components/content_albumvote.php?id=' + photoid;
	randno = parseInt (Math.random () * 999999999999999);
	var modurl = actionurl + "&rand=" + randno;
	http.open ("GET", modurl, true);
	http.onreadystatechange = function () {
			useHttpResponse (http, 'photovotebutton' + photoid);
		}
	http.send (null);
}
