function dinamiclistWork(global_object){
    this.global_object = global_object;
    
    this.blocks = new Array();
    this.block = false;
    
    this.pagers = new Array();

    this.page = new Image();
    this.page.src = 'images/arround_box/circle_page.gif';
    this.page_sel = new Image();
    this.page_sel.src = 'images/arround_box/circle_page_sel.gif';

    this.count = 0;
    this.current = 0;
    this.opacity_stop = 0; // нужна для эфекта переключения картинок

    this.timer = false;
}

dinamiclistWork.prototype.addBlock = function(block_id){
    this.blocks[this.count] = document.getElementById(block_id);
    this.count++;
}

dinamiclistWork.prototype.initialize = function(pager_block_id){
    if(!this.block)
	this.block = this.blocks[0];

    var pagers = document.getElementById(pager_block_id);
    var j=0;
    for(i in pagers.childNodes){
	if(pagers.childNodes[i].nodeName == 'IMG'){
	    this.pagers[j] =  pagers.childNodes[i];
	    j++;
	}
    }
}

dinamiclistWork.prototype.previous = function(){
	//прогон по кругу
	if(this.current <= 0)
		this.current = this.count;
	
	if(this.block && this.blocks[(this.current-1)]){
		this.pagers[(this.current >= this.count ? 0 : this.current)].src = this.page.src;
		this.current--;
		this.opacity(100);
	}

	return false;
}

dinamiclistWork.prototype.next = function(){
	//прогон по кругу
	if(this.current >= this.count-1)
		this.current = -1;
	
	if(this.block && this.blocks[(this.current+1)]){
		this.pagers[(this.current<0 ? (this.count-1) : this.current)].src = this.page.src;
		this.current++;
		this.opacity(100);
	}
	
	return false;
}

dinamiclistWork.prototype.goOn = function(number){
	
	if(this.block && this.blocks[number]){
		this.pagers[this.current].src = this.page.src;
		this.current = number;
		this.opacity(100);
	}
	
	return false;
}

dinamiclistWork.prototype.opacity = function(i){
	if(this.timer)
		window.clearTimeout(this.timer);

	if(i>this.opacity_stop){
		i-=20;
	}
	else if (i==0){
		this.block.style.display = 'none';
		this.block = this.blocks[this.current];
		//выделяем текущую страницу
		this.pagers[this.current].src = this.page_sel.src;
		this.block.style.display = 'block';
		this.opacity_stop = 100;
		i+=20;
		}
	else if(i<this.opacity_stop){
		i+=20;
	}
	else{ 
		this.opacity_stop = 0;
		return;
	}

	this.block.style.opacity = i/100;
	this.block.style.filter="alpha(opacity="+i+")";
	
	this.timer = window.setTimeout(this.global_object+'.opacity('+i+')', 20);
}
