function replaceElem(selector, bgUrl, sw)
{
	$(selector).each(
		function(elem, index) {
			var txt = $(this).text();
			if (!txt) return false;
			txt = txt.toLowerCase();
			txt = encode64(txt);
			$(this).css('background', 'url("' + bgUrl + '?text=' + txt + '&text2=' + txt + '&format=png&base64=true") no-repeat');
			$(this).css('text-indent', '-9999px');
			$(this).css('display','block');
			if (sw)
			{
				var t = $(this);
				var i = new Image();
				i.src = bgUrl + "?text=" + txt + "&text2=" + txt + "&format=png&base64=true";
				i.onload = function() {
					t[0].style.width = this.width + "px";
				}
			}
		}
	);
}


$(function() {
		replaceElem('.left-col-elem h3', '/svg/menu.svg');
		replaceElem('.left-col-elem ul.top > li > a.link span', '/svg/menu.svg', true);
		replaceElem('.left-col-elem ul.top > li > ul a.link span', '/svg/photo/menu-photo.svg', true);
		replaceElem('#pics-top h3', '/svg/photo/menu-photo.svg');
		replaceElem('#copyright span', '/svg/list.svg');
});

