  function RollingPhoto(photoBox){
      this.direction="top";
      this.screenRecordCount=3;
      this.speed=1;
      this.delay=3000;
      this.records=[];
      
      var _this=this;
      var _playId=0;
      var _delayId=0;
      var _intervalValue=10;
      var _currentRollingHeight=0;
      
      var initialize=function(){
          for(var i=0;i<photoBox.childNodes.length;i++){
              if(photoBox.childNodes[i].tagName=="LI"){
                  _this.records.push(photoBox.childNodes[i]);
              }
          }//alert(photoBox.childNodes.length);
          photoBox.style.top=photoBox.style.top?photoBox.style.top:0;
          updateRollingHeight();
      };
      
      var updateRollingHeight=function(){
          _currentRollingHeight=0;
          for(var i=0;i<_this.screenRecordCount;i++){
              _currentRollingHeight+=_this.records[i].offsetHeight;
          }
      };
      
      this.play=function(){
          switch (_this.direction.toLowerCase()) {
              case "top":
                  function rolling(){
                      if (parseInt(photoBox.style.top) != -_currentRollingHeight) {
                          if (parseInt(photoBox.style.top) - _this.speed >= -_currentRollingHeight) {
                              photoBox.style.top = parseInt(photoBox.style.top) - _this.speed + "px";
                          }
                          else {
                              photoBox.style.top = parseInt(photoBox.style.top) - (_currentRollingHeight + parseInt(photoBox.style.top))+"px";
                              
                          }
                      }
                      else {
                          for (var i = 0; i < _this.screenRecordCount; i++) {
                              photoBox.appendChild(_this.records[0]);
                              _this.records.push(_this.records[0]);
                              _this.records.splice(0, 1);
                          }
                          photoBox.style.top = "0px";
                          updateRollingHeight();
                          window.clearInterval(_playId);
                          window.clearTimeout(_delayId);
                          _delayId = window.setTimeout(_this.play, _this.delay);
                      }
              }
              _playId=window.setInterval(rolling,_intervalValue);
              break;
          }
      };
      
      this.stop=function(){
          window.clearInterval(_playId);
      };
      
      initialize();
  }

  //function $(id){
  //    return typeof(id)=="string"?document.getElementById(id):id;
  //}
  
 // window.onload=load;

	if (document.all){
		window.attachEvent('onload',load)//IEÖÐ
	}else{
		window.addEventListener('load',load,false);//firefox
	}
	
  function load(){
      var rp=new RollingPhoto(document.getElementById("photoBox"));
      window.setTimeout(rp.play,rp.delay);
  }
