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";
				}
			}
		}
	);
}

var ie = $.browser.msie;

$(function() {
		replaceElem('.left-col-elem h3', '/svg/graphics/menu.svg', false);
		replaceElem('.left-col-elem li a.link span', '/svg/graphics/menu.svg', true);
		replaceElem('#services li', '/svg/graphics/list.svg', false);
		replaceElem('#contact-short a', '/svg/graphics/link-small.svg', false);
		replaceElem('#contact-short span', '/svg/graphics/list.svg', false);
		replaceElem('dl.news dt.graphics span', '/svg/sections/news-graphics.svg', false);
		replaceElem('dl.news dt.design span', '/svg/sections/news-design.svg', false);
		replaceElem('dl.news dt.photo span', '/svg/sections/news-photo.svg', false);
		replaceElem('h3.graphics-title a', '/svg/graphics/docs.svg', true);
		replaceElem('h3.design-title a', '/svg/graphics/docs-design.svg', true);
		replaceElem('h4.title', '/svg/graphics/doc-title.svg');
		replaceElem('#documents-list-short a.inactive', '/svg/graphics/menu.svg', true);
		replaceElem('#documents-list-short a.active', '/svg/graphics/menu-active.svg', true);
		replaceElem('#copyright span', '/svg/graphics/list.svg');
		replaceElem('a.details', '/svg/graphics/details.svg');

});

