<!--

/* Send AJAX GET request, with callback function if needed */
function ajaxRequest(url,callback) {
		
	if (window.XMLHttpRequest) {
		httpGetObj = new XMLHttpRequest();
	} else {
		httpGetObj = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	httpGetObj.open("GET",url,true);
	httpGetObj.onreadystatechange = function() {
		if (httpGetObj.readyState == 4) {
			eval(callback+'(\''+httpGetObj.responseText+'\')');
			return;
		}
	};

	httpGetObj.send(null);
		
}



/* Takes an XML string of Site Manager content and renders the page */
function loadSiteManagerContentFromURL(url) {

	//Show loading graphic
	siteManagerLoading(1);

	if (window.XMLHttpRequest) {
		httpGetObj = new XMLHttpRequest();
	} else {
		httpGetObj = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	httpGetObj.open("GET",url,true);
	httpGetObj.onreadystatechange = function() {
		if (httpGetObj.readyState == 4) {
					
			xmlObject = httpGetObj.responseXML;

			root = xmlObject.getElementsByTagName('SiteManager')[0];
			page = root.getElementsByTagName('Page')[0];
			
			title = page.getElementsByTagName('Title')[0].firstChild.nodeValue;
			content = page.getElementsByTagName('Content')[0].firstChild.nodeValue;
						
			pagePhotoList = page.getElementsByTagName('PagePhoto');
			pagePhotoDetail = new Array();
			for (i=0;i<pagePhotoList.length;i++) {
				pagePhotoDetail[i] = new Array();
				if (pagePhotoList[i].getElementsByTagName('URL')[0].firstChild) {
					pagePhotoDetail[i]['URL'] = pagePhotoList[i].getElementsByTagName('URL')[0].firstChild.nodeValue;
					if (pagePhotoList[i].getElementsByTagName('AltText')[0].firstChild) {
						pagePhotoDetail[i]['AltText'] = pagePhotoList[i].getElementsByTagName('AltText')[0].firstChild.nodeValue;
					}
				}
			}
						
			siteManagerLoading(0);


			//display title
			renderTitle(title);
			
			//display content
			renderContent(content);
			
			//display page photos
			if (pagePhotoDetail.length>0) { 
				renderPagePhotos(pagePhotoDetail);
			}
			
		}
	};

	httpGetObj.send(null);

}


function loadPage(pageid) {

	url = 'ajaxContent.php?pageid='+pageid;
	loadSiteManagerContentFromURL(url);
	
}


//-->