function QuickList(nameListCount, titleAdd, titleRemove)
{
    this.pListCount = nameListCount;
    this.CookieName = "ql";
    this.st0 = 'pls0';
    this.st0_ = 'pls0_';
    this.st1 = 'pls1';
    this.st1_ = 'pls1_';
    this.st2 = 'pls2';
    this.st2_ = 'pls2_';
    this.std0 = 'dim_1';
    this.std0_ = 'dim_1_';
    this.std1 = 'dim_4';
    this.std1_ = 'dim_4_';
    this.std2='dim_2';
    this.std2_='dim_2_';
    this._d = '_d';
    this.plid = null;
    this.titleAdd = titleAdd;
    this.titleRemove = titleRemove;
    var list = this.Get();
    this.counter = list == null ? 0 : list.split(',').length;
}
QuickList.prototype.Get = function()
{
    var cookies = document.cookie.split('; ');
    for (var i = 0; i < cookies.length; i++) 
    {
        var pair = cookies[i].split('=');
        if((pair[0] == this.CookieName) && (pair[1] != null) && (pair[1] != "Undefined") && (pair[1].length > 0))
            return pair[1];
    }
    return null;
}
QuickList.prototype.Count = function(){return this.counter;}
QuickList.prototype.Set = function(value)
{
    var date = new Date();
    var days = 7;
    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
    var expires = "; expires=" + date.toGMTString();
    document.cookie = this.CookieName + "=" + value + expires + "; path=/";
}
QuickList.prototype.AddRemove = function(id, nowPlay, hs)
{
    var list = this.Get();
    var f = false;
    if(list == null)
    {
        list = id;
        f = true;
    }
    else
    {
        var i = list.indexOf(id);
        if(i < 0)
        {
            list += "," + id;
            f = true;
        }
        else if(i == 0)
            list = list.substr(id.length + 1);
        else if(i + id.length == list.length)
            list = list.substr(0, i - 1);
        else
            list = list.substr(0, i - 1) + list.substr(i + id.length);
    }

    this.Set(list);
    this.UpdateHeader();
}
QuickList.prototype.Remove = function(id)
{
    var list = this.Get();
    if((list != null) && (list.indexOf(id) >= 0))
    {
        var a = list.split(',');
        var i = 0;
        while(a[i] != id) 
            i++;
        a.splice(i, 1);
        this.Set(a.join(','));
    }
}
QuickList.prototype.BatchRemove = function(ids){}
QuickList.prototype.Swap = function(id, place)
{
    var list = this.Get();
    if((list != null) && (list.indexOf(id) >= 0))
    {
        var a = list.split(',');
        var i = 0;
        while(a[i] != id)
            i++;
        var a3 = a.splice(i, 1);
        var a1 = a.slice(0, place);
        var a2 = a.slice(place);
        this.Set(a1.concat(a3, a2).join(','));
    }
}
QuickList.prototype.SetStyle = function(id,flag,nowPlay,hs){
    if(flag)
    { 
        $(id).className = this.st1;
        if(nowPlay == null || nowPlay == false)
        {
            if($(id + '_d') != null && $(id + '_d') != 'undefined')
                $(id + '_d').className = this.std1;
        }
        else if($(id + '_d') != null && $(id + '_d') != 'undefined')
            $(id + '_d').className = this.std1_;
    }
    else
    {
        $(id).className = this.st0; 
        
        if(hs != null) if($(id + '_d') != null && $(id + '_d') != 'undefined')
            $(id + '_d').className = this.std2_;
        else if($(id + '_d') != null && $(id + '_d') != 'undefined')
            $(id + '_d').className = this.std0_;
    }
}
QuickList.prototype.UpdateHeader = function() {
    var list = this.Get();
    this.counter = (list != null && list != 'undefined') ? list.split(',').length : 0;
    if(this.counter >= 0)
    {
        if($(this.pListCount).innerText != 'undefined' && $(this.pListCount).innerText != null)
            $(this.pListCount).innerText = this.counter;
        else 
            $(this.pListCount).textContent = this.counter;
    }
}
QuickList.prototype.SwitchPlsTitle =  function(id, flag)
{
    if(flag && $(id + '_d') != null && $(id + '_d') != 'undefined')
        $(id + '_d').title = this.titleRemove;
    else if($(id + '_d') != null && $(id + '_d') != 'undefined')
        $(id + '_d').title = this.titleAdd;
}
QuickList.prototype.AddEvnt = function(obj, evnt, fnc, f){
    if (!f)
        f=false;
    if (obj.addEventListener)
    {
        obj.addEventListener(evnt,fnc,f);
        return true;
    }
    else if (obj.attachEvent)
        obj.attachEvent('on'+evnt,fnc);
    else
        obj.eval('on'+evnt) = fnc;
}
QuickList.prototype.GetOnClassName = function(id,hs)
{
    var list = this.Get();
    return list == null || list.indexOf(id) < 0 ? hs != null ? this.std2_ : this.std0_ : this.std1_;
}
QuickList.prototype.GetOffClassName = function(id, nowPlay,hs)
{
    var list = this.Get();

    if(nowPlay == null || nowPlay == false)
        return list == null || list.indexOf(id) < 0 ? hs!=null ? this.std2 : this.std0 : this.std1;
    else 
        return list == null || list.indexOf(id) < 0 ? hs!=null ? this.std2 : this.std0_  : this.std1_;
}
QuickList.prototype.GetOnPlsClassName = function(id,hs)
{    
    var list = this.Get();
    return list == null || list.indexOf(id) < 0 ? hs != null ? this.st2_ : this.st0_ : this.st1_;
}
QuickList.prototype.GetOffPlsClassName = function(id, nowPlay,hs)
{
    var list = this.Get();

    if(nowPlay == null || nowPlay == false)
        return list == null || list.indexOf(id) < 0 ? hs!=null ? this.st2 : this.st0 : this.st1;
    else 
        return list == null || list.indexOf(id) < 0 ? hs!=null ? this.st2 : this.st0_  : this.st1_;
}
QuickList.prototype.DecCounter = function()
{
    this.counter -= 1;
    this.UpdateHeader();
}