
	function panel_pager(instance_name, div_id, url, item_count)
	{
		this.instance_name = instance_name;
		this.url = url;
		this.div_id = div_id;
		
		this.item_count = item_count;
		
		this.direction = '';
		this.currObj;
		this.process = 0;
		
		this.reset = function()
		{
			this.currObj = this.direction == 'next' ? 1 : this.item_count
		}
		
		this.next_element = function()
		{
			this.currObj += this.direction == 'next' ? 1 : -1;
		}
		
		this.show_html = function(html)
		{
			document.getElementById(this.div_id).innerHTML = html;
		}

		this.nav = function()
		{
			if (this.process == 0)
			{
				//this.show_html(dict['loading']);
				this.process = 1;
				this.reset();
				this.fade_out();
			}
		}
		
		this.next = function()
		{
			this.direction = 'next';
			this.nav();
		}
		
		this.previous = function()
		{
			this.direction = 'previous';
			this.nav();
		}
		
		this.fade_out = function()
		{
			var id = this.div_id + '__' + this.currObj;
			var obj = document.getElementById(id);
			
			if (obj)
			{
				dojo.fadeOut({ node: id, duration: 150 }).play();
				this.next_element();
				setTimeout(this.instance_name + '.fade_out();', 150)
			}
			else
			if (this.currObj > 0 && this.currObj <= this.item_count)
			{
				this.next_element();
				this.fade_out();
			}
			else
			{
				this.reset();
				this.get_content();
				
				return;
			}
		}
		
		this.fade_in = function()
		{
			var id = this.div_id + '__' + this.currObj;
			var obj = document.getElementById(id);
			
			if (obj)
			{
				dojo.fadeIn({ node: id, duration: 500 }).play();
				this.next_element();
				setTimeout(this.instance_name + '.fade_in();', 150)
			}
			else
			if (this.currObj > 0 && this.currObj <= this.item_count)
			{
				this.next_element();
				this.fade_in();
			}
			else
			{
				this.reset();
				this.process = 0;
				
				return;
			}
		}
		
		this.get_content = function()
		{
			var url = this.url + '&direction=' + this.direction;
			var post = dojo.xhrPost(
					{
						url: url,
						sync: true,
						origin: this,
						mimetype: "text/json-comment-filtered",
						encoding: "utf-8",
						load: this.parse_response,
				        error: this.xhr_error
					});
			
			this.fade_in();
		}
		
		this.xhr_error = function(response, ioArgs)
		{
			this.origin.xhr_error_step_2();
		}
		
		this.xhr_error_step_2 = function()
		{
			 this.show_html(dict['xhrError']);
		}
	
		this.parse_response = function(response, ioArgs)
		{
			this.origin.parse_response_step_2(response);
		}
		
		this.parse_response_step_2 = function (response)
		{
			var pdata = eval(response);
			var html = '';
			
			for (var i = 0; i <pdata.length; i ++)
			{
				html += pdata[i];
			}
			
			this.show_html(html);
		}
	}
	

