function funPicRockPlayer(emId){
    this.elem = $('#' + emId + '_picRockPlayer');
    this.pW = 100;
    this.pH = 145;
    this.pic = [];
    var _pic = this.elem.find('.box');
    for (var i = 0; i < _pic.length; i++) {
        this.pic.push(_pic.eq(i))
    }
    this.index = 0;
    this.p = (this.elem.width() - this.pW) / 2;
    this.lBtn = this.elem.find('.lBtn');
    this.rBtn = this.elem.find('.rBtn');
    this.len = this.pic.length;
    this.time = null;
    this.local = [{
        index: 0,
        width: 40,
        height: 115,
        top: 24,
        zIndex: 2,
        opacity: 1,
        left: 0
    }, {
        index: 1,
        width: 50,
        height: 130,
        top: 12,
        zIndex: 3,
        opacity: 1,
        left: 40
    }, {
        index: 2,
        width: this.pW,
        height: this.pH,
        top: 0,
        zIndex: 3,
        opacity: 1,
        left: this.p
    }, {
        index: 3,
        width: 50,
        height: 130,
        top: 12,
        zIndex: 3,
        opacity: 1,
        left: this.p+100
    }, {
        index: 4,
        width: 40,
        height: 115,
        top: 24,
        zIndex: 2,
        opacity: 1,
        left: this.p + 150
    }];
}

funPicRockPlayer.prototype = {
    constructor: funPicRockPlayer,
    init: function(){
        var that = this;
        that.lBtn.click(function(){
            that.leftBtn();
        })
        that.rBtn.click(function(){
            that.rightBtn();
        })
        that.play();
        
    },
    rightBtn: function(){
        this.index++;
        if (this.index == this.len) {
            this.index = 0;
        }
        var o = this.pic.shift();//方法用于把数组的第一个元素从其中删除，并返回第一个元素的值
        this.pic.push(o);//将新元素添加到一个数组中，并返回数组的新长度值
        this.play();
    },
    leftBtn: function(){
        this.index--;
        if (this.index < 0) {
            this.index = this.len;
        }
        var o = this.pic.pop();//移除数组中的最后一个元素并返回该元素
        this.pic.unshift(o);//unshift() 方法可向数组的开头添加一个或更多元素，并返回新的长度
        this.play();
    },
    play: function(){
        var that = this;
        for (var i = 0; i < that.pic.length; i++) {
            that.pic[i].css({
                zIndex: that.local[i].zIndex
            }).find('span').show();
           	that.pic[i].find("h5").hide();
			that.pic[2].find("h5").show();
			
		    that.pic[2].find('span').hide();
            that.pic[i].animate({
                top: that.local[i].top,
                width: that.local[i].width + 'px',
                left: that.local[i].left + 'px',
                height: that.local[i].height + 'px'
            }, function(){
                $(this).show();
            })
        }
    }
}





