mdvLib.ajax = function(optionsObj) {
	
	var options, lib, method, params, sendRequest, appendToSendOptions, defaultAjaxRequest, sendOptions = {};
	
	// define matching values for optionsObj 
	var jquery = {
		host: 'url',
		method: 'type',
		asynchronous: 'async',
		contentType: 'contentType',
		encoding: 'scriptCharset',
		parameters: 'data',
		onComplete: 'complete',
		onFailure: 'error',
		onSuccess: 'success'
	};
	
	// define matching MOOTOOLS values for optionsObj 
	var moo = {
		host: 'url',
		method: 'method',
		asynchronous: 'async',
		contentType: 'urlEncoded',
		encoding: 'encoding',
		parameters: 'data',
		onComplete: 'onComplete',
		onFailure: 'onFailure',
		onSuccess: 'onSuccess',
		request: null
	};
	
	options = optionsObj || null;
	
	// host is mandatory
	if (!options || options.host === undefined) {
		return null;	
	}
	
	lib = (typeof Prototype !== 'undefined' && Prototype.Version) ? 'PROTOTYPE' : 
			  (typeof jQuery !== 'undefined' && jQuery.fn) ? 'JQUERY' : 
			    (typeof MooTools !== 'undefined' && MooTools.version) ? 'MOOTOOLS' : 
			    	null;
	
	method = options.method || 'post';
	method = method.toLowerCase();
	params = options.parameters || '';
	
	appendToSendOptions = function(obj, exclude) {
		
		var p, q;
		
		for (p in obj) {
			if (obj.hasOwnProperty(p) && (!exclude || exclude[p] !== true)) {
				q = lib === 'PROTOTYPE' ? p : 
					lib === 'JQUERY' ? jquery[p] || p : 
					lib === 'MOOTOOLS' ? moo[p] : p;
				sendOptions[q] = obj[p];
			}
		} 
	};
	
	sendRequest = function() {
		
		switch(lib) {
			
			case 'PROTOTYPE':	// parameters need special treatment
								params = $H(params);
		 						params = params.toQueryString();
		 						sendOptions.parameters = params;
		 						
		 						// method also goes separately
		 						// as it is not mandatory in the options argument 
		 						sendOptions.method = method;
		 						
		 						//append all other options members
		 						appendToSendOptions(options, { host: true, parameters: true }); 
		 						// fire request and return an object reference
		 						return new Ajax.Request(options.host, sendOptions);
		 						
								
			case 'JQUERY':		// jquery handles params format by itself, so append the whole lot
								appendToSendOptions(options);
								if (sendOptions.method === undefined) {
									// jquery defaults to GET. switch it to POST if no method is specified.
									sendOptions.type = method;
								}
                                
								return jq.ajax(sendOptions); //defaultAjaxRequest(sendOptions);

			case 'MOOTOOLS':	appendToSendOptions(options, { parameters: true });
								// parameters need special treatment
								if (params !== '') {
									params = new Hash(params);
									params = params.toQueryString();
								}
								moo.request = new Request(sendOptions);
								return moo.request.send(params);
								
			default: 			// own implementation of AJAX goes here
								return defaultAjaxRequest(params);
		}
	};
    
    
    
    defaultAjaxRequest = function(params) {
        
        var requester;
        
        try
        {
            requester = new XMLHttpRequest();
        }
        catch (error)
        {
            try
            {
                requester = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (error)
            {
                requester = null;
            }
        }

        if (requester != null)
        {
            requester.onreadystatechange = function()
            {
                if (requester.readyState == 4)
                {
                    if (requester.status == 200 || requester.status == 304)
                    {
                        //alert(requester.getAllResponseHeaders());
                        debugger;
                        //success(requester);
                    }
                    else
                    {
                        //failure(requester);
                    }
                }

                return true;
            };
            
            requester.open("GET", params);
            requester.send(null);
        }
        else
        {
            return false;
        }

        return true;
    };
    
	
	return sendRequest();
	
};