function WContainer76_Service()
{
    this.is_clear_queue = true;
    this.call_control = null;
    this.call_type = null;
    this.cancel_types = null; //array of strings
    this.is_canceled = false;
}


/*WContainer76_Service.prototype.clear_queue = function(queue)
{
    if (!this.is_clear_queue || !queue || queue.length < 1) return;
    var i = 0;
    while (i < queue.length)
    {
        var qs = queue[i].queue_service;
        if ((!this.call_control && !this.cancel_types) 
        || (qs && (qs.call_control == this.call_control || this.is_exists(qs.type, this.cancel_types)))
        )
            if (!this.delete_item(queue, qs, i)) i++;
        else
            i++;
    }
}*/


WContainer76_Service.prototype.clear_queue = function(queue)
{
    if (!this.is_clear_queue || !queue || queue.length < 1) return;
    var i = 0;
    while (i < queue.length)
    {
        var qs = queue[i].queue_service;
        if ((!this.call_control && !this.cancel_types) 
        || (qs && (qs.call_control == this.call_control || this.is_exists(qs.type, this.cancel_types))))
            this.delete_item(queue, qs, i);
        
        i++;
    }
}

WContainer76_Service.prototype.is_exists = function(type, types)
{
    if (!types) return false;
    for(var i = 0; i < types.length; i++)
        if (types[i] == type)
            return true;
    return false;
}

WContainer76_Service.prototype.delete_item = function(queue, qs, index)
{
    if (index != 0)
    {
        AddLog('Delete queue item', 1);
        queue.splice(i, i);  //SNV???????
        return true;
    }
    var c = null;
    if (!qs)
    {
        AddLog('create WContainer76_Service for queue item', 1);
        c = new WContainer76_Service();
        c.call_control = this;
        queue[index].queue_service = c;
    }
    else
        c = qs;
    AddLog('Set is_canceled indicator for queue item', 1);
    c.is_canceled = true;
    return false;
}
