var window_factory = function(container,test,options){
		var window_header = new Element('div',{
			className: 'window_header'
		});
		var window_title = new Element('div',{
			className: 'window_title'
		});
		var window_close = new Element('div',{
			className: 'window_close'
		});
		var window_contents = new Element('div',{
			className: 'window_contents'
		});
		if(test == 'terms') 
		{
			var w = new Control.Window(container,Object.extend({
				className: 'simple_window',
				width: 480,
				closeOnClick: window_close,
				draggable: window_header,
				insertRemoteContentAt: window_contents,
				afterOpen: function(){
					window_title.update(container.readAttribute('title'))
					}
				},options || {}));
		}
		else
		{
			var w = new Control.Window(container,Object.extend({
				className: 'simple_window',
				closeOnClick: window_close,
				draggable: window_header,
				insertRemoteContentAt: window_contents,
				afterOpen: function(){
					window_title.update(container.readAttribute('title'))
					}
				},options || {}));
		}
			w.container.insert(window_header);
			window_header.insert(window_title);
			window_header.insert(window_close);
			w.container.insert(window_contents);
			return w;

	};

document.observe("dom:loaded", function() {
    $$('.mo_details').each(function(elm){  
        window_factory(elm.down('.default'),'default');
        window_factory(elm.down('.terms'),'terms');
    });
});