/**
 * (c) COPYRIGHT AVIATION SOFTWARE INC. 2003-2011
 */

/**
 * Wrapper ensuring a correct embedded status request initialization
 *
 * @param string url The url to hit
 * @param hash params Arguments for the url
 * @param string target ID of element to target when JSON status snippets are received
 */
top.EmbeddedStatusRequest = EmbeddedStatusRequest = function EmbeddedStatusRequest ( url, params, target ) {
    this.url = url;
    this.params = params || {};
    this.target = target;
    this.params['updaterTarget'] = target;
    this.params['embedded_progress'] = 1;
}

EmbeddedStatusRequest.prototype.send = function () {
    new Ajax.Request( this.url, {
        parameters: this.params,
        onSuccess: function (transport) {
            try{
                top.transport = transport;
                jr = new JSONSnippetReceiver(transport);
                jr.process();
            } catch (e) {
                if (top.debug && top.debug.log) {
                    top.debug.log('Exception caught in EmbeddedStatusRequest: ' + e);
                }
            }
        }
    });

}
