/*

If you understand what's happening below, why not send me your resume?
I work for a great, young company in New Zealand that wants to take over
the world, but we need your help!  Email me your resume or CV at:

   andrew (dot) hedges (at) vianet (dot) travel

Oh, if you want to use the code below, feel free.  But if you do, please
let me know.  Thanks!

-Andrew

*/
var magnolia = {
	link: new Template('<a href="#{link}">#{title}<\/a><br \/>'),
	src: 'http://ma.gnolia.com/rss/lite/people/segdeha',
	proxy: '/common/proxy.php?src=',
	init: function () {
		magnolia.request();
	},
	request: function () {
		new Ajax.Request(
			magnolia.proxy + encodeURIComponent(magnolia.src), {
			method: 'get',
			onComplete: function (transport) {
				var xml = transport.responseXML;
				if (undefined !== xml) {
					magnolia.process(xml);
				}
			}
		});
	},
	process: function (xml) {
		var items = $A(xml.getElementsByTagName('item'));
		var html = '';
		items.each(function (item) {
			var linkNodes, titleNodes, link, title;
			linkNodes = item.getElementsByTagName('link');
			link = linkNodes[0].firstChild.nodeValue;
			titleNodes = item.getElementsByTagName('title');
			title = titleNodes[0].firstChild.nodeValue.trim();
			html += magnolia.link.evaluate({link: link, title: title});
		});
		$('magnolias').innerHTML = html;
	}
};

