$(function() {
/*
	var cacheid = new Date();
	cacheid.setMilliseconds(0);
	cacheid.setSeconds(0);
	cacheid.setMinutes(Math.floor(cacheid.getMinutes() / 25));
	$.getJSON('http://pipes.yahoo.com/pipes/pipe.run?CacheID=' + cacheid.getTime() + '&Filters=LOOT&ItemLevel=251&Names=Sheeana%2CTaraza%2CWiven%2CLeida%2CIthera%3BOnka%2CGnuss%2CZilah%2CNagatamen%3BWannachei%2CNatural&Server=Defias+Brotherhood&_id=294b01adde21ad11bdce3fc2d79fb1db&_render=json&_callback=?', function(data) {
		var items = data.value.items;
*/
	$.getJSON('/armory_feed.json', function(data) {
		var items = data;
		var $feeder = $(document.createElement('div'));
		$feeder.css('padding', '30px 12px');
		$('#page-footer').children().eq(0).after($feeder);
		$feeder.next().remove();
		$feeder.next().remove();
		$feeder.next().remove();
		$feeder.next().remove();
		for (var i = 0; i < items.length && i < 25; i++) {
			var name = (items[i].description || items[i].content).match(/^<.*?>(.*?)</).pop();
			var item = (items[i].description || items[i].content).match(/>\[(.*?)\]</).pop();
			var itemid = (items[i].description || items[i].content).match(/item-info\.xml\?i=([0-9]+)">/).pop();
			var equip = !!(items[i].description || items[i].content).match(/>\(Equipped\)</);
			var date = items[i].published.match(/^(.*?)T/).pop();
			$feeder.append(date + ' <a href="http://eu.wowarmory.com/character-sheet.xml?r=Defias+Brotherhood&cn=' + name + '" target="_blank" style="color: rgb(0, 112, 221);">' + name + '</a> obtained <a href="http://www.wowhead.com/?item=' + itemid + '" class="q4" target="_blank">' + item + '</a>' + (equip ? ' (equipped)' : '') + '.<br />');
		}
		$('.feeder_wowhead').each(function() {
			var el = $(this);
			$.ajax({
				type: 'GET',
				url: el.attr('href'),
				dataType: 'xml',
				success: function(data) {
					el.html($('name',data).text())
					el.attr('href',$('link',data).text())
					el.addClass('q'+$('quality',data).attr('id'))
				}
			});
		});
	});
});

