var ModalWindow = Class.create({	initialize: function(id, options) {		this.id = 'Modal_' + id;		this.content_id = id;				this.width = options.width ? options.width : 200;		this.height = options.height ? options.height : 100;		this.opacity = options.opacity ? options.opacity : 0.5;		this.modal = typeof options.modal == 'undefined' ? true : options.modal;		this.openEffect = options.openEffect ? options.openEffect : false;		this.openOptions = options.openOptions ? options.openOptions : null;		this.closeEffect = options.closeEffect ? options.closeEffect : false;		this.closeOptions = options.closeOptions ? options.closeOptions : null;				if (!$('ModalOverlay')) {			new Insertion.Bottom(document.body, '<div id="ModalOverlay" style="display:none">&nbsp;</div>');			$('ModalOverlay').absolutize();			$('ModalOverlay').setOpacity(this.opacity);			Event.observe(document.onresize ? document : window, 'resize', this.adjustOverlay.bindAsEventListener(this));			Event.observe(document.onscroll ? document : window, 'scroll', this.adjustOverlay.bindAsEventListener(this));			Event.observe($('ModalOverlay'), 'click', this.onOverlayClick.bindAsEventListener(this));		}				if (!$(this.id)) {			new Insertion.Bottom(document.body, '<div id="' + this.id + '" class="ModalWindow" style="display:none"></div>');			new Insertion.Top(this.id, $(this.content_id).remove());			$(this.id).absolutize();			$(this.id).setStyle({ height : this.height + 'px', width : this.width + 'px' });			this.centerWindow(false);						Event.observe(document.onresize ? document : window, 'resize', this.centerWindow.bindAsEventListener(this));		}				var open = $$('[href=#' + this.content_id + ']');		for (var i=0; i<open.length; i++) 			Event.observe(open[i], 'click', this.open.bindAsEventListener(this));					var close = $$('div#' + this.id + ' .close');		for (var i=0; i<close.length; i++) 			Event.observe(close[i], 'click', this.close.bindAsEventListener(this));			this.adjustOverlay();	},	centerWindow: function(event) {		var left = parseInt((document.viewport.getWidth() - this.width) / 2);		var top = parseInt((document.viewport.getHeight() - this.height) / 2);		if (event != false) {			new Effect.Move(this.id, { x: left, y: top, mode: 'absolute', duration:0.2 });		} else {			$(this.id).setStyle({ top: top + 'px', left: left + 'px' });		}	},	adjustOverlay: function(event) {		$('ModalOverlay').style.height = (document.viewport.getDimensions().height + document.viewport.getScrollOffsets().top) + 'px';	},	open: function(event) {		$(this.id).absolutize();				switch (this.openEffect) {			case 'Appear': 		new Effect.Appear(this.id, this.openOptions); break;			case 'BlindDown': 	new Effect.BlindDown(this.id, this.openOptions); break;			case 'Grow': 		new Effect.Grow(this.id, this.openOptions); break;			case 'SlideDown': 	new Effect.SlideDown(this.id, this.openOptions); break;			default: $(this.id).show();		}		$('ModalOverlay').show();	},	close: function(event) {		switch (this.closeEffect) {			case 'BlindUp': 	new Effect.BlindUp(this.id, this.closeOptions); break;			case 'DropOut': 	new Effect.DropOut(this.id, this.closeOptions); break;			case 'Fade': 		new Effect.Fade(this.id, this.closeOptions); break;			case 'Fold': 		new Effect.Fold(this.id, this.closeOptions); break;			case 'Puff': 		new Effect.Puff(this.id, this.closeOptions); break;						case 'Shrink': 		new Effect.Shrink(this.id, this.closeOptions); break;			case 'SlideUp': 	new Effect.SlideUp(this.id, this.closeOptions); break;			case 'Squish': 		new Effect.Squish(this.id, this.closeOptions); break;			case 'SwitchOff': 	new Effect.SwitchOff(this.id, this.closeOptions); break;			default: $(this.id).hide();		}		this.closeOptions.duration ? Element.hide.delay(this.closeOptions.duration , 'ModalOverlay') : $('ModalOverlay').hide();	},	onOverlayClick: function(event) {		if (!this.modal) this.close(false);	}});