function $(element){
  return element = document.getElementById(element);
}

function $D1(obj){
  var h=obj.offsetHeight;
  var maxh=40;
  function dmove(){
    h+=5; //设置层展开的速度
    if(h>=maxh){
      obj.style.height=maxh+'px';
      clearInterval(iIntervalId);
    }else{
      obj.style.display='block';
      obj.style.height=h+'px';
    }
  }
  iIntervalId=setInterval(dmove,2);
}

function $D2(obj){
  var h=obj.offsetHeight;
  var maxh=40;
  function dmove(){
    h-=5;//设置层收缩的速度
    if(h<=0){
      obj.style.display='none';
      clearInterval(iIntervalId);
    }else{
      obj.style.display='block';
      obj.style.height=h+'px';
    }
  }
  iIntervalId=setInterval(dmove,2);
}

function $use(obj){
  var obj=$(obj);
  var sb=$('stateBut');
  if(obj.style.display=='none'){
    $D1(obj);
    //sb.innerHTML='展开';
  }else{
    $D2(obj);
    //sb.innerHTML='收缩';
  }
}
