function FacebookEventDisplay(options) {

	var self = this;
	
	this.init = function(options) {
		this.div_id = options['div_id'];
		this.access_token = options['token'];
		this.event_id = options['event_id'];
		FB.api(
			'/'+this.event_id+'/attending?access_token='+this.access_token,
			function(response) {
				if (response.data && response.data.length >= 1) {
					self.create_content(response.data);
				}
			}
		);
	}
	
	this.create_content = function(attendees) {
		self.div = $('#'+self.div_id);
		self.div.addClass('facebook-event-display');
		var attendees_count = attendees.length;
		var html = '';
		html += '<div class="event-attendees-container">';
		attendees = attendees.slice(0, 4);
		for (var i in attendees) {
			var attendee = attendees[i];
			var picture_url = self.get_picture_url(attendee['id']);
			var first_name = self.get_first_name(attendee['name']);
			html += '<div class="attendee">'+
					'<div class="attendee-image">'+
						'<img src="'+picture_url+'" />'+
					'</div>'+
					'<div class="attendee-name">'+first_name+'</div>'+
				'</div>';
		}
		html += '</div>';
		html += '<div class="event-meta-container">';
		html += '<div class="event-link">'+
				'<a href="'+self.get_event_url(self.event_id)+'" title="Facebook Event" target="_blank"></a>'+
			'</div>';
		html += '<div class="event-attendees-count">'+
				attendees_count+' '+(attendees_count == 1 ? 'person has' : 'people have')+' confirmed on Facebook'+
			'</div>';
		html += '<div class="clear"></div>';
		html += '</div>';
		self.div.html(html);
	}
	
	this.get_picture_url = function(id) {
		return 'https://graph.facebook.com/'+id+'/picture';
	}
	
	this.get_event_url = function(id) {
		return 'http://www.facebook.com/event.php?eid='+id;
	}
	
	this.get_first_name = function(name) {
		var name_split = name.split(' ');
		return name_split[0];
	}

	if (typeof $.mobile != 'undefined') {
		$("div[data-role*='page']").live('pageshow', function (event, ui) {
			if (typeof FB == 'undefined') {
				window.fbAsyncInit = function() {
					self.init(options);
				};
			} else {
				self.init(options);
			}
		});
	} else {
		$(document).ready(function(){
			self.init(options);
		});
	}

}
