

info_form = {
	load: function() {
		//create our form window element
		info_form.win = new Element('div');
		$(info_form.win).hide();
		$$('body').first().appendChild(info_form.win);


		new Ajax.Updater($(info_form.win), 'form.html', {
			method: 'get',
			onComplete: info_form.show.bind(info_form)
		});
	},

	show: function() {
			//center the window
			this.win.absolutize();
			this.win.style.width = "auto";
			this.win.style.height = "auto";
			this.win.style.zIndex = "10000000"; //everyone picks an arbitrary "high" number to make sure their element is on top ... so I picked an arbitrary higher number :(
			this.win.style.top = (document.viewport.getHeight() / 2) - (this.win.getHeight() / 2) + (document.viewport.getScrollOffsets())['top'] + 'px';
			this.win.style.left = (document.viewport.getWidth() / 2) - (this.win.getWidth() / 2) + (document.viewport.getScrollOffsets())['left'] + 'px';
			this.win.show();

			Event.observe(document, 'click', this._clickHandle = info_form.clickHandle.bindAsEventListener(info_form));
			Event.observe($(this.win).select('form').first(), 'submit', this._submitHandle = info_form.submitHandle.bindAsEventListener(info_form));
	},
			
	close: function() {
					Event.stopObserving(document, 'click', this._clickHandle);
					Event.stopObserving($(this.win).select('form').first(), 'submit', this._submitHandle);
					this.win.hide();
					this._clickHandle = null;
					this._submitHandle = null;
	},

	clickHandle:	function(e) {
				element = Event.element(e);
				if (element.id == "rpc_form_cancel" || !Element.descendantOf(element,this.win)){
					this.close();
					if (element.id == "rpc_form_cancel")
						Event.stop(e);
				}
	},

	submitHandle: function(e) {
		f = Event.element(e);
		new Ajax.Request('rpc_info_form.asp', {
			method: 'post',
			postBody: Form.serialize(f)
		});
		Event.stop(e);
		this.close();
	}
};
	

document.observe("dom:loaded", info_form.load);













