function fct_help(p_mesaj)
{
	if(p_mesaj == 1)
		alert("Comisioanele care se percep din creditul acordat!");
	else
		alert("Comisioanele care se percep din disponibilitatile clientului!");
}

function fct_change_tip_credit(p_sender)
{
	var v_index = document.getElementById('sel_tip_credit').value;
	
	if(p_sender != null)
		fct_make_sel_valuta(p_sender);
	
	document.getElementById('txt_imprumut').value = credit[v_index][document.getElementById('sel_valuta_imprumut').value]['imprumut_maxim'];
	document.getElementById('txt_durata').value = credit[v_index][document.getElementById('sel_valuta_imprumut').value]['termen_maxim'];
	document.getElementById('txt_dobanda_anuala').value = credit[v_index][document.getElementById('sel_valuta_imprumut').value]['dobanda_anuala'];
	document.getElementById('txt_dobanda_anuala').disabled = (v_index == 0) ? false : true;
	document.getElementById('txt_comision_gestiune').value = credit[v_index][document.getElementById('sel_valuta_imprumut').value]['comision_gestiune'];
	document.getElementById('txt_comision_angajament').value = credit[v_index][document.getElementById('sel_valuta_imprumut').value]['comision_angajament'];
	
	document.getElementById('txt_comision_analiza').value = Math.round(parseFloat(credit[v_index]['comision_analiza']) * parseFloat(valuta[credit[v_index]['val_comision_analiza']][1]) * 100) / 100;
	document.getElementById('txt_comision_analiza').disabled = (credit[v_index]['comision_analiza'] > 0) ? true : false;
	document.getElementById('txt_comision_analiza').disabled = ((credit[document.getElementById('sel_tip_credit').value]['nume']).search("Angajat") > 0) ? true : document.getElementById('txt_comision_analiza').disabled;
	
	document.getElementById('txt_comision_administrare').value = credit[v_index]['comision_administrare'] * document.getElementById('txt_imprumut').value / 100;
	document.getElementById('txt_comision_administrare').disabled = (credit[v_index]['comision_administrare'] > 0) ? true : false;
	document.getElementById('txt_comision_administrare').disabled = ((credit[document.getElementById('sel_tip_credit').value]['nume']).search("Angajat") > 0) ? true : document.getElementById('txt_comision_administrare').disabled;
	
	document.getElementById('txt_comision_gestiune').disabled = (v_index == 0) ? false : true;
	document.getElementById('txt_curs').value = valuta[document.getElementById('sel_valuta_imprumut').value][1];
	
	document.getElementById('sel_tip_rate').disabled = (v_index == -1) ? false : true;
	document.getElementById('sel_tip_rate').value = ((credit[document.getElementById('sel_tip_credit').value]['nume']).search("obiect") > 0) ? 2 : 1;
	
	document.getElementById('txt_curs').disabled = (v_index == 0) ? false : true;
	if( ((credit[document.getElementById('sel_tip_credit').value]['nume']).search("Prima") > 0) || ((credit[document.getElementById('sel_tip_credit').value]['nume']).search("Angajat") > 0))
		document.getElementById('txt_comisioane_pc').disabled = false;
	else
	{
		document.getElementById('txt_comisioane_pc').value = "0";
		document.getElementById('txt_comisioane_pc').disabled = true;
	}
	
	fct_make_sel_perioada_gratie();
}



function fct_make_scoring()
{
    if(location.search.substring(1).length != 0)
    {
        document.getElementById('sel_scoring_client').disabled = true;
        
        var my_url = new Array();
        my_url = location.search.substring(1).split('&');
        
        for(var i=0; i<document.getElementById('sel_scoring_client').length; i++)
            if(document.getElementById('sel_scoring_client').options[i].value == my_url[0])
                document.getElementById('sel_scoring_client').selectedIndex = i;
        
        var my_nume = "";
        var my_nume_split = new Array();
        my_nume_split = my_url[1].split('%20');
        for(var i=0; i < my_nume_split.length; i++)
        	if(i==0)
        		my_nume += my_nume_split[i];
        	else
        		my_nume += " " + my_nume_split[i];
        
        document.getElementById('div_client_nume').innerHTML = my_nume.toUpperCase();
        
    
    
    	  var s = new Array('Locul de munca', 'Vechime la actualul loc de munca', 'Varsta', 'Situatia familiala', 'Nr. membrilor de familie sustinuti financiar',
    					 		  'Venit mediu lunar/persoana', 'Retineri salariale', 'Situatie locativa', 'Alte proprietati (casa de vacanta, alta locuinta, teren, masina, depozite plasate la BLR de cel putin 2.000 EUR)',
    					 		  'Alte elemente de analiza'
    							 );
    	  var t = new Array('loc_munca', 'vech_loc_munca', 'varsta', 'sit_fam', 'nr_membr_fam', 'venit', 'ret_sal', 'sit_locativa', 'alte_propr', 'alte_elem_analiza');
    
    		for(var i=0; i<t.length; i++)
    		{
    			document.getElementById('div_sit_scoring').innerHTML += "<br>" + s[i] + " --- ";
    			for(var j=0; j < valori[t[i]].length; j++)
    			{
    				if(valori[(t[i])][j]['id'] == my_url[i+2])
    					document.getElementById('div_sit_scoring').innerHTML += valori[t[i]][j]['sl'];
    			}
   		}
    
    }
    else
    	document.getElementById('div_sit_scoring').style.display = 'none';
}



function fct_renunta()
{
	fct_turn_display_onoff(document.getElementById('tbl_rate'),'none');
	fct_turn_display_onoff(document.getElementById('div_sit_client'),'none');

	var v_tabel = document.getElementById('tbl_body_rate');
	var lg = v_tabel.childNodes.length;
		
	while ( lg > 0)
	{
		lg--;	
		v_tabel.removeChild(v_tabel.childNodes[0]);
	}
}



function form_modif()
{
	fct_turn_display_onoff(document.getElementById('tbl_rate'),'none');
	fct_turn_display_onoff(document.getElementById('div_sit_client'),'none');
	
	document.getElementById('div_imprumut').innerHTML = "";
	document.getElementById('div_durata').innerHTML = "";
	document.getElementById('div_dobanda_anuala').innerHTML = "";
	document.getElementById('div_comision_gestiune').innerHTML = "";
	document.getElementById('div_comision_angajament').innerHTML = "";
	document.getElementById('div_rata_lunara').innerHTML = "";
	document.getElementById('div_suma_totala').innerHTML = "";
	document.getElementById('div_comision_analiza').innerHTML = "";
	document.getElementById('div_comision_administrare').innerHTML = "";
	document.getElementById('div_chelt_evaluare').innerHTML = "";
	document.getElementById('div_prima_asigurare').innerHTML = "";
	document.getElementById('div_val_totala_platibila').innerHTML = "";
	document.getElementById('div_cost_total_credit').innerHTML = "";
	document.getElementById('div_comision_fngcimm').innerHTML = "";
	document.getElementById('div_dobanda_totala').innerHTML = "";
	document.getElementById('div_comision_gestiune_total').innerHTML = "";
	document.getElementById('div_comision_angajament_total').innerHTML = "";
	document.getElementById('div_dae').innerHTML = "";
	document.getElementById('txt_obs_1').innerHTML = "";
	document.getElementById('txt_obs_2').innerHTML = "";
}



function fct_trimite()
{
	if (fct_document_valid() == false)
		return;
	
	
	//preiau valorile introduse de user
	var v_tip_credit = document.getElementById('sel_tip_credit').value;
	var v_imprumut = parseFloat(document.getElementById('txt_imprumut').value);
	var v_durata = parseInt(document.getElementById('txt_durata').value);
	var v_perioada_gratie = parseInt(parseInt(document.getElementById('sel_perioada_gratie').value));
	var v_dobanda_anuala = parseFloat(document.getElementById('txt_dobanda_anuala').value);
	var v_comision_gestiune = parseFloat(document.getElementById('txt_comision_gestiune').value);
	var v_comision_angajament = parseFloat(document.getElementById('txt_comision_angajament').value);
	
	var v_comis_neutiliz_val = parseFloat(credit[document.getElementById('sel_tip_credit').value][document.getElementById('sel_valuta_imprumut').value]['comision_neutilizare_valoare']);
	var v_comis_neutiliz_per = parseInt(credit[document.getElementById('sel_tip_credit').value][document.getElementById('sel_valuta_imprumut').value]['comision_neutilizare_perioada']);
	var v_prima_anuala_asigurare = parseFloat(document.getElementById('txt_prima_asigurare').value) / valuta[document.getElementById('sel_valuta_imprumut').value][1];
	
	var v_durata_2 = parseInt(credit[document.getElementById('sel_tip_credit').value][document.getElementById('sel_valuta_imprumut').value]['perioada_dobanda_2']);
	var v_dobanda_anuala_2 = parseFloat(credit[document.getElementById('sel_tip_credit').value][document.getElementById('sel_valuta_imprumut').value]['dobanda_anuala_2']);
	var v_comision_gestiune_2 = parseFloat(credit[document.getElementById('sel_tip_credit').value][document.getElementById('sel_valuta_imprumut').value]['comision_gestiune_2']);
	
	var v_tip_rate = document.getElementById('sel_tip_rate').value;
	//var v_comis_dincredit = parseFloat(document.getElementById('txt_comis_dincredit').value);
	var v_comis_dincredit = parseFloat(document.getElementById('txt_comision_analiza').value) / valuta[document.getElementById('sel_valuta_imprumut').value][1]
							+ parseFloat(document.getElementById('txt_comision_administrare').value)
							+ parseFloat(document.getElementById('txt_chelt_evaluare').value) / valuta[document.getElementById('sel_valuta_imprumut').value][1]
							+ parseFloat(document.getElementById('txt_comisioane_mijl_plata').value)
							+ parseFloat(document.getElementById('txt_comisioane_pc').value) / valuta[document.getElementById('sel_valuta_imprumut').value][1];
	
	var v_comis_nudincredit = parseFloat(document.getElementById('txt_comis_nudincredit').value);
	var v_grafic_rambursare = document.getElementById('chk_grafic_rambursare').checked;
	
	v_comision_admin_cont = credit[document.getElementById('sel_tip_credit').value]['comision_admin_cont'] / valuta[document.getElementById('sel_valuta_imprumut').value][1];
	
	var v_venituri = new Array();
	v_venituri['ron'] = parseFloat(document.getElementById('txt_venituri_ron').value);
	v_venituri['eur'] = parseFloat(document.getElementById('txt_venituri_eur').value);
	v_venituri['alte'] = parseFloat(document.getElementById('txt_venituri_alte').value);
	
	var v_chelt = new Array();
	v_chelt['ron'] = parseFloat(document.getElementById('txt_chelt_ron').value);
	v_chelt['eur'] = parseFloat(document.getElementById('txt_chelt_eur').value);
	v_chelt['alte'] = parseFloat(document.getElementById('txt_chelt_alte').value);
	
	var v_corelare = new Array();
	v_corelare['ron'] = 0;
	v_corelare['eur'] = 0;
	v_corelare['alte'] = 0;
	
	
	var vals = fct_calc_rate(v_imprumut, v_durata, v_perioada_gratie, v_dobanda_anuala, v_comision_gestiune, v_durata_2, v_dobanda_anuala_2, v_comision_gestiune_2, v_tip_rate
	                         , v_comis_dincredit, v_comis_nudincredit, v_comis_neutiliz_val, v_comis_neutiliz_per, v_prima_anuala_asigurare, v_comision_admin_cont);
	
	
	//aici actualizez partea de venituri
	var v_vl = 0;  //venituri lunare
	
	var v_vl_cert = 0;  //vlc = venituri lunare certe
	var v_vl_net = 0;  //vln = venituri lunare nete
	var chelt_lunare_minime = 0;
	var chelt_lunare = 0;
	var v_cheltuieli = 0;
	var v_procent = 0;
	var i = 0;
	var v_grad_indatorare = 0;
	var acceptat = false;
	var v_tip_perioada = '';
	var v_tip_corelare = '';
	var rata_maxima_idx = 0, rata_maxima = 0;
	
	
	// veniturile lunare = suma veniturilor neajustate (tb sa fie mai mari decat venitul minim acceptat pe produs)
	v_vl = parseFloat(document.getElementById('txt_venituri_ctg_a').value)
	   	 + parseFloat(document.getElementById('txt_venituri_ctg_b').value)
			 + parseFloat(document.getElementById('txt_venituri_ctg_c').value)
			 + parseFloat(document.getElementById('txt_venituri_ctg_d').value)
			 + parseFloat(document.getElementById('txt_venituri_ctg_e').value)
			 + parseFloat(document.getElementById('txt_venituri_ctg_a_codeb').value)
	   	 + parseFloat(document.getElementById('txt_venituri_ctg_b_codeb').value)
			 + parseFloat(document.getElementById('txt_venituri_ctg_c_codeb').value)
			 + parseFloat(document.getElementById('txt_venituri_ctg_d_codeb').value)
			 + parseFloat(document.getElementById('txt_venituri_ctg_e_codeb').value)
			 ;


	//rata se modifica daca produsul este card
	switch(credit[document.getElementById('sel_tip_credit').value]['tip_credit'])
	{
		case 'CRC' :
		case 'CRI' :
								for(i=1; i<=v_durata; i++)
									if(vals['rata'][i] + vals['comision_gestiune'][i] + vals['fngcimm_lunar'][i] > rata_maxima)
									{
										rata_maxima = vals['rata'][i] + vals['comision_gestiune'][i] + vals['fngcimm_lunar'][i];
										rata_maxima_idx = i;
									}
								v_rata_creditcrt = rata_maxima * parseFloat(document.getElementById('txt_curs').value);
						break;
		case 'CC' :
								v_rata_creditcrt = 5 * parseFloat(document.getElementById('txt_imprumut').value) / 100
								           	 			 * parseFloat(document.getElementById('txt_curs').value);
						break;
		case 'CO' :
						    v_rata_creditcrt = 5 * parseFloat(document.getElementById('txt_imprumut').value) / 100
												           * parseFloat(document.getElementById('txt_curs').value);
						break;
	}
	
	
	//ajustez veniturile cu coeficientii de ajustare
	v_vl_cert = coef_ajust_venit['txt_venituri_ctg_a'][document.getElementById('sel_scoring_client').value] * parseFloat(document.getElementById('txt_venituri_ctg_a').value) / 100
				  		+ coef_ajust_venit['txt_venituri_ctg_b'][document.getElementById('sel_scoring_client').value] * parseFloat(document.getElementById('txt_venituri_ctg_b').value) / 100
				  		+ coef_ajust_venit['txt_venituri_ctg_c'][document.getElementById('sel_scoring_client').value] * parseFloat(document.getElementById('txt_venituri_ctg_c').value) / 100
				  		+ coef_ajust_venit['txt_venituri_ctg_d'][document.getElementById('sel_scoring_client').value] * parseFloat(document.getElementById('txt_venituri_ctg_d').value) / 100
				  		+ coef_ajust_venit['txt_venituri_ctg_e'][document.getElementById('sel_scoring_client').value] * parseFloat(document.getElementById('txt_venituri_ctg_e').value) / 100
				  		+ coef_ajust_venit['txt_venituri_ctg_a'][document.getElementById('sel_scoring_client').value] * parseFloat(document.getElementById('txt_venituri_ctg_a_codeb').value) / 100
				  		+ coef_ajust_venit['txt_venituri_ctg_b'][document.getElementById('sel_scoring_client').value] * parseFloat(document.getElementById('txt_venituri_ctg_b_codeb').value) / 100
				  		+ coef_ajust_venit['txt_venituri_ctg_c'][document.getElementById('sel_scoring_client').value] * parseFloat(document.getElementById('txt_venituri_ctg_c_codeb').value) / 100
				  		+ coef_ajust_venit['txt_venituri_ctg_d'][document.getElementById('sel_scoring_client').value] * parseFloat(document.getElementById('txt_venituri_ctg_d_codeb').value) / 100
				  		+ coef_ajust_venit['txt_venituri_ctg_e'][document.getElementById('sel_scoring_client').value] * parseFloat(document.getElementById('txt_venituri_ctg_e_codeb').value) / 100
				  		;
				  
	//calculez cheltuielile minime in functie de venituri din strainatate
	if((parseFloat(document.getElementById('txt_venituri_ctg_e').value) + parseFloat(document.getElementById('txt_venituri_ctg_e_codeb').value)) == 0)
	{
		i = 0;
		while(i < limite_venituri.length)
		{
			if(v_vl <= limite_venituri[i])
				break;
			i++;
		}
		chelt_lunare_minime = chelt_lunare_1[i] + chelt_lunare_2[i] * (parseFloat(document.getElementById('txt_nr_membri').value) - 1);
	}
	else
	{
		chelt_lunare_minime = (700 + 200 * (parseFloat(document.getElementById('txt_nr_membri').value) - 1)) * valuta['eur'][1];
	}
	
	//cheltuielile lunare permanente = max dintre chelt minime declarate si cele calculate
	if(chelt_lunare_minime >= parseFloat(document.getElementById('txt_chelt_altele').value))
		chelt_lunare_minime = chelt_lunare_minime;
	else
		chelt_lunare_minime = parseFloat(document.getElementById('txt_chelt_altele').value);
	
	//adaug si ratele altor credite sau carduri
	chelt_lunare += parseFloat(document.getElementById('txt_angaj_credit').value)
						 + parseFloat(document.getElementById('txt_chelt_card_credit').value)
						 + parseFloat(document.getElementById('txt_chelt_card_overdraft').value)
						 + v_rata_creditcrt;

	//venitul net
	v_vl_net = v_vl_cert - chelt_lunare_minime;
	if(v_vl_net < 0)
		v_vl_net = 0;
	
	//calculez gradul real de indatorare al clientului
	v_procent = Math.ceil(chelt_lunare * 10000 / v_vl_net)/100;
	
	//aflu tipul de perioada, folosit ca indice pt tabloul grad_indat
	if(v_durata < 12)
		v_tip_perioada = '<1an';
	else
	{
		if(v_durata < 60)
			v_tip_perioada = '1-5ani';
		else
			v_tip_perioada = '>=5ani';
	}
	
	//aflu tipul de corelare, folosit ca indice pt tabloul grad_indat
	v_chelt[document.getElementById('sel_valuta_imprumut').value] += v_rata_creditcrt;
	if(v_chelt['ron'] == 0)
		v_corelare['ron'] = 1;
	else
		if((v_venituri['ron'] / v_chelt['ron']) >= 1)
			v_corelare['ron'] = 1;
	if(v_chelt['eur'] == 0)
		v_corelare['eur'] = 1;
	else
		if((v_venituri['eur'] / v_chelt['eur']) >= 1)
			v_corelare['eur'] = 1;
	if(v_chelt['alte'] == 0)
		v_corelare['alte'] = 1;
	else
		if((v_venituri['alte'] / v_chelt['alte']) >= 1)
			v_corelare['alte'] = 1;
	if( (v_corelare['ron'] == 1) && (v_corelare['eur'] == 1) && (v_corelare['alte'] == 1) )
		v_tip_corelare = 'corelare';
	else
		if( (v_venituri['alte'] > 0) || (v_chelt['alte'] > 0) )
			v_tip_corelare = 'necorelare_alte_val';
		else
			v_tip_corelare = 'necorelare_eur_ron';
			
	
	//aici aflu in ce categorie se incadreaza veniturile clientului; i este indice in tabloul grad_indat
	i = 0;
	while(i < limite_venituri.length)
	{
		if(v_vl <= limite_venituri[i])
			break;
		i++;
	}
	
	//vad gradul de indatorare maxim permis
	var v_tip_dobanda;
	/*if ( (v_durata <= 12)
				&&
					(
						(document.getElementById('sel_tip_credit').value == 'Ipotecar')
						|| (document.getElementById('sel_tip_credit').value == 'Nev.pers.ipoteca')
					)
			)
			v_tip_dobanda = 'dob_fixa';
	else*/
		v_grad_indatorare = grad_indat[ credit[document.getElementById('sel_tip_credit').value]['tip_garantie'] ][v_tip_corelare][ credit[document.getElementById('sel_tip_credit').value]['tip_dobanda'] ][ document.getElementById('sel_scoring_client').value ][v_tip_perioada][i];

	document.getElementById('div_total_cheltuieli').innerHTML = fct_format(v_cheltuieli) + " RON";
	
	//verificarea conditiilor
	if( (document.getElementById('sel_scoring_client').value == 'A') || (document.getElementById('sel_scoring_client').value == 'B') || (document.getElementById('sel_scoring_client').value == 'C' && credit[document.getElementById('sel_tip_credit').value]['tip_credit'] == 'CRI') )
	{
		if(
				( ( parseFloat(document.getElementById('txt_venituri_ctg_e').value) + parseFloat(document.getElementById('txt_venituri_ctg_e_codeb').value) == 0)
			   	&& (v_vl >= parseFloat(credit[document.getElementById('sel_tip_credit').value]['venit_minim_admis']))
				)
				||
				( (parseFloat(document.getElementById('txt_venituri_ctg_e').value) + parseFloat(document.getElementById('txt_venituri_ctg_e_codeb').value) != 0)
			   	&& (v_vl >= 2000 * valuta['eur'][1])
			   	&& (v_vl >= parseFloat(credit[document.getElementById('sel_tip_credit').value]['venit_minim_admis']))
				)
		   )
		{
			if(v_vl_net >= 0)
			{
				if(v_procent <= v_grad_indatorare)
				{
					acceptat = true;
					//alert("A");
				}
				else
				{
					acceptat = false;
					//alert("B");
				}
			}
			else
			{
				acceptat = false;
				//alert("C");
			}
		}
		else
		{
			acceptat = false;
			//alert("D");
		}
	}
	else
	{
		acceptat = false;
		//alert("E");
	}
	
	if(acceptat == true)
	{
		if(location.search.substring(1).length != 0)
			document.getElementById('div_sit_client').innerHTML = "Cerere acceptata pentru datele introduse!<br>Orice modificare survenita implica reanaliza!";
		else
			document.getElementById('div_sit_client').innerHTML = "Cerere pre-aprobata pentru datele introduse!<br>Calculele din prezentul buget sunt informative si nu angajeaza cu nimic Bank Leumi Romania.<br>Pentru o analiza detaliata va rugam sa va adresati celui mai apropiat sediu al Bank Leumi Romania!";
		if(document.getElementById('sel_valuta_imprumut').value != 'ron')
			document.getElementById('div_sit_client').innerHTML += "<br>Va rugam sa luati in considere faptul ca prin contractarea unui imprumut in valuta acceptati toate riscurile iminente pietei financiare. Fluctuatiile pietei valutare pot avea impact asupra costului real al ratei dumneavoastra lunare."
		document.getElementById('div_sit_client').innerHTML += "<br>Dobanda dumneavoastra este variabila (revizuibila): modificarile dobanzilor sunt transparente si determinate de variatiile pietei financiare interne si internationale si pot avea impact asupra costului real al ratei dumneavoastra lunare."
		if( (credit[document.getElementById('sel_tip_credit').value]['nume']).search("Prima") > 0)
			document.getElementById('div_sit_client').innerHTML += "<br>Gradul de indatorare este " + v_procent + "%.";
	}
	else
		document.getElementById('div_sit_client').innerHTML = "Cerere respinsa pentru datele introduse!";
		
	
	//debug
	/*
	document.getElementById('div_sit_client').innerHTML += "<br><br>DEBUG<br>";
	document.getElementById('div_sit_client').innerHTML += "<br><br>Rata credit cerut = " + v_rata_creditcrt;
	document.getElementById('div_sit_client').innerHTML += "<br>Venituri lunare certe = " + v_vl_cert;
	document.getElementById('div_sit_client').innerHTML += "<br>Cheltuieli lunare minime = " + chelt_lunare_minime;
	document.getElementById('div_sit_client').innerHTML += "<br>Tip perioada = " + v_tip_perioada;
	document.getElementById('div_sit_client').innerHTML += "<br>Tip corelare = " + v_tip_corelare;
	document.getElementById('div_sit_client').innerHTML += "<br>Tip garantie = " + credit[document.getElementById('sel_tip_credit').value]['tip_garantie'];
	document.getElementById('div_sit_client').innerHTML += "<br>Tip dobanda = " + credit[document.getElementById('sel_tip_credit').value]['tip_dobanda'];
	document.getElementById('div_sit_client').innerHTML += "<br>Grad indatorare maxim permis = " + v_grad_indatorare;
	document.getElementById('div_sit_client').innerHTML += "<br>Grad indatorare = " + v_procent;
	*/
	//debug
		

	fct_turn_display_onoff(document.getElementById('div_sit_client'),'');
	
	
	//scriu informatii in detalii credit
	if(acceptat == true)
	{
	document.getElementById('div_imprumut').innerHTML = fct_format(v_imprumut) + " " + document.getElementById('sel_valuta_imprumut').value.toUpperCase();
	document.getElementById('div_durata').innerHTML = v_durata + " luni";
	document.getElementById('div_dobanda_anuala').innerHTML = v_dobanda_anuala + " %";
	document.getElementById('div_comision_gestiune').innerHTML = v_comision_gestiune + " %";
	document.getElementById('div_comision_angajament').innerHTML = v_comision_angajament + " %";
	//document.getElementById('div_rata_lunara').innerHTML = fct_format(v_rata_creditcrt/parseFloat(document.getElementById('txt_curs').value)) + document.getElementById('sel_valuta_imprumut').value.toUpperCase();
	switch(credit[document.getElementById('sel_tip_credit').value]['tip_credit'])
	{
		case 'CRC' :
		case 'CRI' :
								document.getElementById('div_rata_lunara').innerHTML = fct_format(vals['rata'][1+v_comis_neutiliz_per] + vals['administrare_anuala'][1+v_comis_neutiliz_per]) + " " + document.getElementById('sel_valuta_imprumut').value.toUpperCase();
								break;
		case 'CC' :
								if((credit[document.getElementById('sel_tip_credit').value]['nume']).search("VISA Gold") >= 0)
									document.getElementById('div_rata_lunara').innerHTML = fct_format(vals['rata'][1+v_comis_neutiliz_per] + vals['administrare_anuala'][1+v_comis_neutiliz_per]) + " " + document.getElementById('sel_valuta_imprumut').value.toUpperCase();
								else
									document.getElementById('div_rata_lunara').innerHTML = 5 * parseFloat(document.getElementById('txt_imprumut').value) / 100 + " " + document.getElementById('sel_valuta_imprumut').value.toUpperCase();
								break;
		case 'CO' :
								document.getElementById('div_rata_lunara').innerHTML = fct_format(vals['rata'][1] + vals['administrare_anuala'][1]) + " " + document.getElementById('sel_valuta_imprumut').value.toUpperCase();
								break;
	}
	document.getElementById('div_suma_totala').innerHTML = fct_format(vals['total'] + vals['total_com_gest']) + " " + document.getElementById('sel_valuta_imprumut').value.toUpperCase() + ((v_durata_2 > 0) ? "<span style='color: red;'> (*)</span>" : " ");
	document.getElementById('div_comision_analiza').innerHTML = fct_format(parseFloat(document.getElementById('txt_comision_analiza').value) / valuta[document.getElementById('sel_valuta_imprumut').value][1]) + " " + document.getElementById('sel_valuta_imprumut').value.toUpperCase();
	document.getElementById('div_comision_administrare').innerHTML = fct_format(parseFloat(document.getElementById('txt_comision_administrare').value)) + " " + document.getElementById('sel_valuta_imprumut').value.toUpperCase();
	document.getElementById('div_chelt_evaluare').innerHTML = fct_format(parseFloat(document.getElementById('txt_chelt_evaluare').value) / valuta[document.getElementById('sel_valuta_imprumut').value][1]) + " " + document.getElementById('sel_valuta_imprumut').value.toUpperCase();
	document.getElementById('div_prima_asigurare').innerHTML = fct_format(parseFloat(document.getElementById('txt_prima_asigurare').value) / valuta[document.getElementById('sel_valuta_imprumut').value][1]) + " " + document.getElementById('sel_valuta_imprumut').value.toUpperCase();
	document.getElementById('div_dobanda_totala').innerHTML = fct_format(vals['total'] - v_imprumut) + " " + document.getElementById('sel_valuta_imprumut').value.toUpperCase() + ((v_durata_2 > 0) ? "<span style='color: red;'> (*)</span>" : " ");
	document.getElementById('div_cost_total_credit').innerHTML = fct_format(
							vals['totaldob']
							+ vals['total_com_fngcimm']
							+ vals['total_prima_asigurare']
							+ parseFloat(document.getElementById('txt_comision_analiza').value) / valuta[document.getElementById('sel_valuta_imprumut').value][1]
							+ parseFloat(document.getElementById('txt_comision_administrare').value)
							+ parseFloat(document.getElementById('txt_chelt_evaluare').value) / valuta[document.getElementById('sel_valuta_imprumut').value][1]
							+ parseFloat(document.getElementById('txt_comisioane_mijl_plata').value)
							+ parseFloat(document.getElementById('txt_comisioane_pc').value) / valuta[document.getElementById('sel_valuta_imprumut').value][1]
	         ) + " " + document.getElementById('sel_valuta_imprumut').value.toUpperCase();
	document.getElementById('div_val_totala_platibila').innerHTML = fct_format(
							parseFloat(document.getElementById('txt_imprumut').value)
							+ vals['totaldob']
							+ vals['total_com_fngcimm']
							+ vals['total_prima_asigurare']
							+ parseFloat(document.getElementById('txt_comision_analiza').value) / valuta[document.getElementById('sel_valuta_imprumut').value][1]
							+ parseFloat(document.getElementById('txt_comision_administrare').value)
							+ parseFloat(document.getElementById('txt_chelt_evaluare').value) / valuta[document.getElementById('sel_valuta_imprumut').value][1]
							+ parseFloat(document.getElementById('txt_comisioane_mijl_plata').value)
							+ parseFloat(document.getElementById('txt_comisioane_pc').value) / valuta[document.getElementById('sel_valuta_imprumut').value][1]
	         ) + " " + document.getElementById('sel_valuta_imprumut').value.toUpperCase();
	document.getElementById('div_comision_fngcimm').innerHTML = fct_format(vals['fngcimm'][1]) + " " + document.getElementById('sel_valuta_imprumut').value.toUpperCase();
	document.getElementById('div_comision_gestiune_total').innerHTML = fct_format(vals['total_com_gest']) + " " + document.getElementById('sel_valuta_imprumut').value.toUpperCase();
	document.getElementById('div_comision_angajament_total').innerHTML = fct_format(v_comision_angajament * document.getElementById('txt_imprumut').value / 100) + " " + document.getElementById('sel_valuta_imprumut').value.toUpperCase();
	//if(credit[document.getElementById('sel_tip_credit').value]['tip_credit'] != 'CRI')
	document.getElementById('div_dae').innerHTML = fct_format(vals['principal'][0]) + " %";
	if(v_durata_2 > 0)
	{
		document.getElementById('txt_obs_1').innerHTML = "(*) Calculul are in vedere nivelul de astazi al EURIBOR/ROBOR la 3 luni";
		document.getElementById('txt_obs_2').innerHTML = "(*) Total lunar plata orientativ incepand cu anul II: " + fct_format(vals['rata'][v_durata_2+1] + vals['comision_gestiune'][v_durata_2+1]);
	}
  }
  else
  {
  document.getElementById('div_imprumut').innerHTML = "";
	document.getElementById('div_durata').innerHTML = "";
	document.getElementById('div_dobanda_anuala').innerHTML = "";
	document.getElementById('div_comision_gestiune').innerHTML = "";
	document.getElementById('div_rata_lunara').innerHTML = "";
	document.getElementById('div_suma_totala').innerHTML = "";
	document.getElementById('div_dobanda_totala').innerHTML = "";
	document.getElementById('div_comision_gestiune_total').innerHTML = "";
  }
	
	
	//creez scadentarul
	if ( (v_grafic_rambursare) && (acceptat == true) &&  (credit[document.getElementById('sel_tip_credit').value]['tip_credit'] != 'CC') && (credit[document.getElementById('sel_tip_credit').value]['tip_credit'] != 'CO'))
	{
		var v_tabel = document.getElementById('tbl_body_rate');
		var lg = v_tabel.childNodes.length;
		while ( lg > 0)
		{
			lg--;	
			v_tabel.removeChild(v_tabel.childNodes[0]);
		}
		
		if (v_tabel)
		{
			for (i = 1; i <= v_durata + v_comis_neutiliz_per; i++)
			{
				v_rand = document.createElement('tr');
			
				v_cell1 = document.createElement('td');
				v_cell1.innerHTML = i + ".";
				v_cell1.style.textAlign = "right";
				
				v_cell2 = document.createElement('td');
				v_cell2.innerHTML = fct_format(vals['rata'][i] + vals['administrare_anuala'][i]/* + vals['comision_gestiune'][i] + vals['comision_neutiliz'][i] + vals['fngcimm'][i]*/);
				v_cell2.style.textAlign = "right";
			
				v_cell3 = document.createElement('td');
				v_cell3.innerHTML = fct_format(vals['rata'][i]);
				v_cell3.style.textAlign = "right";
							
				v_cell4 = document.createElement('td');
				v_cell4.innerHTML = fct_format(vals['principal'][i]);
				v_cell4.style.textAlign = "right";
			
				v_cell5 = document.createElement('td');
				v_cell5.innerHTML = fct_format(vals['dobanda'][i]);
				v_cell5.style.textAlign = "right";
				
				v_cell6 = document.createElement('td');
				v_cell6.innerHTML = fct_format(vals['comision_gestiune'][i]);
				v_cell6.style.textAlign = "right";
				
				v_cell7 = document.createElement('td');
				v_cell7.innerHTML = fct_format(vals['administrare_anuala'][i]);
				v_cell7.style.textAlign = "right";
			
				v_cell8 = document.createElement('td');
				v_cell8.innerHTML = fct_format(vals['sramasa'][i]);
				v_cell8.style.textAlign = "right";
				
				v_cell81 = document.createElement('td');
				v_cell81.innerHTML = "&nbsp;";
				v_cell81.style.textAlign = "right";
				
				v_cell9 = document.createElement('td');
				v_cell9.innerHTML = fct_format(vals['fngcimm'][i]);
				v_cell9.style.textAlign = "right";
				
				v_cell10 = document.createElement('td');
				v_cell10.innerHTML = vals['data_luna'][i] + "-" + vals['data_an'][i] + " --- " + vals['fngcimm_lunar'][i];
				v_cell10.style.textAlign = "right";
				
				v_cell11 = document.createElement('td');
				v_cell11.innerHTML = fct_format(vals['prima_asigurare'][i]);
				v_cell11.style.textAlign = "right";
				
				v_cell12 = document.createElement('td');
				v_cell12.innerHTML = fct_format(vals['comision_neutiliz'][i]);
				v_cell12.style.textAlign = "right";

				v_cell13 = document.createElement('td');
				v_cell13.innerHTML = fct_format(vals['admin_cont'][i]);
				v_cell13.style.textAlign = "right";
				
					
				v_rand.appendChild(v_cell1);
				v_rand.appendChild(v_cell2);
				v_rand.appendChild(v_cell3);
				v_rand.appendChild(v_cell4);
				v_rand.appendChild(v_cell5);
				//v_rand.appendChild(v_cell6);
				v_rand.appendChild(v_cell7);
				v_rand.appendChild(v_cell8);
				v_rand.appendChild(v_cell81);
				v_rand.appendChild(v_cell9);
				
				
				//v_rand.appendChild(v_cell10);
				//v_rand.appendChild(v_cell11);
				//v_rand.appendChild(v_cell12);
				//v_rand.appendChild(v_cell13);
			
				v_tabel.appendChild(v_rand);
			}
		}
		fct_turn_display_onoff(document.getElementById('tbl_rate'),'');
	}
	else
	{
		fct_turn_display_onoff(document.getElementById('tbl_rate'),'none');
	}
				
	window.scroll(0,500);
}

