
var GrText = function(input, container, priceContainer) {


	var replacements = {

		"~": { "code": "<div style=\"background-image: url( /img/sym/misc/space.gif\"  />", "price": 0 },

		"ÕÓÉ": { "code": "<div style=\"background-image: url( /img/sym/words/lebedev10.jpg); width: 600px; height: 450px;\" title=\"Ìîïåä íå íàø :-)\">&nbsp;</div>", "price": 3 },
		"ÏÈÇÄÀ": { "code": "<div style=\"background-image: url( /img/sym/words/censored.gif); width: 487px; height: 100px;\">&nbsp;</div>", "price": 5 },
//		"ÁËß": { "code": "<div style=\"background-image: url( /img/sym/words/censored.gif); width: 487px; height: 100px;\">&nbsp;</div>", "price": 3 },
//		"ÁËßÒÜ": { "code": "<div style=\"background-image: url( /img/sym/words/censored.gif); width: 487px; height: 100px;\">&nbsp;</div>", "price": 5 },
		"ÁËßÄÜ": { "code": "<div style=\"background-image: url( /img/sym/words/censored.gif); width: 487px; height: 100px;\">&nbsp;</div>", "price": 5 },
		"ÁËßÄÈÙÀ": { "code": "<div style=\"background-image: url( /img/sym/words/censored.gif); width: 487px; height: 100px;\">&nbsp;</div>", "price": 7 },
		"ÁËßÄÈ": { "code": "<div style=\"background-image: url( /img/sym/words/censored.gif); width: 487px; height: 100px;\">&nbsp;</div>", "price": 5 },
		"ÏÈËßÒÜ": { "code": "<div style=\"background-image: url( /img/sym/words/censored.gif); width: 487px; height: 100px;\">&nbsp;</div>", "price": 6 },
		"ÁËßÄÈÙÈ": { "code": "<div style=\"background-image: url( /img/sym/words/censored.gif); width: 487px; height: 100px;\">&nbsp;</div>", "price": 7 },
		"ÁËßÄÎÂÀÒÜ": { "code": "<div style=\"background-image: url( /img/sym/words/censored.gif); width: 487px; height: 100px;\">&nbsp;</div>", "price": 9 },
		"ÁËßÄÎÂÊÀ": { "code": "<div style=\"background-image: url( /img/sym/words/censored.gif); width: 487px; height: 100px;\">&nbsp;</div>", "price": 8 },
		"ÏÐÎÁËßÄÎÂÊÀ": { "code": "<div style=\"background-image: url( /img/sym/words/censored.gif); width: 487px; height: 100px;\">&nbsp;</div>", "price": 11 },
		"ÁËßÄÓÅÒ": { "code": "<div style=\"background-image: url( /img/sym/words/censored.gif); width: 487px; height: 100px;\">&nbsp;</div>", "price": 7 },
		"ÁËßÄÎÂÀÍÈÅ": { "code": "<div style=\"background-image: url( /img/sym/words/censored.gif); width: 487px; height: 100px;\">&nbsp;</div>", "price": 10 },

		"ßÍÄÅÊÑ": { "code": "<div style=\"background-image: url( /img/sym/words/yandex.gif); width: 355px; height: 100px;\">&nbsp;</div>", "price": 6 },
		"ßÍÄÅX": { "code": "<div style=\"background-image: url( /img/sym/words/yandexwrong.gif); width: 355px; height: 100px;\">&nbsp;</div>", "price": 6 },
		"YANDEX": { "code": "<div style=\"background-image: url( /img/sym/words/yandex.gif); width: 355px; height: 100px;\">&nbsp;</div>", "price": 6 },
		"YANDEKS": { "code": "<div style=\"background-image: url( /img/sym/words/yandexwrong.gif); width: 355px; height: 100px;\">&nbsp;</div>", "price": 6 },
		"ßNDEX": { "code": "<div style=\"background-image: url( /img/sym/words/yandexwrong.gif); width: 355px; height: 100px;\">&nbsp;</div>", "price": 6 },
		"ÉÀÍÄÅÊÑ": { "code": "<div style=\"background-image: url( /img/sym/words/yandexwrong.gif); width: 355px; height: 100px;\">&nbsp;</div>", "price": 6 },


		"0": { "code": "<div style=\"background-image: url( /img/sym/dig/0.gif); width: 53px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"1": { "code": "<div style=\"background-image: url( /img/sym/dig/1.gif); width: 45px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"2": { "code": "<div style=\"background-image: url( /img/sym/dig/2.gif); width: 43px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"3": { "code": "<div style=\"background-image: url( /img/sym/dig/3.gif); width: 44px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"4": { "code": "<div style=\"background-image: url( /img/sym/dig/4.gif); width: 46px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"5": { "code": "<div style=\"background-image: url( /img/sym/dig/5.gif); width: 53px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"6": { "code": "<div style=\"background-image: url( /img/sym/dig/6.gif); width: 44px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"7": { "code": "<div style=\"background-image: url( /img/sym/dig/7.gif); width: 45px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"8": { "code": "<div style=\"background-image: url( /img/sym/dig/8.gif); width: 48px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"9": { "code": "<div style=\"background-image: url( /img/sym/dig/9.gif); width: 44px; height: 100px;\">&nbsp;</div>", "price": 1 },

		"A": { "code": "<div style=\"background-image: url( /img/sym/lat/a.gif); width: 62px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"B": { "code": "<div style=\"background-image: url( /img/sym/lat/b.gif); width: 57px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"C": { "code": "<div style=\"background-image: url( /img/sym/lat/c.gif); width: 60px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"D": { "code": "<div style=\"background-image: url( /img/sym/lat/d.gif); width: 48px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"E": { "code": "<div style=\"background-image: url( /img/sym/lat/e.gif); width: 56px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"F": { "code": "<div style=\"background-image: url( /img/sym/lat/f.gif); width: 56px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"G": { "code": "<div style=\"background-image: url( /img/sym/lat/g.gif); width: 70px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"H": { "code": "<div style=\"background-image: url( /img/sym/lat/h.gif); width: 57px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"I": { "code": "<div style=\"background-image: url( /img/sym/lat/i.gif); width: 24px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"J": { "code": "<div style=\"background-image: url( /img/sym/lat/j.gif); width: 41px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"K": { "code": "<div style=\"background-image: url( /img/sym/lat/k.gif); width: 55px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"L": { "code": "<div style=\"background-image: url( /img/sym/lat/l.gif); width: 50px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"M": { "code": "<div style=\"background-image: url( /img/sym/lat/m.gif); width: 72px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"N": { "code": "<div style=\"background-image: url( /img/sym/lat/n.gif); width: 52px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"O": { "code": "<div style=\"background-image: url( /img/sym/lat/o.gif); width: 71px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"P": { "code": "<div style=\"background-image: url( /img/sym/lat/p.gif); width: 57px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Q": { "code": "<div style=\"background-image: url( /img/sym/lat/q.gif); width: 77px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"R": { "code": "<div style=\"background-image: url( /img/sym/lat/r.gif); width: 55px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"S": { "code": "<div style=\"background-image: url( /img/sym/lat/s.gif); width: 49px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"T": { "code": "<div style=\"background-image: url( /img/sym/lat/t.gif); width: 55px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"U": { "code": "<div style=\"background-image: url( /img/sym/lat/u.gif); width: 55px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"V": { "code": "<div style=\"background-image: url( /img/sym/lat/v.gif); width: 62px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"W": { "code": "<div style=\"background-image: url( /img/sym/lat/w.gif); width: 84px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"X": { "code": "<div style=\"background-image: url( /img/sym/lat/x.gif); width: 51px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Y": { "code": "<div style=\"background-image: url( /img/sym/lat/y.gif); width: 51px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Z": { "code": "<div style=\"background-image: url( /img/sym/lat/z.gif); width: 49px; height: 100px;\">&nbsp;</div>", "price": 1 },

		"À": { "code": "<div style=\"background-image: url( /img/sym/cyr/a.gif); width: 62px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Á": { "code": "<div style=\"background-image: url( /img/sym/cyr/b.gif); width: 57px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Â": { "code": "<div style=\"background-image: url( /img/sym/cyr/v.gif); width: 57px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Ã": { "code": "<div style=\"background-image: url( /img/sym/cyr/g.gif); width: 57px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Ä": { "code": "<div style=\"background-image: url( /img/sym/cyr/de.gif); width: 72px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Å": { "code": "<div style=\"background-image: url( /img/sym/cyr/e.gif); width: 57px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"¨": { "code": "<div style=\"background-image: url( /img/sym/cyr/yo.gif); width: 57px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Æ": { "code": "<div style=\"background-image: url( /img/sym/cyr/zh.gif); width: 76px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Ç": { "code": "<div style=\"background-image: url( /img/sym/cyr/z.gif); width: 44px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"È": { "code": "<div style=\"background-image: url( /img/sym/cyr/i.gif); width: 57px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"É": { "code": "<div style=\"background-image: url( /img/sym/cyr/ikr.gif); width: 56px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Ê": { "code": "<div style=\"background-image: url( /img/sym/cyr/k.gif); width: 55px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Ë": { "code": "<div style=\"background-image: url( /img/sym/cyr/l.gif); width: 62px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Ì": { "code": "<div style=\"background-image: url( /img/sym/cyr/m.gif); width: 72px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Í": { "code": "<div style=\"background-image: url( /img/sym/cyr/n.gif); width: 57px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Î": { "code": "<div style=\"background-image: url( /img/sym/cyr/o.gif); width: 71px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Ï": { "code": "<div style=\"background-image: url( /img/sym/cyr/p.gif); width: 57px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Ð": { "code": "<div style=\"background-image: url( /img/sym/cyr/r.gif); width: 51px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Ñ": { "code": "<div style=\"background-image: url( /img/sym/cyr/s.gif); width: 60px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Ò": { "code": "<div style=\"background-image: url( /img/sym/cyr/t.gif); width: 55px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Ó": { "code": "<div style=\"background-image: url( /img/sym/cyr/u.gif); width: 51px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Ô": { "code": "<div style=\"background-image: url( /img/sym/cyr/f.gif); width: 66px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Õ": { "code": "<div style=\"background-image: url( /img/sym/cyr/h.gif); width: 51px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Ö": { "code": "<div style=\"background-image: url( /img/sym/cyr/ce.gif); width: 57px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"×": { "code": "<div style=\"background-image: url( /img/sym/cyr/ch.gif); width: 55px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Ø": { "code": "<div style=\"background-image: url( /img/sym/cyr/sh.gif); width: 80px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Ù": { "code": "<div style=\"background-image: url( /img/sym/cyr/sch.gif); width: 85px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Ú": { "code": "<div style=\"background-image: url( /img/sym/cyr/tvznak.gif); width: 57px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Û": { "code": "<div style=\"background-image: url( /img/sym/cyr/hzkaknazvat.gif); width: 60px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Ü": { "code": "<div style=\"background-image: url( /img/sym/cyr/mznak.gif); width: 52px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Ý": { "code": "<div style=\"background-image: url( /img/sym/cyr/oe.gif); width: 48px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"Þ": { "code": "<div style=\"background-image: url( /img/sym/cyr/yu.gif); width: 95px; height: 100px;\">&nbsp;</div>", "price": 1 },
		"ß": { "code": "<div style=\"background-image: url( /img/sym/cyr/ya.gif); width: 45px; height: 100px;\">&nbsp;</div>", "price": 1 },

		" ": { "code": "<div style=\"background-image: url( /img/sym/misc/space.gif); width: 44px; height: 100px;\">&nbsp;</div>", "price": 0 },
		".": { "code": "<div style=\"background-image: url( /img/sym/misc/dot.gif); width: 24px; height: 100px;\">&nbsp;</div>", "price": 0 },
		",": { "code": "<div style=\"background-image: url( /img/sym/misc/comma.gif); width: 24px; height: 100px;\">&nbsp;</div>", "price": 0 },
		"!": { "code": "<div style=\"background-image: url( /img/sym/misc/excl.gif); width: 24px; height: 100px;\">&nbsp;</div>", "price": 0 },
		"?": { "code": "<div style=\"background-image: url( /img/sym/misc/quest.gif); width: 43px; height: 100px;\">&nbsp;</div>", "price": 0 },
		"%": { "code": "<div style=\"background-image: url( /img/sym/misc/proc.gif); width: 64px; height: 100px;\">&nbsp;</div>", "price": 0 },
		"+": { "code": "<div style=\"background-image: url( /img/sym/misc/plus.gif); width: 49px; height: 100px;\">&nbsp;</div>", "price": 0 },
		"(": { "code": "<div style=\"background-image: url( /img/sym/misc/lsk.gif); width: 34px; height: 100px;\">&nbsp;</div>", "price": 0 },
		")": { "code": "<div style=\"background-image: url( /img/sym/misc/rsk.gif); width: 34px; height: 100px;\">&nbsp;</div>", "price": 0 },
		"<": { "code": "<div style=\"background-image: url( /img/sym/misc/lt.gif); width: 44px; height: 100px;\">&nbsp;</div>", "price": 0 },
		">": { "code": "<div style=\"background-image: url( /img/sym/misc/gt.gif); width: 44px; height: 100px;\">&nbsp;</div>", "price": 0 },
		"=": { "code": "<div style=\"background-image: url( /img/sym/misc/ravno.gif); width: 49px; height: 100px;\">&nbsp;</div>", "price": 0 },
		":": { "code": "<div style=\"background-image: url( /img/sym/misc/ddot.gif); width: 24px; height: 100px;\">&nbsp;</div>", "price": 0 },
		";": { "code": "<div style=\"background-image: url( /img/sym/misc/tz.gif); width: 24px; height: 100px;\">&nbsp;</div>", "price": 0 },
		"__": { "code": "<div style=\"background-image: url( /img/sym/misc/line.gif); width: 72px; height: 100px;\">&nbsp;</div>", "price": 0 },
		"--": { "code": "<div style=\"background-image: url( /img/sym/misc/mdash.gif\"  ); width: 64px; height: 100px;\">&nbsp;</div>", "price": 0 },
		"_": { "code": "<div style=\"background-image: url( /img/sym/misc/sub.gif); width: 64px; height: 100px;\">&nbsp;</div>", "price": 0 },
		"—": { "code": "<div style=\"background-image: url( /img/sym/misc/mdash.gif); width: 64px; height: 100px;\">&nbsp;</div>", "price": 0 },
		"-": { "code": "<div style=\"background-image: url( /img/sym/misc/minus.gif); width: 49px; height: 100px;\">&nbsp;</div>", "price": 0 }

	};

	var price;

	var replace = function(source) {
		var target = "";
		price = 0;
		while(source.length > 0) {
			var found = false;
			for(var i in replacements) {
				if(source.substr(0, i.length) == i) {
					var os = source;
					source = source.substr(i.length);
					target += replacements[i].code;
					price += replacements[i].price;
					found = true;
					break;
				}
			}
			if(!found) {
				source = source.substr(1);
				target += replacements["~"].code;
				price += replacements["~"].price;
			}
		}
		return target;
	}

	this.upd = function() {
		container.innerHTML = replace(input.value.toUpperCase());

		var sum;

		if(price <= 3) {
			sum = price * 1000;
		} else if(price <= 10) {
			sum = 3 * 1000 + (price-3) * 750;
		} else {
			sum = 3 * 1000 + 7 * 750 + (price-10) * 500;
		}

		priceContainer.innerHTML = sum;
	};

	this.upd();

};


