$.ajaxSetup({
    //beforeSend: function () { $.mobile.showPageLoadingMsg(); }, // Show spinner
    //complete: function () { $.mobile.hidePageLoadingMsg(); }, // Hide spinner
    url: config.webServiceURL,
    type: "POST",
    dataType: "json",
    contentType: "application/json; charset=utf-8"
    //    dataType: "xml",
    //    contentType: "application/soap+xml; charset=utf-8"
});

// Fuction for wrapping the ajax calls
var AjaxRequest = function (options) {

    if (!(this instanceof AjaxRequest))
        return new AjaxRequest(name);
    this.requestText = options.data;
    this.functionSuccess = options.success;
    this.functionFail = options.error;
    this.contentType = options.contentType;
    this.url = options.url;

    this.getRequestText = function () {
        return this.requestText;
    }
    this.getFunctionSuccess = function () {
        return this.functionSuccess;
    }
    this.getFunctionFail = function () {
        return this.functionFail;
    }

    this.ExecuteRequest = function () {
        //        console.log('Ajax Request ::  ');
        //        alert("url: ");
        if (defined(this.contentType) && this.contentType != null) {
            $.ajax({

                data: this.requestText,
                success: this.functionSuccess,
                error: this.functionFail,
                contentType: options.contentType,   // is the header sent to the server
                dataType: "xml",                    // is you telling jQuery what kind of response to expect.
            });
        }
        else {
            // this is the default. json communication 
            //debugLogWrite('jsone call');
            $.ajax({
                data: JSON.stringify(this.requestText),
                success: this.functionSuccess,
                error: this.functionFail,
                url: config.webServiceURL + "/" + this.url
            });
        }
    }
    //In order to move this object around in other lists we must declare a function that returns the instance of the object... ishish.... it is unknown how js
    //handles manipulation of the returned object if added to another array for example..
    this.getAjaxRequest = function () {
        return this;
    }
};