var RoundedCorners = {
	init: function () {
		$$('.post').each(function (el) {
			RoundedCorners.make_corner(el, 'corner-grey', 'tl', -1);
			RoundedCorners.make_corner(el, 'corner-grey', 'tr', -1);
			RoundedCorners.make_corner(el, 'corner-grey', 'bl', -1);
			RoundedCorners.make_corner(el, 'corner-grey', 'br', -1);
		});

		$$('.widget h3').each(function (el) {
			RoundedCorners.make_corner(el, 'corner-trans', 'tl');
			RoundedCorners.make_corner(el, 'corner-trans', 'tr');
		});

		$$('.widget').each(function (el) {
			RoundedCorners.make_corner(el, 'corner-trans', 'bl');
			RoundedCorners.make_corner(el, 'corner-trans', 'br');
		});
	},

	make_corner: function (elem, iclass, which, off) {
		elem.setStyle({position: 'relative'});
		var d = new Element('div');
		d.addClassName(iclass);

		var bpos = '';
		var map = {'t': 'top', 'l': 'left', 'r': 'right', 'b': 'bottom'};
		var style = {'position': 'absolute'};

		for (var i=0; i < which.length; i++) {
			var c = which.charAt(i);
			
			if (bpos)
				bpos += ' ';
			bpos += map[c];

			style[map[c]] = (off) ? off + 'px' : '0';
		}
		style['backgroundPosition'] = bpos;		

		d.setStyle(style);

		elem.insert(d);
	}
};

Event.observe(document, 'dom:loaded', RoundedCorners.init);


