/*This is a barebones Ajax library written by Tim Tripcony (http://www.timtripcony.com).*/var Ajax = function() {    var transport; // private variable, will store the request object    var callback; // private variable, will store the function to run against the returned data    var errorHandler; // private variable, will store the function to run if the request fails    try {        transport = new XMLHttpRequest(); // first preference, supported in all major browsers except I.E.    } catch (e) {        try {                        transport = new ActiveXObject('Msxml2.XMLHTTP'); // newer versions of I.E.        } catch (e) {            try {                            transport = new ActiveXObject('Microsoft.XMLHTTP'); // older versions of I.E., last resort            } catch (e) {                alert(e.description); // inform the user their browser doesn't support Ajax            }        }    }    var processStateChange = function() { // private function, runs whenever the request object's state changes        if (transport.readyState === 4) { // indicates the request is completed            if (transport.status === 200) { // indicates the request was successful                if (callback) { // skip if no callback function was defined                    callback(transport); // run the function defined in the options parameter and pass a handle to the request object                }            } else {                if (errorHandler) {                    errorHandler(transport); // run the function defined in the options parameter and pass a handle to the request object                }            }        }    };    transport.onreadystatechange = processStateChange; // bind the private function to all state changes    return { // return an object with public members that still have access to the private members        request: function (options) {            callback = options.onSuccess || null; // if defined, sets the private variable, otherwise replaces undefined with null            errorHandler = options.onFailure || null; // if defined, sets the private variable, otherwise replaces undefined with null            transport.open(options.method || 'GET',options.url,options.async || false); // establish the URL connection            transport.send(options.postData || null); // retrieve the data        }    };}(); // runs the anonymous function and sets the Ajax variable to the returned object// Crockford's object function (http://javascript.crockford.com/prototypal.html)function object (o) {	function F(){}	F.prototype = o;	return new F();}/*The following extends the Google AJAXSLT library (http://code.google.com/p/ajaxslt/).It allows both the XML and the XSL to be retrieved from the server in a single call.*/var Xslt = function() {	var xmlDoc;	var xslDoc;	var onXmlLoaded;	var onXslLoaded;	var NestedAjax = object(Ajax); // allows us to handle a nested Ajax call with a separate object	return {		transform: function (options) {			onXmlLoaded = options.onXmlLoaded || null;			onXslLoaded = options.onXslLoaded || null;			Ajax.request({				method: 'POST',				url: options.xmlUrl,				async: true,				onSuccess: function (xmlObject) {					if (!!onXmlLoaded) {						onXmlLoaded(xmlObject);					}					xmlDoc = xmlParse(xmlObject.responseText);					NestedAjax.request({						method: 'POST',						url: options.xslUrl,						async: true,						onSuccess: function (xslObject) {							if (!!onXslLoaded) {								onXslLoaded(xslObject);							}							xslDoc = xmlParse(xslObject.responseText);							options.callback(xsltProcess(xmlDoc,xslDoc));						}					});									}			});		}	};}();
