var deposit_id=0;
var deposits = new Array();
var deposit_currencies = new Array();
var deposit_period = new Array();
/* old deposit data
deposits[deposits.length] = {"title" : "ACTUAL", "period_min" : 1, "period_max": 24, "currency": "MDL", "min":1000, "percent":"", "float_percent": 3, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "ACTUAL", "period_min" : 1, "period_max": 24, "currency": "EUR/USD", "min":500, "percent":"", "float_percent": 1, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "ACTUAL+VISA ELECTRON", "period_min" : 1, "period_max": 24, "currency": "MDL", "min":1000, "percent":"", "float_percent": 3.5, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "ACTUAL+VISA ELECTRON", "period_min" : 1, "period_max": 24, "currency": "EUR/USD", "min":500, "percent":"", "float_percent": 1.25, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "ACTUAL+VISA CLASSIC", "period_min" : 1, "period_max": 24, "currency": "MDL", "min":3000, "percent":"", "float_percent": 4, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "ACTUAL+VISA CLASSIC", "period_min" : 1, "period_max": 24, "currency": "EUR/USD", "min":500, "percent":"", "float_percent": 1.5, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "OPTIM", "period_min" : 3, "period_max": 3, "currency": "MDL", "min":1000, "percent":4, "float_percent": 5, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "OPTIM", "period_min" : 6, "period_max": 6, "currency": "MDL", "min":1000, "percent":6, "float_percent": 7, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "OPTIM", "period_min" : 12, "period_max": 12, "currency": "MDL", "min":1000, "percent":9, "float_percent": 10, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "OPTIM", "period_min" : 3, "period_max": 3, "currency": "EUR/USD", "min":500, "percent":1, "float_percent": 2, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "OPTIM", "period_min" : 6, "period_max": 6, "currency": "EUR/USD", "min":500, "percent":2, "float_percent": 3, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "OPTIM", "period_min" : 12, "period_max": 12, "currency": "EUR/USD", "min":500, "percent":4, "float_percent": 5, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "BUNĂSTARE", "period_min" : 6, "period_max": 6, "currency": "MDL", "min":250000, "percent":"", "float_percent": 11, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "BUNĂSTARE", "period_min" : 12, "period_max": 12, "currency": "MDL", "min":250000, "percent":"", "float_percent": 12, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "BUNĂSTARE", "period_min" : 6, "period_max": 6, "currency": "EUR/USD", "min":25000, "percent":"", "float_percent": 6, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "BUNĂSTARE", "period_min" : 12, "period_max": 12, "currency": "EUR/USD", "min":25000, "percent":"", "float_percent": 7, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "PENSIONAR", "period_min" : 6, "period_max": 6, "currency": "MDL", "min":200, "percent":8, "float_percent": "", "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "PENSIONAR", "period_min" : 12, "period_max": 12, "currency": "MDL", "min":200, "percent":11, "float_percent": "", "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "PENSIONAR", "period_min" : 6, "period_max": 6, "currency": "EUR/USD", "min":100, "percent":4, "float_percent": "", "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "PENSIONAR", "period_min" : 12, "period_max": 12, "currency": "EUR/USD", "min":100, "percent":5, "float_percent": "", "capital":"yes", "description" : ""}
*/
deposits[deposits.length] = {"title" : "GOTIC", "period_min" : 6, "period_max": 6, "currency": "MDL", "min":1000, "percent":8, "float_percent": "", "capital":"", "description" : ""}
deposits[deposits.length] = {"title" : "GOTIC", "period_min" : 12, "period_max": 12, "currency": "MDL", "min":1000, "percent":9.25, "float_percent": "", "capital":"", "description" : ""}
deposits[deposits.length] = {"title" : "GOTIC", "period_min" : 18, "period_max": 18, "currency": "MDL", "min":1000, "percent":9.5, "float_percent": "", "capital":"", "description" : ""}
deposits[deposits.length] = {"title" : "GOTIC", "period_min" : 25, "period_max": 25, "currency": "MDL", "min":1000, "percent":10, "float_percent": "", "capital":"", "description" : ""}

deposits[deposits.length] = {"title" : "GOTIC", "period_min" : 6, "period_max": 6, "currency": "EUR/USD", "min":100, "percent":2, "float_percent": "", "capital":"", "description" : ""}
deposits[deposits.length] = {"title" : "GOTIC", "period_min" : 12, "period_max": 12, "currency": "EUR/USD", "min":100, "percent":5.5, "float_percent": "", "capital":"", "description" : ""}
deposits[deposits.length] = {"title" : "GOTIC", "period_min" : 18, "period_max": 18, "currency": "EUR/USD", "min":100, "percent":4.25, "float_percent": "", "capital":"", "description" : ""}
deposits[deposits.length] = {"title" : "GOTIC", "period_min" : 25, "period_max": 25, "currency": "EUR", "min":100, "percent":4.5, "float_percent": "", "capital":"", "description" : ""}
deposits[deposits.length] = {"title" : "GOTIC", "period_min" : 25, "period_max": 25, "currency": "USD", "min":100, "percent":5.5, "float_percent": "", "capital":"", "description" : ""}

deposits[deposits.length] = {"title" : "BAROCCO", "period_min" : 6, "period_max": 6, "currency": "MDL", "min":1000, "percent":"", "float_percent": 9, "capital":"", "description" : ""}
deposits[deposits.length] = {"title" : "BAROCCO", "period_min" : 12, "period_max": 12, "currency": "MDL", "min":1000, "percent":"", "float_percent": 12, "capital":"", "description" : ""}
deposits[deposits.length] = {"title" : "BAROCCO", "period_min" : 18, "period_max": 18, "currency": "MDL", "min":1000, "percent":"", "float_percent": 12, "capital":"", "description" : ""}
deposits[deposits.length] = {"title" : "BAROCCO", "period_min" : 25, "period_max": 25, "currency": "MDL", "min":1000, "percent":"", "float_percent": 12.75, "capital":"", "description" : ""}

deposits[deposits.length] = {"title" : "BAROCCO", "period_min" : 6, "period_max": 6, "currency": "EUR/USD", "min":100, "percent":"", "float_percent": 2.5, "capital":"", "description" : ""}
deposits[deposits.length] = {"title" : "BAROCCO", "period_min" : 12, "period_max": 12, "currency": "EUR/USD", "min":100, "percent":"", "float_percent": 6.5, "capital":"", "description" : ""}
deposits[deposits.length] = {"title" : "BAROCCO", "period_min" : 18, "period_max": 18, "currency": "EUR/USD", "min":100, "percent":"", "float_percent": 6.5, "capital":"", "description" : ""}
deposits[deposits.length] = {"title" : "BAROCCO", "period_min" : 25, "period_max": 25, "currency": "EUR", "min":100, "percent":"", "float_percent": 7, "capital":"", "description" : ""}
deposits[deposits.length] = {"title" : "BAROCCO", "period_min" : 25, "period_max": 25, "currency": "USD", "min":100, "percent":"", "float_percent": 7.5, "capital":"", "description" : ""}

deposits[deposits.length] = {"title" : "RENAISSANCE", "period_min" : 6, "period_max": 6, "currency": "MDL", "min":1000, "percent":"", "float_percent": 8.5, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "RENAISSANCE", "period_min" : 12, "period_max": 12, "currency": "MDL", "min":1000, "percent":"", "float_percent": 10.5, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "RENAISSANCE", "period_min" : 18, "period_max": 18, "currency": "MDL", "min":1000, "percent":"", "float_percent": 11, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "RENAISSANCE", "period_min" : 25, "period_max": 25, "currency": "MDL", "min":1000, "percent":"", "float_percent": 11.5, "capital":"yes", "description" : ""}

deposits[deposits.length] = {"title" : "RENAISSANCE", "period_min" : 6, "period_max": 6, "currency": "EUR/USD", "min":100, "percent":"", "float_percent": 2, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "RENAISSANCE", "period_min" : 12, "period_max": 12, "currency": "EUR/USD", "min":100, "percent":"", "float_percent": 4, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "RENAISSANCE", "period_min" : 18, "period_max": 18, "currency": "EUR/USD", "min":100, "percent":"", "float_percent": 4.5, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "RENAISSANCE", "period_min" : 25, "period_max": 25, "currency": "EUR/USD", "min":100, "percent":"", "float_percent": 4.75, "capital":"yes", "description" : ""}

deposits[deposits.length] = {"title" : "MODERN", "period_min" : 3, "period_max": 3, "currency": "MDL", "min":500, "percent":"", "float_percent": 5, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "MODERN", "period_min" : 6, "period_max": 6, "currency": "MDL", "min":500, "percent":"", "float_percent": 7, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "MODERN", "period_min" : 12, "period_max": 12, "currency": "MDL", "min":500, "percent":"", "float_percent": 10, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "MODERN", "period_min" : 18, "period_max": 18, "currency": "MDL", "min":500, "percent":"", "float_percent": 10.5, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "MODERN", "period_min" : 25, "period_max": 25, "currency": "MDL", "min":500, "percent":"", "float_percent": 11, "capital":"yes", "description" : ""}

deposits[deposits.length] = {"title" : "MODERN", "period_min" : 3, "period_max": 3, "currency": "EUR/USD", "min":100, "percent":"", "float_percent": 1, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "MODERN", "period_min" : 6, "period_max": 6, "currency": "EUR/USD", "min":100, "percent":"", "float_percent": 2, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "MODERN", "period_min" : 12, "period_max": 12, "currency": "EUR/USD", "min":100, "percent":"", "float_percent": 3.5, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "MODERN", "period_min" : 18, "period_max": 18, "currency": "EUR/USD", "min":100, "percent":"", "float_percent": 4, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "MODERN", "period_min" : 25, "period_max": 25, "currency": "EUR/USD", "min":100, "percent":"", "float_percent": 4.5, "capital":"yes", "description" : ""}

deposits[deposits.length] = {"title" : "HI TECH", "period_min" : 12, "period_max": 12, "currency": "MDL", "min":1000, "percent":"", "float_percent": 5, "capital":"", "description" : ""}
deposits[deposits.length] = {"title" : "HI TECH", "period_min" : 12, "period_max": 12, "currency": "EUR/USD", "min":100, "percent":"", "float_percent": 1, "capital":"", "description" : ""}

deposits[deposits.length] = {"title" : "Pensionar", "period_min" : 6, "period_max": 6, "currency": "MDL", "min":500, "percent":8, "float_percent":"", "capital":"", "description" : ""}
deposits[deposits.length] = {"title" : "Pensionar", "period_min" : 12, "period_max": 12, "currency": "MDL", "min":500, "percent":11.75, "float_percent":"", "capital":"", "description" : ""}

deposits[deposits.length] = {"title" : "Pensionar", "period_min" : 6, "period_max": 6, "currency": "USD", "min":100, "percent":4, "float_percent":"", "capital":"", "description" : ""}
deposits[deposits.length] = {"title" : "Pensionar", "period_min" : 12, "period_max": 12, "currency": "USD", "min":100, "percent":6, "float_percent":"", "capital":"", "description" : ""}

deposits[deposits.length] = {"title" : "Pensionar", "period_min" : 6, "period_max": 6, "currency": "EUR", "min":100, "percent":4, "float_percent":"", "capital":"", "description" : ""}
deposits[deposits.length] = {"title" : "Pensionar", "period_min" : 12, "period_max": 12, "currency": "EUR", "min":100, "percent":5, "float_percent":"", "capital":"", "description" : ""}

deposits[deposits.length] = {"title" : "BAROCCO VIP", "period_min" : 6, "period_max": 6, "currency": "MDL", "min":250000, "percent":"", "float_percent": 10, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "BAROCCO VIP", "period_min" : 12, "period_max": 12, "currency": "MDL", "min":250000, "percent":"", "float_percent": 11.5, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "BAROCCO VIP", "period_min" : 18, "period_max": 18, "currency": "MDL", "min":250000, "percent":"", "float_percent": 11, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "BAROCCO VIP", "period_min" : 25, "period_max": 25, "currency": "MDL", "min":250000, "percent":"", "float_percent": 13.5, "capital":"yes", "description" : ""}

deposits[deposits.length] = {"title" : "BAROCCO VIP", "period_min" : 6, "period_max": 6, "currency": "EUR/USD", "min":25000, "percent":"", "float_percent": 5, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "BAROCCO VIP", "period_min" : 12, "period_max": 12, "currency": "EUR", "min":25000, "percent":"", "float_percent": 6, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "BAROCCO VIP", "period_min" : 12, "period_max": 12, "currency": "USD", "min":25000, "percent":"", "float_percent": 6.5, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "BAROCCO VIP", "period_min" : 18, "period_max": 18, "currency": "EUR/USD", "min":25000, "percent":"", "float_percent": 6.25, "capital":"yes", "description" : ""}
deposits[deposits.length] = {"title" : "BAROCCO VIP", "period_min" : 25, "period_max": 25, "currency": "EUR/USD", "min":25000, "percent":"", "float_percent": 6.5, "capital":"yes", "description" : ""}




function updateBankstoreDepositSelectBox( new_deposit_title ) {
	var last_deposit_tip;
	var title

	if (!new_deposit_title) {
		new_deposit_title = deposits[0]['title'];
		deposit_id = 0;
		lst = $("#deposit_calc_deposit").empty();
	}

	//Reset value lists
	deposit_currencies = new Array();
	deposit_period = new Array();
	// Init deposit name selector
	for(list_deposit_id in deposits) {
		title = deposits[list_deposit_id]['title']
		if (title == new_deposit_title ) {
			deposit_currencies[deposits[list_deposit_id]['currency']] = deposits[list_deposit_id]['currency'];
			if (deposits[list_deposit_id]['period_max']) {
				for (pi = deposits[list_deposit_id]['period_min']; pi <= deposits[list_deposit_id]['period_max']; pi++) {
					deposit_period[pi] = pi;
				}
			} else {
				deposit_period[deposits[list_deposit_id]['period_min']] = deposits[list_deposit_id]['period_min'];
			}
			deposit_currencies[deposits[list_deposit_id]['currency']] = deposits[list_deposit_id]['currency'];
		}
		if (lst && last_deposit_tip != title) {
			last_deposit_tip = title;
			$(lst).append('<option value="' + title + '" ' + ( title==new_deposit_title ? 'selected="true"' : '') + '>' + title + '</option>');
		}
	}
	//Sort period array
	//deposit_period.sort(function(a,b){return a - b});

	if( lst.length > 0 ) $(lst).attr("disabled", false); else $(lst).attr("disabled", true);
	

	updateBankstoreCurrencySelectBox();
}

function updateBankstoreCurrencySelectBox(new_currency_id){
	// Init currency selector
	if (!new_currency_id ) {
		lst = $("#deposit_calc_currency").empty();
		for(currency_id in deposit_currencies) {
			$(lst).append('<option value="'+currency_id+'" ' + ( currency_id==deposits[deposit_id]['currency'] ? 'selected' : '') + '>'+currency_id+'</option>');
		}
	
		if( lst.length > 0 ) $(lst).attr("disabled", false); else $(lst).attr("disabled", true);
	}
	
	updateBankstorePeriodSelectBox();
	updateBankstoreSumInputBox();
}

function updateBankstorePeriodSelectBox(new_period){
	if (!new_period) {
		// Init currency selector
		old_period = $("#deposit_calc_period").val();
		lst = $("#deposit_calc_period").empty();
		for(period in deposit_period) {
			$(lst).append('<option value="'+deposit_period[period]+'" ' + ( deposit_period[period]==old_period ? 'selected' : '') + '>' + deposit_period[period] + '</option>');
		}
		if( lst.length > 0 ) $(lst).attr("disabled", false); else $(lst).attr("disabled", true);
	}
	
	updateDepositID();
}

function updateBankstoreSumInputBox(){
	//Init minimal sum input field
	var deposit_sum = parseFloat($('#deposit_sum').val());
	if (isNaN(deposit_sum) || deposit_sum < parseFloat(deposits[deposit_id]['min']) ) {
		$('#deposit_sum').val(deposits[deposit_id]['min']);
	}
}

function updateDepositID(){
	var period = parseInt($("#deposit_calc_period").val());
	var currency = $("#deposit_calc_currency").val();
	var title = $("#deposit_calc_deposit").val();
	if (!title) {
		title = deposits[0]['title']
	}
	if (!currency) {
		currency = deposits[0]['currency']
	}
	if (!period) {
		period = deposits[0]['period_min']
	}
	for(list_deposit_id in deposits) {
		if (currency == deposits[list_deposit_id]['currency'] && 
			title == deposits[list_deposit_id]['title'] && 
			period >= deposits[list_deposit_id]['period_min'] && 
			( !deposits[list_deposit_id]['period_max'] || (period<=deposits[list_deposit_id]['period_max']) )
		) {
			deposit_id = list_deposit_id;
			a = period >= deposits[list_deposit_id]['period_min'];
			b = !deposits[list_deposit_id]['period_max']
			c = period<=deposits[list_deposit_id]['period_max']
			break;
		}
	}
	
	
	updateBankstorePercentSelectBox( );
}

function updateBankstorePercentSelectBox( percent_type_id ) {
	if (!percent_type_id) {
		old_percent = $("#deposit_calc_percent_type").val()
		//percent type
		lst = $("#deposit_calc_percent_type").empty();
		if (deposits[deposit_id]['percent']) {
			$(lst).append('<option value="fixed" >'+Lang.get('фиксированная')+'</option>');
			percent_type_id = 'fixed';
		} else {
			percent_type_id = 'float';
		}
		if (deposits[deposit_id]['float_percent']) {
			$(lst).append('<option value="float" ' + (old_percent=='float' ? '"selected"' : '') + '>'+Lang.get('плавающая')+'</option>');
		}
	
		if( lst.length > 0 ) $(lst).attr("disabled", false); else $(lst).attr("disabled", true);
		if( lst.length == 1 ) $(lst).attr("readonly", true); else $(lst).attr("readonly", false);

		//capitalization
		old_capital = $("#deposit_calc_capital").val()
		lst = $("#deposit_calc_capital").empty();
		$(lst).append('<option value="0" >'+Lang.get('нет')+'</option>');
		if (deposits[deposit_id]['capital']) {
			$(lst).append('<option value="1" ' + (old_capital=='1' ? '"selected"' : '') + '>'+Lang.get('да')+'</option>');
		}
	
		if( lst.length > 0 ) $(lst).attr("disabled", false); else $(lst).attr("disabled", true);
		if( lst.length == 1 ) $(lst).attr("readonly", true); else $(lst).attr("readonly", false);

		
	}
	
	d = (percent_type_id == 'float' ? deposits[deposit_id]['float_percent'] : deposits[deposit_id]['percent'])
	$('#deposit_percent').val( (percent_type_id == 'float' ? deposits[deposit_id]['float_percent'] : deposits[deposit_id]['percent']) + '%');
}

function showBankstoreDepositCalculator() {

	var b_c_str = '';
	var b_c_str_c_t = '';
	var b_c_str_c_b = '';

	b_c_str_c_t = '<div id="depositcalc_form_container" style="visibility: hidden;">';
	b_c_str = '<table class="depositcalc" cellpadding="0" cellspacing="0">';

	b_c_str += '<tr>';
	b_c_str += '<td colspan="2" class="depositcalc_tabs">';

	b_c_str += '</td>';
	b_c_str += '</tr>';

	b_c_str += '<tr><td><table class="depositcalc_form_fields">';

	b_c_str += '<tr class="unhidden">';
	b_c_str += '<td class="depositcalc_label">';
	b_c_str += '<label for="deposit_calc_deposit">'+Lang.get("Депозитные продукты")+':</label>';
	b_c_str += '</td>';
	b_c_str += '<td class="depositcalc_input">';
	b_c_str += '<select id="deposit_calc_deposit" name="deposit_calc_deposit" size="1" onchange="updateBankstoreDepositSelectBox(this.value);" disabled="false" style="width: 12em;">';
	b_c_str += '</select>';
	b_c_str += '</td>';
	b_c_str += '</tr>';

	b_c_str += '<tr class="unhidden">';
	b_c_str += '<td class="depositcalc_label">';
	b_c_str += '<label for="deposit_calc_sum">'+Lang.get("Сумма вклада")+':</label>';
	b_c_str += '</td>';
	b_c_str += '<td class="depositcalc_input">';
	b_c_str += '<input id="deposit_sum" name="deposit_sum" type="text" size="5"  onchange="updateBankstoreSumInputBox(this.value);" />';
	b_c_str += '<select id="deposit_calc_currency" name="deposit_calc_currency" size="1" onchange="updateBankstoreCurrencySelectBox(this.value);" disabled="false" style="width: 7em;">';
	b_c_str += '</select>';
	b_c_str += '</td>';
	b_c_str += '</tr>';

	b_c_str += '<tr class="unhidden">';
	b_c_str += '<td class="depositcalc_label">';
	b_c_str += '<label for="deposit_calc_period">'+Lang.get("Срок вклада (мес.)")+':</label>';
	b_c_str += '</td>';
	b_c_str += '<td class="depositcalc_input">';
	b_c_str += '<select id="deposit_calc_period" name="deposit_calc_period" size="1" onchange="updateBankstorePeriodSelectBox(this.value);" disabled="false" style="width: 12em;">';
	b_c_str += '</select>';
	b_c_str += '</td>';
	b_c_str += '</tr>';
	
	b_c_str += '<tr class="unhidden">';
	b_c_str += '<td class="depositcalc_label">';
	b_c_str += '<label for="deposit_calc_percent_type">'+Lang.get("Процентная ставка депозита")+':</label>';
	b_c_str += '</td>';
	b_c_str += '<td class="depositcalc_input">';
	b_c_str += '<select id="deposit_calc_percent_type" name="deposit_calc_percent_type" size="1" onchange="updateBankstorePercentSelectBox(this.value);" disabled="false" style="width: 12em;">';
	b_c_str += '<input id="deposit_percent" name="deposit_percent" type="text" size="5" readonly="true" />';
	b_c_str += '</select>';
	b_c_str += '</td>';
	b_c_str += '</tr>';
	
	b_c_str += '<tr class="unhidden">';
	b_c_str += '<td class="depositcalc_label">';
	b_c_str += '<label for="deposit_calc_capital">'+Lang.get("Возможность капитализации")+':</label>';
	b_c_str += '</td>';
	b_c_str += '<td class="depositcalc_input">';
	b_c_str += '<select id="deposit_calc_capital" name="deposit_calc_capital" size="1" disabled="false" style="width: 12em;">';
	b_c_str += '</select>';
	b_c_str += '</td>';
	b_c_str += '</tr>';

	b_c_str += '</table></td></tr>';

	b_c_str += '<tr>';
	b_c_str += '<td colspan="2" class="depositcalc_submit">';
	b_c_str += '<input type="button" onclick="depositcalc_make_calculation();" id="depositcalc_calc_button" value="'+Lang.get("Рассчитать")+'" />';
	b_c_str += '</td>';
	b_c_str += '</tr>';

	b_c_str += '</table>';
	b_c_str_c_b += '</div>';

	b_c_str_c_b += '<div id="depositcalc_result_container"></div>';

	if( $("#depositcalc_form_container").length>0 ) $("#depositcalc_form_container").html(b_c_str);
	else
	{
		$("#depositcalc").html(b_c_str_c_t + b_c_str + b_c_str_c_b);
		$("#depositcalc_form_container").show();
	}
	$("#deposit_calc_deposit").focus();
}


function roundNumber(rnum, rlength)
{
	return Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
}

function str_repeat( str, num )
{
	var result_str = '';
	for( var i=1;i<=num;i++ ) result_str += str;
	return result_str;
}

function getValueMoney( value, round, delim )
{
	value = '' + value;
	len = value.length;
	pos = value.indexOf( '.' );
	if( pos == -1 )
	{
		pos = value.indexOf( ',' );
		if( pos == -1 )
		{
			return value + delim + str_repeat( '0', round );
		}
	}

	if( len - pos - 1 < round ) value = value + str_repeat( '0', round - (len - pos - 1) );
	value = value.substr( 0, pos + 1 + round ).replace( /\./, delim );

	return value;
}

function depositcalc_make_calculation( )
{
	
	var l_deposit_sum = parseFloat( $("#deposit_sum").val().replace( /,/, "." ) );
	var deposit_period = parseInt( $("#deposit_calc_period").val().replace( /,/, "." ) );
	var is_deposit_float = $("#deposit_calc_percent_type").val() == 'float';
	var is_deposit_capital = $("#deposit_calc_capital").val() == '1';

	var percent = parseFloat(is_deposit_float ? deposits[deposit_id]['float_percent'] : deposits[deposit_id]['percent'] );
	if (is_deposit_capital) {
		var sum_percent = l_deposit_sum * Math.pow(1+(percent*30)/(100*365), deposit_period) - l_deposit_sum;
	} else {
		var sum_percent = (l_deposit_sum * percent * 30 * deposit_period )/(100*365)
	}


	var results_table = "";
	results_table += "<table class=\"result_data\" cellspacing=\"0\" cellpadding=\"0\">\n";

	results_table += "<thead><tr>\n";
	results_table += "<th>" + Lang.get('Наименование вклада') + "</th>\n";
	results_table += "<th colspan=2>" + Lang.get('Полученный доход') + "</th>\n";
	results_table += "</tr></thead>\n";
	results_table += "<tbody>\n";
	results_table += "<tr>\n";
	results_table += "<td class=\"total_sum\"  align='right'>" + deposits[deposit_id]['title'] + "</td>\n";
	results_table += "<td class=\"overpayment\" align='right'>" + getValueMoney( sum_percent, 2, ',' ) + "</td>\n";
	results_table += "<td align='left'>" + deposits[deposit_id]['currency'] + "</td>\n";
	results_table += "</tr>\n";
	results_table += "</tbody>";
	results_table += "</table>\n";


	$("#depositcalc_result_container").html(results_table);

	return true;
}

