/**
 * Adds a notice to IE6 and below notifying the user that their browser sucks.
 */
var IE6Notice = {
	initialize: function() {
		var note = Builder.node('p',{id: 'ie6notice'},'You are using a horrible browser that I just don\'t have time to deal with, so my site might look like crap on your computer. Upgrade.');
		$('page').insertBefore(note,$('content'));
	}
}

/**
 * Grabs a JSON feed and outputs it on the page as an unordered list
 * 
 * @class
 * @param {string} sUrl
 * @param {string/DOMElement} The element to add the UL to
 */
var DeliciousFeed = Class.create();
DeliciousFeed.prototype = {
	initialize: function(sUrl, mElement) {
		// add delicious url checking here!!!
		new Ajax.Request('/wp-content/themes/dandean/_inc/js/gateway.php', {
			method: 'post',
			parameters: {url: sUrl},
			onSuccess: function(transport) {
				var json = eval(transport.responseText);
				var ul = Builder.node('ul');
				json.each(function(item, i) {
					var text = (item.n) ? item.n : item.d ;
					ul.appendChild(
						Builder.node('li',Builder.node('a',{href: item.u,target:'_blank'},text))
					);
				});
				mElement.appendChild(ul);
			},
			onFailure: function(transport) {
				if (typeof console != 'undefined') {
					console.log(transport);
				}
			}
		});
	}
}

Event.observe(window,'load',function() {
	if (location.host.toLowerCase().indexOf('dandean.com') > -1) {
		var pageTracker = _gat._getTracker("UA-317916-1");
		pageTracker._setDomainName("dandean.com");
		pageTracker._initData();
		pageTracker._trackPageview();
	}
	new DeliciousFeed('http://feeds.delicious.com/feeds/json/dandean/linkroll?raw',$('links'));
});