//document.observe("dom:loaded", function() {
Event.observe(window,'load',function(){
	var maxh = $$('div.smBox').max(function(elm) {
		return elm.getHeight();
	});
	$$('div.smBox').each(function(elm) {
		elm.setStyle({ height:maxh-20+'px' });
	});

	$$('div[class~=borderBox]').each(function(elm) {
		if (elm.readAttribute('box').isJSON()) {
			var params = elm.readAttribute('box').evalJSON();
			if (params.w && params.h && params.pre) {
				var w = params.w;
				var h = params.h;
				var pre = params.pre;

				elm.setStyle({ position:'relative' });
				elm.insert(new Element('div').setStyle({ position:'absolute', top:'-'+h+'px', left:'-'+w+'px', background:'url(/_mf/_img/'+pre+'_corners.png) left top no-repeat', width:w+'px', height:h+'px' }));
				elm.insert(new Element('div').setStyle({ position:'absolute', top:'-'+h+'px', right:'-'+w+'px', background:'url(/_mf/_img/'+pre+'_corners.png) right top no-repeat', width:w+'px', height:h+'px' }));
				elm.insert(new Element('div').setStyle({ position:'absolute', bottom:'-'+h+'px', left:'-'+w+'px', background:'url(/_mf/_img/'+pre+'_corners.png) left bottom no-repeat', width:w+'px', height:h+'px' }));
				elm.insert(new Element('div').setStyle({ position:'absolute', bottom:'-'+h+'px', right:'-'+w+'px', background:'url(/_mf/_img/'+pre+'_corners.png) right bottom no-repeat', width:w+'px', height:h+'px' }));
				elm.insert(new Element('div').setStyle({ position:'absolute', top:'-'+h+'px', left:'0px', background:'url(/_mf/_img/'+pre+'_top.png) repeat-x', width:elm.getWidth()+'px', height:h+'px' }));
				elm.insert(new Element('div').setStyle({ position:'absolute', bottom:'-'+h+'px', left:'0px', background:'url(/_mf/_img/'+pre+'_btm.png) repeat-x', width:elm.getWidth()+'px', height:h+'px' }));
				elm.insert(new Element('div').setStyle({ position:'absolute', top:'0px', left:'-'+w+'px', background:'url(/_mf/_img/'+pre+'_left.png) repeat-y', width:w+'px', height:elm.getHeight()+'px' }));
				elm.insert(new Element('div').setStyle({ position:'absolute', top:'0px', right:'-'+w+'px', background:'url(/_mf/_img/'+pre+'_right.png) repeat-y', width:w+'px', height:elm.getHeight()+'px' }));
			}
		} else {
			alert('Invalid borderBox definition');
		}
	});
});