if ( typeof($) != 'function'){
    function $(id){
        return typeof(id)=='string'?document.getElementById(id):id;
    }
}
 var showObject = {
     totalCount : 0,   // 总的数量
     current : 0,      // 当前的
     myO : null ,
     objectHeight : 0,
     direction : 1,    // 1是向上,-1是向下
     step : 10,
     timer : null,     // 定时器
     breakTime : 4000, // 间隔时间
     intervalTime : 20,
     targetHeight : 0,
     isStarted : false,
     auto : 1,
     start : function(id, height,count){
         this.myO = $(id);
         this.objectHeight = height;
         this.totalCount = count;
         this.isStarted = true;
         if ( this.auto ){
             this.scroll();
         }
     },
     scroll : function() {
         if ( this.timer ){
             clearTimeout(this.timer);
         }
         if ( this.totalCount == 0 || this.objectHeight == 0 ){
             return false;
         }
         if ( this.current + this.direction == this.totalCount || this.current + this.direction == -1 )
         {
             // 换方向
             this.direction = -this.direction;
         }
         // 等于这个,也不动
         if ( this.totalCount == 1 ){
             return false;
         }
         // 计算终点位置
         var nextPoint = (this.current + this.direction)%this.totalCount;
         this.targetHeight = -(nextPoint * this.objectHeight);
//			             alert(this.targetHeight);
         // 设置
         this.current = nextPoint;
         this.move();
     },
     move : function(){
         var o = this;
         // 对象的top
         if ( this.myO == null ){
             return false;
         }
         if ( !this.myO.style.top ){
             this.myO.style.top = '0px';
         }
         var ypos = parseInt(this.myO.style.top);
//			             alert(this.targetHeight + '     ' + ypos);return false;
         if ( ypos == this.targetHeight ){
             this.timer = setTimeout(function(){o.scroll()}, o.breakTime);
             return true;
         }
//			             alert(this.targetHeight - ypos);return;
         var dist = Math.abs(Math.ceil(Math.abs(this.targetHeight - ypos)/this.step));
         if ( dist == 0 ){
             dist = 1;
         }
//			             alert(ypos - this.direction * dist);return false;
         this.myO.style.top = (ypos - this.direction * dist) + 'px';
         this.timer = setTimeout(function(){o.move()}, o.intervalTime);
     },
     pause : function(){
         // 设置下current
         this.auto = 0;
         if ( this.isStarted ){
             if ( this.timer ){
                 clearTimeout(this.timer);
             }
         }
         
     },
     play : function(){
         this.auto = 1;
         if ( this.isStarted ){
             if ( this.timer ){
                 clearTimeout(this.timer);
             }
             this.move();
         }
     },
     pre : function(){
         if ( this.isStarted ){
             if ( this.timer ){
                 clearTimeout(this.timer);
             }
             if ( this.current+1 == this.totalCount ){
                 this.move();
             }else{
                 this.direction = 1;
                 this.scroll();
             }
         }
     },
     next : function(){
         if ( this.isStarted ){
             if ( this.timer ){
                 clearTimeout(this.timer);
             }
             if ( this.current == 0 ){
                 this.move();
             }else{
                 this.direction = -1;
                 this.scroll();
             }
         }
     }
 };