1. /**  
  2.  * 底部工具栏左右控制js  
  3.  * @author:tangw 2010-11-07  
  4.  */ 
  5. var RL = {};  
  6. RL = {  
  7.     defCount:6,  
  8.     arWindow:[],  
  9.     startIndex: 0,  
  10.     endIndex:5,  
  11.     currShowW:"",  
  12.     up:function(){//向上  
  13.         var len = this.arWindow.length;  
  14.         ifthis.endIndex == (len-1) ){  
  15.              this.setStyle("f_v_w_down""");  
  16.         }  
  17.         var sid = --this.startIndex;  
  18.         var eid = this.endIndex;  
  19.         if(sid==0){  
  20.             this.setStyle("f_v_w_up""none");  
  21.         }  
  22.         var _eid = this.arWindow[eid];  
  23.         this.setStyle("f_v_window_min_"+_eid, "none");  
  24.           
  25.         var _sid = this.arWindow[sid];  
  26.         this.setStyle("f_v_window_min_"+_sid, "block");  
  27.         this.endIndex--;  
  28.     },  
  29.     down:function(){//向下  
  30.          var len = this.arWindow.length;  
  31.          this.setStyle("f_v_w_up""block");  
  32.            
  33.          var id = this.arWindow[this.startIndex];  
  34.          this.setStyle("f_v_window_min_"+id, "none");  
  35.         var count = ++this.endIndex;  
  36.          if( count == len-1 ){  
  37.              this.setStyle("f_v_w_down","none");  
  38.          }  
  39.          var eid =  this.arWindow[count];  
  40.          this.setStyle("f_v_window_min_"+eid,"block");  
  41.          this.startIndex++;  
  42.     },  
  43.     addW:function(id){  
  44.         var count = this.arWindow.length;  
  45.         if( count > (this.defCount-1)){  
  46.             this.setStyle("f_v_w_down","block");  
  47.         }  
  48.         this.arWindow[count] = id;  
  49.     },  
  50.     setStyle:function(id,str){  
  51.         var o = this.getObj(id);  
  52.         if(o){  
  53.             o.style.display = str;  
  54.         }  
  55.     },  
  56.     getObj:function(id){  
  57.         return document.getElementById(id);  
  58.     },  
  59.     getArCount:function(id){  
  60.        var c = 0;  
  61.        var len = this.getLen();  
  62.        for(var i=0;i<len;i++){  
  63.             if( id == this.arWindow[i]){  
  64.                 c= i;  
  65.                 break;  
  66.             }  
  67.        }  
  68.        return c;  
  69.     },  
  70.     getLen:function(){  
  71.         return  this.arWindow.length;  
  72.     },  
  73.     removeAr:function(c){  
  74.         var len = this.getLen();  
  75.         this.arWindow = this.arWindow.slice(0,c).concat(this.arWindow.slice(c+1,len));  
  76.     },  
  77.     removeW:function(id){  
  78.         var len = this.getLen();  
  79.         var currIndex = this.getArCount(id);//当前位置  
  80.         if( len >= (this.defCount+1) ){  
  81.             if( currIndex<=this.startIndex ){//当前 <= 开始  
  82.                 if( currIndex<this.startIndex ){  
  83.                     //直接隐藏  
  84.                     this.setStyle("f_v_window_min_"+id, "none");  
  85.                 }else{  
  86.                    var e = this.endIndex+1;  
  87.                     //隐藏  
  88.                     this.setStyle("f_v_window_min_"+id, "none");  
  89.                     //显示  
  90.                     var eid = this.arWindow[e];  
  91.                     this.setStyle("f_v_window_min_"+eid, "block");  
  92.                 }  
  93.             }else if( currIndex>=this.endIndex ){// 当前>=结束  
  94.                 if( currIndex==this.endIndex ){  
  95.                       var e = -1;  
  96.                       if( currIndex==(len-1) ){  
  97.                           if(this.startIndex>0){  
  98.                               e = --this.startIndex;  
  99.                               --this.endIndex;  
  100.                           }  
  101.                       }else{  
  102.                           e = this.endIndex+1;     
  103.                       }  
  104.                       if(e!=-1){  
  105.                           var eid = this.arWindow[e];  
  106.                           this.setStyle("f_v_window_min_"+eid, "block");  
  107.                       }  
  108.                 }else{  
  109.                     //直接隐藏  
  110.                     this.setStyle("f_v_window_min_"+id, "none");  
  111.                 }  
  112.             }else ifthis.startIndex < currIndex < this.endIndex){ //开始<当前<结束  
  113.                 var e = -1;  
  114.                 ifthis.startIndex == 0 ){  
  115.                    e =  this.endIndex+1;  
  116.                 }else{  
  117.                     ifthis.endIndex == (len-1) ){  
  118.                        e =  --this.startIndex;  
  119.                         --this.endIndex;  
  120.                     }else{  
  121.                         e =  this.endIndex+1;  
  122.                     }  
  123.                 }  
  124.                 this.setStyle("f_v_window_min_"+id, "none");  
  125.                 if( e!=-1){  
  126.                       var eid = this.arWindow[e];  
  127.                       this.setStyle("f_v_window_min_"+eid, "block");  
  128.                 }  
  129.             }  
  130.             //删除  
  131.             this.removeAr(currIndex);  
  132.             //控制样式  
  133.             this.setStyle("f_v_w_up",this.startIndex==0?"none":"block");  
  134.             this.setStyle("f_v_w_down",this.endIndex == (this.getLen()-1)?"none":"block");  
  135.         }else{  
  136.             this.removeAr(currIndex);  
  137.         }  
  138.     }