/**
 * @author Gethin
 */
(function(){
	var script = document.getElementById('gwBuyLink'),
		album = 'scarecrow',
		data = {scarecrow: {
			title: 'Scarecrow',
			paypal: {price: 'Only &pound;6.99 (+ &pound;1 p&amp;p)', id: 6147475},
			others: [
				{href: 'http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewAlbum?id=317207943&amp;s=143444',
				src: 'http://www.allthingsconsidered.org.uk/images/iTunes_142x38.png',
				alt: 'iTunes'
				},
				{href: 'http://www.amazon.co.uk/gp/product/B002BWIX04/',
				src: 'http://www.allthingsconsidered.org.uk/images/Amazon_logo.gif',
				alt: 'Amazon.co.uk'
				},
				{href: 'http://www.amazon.co.uk/Scarecrow/dp/B002B3K39W',
				src: 'http://www.allthingsconsidered.org.uk/images/Amazon_Mp3_142x38.png',
				alt: 'Amazon MP3'
				}
			]
		}},
		html = '<style type="text/css">.gwBuyLink a img, .gwBuyLink a, .gwBuyLink img {border: 0;} .gwBuyLink dl, .gwBuyLink dt, .gwBuyLink dd {margin: 0;} .gwBuyLink {text-align: center;}</style>' + 
    '<dl class="gwBuyLink">' + 
			'<dt style="font-size:1.2em;font-weight:bold">Buy "' + data[album].title + '" online</dt>' + 
			'<dd><form action="https://www.paypal.com/cgi-bin/webscr" method="post"><div>' +
				'<input type="hidden" name="cmd" value="_s-xclick"/>' +
				'<input type="hidden" name="hosted_button_id" value="' + data[album].paypal.id + '"/>' +
				'<input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_buynow_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online."/>' +
				'<img alt="" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1"/>' +
					'</div></form></dd>' + 
			'<dd>' + data[album].paypal.price + '</dd>' + 
			'<dt style="font-size:1.2em;font-weight:bold">Also available from:</dt>',
		newEl = document.createElement('div');
	
	for (var i=0; i<data[album].others.length; i++) {
		html += '<dd><a href="' + data[album].others[i].href + '" title="' + data[album].others[i].alt + '">';
		html += '<img src="' + data[album].others[i].src + '" alt="' + data[album].others[i].alt + '"/>';
		html += '</a></dd>';
	}
	html += '</dl>';
	newEl.innerHTML = html; 
	script.parentNode.insertBefore(newEl,script);
})();
