// <![CDATA[

var operatorList = [
		[ [ "38067", "38096", "38097", "38098" ], "kyivstar.gif" ],
		[ [ "38050", "38066", "38095", "38099" ], [ "mts.gif" ] ],
		[ [ "38063", "38093" ], [ "life.gif" ] ],
		[ [ "38068" ], [ "beeline.gif" ] ],
		[ [ "38094" ], [ "intertelecom.gif" ] ],
		[ [ "38092" ], [ "peoplenet.gif" ] ], [ [ "38091" ], [ "utel.gif" ] ] ];

function account_onkeyup() {

	var accountElement = document.getElementById("account");
	
	if (null == accountElement)
		return;
	
	var account = accountElement.value;

	account = account.replace(/[^\d]+/g, "");
	account = account;

	var logo = "phone.gif";

	for ( var operatorIndex in operatorList) {
		var prefixList = operatorList[operatorIndex][0];
		for ( var prefixIndex in prefixList) {
			if (0 == account.indexOf(prefixList[prefixIndex])) {
				logo = [ operatorList[operatorIndex][1] ];
				break;
			}
		}
	}

	accountElement.style.backgroundImage = "url(/_pictures/" + logo + ")";
}

function amount_onkeyup() {

	var amountElement = document.getElementById("amount");
	var currencyElement = document.getElementById("currency");
	var totalElement = document.getElementById("total");

	if (null == amountElement || null == currencyElement
			|| null == totalElement)
		return;

	var currency = currencyElement[currencyElement.selectedIndex].value;
	var rate = rateList[currency];

	var temp = amountElement.value.replace(",", ".");
	var amount = parseFloat(temp);

	if (!isNaN(amount)) {

		if (rate > 0) {

			amount *= rate;

			amount *= 100;
			amount = Math.round(amount);

			if (amount == 0)
				amount = 1;

			if (amount < 100)
				amount += 1;

			amount /= 100;

		} else {
			amount = 0;
		}

		totalElement.innerHTML = amount;
	} else {
		totalElement.innerHTML = "?";
	}
}

// ]]>

