function DivChange(name,splittime,count,ismove,changed_callback)
{
    this.count = count;
    this.splittime = splittime;
    this.now = 0;
    this.name = name;
    this.timeid1;
    this.timeid2;
    this.ismove = ismove;
    this.changed_callback = changed_callback;
    this.next_button = document.getElementById(name+"_next_button");
    this.previous_button = document.getElementById(name+"_previous_button");
    this.isplay = true;
    var self = this;
    this.SetFocus = function() {
		if(self.now>=self.count) self.now=0;
		self.now = self.now+1;
        self.SelectLayer(self.now);
    };
	this.SelectLayer = function(i) {
      for(var j=1;j<=self.count;j++) {
        try
		    {
            if (j==i) {
                document.getElementById(name+"_panel_"+j).style.display="block";
                //document.getElementById(name+"__"+j).style.display="block";
            } else {
		        document.getElementById(name+"_panel_"+j).style.display="none";
		        //document.getElementById(name+"_panel_"+j).style.display="block";
            }
        }catch(e)
		    {}
      }
      if(typeof self.changed_callback == "function")
      {
        self.changed_callback(i);
      }
    };
    this.ChangeImg = function() {
        if(self.isplay)
        {
            self.timeid1 = setTimeout(self.SetFocus,self.splittime);
        }
        self.timeid2 = setTimeout(self.ChangeImg,self.splittime);
    };
	this.ChangeImg();
    
    this.Stop = function()
    {
        clearTimeout(this.timeid1);
        clearTimeout(this.timeid2);
    };
    this.Start = function()
    {
        this.ChangeImg();
    };
    this.Reset = function()
    {
        this.Stop();
        this.Start();
    };
    
	if(this.ismove!=1)
	{
        if(this.next_button)
        {
            this.next_button.onclick = function()
            {
			    self.Stop();
                if(self.now>=self.count)
                {
                    self.now = 0;
                }
                self.SelectLayer(self.now+1);
		        self.now = self.now+1;
			    self.Start();
            }
        }
        if(this.previous_button)
        {
            this.previous_button.onclick = function()
            {
			    self.Stop();
                if(self.now<=1)
                {
                    self.now = self.count+1;
                }
                self.SelectLayer(self.now-1);
			    self.now = self.now-1;
			    self.Start();
            }
        }
        for(var j=1;j<=count;j++)
        {
		    try
		    {
			    var now_button = document.getElementById(name+"_button_"+j);
			    if(now_button)
			    {
				    now_button.onclick = function()
				    {
					    self.Stop();
					    var num = parseInt(this.id.replace(name+"_button_",""));
					    self.SelectLayer(num);
					    self.now = num;
					    self.Start();
				    }
			    }
		    }catch(e)
		    {}
        }
    }
    else
    {
        if(this.next_button)
        {
            this.next_button.onmouseover = function()
            {
			    self.Stop();
                if(self.now>=self.count)
                {
                    self.now = 0;
                }
                self.SelectLayer(self.now+1);
		        self.now = self.now+1;
			    self.Start();
            }
        }
        if(this.previous_button)
        {
            this.previous_button.onmouseover = function()
            {
			    self.Stop();
                if(self.now<=1)
                {
                    self.now = self.count+1;
                }
                self.SelectLayer(self.now-1);
			    self.now = self.now-1;
			    self.Start();
            }
        }
        for(var j=1;j<=count;j++)
        {
		    try
		    {
			    var now_button = document.getElementById(name+"_button_"+j);
			    if(now_button)
			    {
				    now_button.onmouseover = function()
				    {
					    self.Stop();
					    var num = parseInt(this.id.replace(name+"_button_",""));
					    self.SelectLayer(num);
					    self.now = num;
				    }
				    now_button.onmouseout = function()
				    {
					    self.Start();
				    }
			    }
		    }catch(e)
		    {}
        }
    }
    for(var j=1;j<=count;j++)
    {
		try
		{
			var now_panel = document.getElementById(name+"_panel_"+j);
			if(now_panel)
			{
				now_panel.onmouseover = function()
				{
					self.Stop();
				}
				now_panel.onmousemove = function()
				{
					self.Stop();
				}
				now_panel.onmouseout = function()
				{
					self.Start();
				}
			}
		}catch(e)
		{}
    }
};
