$(function() {
	rcorners_rebuild();
});
function rcorners_get_markup(className, bgcolor, hide, inverse) {
	var hide_html = hide ? ' style="display: none"' : '';
	var background_html = bgcolor ? ' style="background: ' + bgcolor + '"' : '';
	var h1 = '<b class="n1- s3-"><i><span></span></i></b>';
	var h2 = '<b class="n2- s2-"><i><span></span></i></b>';
	var h3 = '<b' + background_html + ' class="n3- s1-"><i><span></span></i></b>';
	var h4 = '<b' + background_html + ' class="n4-"><i><span></span></i></b>';
	var h5 = '<b' + background_html + ' class="n5-"><i><span></span></i></b>';
	var html = '<div' + hide_html + ' class="rcorners-added ' + className + '">';
	html += !inverse ? (h1 + h2 + h3 + h4 + h5) : (h5 + h4 + h3 + h2 + h1);
	html += '</div>';
	return html;
}
function rcorners_rebuild() {
	$('.rcorners-top-color-5-2').each(function() {
		if ($(this).attr('processed_top')) return;
		$(this).css('border-top', '0');
		$(this).parent().css('border-top', '0');
		$(this).parent().before(rcorners_get_markup('rcorners-color show-with-h2', rcorners_config.bgcolor_1, false));
		$(this).attr('processed_top', '1');
	});
	$('.rcorners-top-white-5-2').each(function() {
		if ($(this).attr('processed_top')) return;
		$(this).css('border-top', '0');
		$(this).parent().css('border-top', '0');
		$(this).parent().before(rcorners_get_markup('rcorners-white show-without-h2', '#fff', false));
		$(this).attr('processed_top', '1');
	});
	$('.rcorners-top-color-5-2-invisible').each(function() {
		if ($(this).attr('processed_top')) return;
		$(this).css('border-top', '0');
		$(this).parent().css('border-top', '0');
		$(this).parent().before(rcorners_get_markup('rcorners-color show-with-h2', rcorners_config.bgcolor_1, true));
		$(this).attr('processed_top', '1');
	});
	$('.rcorners-top-white-5-2-invisible').each(function() {
		if ($(this).attr('processed_top')) return;
		$(this).parent().css('border-top', '0');
		$(this).parent().before(rcorners_get_markup('rcorners-white show-without-h2', '#fff', true));
		$(this).attr('processed_top', '1');
	});
	$('.rcorners-bottom-widget-5-2').each(function() {
		if ($(this).attr('processed_bottom')) return;
		$(this).css('border-bottom', '0');
		$(this).after(rcorners_get_markup('rcorners-widget', '', false, true));
		$(this).attr('processed_bottom', '1');
	});
	$('.rcorners-top-gray-5-2').each(function() {
		if ($(this).attr('processed_top')) return;
		$(this).css('border-top', '0');
		$(this).parent().css('border-top', '0');
		$(this).parent().parent().css('border-top', '0');
		$(this).parent().parent().before(rcorners_get_markup('rcorners-gray', '#ecedea', false));
		$(this).attr('processed_top', '1');
	});
	$('.rcorners-bottom-gray-5-2').each(function() {
		if ($(this).attr('processed_bottom')) return;
		$(this).css('border-bottom', '0');
		$(this).parent().css('border-bottom', '0');
		$(this).parent().parent().css('border-bottom', '0');
		$(this).parent().parent().after(rcorners_get_markup('rcorners-gray', '#ecedea', false, true));
		$(this).attr('processed_bottom', '1');
	});
}
