var xhrA = false;
function makeRequest(url){
	if(window.XMLHttpRequest){
		xhrA = new XMLHttpRequest();
	} else {
		if(window.ActiveXObject){
			try {
				xhrA = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {}
		}
	}
	if(xhrA) {
		xhrA.onreadystatechange = showContents;
		xhrA.open("GET", url, true);
		xhrA.send(null);
		
	} else {
		alert('nope, cannot get that XML');
	}
}

function showContents(){
	if(xhrA.readyState == 4){
		if(xhrA.status == 200){
					function removeWhiteSpace(root) {
						var i = 0;
						while (i != root.childNodes.length) {
							if (root.childNodes[i].nodeType == 3) {
							root.removeChild(root.childNodes[i])
							} else {
								var j = 0;
								while (j != root.childNodes[i].childNodes.length) {
									if (root.childNodes[i].childNodes[j].nodeType == 3) {
									root.childNodes[i].removeChild(root.childNodes[i].childNodes[j])
									} else {
									j++;
									}
								}
								i++;
							}
						}
						return root;
					}
					var xml = removeWhiteSpace(xhrA.responseXML.documentElement);
					
					var contentIndex = $('.contentIndex');
					if(contentIndex.length > 0){
						var allProjects = xml.getElementsByTagName("project"); 
						displayThumbs(allProjects);
					}
					var contentNews = $('.contentNews');
					if(contentNews.length > 0){
						var allNews = xml.getElementsByTagName("newsItem"); 
						displayNews(allNews);
					}
					var contentProfile = $('.contentProfile');
					if(contentProfile.length > 0){
						var allProfile = xml; 
						displayProfile(allProfile);
					}
					
					
		} else {
			alert('problem with xml request');  
		}
	}
}
