NudgeList = function( properties )
{
	this.properties = properties;
	this.reload();
	this.times = 0;
}
NudgeList.prototype = {
	reload: function() {
		var that = this;
		$.ajax({
			url: this.properties.url,
			dataType: "html",
			type: "GET",
			success: function(data) { that.receive(data); },
			error: function( e ) { that.error(e); }
		});
	},
	receive: function( data ) {
		var hits = new Array();
		var ids = new Array();
		data = $( "<xml>"+data+"</xml>" );
		$("item", data ).each( function( no, elem ) {
			hits.push( $(elem).attr("hits") );
			ids.push( $(elem).text() );
		});
		for( var i=ids.length; i>=0; --i )
		{
			if (window.hiddenNudges && window.hiddenNudges.indexOf(ids[i]+';') >= 0) {
        if (hits)
        {
          hits.splice(i,1);
        }
        ids.splice(i,1);
      }
		}
		this.properties.update( ids, hits );
		var that = this;
		setTimeout( function(){ that.reload() }, 60000 );
	},
	error: function( request,e) {
		if( this.times < 3 )
		{
			var that = this;
			this.times ++;
			setTimeout( function(){ that.reload() }, 500 );
		}
	}
}