function createXMLHttpRequest() {
	try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
	try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
	try { return new XMLHttpRequest(); } catch (e) {}
	alert("XMLHttpRequest not supported");
	return null;
}

function $(id) {
	return document.getElementById(id);
}

function getFullStory(id, image_id, thumb, model_image) {
	var xhr = createXMLHttpRequest();
	xhr.open("GET", "articles/"+id+"_full.php", true);
	xhr.onreadystatechange = function() {
		if (xhr.readyState != 4) { return; }
		$(id).innerHTML = xhr.responseText;
		$(id).innerHTML += '<p><a onClick="collapseStory(\''+id+'\', \''+image_id+'\', \''+thumb+'\', \''+model_image+'\');" href="javascript:void(0);" style="color: #00f;">[Collapse Story]</a></p>';
		
		$(image_id).src = model_image;
	}
	xhr.send(null);
}
			
function collapseStory(id, image_id, thumb, model_image) {
	var xhr = createXMLHttpRequest();
	xhr.open("GET", "articles/"+id+".php", true);
	xhr.onreadystatechange = function() {
		if (xhr.readyState != 4) { return; }
		$(id).innerHTML = xhr.responseText;
		$(id).innerHTML += '<a onclick="getFullStory(\''+id+'\', \''+image_id+'\', \''+thumb+'\', \''+model_image+'\');" href="javascript:void(0);" style="color: #00f;">[Full Story]</a></p>';
		
		$(image_id).src = thumb;
	}
	xhr.send(null);	
}
			


