

function xmlLoader ( hash, tmpl){
	this.target_id = hash.target_id;
	this.maxlength= hash.maxlength;
	this.hash = hash;
	this.hash.url = this.hash.url + "?date="+(new Date()).getTime();
	this.tmpl_success = tmpl;
	this.itemLength = 0;
}

xmlLoader.prototype = {

	load: function(hash) {
		var _this = this;
		_this.hash.success = function( xml, status ){
			_this.success( xml, status, _this );
		}
		_this.hash.error = function( xml, status ){
			_this.error( xml, status, _this );
		}
		$.ajax(_this.hash);
	},

	success: function( xml, status, el ){

		var html = '';
		var _this = el;

		_this.itemLength = $(xml).find('item').length;

		$(xml).find('item').each(function(i){
			if( i>=_this.maxlength ) return;
			html += _this.tmpl_success.template( $(this) );
		});

		$(_this.target_id).empty();
		$(_this.target_id).append(
			$(_this.tmpl_success.container).html(html)
		);
/*
		if( $(_this.tmpl_success.heading) )
			$(_this.tmpl_success.heading).prependTo($(_this.target_id));
*/

		if( typeof (_this.loaded) == "function") _this.loaded();
	},

	error: function( xml, status, el ){
		
	},


	tmpl_success: {
		container: '',
		template: function(){}
	}
}



