var SelectionCookieArray = 0;
var SelectionCookieName;
var SelectionTickOnImage;
var SelectionTickOffImage;

function Selection_init(cookiename, tickOnImage, tickOffImage)
{
    SelectionCookieName = cookiename
    SelectionTickOnImage = tickOnImage
    SelectionTickOffImage = tickOffImage

    var theCookie = CookieGetCookie(SelectionCookieName)

    if(theCookie)
        SelectionCookieArray = theCookie.split(',')
    else
        SelectionCookieArray = new Array(0);

    for(var idx = 0; idx < SelectionCookieArray.length; idx++)
    {
        var itemId = SelectionCookieArray[idx]

        var checkbox = document.getElementById(itemId)

        if(checkbox)
            checkbox.src = tickOnImage
    }
}
function Selection(me)
{
    var itemId = me.id
    var theIndex = SelectionCookieArray.indexOf(itemId)

    if(theIndex == -1)
    {
        SelectionCookieArray[SelectionCookieArray.length] = itemId;
        me.src = SelectionTickOnImage
    }
    else
    {
        SelectionCookieArray.remove(theIndex)
        me.src = SelectionTickOffImage
    }

    var cookiestring = SelectionCookieArray.join(',')

    document.cookie = SelectionCookieName + '=' + escape(cookiestring)
}

