// Version 1.0.0

var Trend=new Object();
Trend.url=		'';
Trend.parameters=	new Object();

Trend.setParameter = function(name, value) {
	if (name) this.parameters[name]=value;
}

Trend.setUrl = function(url) {
	this.url=url;
}

Trend.getData = function() {
	Preloader.show();
	if (this.url) $.get(this.url, this.parameters, Trend.onLoadData, 'xml');
}

Trend.onLoadData = function(xmlData) {
	var id, i, j, attr;
	Preloader.hide();
	var items=xmlData.getElementsByTagName('item');
	for (i=0; i<items.length; i++) {
		attr=items[i].attributes;
		if (attr.length) {
			if (attr.getNamedItem('id')) {
				id=attr.getNamedItem('id').nodeValue;
				$('#trend_'+id+'_container').attr('className', (attr.getNamedItem('arrow') ? attr.getNamedItem('arrow').nodeValue : ''));
				$('#trend_'+id+'_count').html(attr.getNamedItem('count') ? attr.getNamedItem('count').nodeValue : 0);
				$('#trend_'+id+'_percent').html(attr.getNamedItem('percent') ? attr.getNamedItem('percent').nodeValue : 0);
			}
		}
	}
	onResize();
}