/******************************************
 * The Content Modal Class
 *
 * Opens a content modal on the page.
 ******************************************/

onepica.Modal.Content = Class.create(onepica.Modal, {
	/**
	 * Constructor
	 *
	 * Add the option {useOverlay: true} to disable the screen when the modal is open.
	 */
	initialize: function (customOptions) {
		this.containerId = 'content-modal';
		var options = Object.extend(this.options, {
			className: 'content-modal',
			zIndex: 1000,
			showEffect: Effect.Appear,
			hideEffect: Effect.Fade,
			useOverlay: true,
			onClose: this.hideWindow.bindAsEventListener(this),
			recenterAuto: false
		});

		// custom options
		options = Object.extend(options, customOptions || {});
		loadOptions = Object.extend(this.loadOptions, customOptions);
		if (options['useOverlay'] && options['useOverlay'] === true) {
			this.useOverlay = true;
		}
		loadOptions['destroyOnClose'] = options['destroyOnClose'];

		this.window = new Window(this.containerId, options);
		this.loadWindow = new Window(this.containerId + '-load', loadOptions);
	},

	/**
	 * Load content via an asynchronous request.
	 *
	 * @param Event e
	 * @param string url
	 */
	load: function($super, e, url) {
		if (Object.isString(url))
			this.setUrl(url);

		this.eventCreate = this.loadCreate.bindAsEventListener(this);
		this.eventSuccess = this.loadSuccess.bindAsEventListener(this);
		this.eventFailure = this.loadFailure.bindAsEventListener(this);

		var options = {
			method: 'get',
			onCreate: this.eventCreate,
			onSuccess: this.eventSuccess,
			onFailure: this.eventFailure
		};	
		$super(options);
	}
});