var animationClientID;

function setAnimationPrefix(v) {
    animationClientID = v;
}

function getAnimationPrefix() {
    return animationClientID;
}

function getPreviousAnimationBehaviorID() {
    return getAnimationPrefix() + 'PreviousAnimation';
}

function getNextAnimationBehaviorID() {
    return getAnimationPrefix() + 'NextAnimation';
}

function getAnimationTarget() {
    return getAnimationPrefix() + 'AnimationSpan';
}

function move(behavior, delta) {
    $get(getAnimationPrefix() + 'ScrollLabelStatusRow').style.display = "none";
    $get(getAnimationPrefix() + 'ScrollImageStatusRow').style.display = "";

    var images = $get(getAnimationTarget());

    if ( images )
        images.visibleIndex += delta;
    else
        images.visibleIndex = 0;

    var animation = behavior._onClick._animation._animations[1]._animations[0];
    
    if ( delta > 0 ) {
        animation.set_startValue(-655);
        animation.set_endValue(-1311);
    }
    else {
        animation.set_startValue(-655);
        animation.set_endValue(1);
    }
}

function nextButtonClickEvent() {
    var buttonName = $get(getAnimationPrefix() + 'AnimationNextButton').name;
    __doPostBack(buttonName,"");
}

function previousButtonClickEvent() {
    var buttonName = $get(getAnimationPrefix() + 'AnimationPreviousButton').name;
    __doPostBack(buttonName,"");
}

function showcaseslotselect(slotparentid, slotid, descparentid, descid) 
{
    // handle slots
    slots=document.getElementById(slotparentid).getElementsByTagName('div');
    for(i=0;i<slots.length;i++)
    {
        if(slots[i].className=='showcaseimagearrow'||slots[i].className=='showcaseimagearrowoff')
            slots[i].className=(slots[i].id==slotid)?'showcaseimagearrow':'showcaseimagearrowoff';
    }
    
    // handle slot descs
    descs=document.getElementById(descparentid).getElementsByTagName('div');
    for(i=0;i<descs.length;i++)
    {
        if(descs[i].className=='showcaseboxdescslot'||descs[i].className=='showcaseboxdescslotoff')
            descs[i].className=(descs[i].id==descid)?'showcaseboxdescslot':'showcaseboxdescslotoff';
    }
}

function showcaseslotinit(parentid, classon, classoff, slot)
{
    divs=document.getElementById(parentid).getElementsByTagName('div');
    j = 0;
    
    for(i=0;i<divs.length;i++)
    {
        if(divs[i].className==classon || divs[i].className==classoff) 
        {
            if (j==slot || j==slot)
            {
                divs[i].className=classon;
            }
            else
            {
                divs[i].className=classoff;
            }
            
            ++j;
        }
    }
}

function showcaseinit(parentid)
{
    showcasetbls=document.getElementById(parentid).getElementsByTagName('table');
    
    for(i=0;i<showcasetbls.length;i++)
    {
        if(showcasetbls[i].className=='showcase')
        {
            tbls=showcasetbls[i].getElementsByTagName('table');
            for(k=0;k<tbls.length;k++)
            {
                // handle image arrows
                if(tbls[k].className=='showcasebox')
                {
                    showcaseslotinit(tbls[k].id, 'showcaseimagearrow', 'showcaseimagearrowoff', 6)
                }
                
                // handle descriptions
                if(tbls[k].className=='showcaseboxdesc')
                {
                    showcaseslotinit(tbls[k].id, 'showcaseboxdescslot', 'showcaseboxdescslotoff', 0)
                }
            }
        }
    }
}
