if (typeof this['vuit_defined'] == 'undefined')
{
    // this is to disable parsing all widgets in the entire HTML document
    //This is required for Mac Safari which gives "Maximum call stack size exceeded" error
    vuitConfig = {
        parseWidgets: false, searchIds: []

    };
    document.write("<script type='text/javascript' src='/vgn-ext-templating/hcc/js/vuit.js'><" + "/script>")
    vuit_defined = true;
}

var VignettePortal = new Object();

VignettePortal.AJAXClient = function() {


}

VignettePortal.AJAXClient.prototype = {

// sends the data to the URL in AJAX style and invokes the callback method
    sendURL :  function(url, callbackMethod) {

        vuit.io.bind({
            url: url,
            handler: vuit.lang.hitch(this, function(type, data, evt) {

                this.processResponse(type, data, evt, callbackMethod);

            })
        });
        return false;
    },


// sends the form data to the Action URL of the Form in AJAX style and
//invokes the callback method
    sendForm : function(formNodeValue, callbackMethod) {

        vuit.io.bind({
            formNode: formNodeValue,
            handler: vuit.lang.hitch(this, function(type, data, evt) {

                this.processResponse(type, data, evt, callbackMethod);

            })
        });

        return false;
    },

// posts the multipart form data to the Action URL of the Form in AJAX style and
//invokes the callback method

    sendMultiPartForm : function(formNodeValue, callbackMethod, responseMimeType) {

        if (responseMimeType == null)
            responseMimeType = "text/plain";

        vuit.io.bind({
            formNode: formNodeValue,
            mimetype: responseMimeType,
            handler: vuit.lang.hitch(this, function(type, data, evt) {

                this.processMultiPartResponse(type, data, evt, callbackMethod);

            })
        });
        return false;
    },

// handles AJAX response by doing some preliminary error handling

    processResponse : function (type, data, evt, callback) {

	callback(evt);
	/*	
        var isValidResponse = evt.getResponseHeader("X-Vignette-RespondedWith");

        if (isValidResponse != "AJAX") {
            // If the response is not valid (i.e., timeout, error), display it in the cuurent window
            window.document.body.innerHTML = evt.responseText;
            return;
        }
        else {
            callback(evt);
        }
	*/

    },

    // handles Multipart response

    processMultiPartResponse : function (type, data, evt, callback) {

        callback(data);

    }


};
