/******************************************************************************

	This code based on example code found at
	http://www.boutell.com/newfaq/creating/include.html, with some
	modifications.  It works with Firefox, Safari, and IE 5+.  So
	saith a notice at the bottom of that page:

		Legal Note: yes, you may use sample HTML, Javascript, PHP and
		other code presented above in your own projects. You may not
		reproduce large portions of the text of the article without
		our express permission.

	Modification: Boutell's code requires a div to be inserted before
	calling this function.  This one doesn't.

	Caveat: <style> elements within the include files won't work.

******************************************************************************/

function clientSideInclude(url) {
	var req = false;
	if (window.XMLHttpRequest) {
		// For Safari, Firefox, and other non-MS browsers
		try {
			req = new XMLHttpRequest();
		} catch (e) {
			req = false;
		}
	} else if (window.ActiveXObject) {
		// For Internet Explorer on Windows
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				req = false;
			}
		}
	}
	if (req) {
		// Synchronous request, wait till we have it all
		req.open('GET', url, false);
		var failure = false;
		try {
			req.send(null);
		} catch (e) {
			failure = true;
		}
		if (!failure) {
			document.write("<div class='includedViaClientSideInclude'>");
			document.write(req.responseText);
			document.write("</div>");
		}
	} else {
		/* compatibility warning */
		//	element.innerHTML =
		//		"Sorry, your browser does not support " +
		//		"XMLHTTPRequest objects. This page requires " +
		//		"Internet Explorer 5 or better for Windows, " +
		//		"or Firefox for any system, or Safari. Other " +
		//		"compatible browsers may also exist.";
	}
}

