function sideShow(p){
    var width = 200; //设置宽度
    var height = 100; //设置高度
    var time = 3000; //设置滚动时间
    var changeTime = 1000; //设置效果时间
    var title = 8; //设置标题位置从1-12
    var titleSize = '12px'; //设置标题字体大小
    var titleColor = '#ffffff'; //设置标题字体颜色
    var titleHeight = '20px'; //设置标题高度
    var titleBgColor = '#000000'; //设置标题背景颜色
    var titleOpacity = null; //设置标题透明度
    var index = 3; //设置索引位置从0-3，0是没有
    var indexHeight = '20px'; //设置索引高度
    var indexWidth = '20px'; //设置索引宽度
    var indexColor = '#ffffff'; //设置索引字体颜色
    var indexBgColor = '#000000'; //设置索引背景颜色
    var indexOverColor = '#ffffff'; //设置索引鼠标激活颜色
    var indexOverBgColor = 'red'; //设置索引鼠标激活背景颜色
    var indexBorder = '1px'; //设置索引边框宽度
    var indexBorderColor = null; //设置索引边框颜色
    var indexOverBorderColor = null; //设置索引边框激活颜色
    var imgHeight = null; //不需要用户设置
    var thisIndex = null; //不需要用户设置
    var afterIndex = null; //不需要用户设置
    var seletTime = 0; //不需要用户设置
    var itemNum = 0; //不需要用户设置
    var titleItem = []; //不需要用户设置
    this.addItem = function(p){
        $('div.__sideShow').append('<div></div>');
        var obj = $('div.__sideShow div:last');
        if (p.url) {
            obj.append('<a href="' + p.url + '"></a>');
            var obj = $('div.__sideShow a:last');
        }
        obj.append('<img src="' + p.src + '" />');
        if (p.title) {
            titleItem[titleItem.length] = p.title;
        }
        else {
            titleItem[titleItem.length] = '';
        }
        itemNum = $('div.__sideShow div').length;
    }
    
    this.selectItem = function(indexId){
        if (thisIndex == null) {
            $('div.__sideShow div:first').css('zIndex', 2).next().css('zIndex', 1);
            thisIndex = 0;
            afterIndex = thisIndex + 1;
            if (afterIndex == itemNum) {
                afterIndex = 0;
            }
            changeTitle();
            changeIndexStyle();
        }
        else {
            if (indexId != afterIndex && indexId != thisIndex) {
                $('div.__sideShow div').eq(afterIndex).css('zIndex', 0);
                $('div.__sideShow div').eq(indexId).css('zIndex', 1);
            }
            else {
                var timeout = (new Date).getTime() - seletTime;
                if (timeout < time - 100) {
                    //setTimeout(';', time - timeout);
                    return;
                }
            }
            
            $('div.__sideShow div').eq(thisIndex).animate({
                opacity: 0.0
            }, changeTime, function(){
                $(this).css({
                    zIndex: 0,
                    opacity: 1.0
                });
                thisIndex = indexId;
                
                if (thisIndex == itemNum) {
                    thisIndex = 0;
                }
                
                changeTitle();
                changeIndexStyle();
                
                $('div.__sideShow div').eq(thisIndex).css('zIndex', 2);
                afterIndex = thisIndex + 1;
                if (afterIndex == itemNum) {
                    afterIndex = 0;
                }
                $('div.__sideShow div').eq(afterIndex).css('zIndex', 1);
            });
        }
        seletTime = (new Date).getTime();
    }
    
    this.addTitle = function(){
        $('div.__sideShow').append('<h3><span></span></h3>');
        $('div.__sideShow h3').css({
            width: width,
            position: 'absolute',
            left: '0px',
            top: '0px',
            margin: '0px',
            padding: '0px',
            zIndex: 3,
            lineHeight: titleHeight,
            fontSize: titleSize,
            color: titleColor
        });
        if (titleOpacity != null) {
            $('div.__sideShow h3').css({
                opacity: titleOpacity,
                background: titleBgColor
            });
        }
        $('div.__sideShow span').css({
            margin: '0px 5px'
        });
        
        switch (title % 3) {
            case 0:
                $('div.__sideShow h3').css('textAlign', 'right');
                break;
            case 1:
                $('div.__sideShow h3').css('textAlign', 'left');
                break;
            case 2:
                $('div.__sideShow h3').css('textAlign', 'center');
                break;
        }
        
        if (title > 9) {
            $('div.__sideShow h3').css('top', imgHeight);
        }
        else 
            if (title > 6) {
                iImgHeight = imgHeight.replace(/[a-zA-Z]+/, '') * 1;
                iTitleHeight = titleHeight.replace(/[a-zA-Z]+/, '') * 1;
                $('div.__sideShow h3').css('top', iImgHeight - iTitleHeight + 'px');
            }
            else 
                if (title > 3) {
                    iImgHeight = imgHeight.replace(/[a-zA-Z]+/, '') * 1;
                    iTitleHeight = titleHeight.replace(/[a-zA-Z]+/, '') * 1;
                    $('div.__sideShow h3').css('top', (iImgHeight - iTitleHeight) / 2 + 'px');
                }
    }
    
    this.addIndex = function(){
        if (index == null || index == 0) {
            return;
        }
        
        $('div.__sideShow').append('<ul></ul>');
        $('div.__sideShow ul').css({
            position: 'absolute',
            margin: '0px',
            padding: '0px',
            zIndex: 3
        });
        
        for (var i = 1; i <= itemNum; i++) {
            $('div.__sideShow ul').append('<li>' + i + '</li>');
        }
        var self = this;
        $('div.__sideShow li').css({
            'float': 'left',
            margin: '0px',
            padding: '0px',
            listStyleType: 'none',
            lineHeight: indexHeight,
            height: indexHeight,
            width: indexWidth,
            textAlign: 'center',
            cursor: 'pointer',
            background: indexBgColor,
            color: indexColor
        }).click(function(){
            self.selectItem($(this).text() * 1 - 1);
        });
        
        if (indexBorderColor == null || indexBorderColor == '') {
            $('div.__sideShow li').css('margin', indexBorder);
        }
        else {
            $('div.__sideShow li').css('margin', indexBorder + ' solid ' + indexBorderColor);
        }
        
        switch (index) {
            case 1:
                $('div.__sideShow ul').css('left', '5px');
                break;
            case 2:
                iIndexWidth = $('div.__sideShow ul').width();
                iWidth = width.replace(/[a-zA-Z]+/, '') * 1;
                $('div.__sideShow ul').css('left', (iWidth - iIndexWidth) / 2 + 'px');
                break;
            case 3:
                iIndexWidth = $('div.__sideShow ul').width();
                iWidth = width.replace(/[a-zA-Z]+/, '') * 1;
                $('div.__sideShow ul').css('left', iWidth - iIndexWidth - 5 + 'px');
                break;
        }
        
        if (title > 6 && title < 10) {
            iHeight = height.replace(/[a-zA-Z]+/, '') * 1;
            iTitleHeight = titleHeight.replace(/[a-zA-Z]+/, '') * 1;
            iIndexHeight = indexHeight.replace(/[a-zA-Z]+/, '') * 1;
            $('div.__sideShow ul').css('top', iHeight - iTitleHeight - iIndexHeight - 5 + 'px');
        }
        else {
            iHeight = height.replace(/[a-zA-Z]+/, '') * 1;
            iIndexHeight = indexHeight.replace(/[a-zA-Z]+/, '') * 1;
            $('div.__sideShow ul').css('top', iHeight - iIndexHeight - 5 + 'px');
        }
    }
    
    function changeTitle(){
        if (titleItem[thisIndex] == null || titleItem[thisIndex] == '') {
            $('div.__sideShow h3').css('display', 'none');
        }
        else {
            $('div.__sideShow h3').css('display', 'block');
            $('div.__sideShow span').text(titleItem[thisIndex]);
        }
    }
    
    function changeIndexStyle(){
        if (index > 0) {
            $('div.__sideShow li').css('background', indexBgColor);
            $('div.__sideShow li').eq(thisIndex).css('background', indexOverBgColor);
        }
    }
    
    this.run = function(){
        if (thisIndex == null) {
            this.selectItem(0);
        }
        else {
            this.selectItem(afterIndex);
        }
        
        if ($('div.__sideShow div').length > 1) {
            var self = this;
            setTimeout('self.run()', time);
        }
    }
    
    document.write('<div class="__sideShow"></div>');
    
    for (var i in p['item']) {
        this.addItem(p['item'][i]);
    }
    
    for (var i in p) {
        if (typeof p[i] == 'string') {
            eval(i + '="' + p[i] + '";');
        }
        else 
            if (typeof p[i] == 'number') {
                eval(i + '=' + p[i] + ';');
            }
    }
    
    if (title > 9) {
        iHeight = height.replace(/[a-zA-Z]+/, '') * 1;
        iTitleHeight = titleHeight.replace(/[a-zA-Z]+/, '') * 1;
        imgHeight = iHeight - iTitleHeight + 'px';
    }
    else {
        imgHeight = height;
    }
    
    $('div.__sideShow').css({
        position: 'relative',
        width: width,
        height: height
    });
    
    $('div.__sideShow div').css({
        position: 'absolute',
        left: '0px',
        top: '0px',
        zIndex: 0
    });
    
    $('div.__sideShow img').css({
        width: width,
        height: imgHeight,
        border: '0px'
    });
    
    this.addTitle();
    this.addIndex();
    this.run();
}

function show(obj, index, speed){
    $('.' + obj).hide(speed);
    $('.' + obj).eq(index).show(speed);
}

function underline(obj){
    $('span', $(obj).parent().parent().parent()).css('textDecoration', 'none');
    $(obj).css('textDecoration', 'underline');
}
