var fancy_border_is_init = 0;

function fancyborder(){

	if(fancy_border_is_init == 1) return;	
	var tl = 'url(wp-content/themes/default/images/rounded_tl.gif)';
	var tc = 'white';
	var tr = 'url(wp-content/themes/default/images/rounded_tr.gif)';
	
	var cl = 'white';
	var cc = 'white';
	var cr = 'white';
	
	var bl = 'url(wp-content/themes/default/images/rounded_bl.gif)';
	var bc = 'white';
	var br = 'url(wp-content/themes/default/images/rounded_br.gif)';
	
	var height_top = 10;
	var height_bottom = 11;
	var width_left = 10;
	var width_right = 10;
	
	var divs = $$('.fancy-border');
	var content = '';
	var width;
	var height;
	for(var i = 0; i<divs.length; i++){
		var div = divs[i];
		width = div.offsetWidth;
		height = div.offsetHeight;
		content = div.innerHTML;

		div.style.width = width + width_left + width_right + 'px';
		div.style.height = height + height_top + height_bottom + 'px';
		
		var html = '<div style="background:'+tl+' no-repeat; width:'+width_left+'px; height:'+height_top+'px; float:left; overflow:hidden;"></div>';
		html += '<div style="background:'+tc+' repeat-x; width:'+width+'px; height:'+height_top+'px; float:left; overflow:hidden;"></div>';
		html += '<div style="background:'+tr+' no-repeat; width:'+width_right+'px; height:'+height_top+'px; float:left; overflow:hidden;"></div>';
		html += '<div style="clear:left"></div>';
		html += '<div style="background:'+cl+' repeat-y; width:'+width_left+'px; height:'+height+'px; float:left; overflow:hidden;"></div>';
		html += '<div style="overflow:auto; background:'+cc+'; width:'+width+'px; height:'+height+'px; float:left;">';
		html += content;
		html += '</div>';
		html += '<div style="background:'+cr+' repeat-y; width:'+width_right+'px; height:'+height+'px; float:left; overflow:hidden;"></div>';
		html += '<div style="clear:left"></div>';
		html += '<div style="background:'+bl+' no-repeat; width:'+width_left+'px; height:'+height_bottom+'px; float:left; overflow:hidden;"></div>';
		html += '<div style="background:'+bc+' repeat-x; width:'+width+'px; height:'+height_top+'px; float:left; overflow:hidden;"></div>';
		html += '<div style="background:'+br+' no-repeat; width:'+width_right+'px; height:'+height_bottom+'px; float:left; overflow:hidden;"></div>';
		html += '<div style="clear:left"></div>';
		
		div.innerHTML = html;
	}
	div.removeClassName('fancy-border'); 
}

//document.observe('dom:loaded',function(){ fancyborder(); });
