if(!window.jrayl){window.jrayl = {};}
if(!jrayl.RssToList){jrayl.RssToList = {};}

jrayl.RssToList = function(options){
	this.parentEl = $(options.parent);
	this.url = options.url;
	this.title = options.title;

	this.populate();
}
jrayl.RssToList.prototype = {
	populate: function(){
	    var ref = this;

		if( this.title.length > 0){
	    	ref.header = $('<h2>' + ref.title + '</h2>').appendTo(ref.parentEl);
	    }
	    
		ref.list = $('<ul>').appendTo(ref.parentEl);

        $.ajax({
		    type: "GET",
			url: ref.url, // "rss/last_10_deliveries.rss",
			async: false,
			dataType: "xml",
			success: function(xml) {
			    $(xml).find('item').each(
					function(){
					    //alert($(this).find('title').text());
					    $('<li>' + $(this).find('description').text() + '</li>').appendTo(ref.list);
					}
				);
			}
		});

	}
}
