var Contents = Class.create();

Contents.prototype = Object.extend(new AttachInnerHTML(), {
	initialize: function() {
		this.loadContents();
	},

	loadContents: function() {
		new Ajax.Request(
			"contents/contents.xml", {
				method: 'get',
				requestHeaders: ['If-Modified-Since','Wed, 15 Nov 1995 00:00:00 GMT'],
				onSuccess: this.viewContents.bind(this),
				onFailure : function(error) {
					alert(error.responseText);
				}
			});
	},

	viewContents: function(xml) {
		var xml = xml.responseXML.documentElement;
		var items = getNode('item', xml);
		var text = "";

		for	(var cnt = 0; cnt < items.length; cnt++) {
			var title = getAttributes(items[cnt])['-title'];
			var url = getSimpleValue('url', items[cnt]);
			var description = getSimpleValue('description', items[cnt]);
			text += '<a href="' + url + '">' + title + '</a>';
			if	(description != "") text += '<span class="contents_description">（' + description + '）</span>';
			text += '<br/>';
		}
		this.attachInnerHTML('contents',  text);
	}
});

