public/javascripts/yui/carousel/carousel-debug.js
function setItemSelection(newpos, oldpos) {
        var carousel = this,
            cssClass   = carousel.CLASSES,
            el,
            firstItem  = carousel._firstItem,
            isCircular = carousel.get("isCircular"),
            numItems   = carousel.get("numItems"),
            numVisible = carousel.get("numVisible"),
            position   = oldpos,
            sentinel   = firstItem + numVisible - 1;

        if (position >= 0 && position < numItems) {
            if (!JS.isUndefined(carousel._itemsTable.items[position])) {
                el = Dom.get(carousel._itemsTable.items[position].id);
                if (el) {
                    Dom.removeClass(el, cssClass.SELECTED_ITEM);
                }
            }
        }

        if (JS.isNumber(newpos)) {
            newpos = parseInt(newpos, 10);
            newpos = JS.isNumber(newpos) ? newpos : 0;
        } else {
            newpos = firstItem;
        }

        if (JS.isUndefined(carousel._itemsTable.items[newpos])) {
            newpos = getFirstVisibleForPosition.call(carousel, newpos);
            carousel.scrollTo(newpos); // still loading the item
        }

        if (!JS.isUndefined(carousel._itemsTable.items[newpos])) {
            el = Dom.get(carousel._itemsTable.items[newpos].id);
            if (el) {
                Dom.addClass(el, cssClass.SELECTED_ITEM);
            }
        }

        if (newpos < firstItem || newpos > sentinel) { // out of focus
            newpos = getFirstVisibleForPosition.call(carousel, newpos);
            carousel.scrollTo(newpos);
        }
    }
function setItemSelection(newpos, oldpos) {
        var carousel = this,
            cssClass   = carousel.CLASSES,
            el,
            firstItem  = carousel._firstItem,
            isCircular = carousel.get("isCircular"),
            numItems   = carousel.get("numItems"),
            numVisible = carousel.get("numVisible"),
            position   = oldpos,
            sentinel   = firstItem + numVisible - 1;

        if (position >= 0 && position < numItems) {
            if (!JS.isUndefined(carousel._itemsTable.items[position])) {
                el = Dom.get(carousel._itemsTable.items[position].id);
                if (el) {
                    Dom.removeClass(el, cssClass.SELECTED_ITEM);
                }
            }
        }

        if (JS.isNumber(newpos)) {
            newpos = parseInt(newpos, 10);
            newpos = JS.isNumber(newpos) ? newpos : 0;
        } else {
            newpos = firstItem;
        }

        if (JS.isUndefined(carousel._itemsTable.items[newpos])) {
            newpos = getFirstVisibleForPosition.call(carousel, newpos);
            carousel.scrollTo(newpos); // still loading the item
        }

        if (!JS.isUndefined(carousel._itemsTable.items[newpos])) {
            el = Dom.get(carousel._itemsTable.items[newpos].id);
            if (el) {
                Dom.addClass(el, cssClass.SELECTED_ITEM);
            }
        }

        if (newpos < firstItem || newpos > sentinel) { // out of focus
            newpos = getFirstVisibleForPosition.call(carousel, newpos);
            carousel.scrollTo(newpos);
        }
    }
function setItemSelection ( newpos , oldpos ) { var carousel = this , cssClass = carousel . CLASSES , el , firstItem = carousel . _firstItem , isCircular = carousel . get ( "isCircular" ) , numItems = carousel . get ( "numItems" ) , numVisible = carousel . get ( "numVisible" ) , position = oldpos , sentinel = firstItem + numVisible - 1 ; if ( position >= 0 && position < numItems ) { if ( ! JS . isUndefined ( carousel . _itemsTable . items [ position ] ) ) { el = Dom . get ( carousel . _itemsTable . items [ position ] . id ) ; if ( el ) { Dom . removeClass ( el , cssClass . SELECTED_ITEM ) ; } } } if ( JS . isNumber ( newpos ) ) { newpos = parseInt ( newpos , 10 ) ; newpos = JS . isNumber ( newpos ) ? newpos : 0 ; } else { newpos = firstItem ; } if ( JS . isUndefined ( carousel . _itemsTable . items [ newpos ] ) ) { newpos = getFirstVisibleForPosition . call ( carousel , newpos ) ; carousel . scrollTo ( newpos ) ; // still loading the item } if ( ! JS . isUndefined ( carousel . _itemsTable . items [ newpos ] ) ) { el = Dom . get ( carousel . _itemsTable . items [ newpos ] . id ) ; if ( el ) { Dom . addClass ( el , cssClass . SELECTED_ITEM ) ; } } if ( newpos < firstItem || newpos > sentinel ) { // out of focus newpos = getFirstVisibleForPosition . call ( carousel , newpos ) ; carousel . scrollTo ( newpos ) ; } }
Set the selected item.

@method setItemSelection
@param {Number} newpos The index of the new position
@param {Number} oldpos The index of the previous position
@private
Set the selected item .