function parseSpans(anchor)
{
	anchor = anchor.toLowerCase();
	var prevtitle = "";

	$("span[class*='" + anchor + "']").each(function()
	{
		if(!this.className) return;

		var span = $(this);
		var classes = this.className.toLowerCase().split(" ");
		var element = "";

		if(typeof(classes) == "string")
		{
			var tmp = classes;
			classes = [];
			classes[0] = tmp;
		}

		for(var i = 0; i < classes.length; i++)
		{
			var class_ = classes[i].split("-");

			if(class_[0] == anchor)
			{
				element = class_[1];
				break;
			}
		}

		if(!element.length) return;

		var link = document.createElement("a");
		if(element == "a")
		{
			prevtitle = link.href = this.title;
			this.removeAttribute("title");

			span.wrapInner(link);
		}
		else if(element == "b")
		{
			if(prevtitle.length)
			{
				link.href = prevtitle + ((this.title && this.title.length) ? this.title : "");
				span.wrapInner(link);
			}
		}
	});
}
$(function()
{
  parseSpans("internal");
});