function VPA_singleton ()
{
	this.objects=new Object;
	
	if (!window.__VPA_singleton)
	{
		__VPA_singleton=this;
	}
	
	__VPA_singleton.add=function(name,obj)
	{
		__VPA_singleton.objects[name]=obj;
	}
	
	__VPA_singleton.get=function (name)
	{
		return __VPA_singleton.objects[name];
	}
	
	return __VPA_singleton;
}

VPA_singleton.prototype.toString=function() { return 'Object VPA_singleton';};

function VPA_vscroller(name,current_cell_index,show_cells)
{
	this.singleton_name=name;
	this.name=name;
	this.show_cells=show_cells;
	this.offset=0;
	this.timer=null;
	this.obj=document.getElementById(this.name);
	this.scroll_obj=this.obj.getElementsByTagName('table')[0];
	this.scroll_obj_left=this.scroll_obj.offsetLeft;
	this.cells=this.scroll_obj.rows[0].cells.length;
	this.cell_first=this.scroll_obj.rows[0].cells[0];
	this.cell_last=this.scroll_obj.rows[0].cells[this.cells-1];
	this.current_cell_index=current_cell_index;
	this.cell_current=this.scroll_obj.rows[0].cells[this.current_cell_index];
	this.left_link=this.obj.rows[0].cells[0].getElementsByTagName('a')[0];
	this.left_link.setAttribute('obj', this.singleton_name);
	this.right_link=this.obj.rows[0].cells[2].getElementsByTagName('a')[0];
	this.right_link.setAttribute('obj', this.singleton_name);
	
	this.set_cell=function (cell)
	{
		if (cell>=0 && this.cells-cell>=this.show_cells)
		{
			this.current_cell_index=cell;
			this.cell_current=this.scroll_obj.rows[0].cells[this.current_cell_index];
			this.left=-this.cell_current.offsetLeft;
			this.offset=parseInt(this.scroll_obj.style.left.replace(/px/i,''));
			//alert (this.offset);
			//alert (this.cell_current.offsetLeft);
			//this.scroll_obj.style.left=-left;
			this.slow_motion();
		}
	}
	
	this.slow_motion=function ()
	{
		this.timer=window.setInterval(function()
			{
				var sg=new VPA_singleton;
				var obj=sg.get('scroller');
				if (obj.offset!=obj.left)
				{
					window.status=obj.offset;
					var desc=(obj.offset-obj.left>=0) ? 1 : -1;
					obj.offset-=desc;
					obj.scroll_obj.style.left=obj.offset+'px';
				}
				else
				{
					window.clearInterval(obj.timer);
				}
			},15);
	}
  
	this.left_link.onmousemove=function ()
	{
		var name=this.getAttribute('obj');
		var sg=new VPA_singleton;
		var obj=sg.get(name);
		obj.set_cell(obj.current_cell_index-1);
	}

	this.right_link.onmousemove=function ()
	{
		var name=this.getAttribute('obj');
		var sg=new VPA_singleton;
		var obj=sg.get(name);
		obj.set_cell(obj.current_cell_index+1);
	}

	this.set_cell(this.current_cell_index);
}

VPA_vscroller.prototype.toString=function() { return 'Object VPA_vscroller\n\nDeveloped by Andrey Pahomov (andrey.pahomov@gmail.com)';};

