/**
 * @author David Sugden
 */
jQuery.fn.feed = function(options) {

	var container = jQuery(this);

	var output = '';

	var url = '/proxy/venuetickets.php';

	var feedExtract = function(xmlResponse) {
		jQuery("gig", xmlResponse).each( function() {
			var title = jQuery("title", this).text();
			var link = jQuery("link", this).text();
			var description = jQuery("description", this).text();
			var item = '<a href="' + link + '">' + title + '</a>';
			item = '<li>' + item + '</li>';
			output += item;
		});
		output = '<ul class="list">' + output + '</ul>';
		jQuery(container).replaceWith(output);
	};
		
	jQuery.ajax({
		type: "GET",
		url: url,
		data: { venue: venue },
		dataType: "xml",
		timeout: 4000,
		success: function(xmlResponse){
			feedExtract(xmlResponse);
		},
		error: function(x,y,z){
			jQuery(container).replaceWith('No tickets found.');
		}
	});   

	return container;
};