/* #############################################################################

© Tesco.com 2008. All rights reserved.

NS:
	TESCODIRECT.lib.Ajax

dependancies:
	TESCODIRECT

History:
	December 2008	-  Tesco.Direct AJAX Functionality
	
############################################################################# */

TESCODIRECT.lib.Ajax = function(URL, queryString, callbackFn) {

    this.VERSION = "1.0.0";
    this.NAME = "TESCODIRECT.lib.Ajax";

    var _xmlHttp;
    var _URL = URL;
    var _request = _URL + (queryString != '' ? '?' + queryString : '');
    var _callbackFn = callbackFn;
    function init() {
        try {
            // Firefox, Opera 8.0+, Safari
            _xmlHttp = new XMLHttpRequest();
        }
        catch (e) {
            // Internet Explorer  
            try {
                _xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e) {
                try {
                    _xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch (e) {
                    _status = null;
                    return;
                }
            }
        }
        _xmlHttp.onreadystatechange = function() {
            if (_xmlHttp.readyState == 4) {
                if (_xmlHttp.status == 200) {
                    _callbackFn(_xmlHttp.responseText);
                }
                else
                    _callbackFn(null);

                _xmlHttp = null;
            }
        }
    }
    this.invoke = function() {
        _xmlHttp.open("GET", _request, true);
        _xmlHttp.send(null);
    }
    init();

}


