/**
* tekMessage contiene un mensaje
*
*/

    function tekMessage(num, command, object, products, tags, noTags){
        this.Num    = num;
        this.Command = command;
        this.Object = object;
        this.Products = products;
        this.Tags   = tags;
        this.NoTags = noTags;
    }

/**
* TM_send es la función de envío del envelope
*
*/
    function TM_send(sUser, sPasswordHash, sSystem_id, sEnvelopeNum, sLanguage, CallBackFunction){

        var params = 'u=' + sUser + '&p=' + sPasswordHash + '&s=' + sSystem_id + '&e=' + sEnvelopeNum + '&l=' + sLanguage + '&m=' + this.Messages.toJSON();

        if(this.Debug == true){
            trace('<b>ENVELOPE SENT</b><br>' + params);
        }

        var myAjax = new Ajax.Request(
            this.URL,
            {
                method: 'POST',
                parameters: params,
                onComplete: CallBackFunction
            });
    }

/**
* TM_get es la función de recepción del envelope
*
*/
    function TM_get(request){
        var sResponseText = '';
        var sResponseText = String(request.responseText);

        if(this.Debug == true){
            trace('<b>ENVELOPE RECEIVED</b><br>' + sResponseText);
        }
        var aResponse = sResponseText.split('|-|');

        aResponse[1] = aResponse[1].evalJSON();

        return(aResponse);
    }


/**
* tekEnvelope es el objeto de envelope
*
*/
    function tekEnvelope(QueryURL){
        this.URL    = QueryURL;
        this.Debug  = false;
        this.Send   = TM_send;
        this.Get    = TM_get;
        this.Messages = new Array();
    }

