YUI().use('overlay', 'node', function(Y){
	/* Lightbox class constructor */
	function Lightbox(config) {
		Lightbox.superclass.constructor.apply(this, arguments);
	}

	Lightbox.NAME = 'overlay';
	Lightbox.ATTRS = {
	};

	Y.extend(Lightbox, Y.Overlay, {
		_setContent: function(href){
			var iframe = Y.Node.create('<iframe id="elite_club_iframe" width="100%" height="585" src="' + href + '" />');
			this.setStdModContent('body', iframe);
			this.set('centered', true);
		},

		bindUI: function(){
			Y.on('click', Y.bind(this._onClick, this), '#elite_club_signup');
			Y.before(this._attachCloseListener, this, 'show');
			Y.before(this._detachCloseListener, this, 'hide');
		},

		_attachCloseListener: function(){
			var boundingBox = this.get('boundingBox');
			var close = boundingBox.one('.close');
			Y.on('click', Y.bind(this._hide, this), close);
		},

		_detachCloseListener: function(){
			Y.Event.detach('click', null, this.get('boundingBox').one('.close'));
		},

		_hide: function(e){
			e.preventDefault();
			this.hide();
			if (Y.UA.ie > 0) {
				this._setContent(' ');
			}
		},

		_onClick: function(e){
			e.preventDefault();
			this._setContent(e.currentTarget.get('href'));
			this.show();
		}
	});

	// Create a new Lightbox instance
	var lightbox = new Lightbox({
		width: '50%',
		height: '585px',
		zIndex: 10,
		visible: false,
		centered: true,
		constrain: true,
		headerContent: '<a href="#" class="close">X</a>',
		modal: true
	});
	lightbox.render();
});

