Edit = {
	open: function(url, param) {
		if (!param.confirm || confirm(param.confirm)) {
			editCache = null;
			window.open(url, 'edit', {
				width: param.width, height: param.height,
				left: (screen.width - width - 20),
				top: 40, resizable: 1, scrollbars: 1, noFocus: 1
			});
		}
		return false;
	}, 
	
	openFrame: function(url, param) {
		if (!param.confirm || confirm(param.confirm)) {
			var name = param.id + "-edit-frame";
			if (self.editMask) {
				// only close if not the same
				if (editMask.frame.name != name)
					editMask.close();
				delete editMask;
				delete editCache;
			}
			var el = $(param.id);
			var bounds = el.getBounds();
			var prog = $(param.editId + "-edit-progress");
			var btns = $(param.editId + "-edit-buttons");
			if (prog) {
				var hideBtns = prog.getParent() != btns;
				prog.removeClass('hidden');
				if (hideBtns) btns.addClass('hidden');
			}
			var form = $E('form', btns);
			form.enable(false);
			
			// create / reuse edit frame
			var frame = el.frame;
			if (frame) frame.removeClass('hidden');
			else frame = el.frame = new Element('iframe')
				.setProperties({ name: name, id: name, scrolling: 'no' })
				.setStyles({ width: "100%", border: 'none' })
				.injectAfter(el);
			frame.height = 0;

			frame.show = function() {
				el.addClass('hidden');
				if (prog) {
					prog.addClass('hidden');
					if (hideBtns) btns.removeClass('hidden');
				}
				window.scrollBy(0, -1);
				window.scrollBy(0, 1);
				form.enable(true);
			};

			frame.close = function() {
				frame.addClass('hidden');
				el.removeClass('hidden');
			};

			frame.autoSize = function(body) {
				var height = body.offsetHeight;
				if (Browser.MACIE) {
					// on mac, clear height, then wait for offsetHeight to change...
					frame.height = "";
					var count = 0;
					var timer = (function() {
						window.status = count;
						var newHeight = body.offsetHeight;
						if (newHeight != height || count++ > 50) {
							frame.height = newHeight + "px";
							timer.clear();
						}
					}).periodic(1);
				} else {
					frame.height = height + 'px';
				}
			};

			(function() {
				window.frames[name].location = url;
			}).delay(1);
		}
		return false;
	}
}