	//vld[id] contine id-ul inputului care trebuie verificat ca si numeric pozitiv
	//vld[id] contine mesajul de eroare care va fi dat userului
	var vld = new Array();
	vld['id'] = new Array();
	vld['msg'] = new Array();
	vld['crsp'] = new Array();
	
	vld['id'][0] = 'txt_imprumut';
	vld['msg'][0] = "Soldul creditului trebuie sa fie numeric si pozitiv!!!";
	vld['crsp'][0] = "imprumut_maxim";
	vld['id'][1] = 'txt_durata';
	vld['msg'][1] = "Durata creditului trebuie sa fie numerica si pozitiva!!!";
	vld['crsp'][1] = "termen_maxim";
	vld['id'][2] = 'txt_dobanda_anuala';
	vld['msg'][2] = "Dobanda creditului trebuie sa fie numerica si pozitiva!!!";
	vld['id'][3] = 'txt_comision_gestiune';
	vld['msg'][3] = "Comisionul trebuie sa fie numeric si pozitiv!!!";
	vld['id'][4] = 'txt_curs';
	vld['msg'][4] = "Cursul trebuie sa fie numeric si pozitiv!!!";
	vld['id'][5] = 'txt_venituri_ctg_a';
	vld['msg'][5] = "Veniturile trebuie sa fie numerice si pozitive!!!";
	vld['id'][6] = 'txt_venituri_ctg_b';
	vld['msg'][6] = "Veniturile trebuie sa fie numerice si pozitive!!!";
	vld['id'][7] = 'txt_venituri_ctg_c';
	vld['msg'][7] = "Veniturile trebuie sa fie numerice si pozitive!!!";
	vld['id'][8] = 'txt_venituri_ctg_d';
	vld['msg'][8] = "Veniturile trebuie sa fie numerice si pozitive!!!";
	vld['id'][9] = 'txt_venituri_ctg_e';
	vld['msg'][9] = "Veniturile trebuie sa fie numerice si pozitive!!!";
	vld['id'][10] = 'txt_angaj_credit';
	vld['msg'][10] = "Angajamente alte credite trebuie sa fie numeric si pozitiv!!!";
	vld['id'][11] = 'txt_chelt_card_credit';
	vld['msg'][11] = "Rata card credit trebuie sa fie numerica si pozitiva!!!";
	vld['id'][12] = 'txt_chelt_card_overdraft';
	vld['msg'][12] = "Rata card overdraft trebuie sa fie numerica si pozitiva!!!";
	vld['id'][13] = 'txt_chelt_altele';
	vld['msg'][13] = "Valoarea pt alte cheltuieli trebuie sa fie numerica si pozitiva!!!";
	vld['id'][14] = 'txt_valoare_imobil';
	vld['msg'][14] = "Valoarea imobilului trebuie sa fie numerica si pozitiva!!!";
	vld['id'][15] = 'txt_comision_analiza';
	vld['msg'][15] = "Valoarea comisionului trebuie sa fie numerica si pozitiva!!!";
	vld['id'][16] = 'txt_comision_administrare';
	vld['msg'][16] = "Valoarea comisionului trebuie sa fie numerica si pozitiva!!!";
	vld['id'][17] = 'txt_chelt_evaluare';
	vld['msg'][17] = "Valoarea comisionului trebuie sa fie numerica si pozitiva!!!";
	vld['id'][18] = 'txt_prima_asigurare';
	vld['msg'][18] = "Valoarea comisionului trebuie sa fie numerica si pozitiva!!!";
	vld['id'][19] = 'txt_comisioane_mijl_plata';
	vld['msg'][19] = "Valoarea comisionului trebuie sa fie numerica si pozitiva!!!";
	vld['id'][20] = 'txt_comisioane_pc';
	vld['msg'][20] = "Valoarea comisionului trebuie sa fie numerica si pozitiva!!!";
	vld['id'][21] = 'txt_venituri_ctg_a_codeb';
	vld['msg'][21] = "Veniturile trebuie sa fie numerice si pozitive!!!";
	vld['id'][22] = 'txt_venituri_ctg_b_codeb';
	vld['msg'][22] = "Veniturile trebuie sa fie numerice si pozitive!!!";
	vld['id'][23] = 'txt_venituri_ctg_c_codeb';
	vld['msg'][23] = "Veniturile trebuie sa fie numerice si pozitive!!!";
	vld['id'][24] = 'txt_venituri_ctg_d_codeb';
	vld['msg'][24] = "Veniturile trebuie sa fie numerice si pozitive!!!";
	vld['id'][25] = 'txt_venituri_ctg_e_codeb';
	vld['msg'][25] = "Veniturile trebuie sa fie numerice si pozitive!!!";
	
	
var limite_valoare_imobil = new Array();
limite_valoare_imobil[0] =  55000;
limite_valoare_imobil[1] =  75000;
limite_valoare_imobil[2] = 100000;

var LTV_Adama = new Array();
LTV_Adama['A'] = new Array();
LTV_Adama['A'][0] = 75;
LTV_Adama['A'][1] = 70;
LTV_Adama['A'][2] = 65;
LTV_Adama['A'][3] = 60;
LTV_Adama['B'] = new Array();
LTV_Adama['B'][0] = 70;
LTV_Adama['B'][1] = 65;
LTV_Adama['B'][2] = 60;
LTV_Adama['B'][3] = 55;
LTV_Adama['C'] = new Array();
LTV_Adama['C'][0] = 65;
LTV_Adama['C'][1] = 60;
LTV_Adama['C'][2] = 55;
LTV_Adama['C'][3] = 50;


var LTV = new Array();
LTV['A'] = new Array();
LTV['A']['urban'] = 70;
LTV['A']['rural'] = 40;
LTV['B'] = new Array();
LTV['B']['urban'] = 65;
LTV['B']['rural'] = 40;
LTV['C'] = new Array();
LTV['C']['urban'] = 60;
LTV['C']['rural'] = 40;



function fct_document_valid()
{
	for(i=0; i<vld['id'].length; i++)
	{
		if(!is_valid(document.getElementById(vld['id'][i]), vld['msg'][i]))
			return false;
	}
			
	for(i=0; i<vld['id'].length; i++)
		document.getElementById(vld['id'][i]).value = parseFloat(document.getElementById(vld['id'][i]).value);
		
	for(i=0; i <= 1; i++)
		if((document.getElementById(vld['id'][i]).value <= 0) || (document.getElementById(vld['id'][i]).value > credit[document.getElementById('sel_tip_credit').value][document.getElementById('sel_valuta_imprumut').value][vld['crsp'][i]] && credit[document.getElementById('sel_tip_credit').value][document.getElementById('sel_valuta_imprumut').value][vld['crsp'][i]] != 0))
		{
			alert("Valoarea creditului trebuie sa fie mai mare ca 0" + ((credit[document.getElementById('sel_tip_credit').value][document.getElementById('sel_valuta_imprumut').value][vld['crsp'][i]] != 0) ? (" si mai mica sau egala cu " + credit[document.getElementById('sel_tip_credit').value][document.getElementById('sel_valuta_imprumut').value][vld['crsp'][i]]): ("")) + "!");
			document.getElementById(vld['id'][i]).focus;
			document.getElementById(vld['id'][i]).select();
			return false;
		}

  if(isNaN(parseInt(document.getElementById('txt_nr_membri').value)) || (document.getElementById('txt_nr_membri').value < 1) || (parseInt(document.getElementById('txt_nr_membri').value) != parseFloat(document.getElementById('txt_nr_membri').value)))
  {
  	alert("Nr de membri familie incorect (>=1)!!!");
  	return false;
  }
  
  if (
     (
  	 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)
		 )
		 !=
		 (
		 parseFloat(document.getElementById('txt_venituri_ron').value)
		 + parseFloat(document.getElementById('txt_venituri_eur').value)
		 + parseFloat(document.getElementById('txt_venituri_alte').value)
		 )
		 )
	{
		alert("Venitul splitat pe tip trebuie sa fie egal cu venitul splitat pe valuta de provenienta!");
		return false;
	}
	
	if (
			(
			 parseFloat(document.getElementById('txt_angaj_credit').value)
			 + parseFloat(document.getElementById('txt_chelt_card_credit').value)
			 + parseFloat(document.getElementById('txt_chelt_card_overdraft').value)
			)
			!=
			(
			 parseFloat(document.getElementById('txt_chelt_ron').value)
			 + parseFloat(document.getElementById('txt_chelt_eur').value)
			 + parseFloat(document.getElementById('txt_chelt_alte').value)
			)
		)
	{
		alert("Ratele splitate pe tip trebuie sa fie egale cu ratele splitate pe valuta de provenienta!");
		return false;
	}
	
	if( (credit[document.getElementById('sel_tip_credit').value]['nume']).search("Adama") > 0)
	{
		for(i=0; i < limite_valoare_imobil.length; i++)
			if (parseFloat(document.getElementById('txt_valoare_imobil').value) <= limite_valoare_imobil[i])
				break;

		if( ( parseFloat(document.getElementById('txt_imprumut').value) * ( parseFloat(document.getElementById('txt_curs').value) /  valuta['eur'][1]) )
	    	>  LTV_Adama[document.getElementById('sel_scoring_client').value][i] * parseFloat(document.getElementById('txt_valoare_imobil').value) / 100 )
		{
			alert("Valoarea finantata este prea mare fata de pretul imobilului!!!");
			return false;
		}
	}
	
	
	if( (credit[document.getElementById('sel_tip_credit').value]['nume']).search("Prima") > 0)
	{
		if( ( parseFloat(document.getElementById('txt_imprumut').value) * ( parseFloat(document.getElementById('txt_curs').value) /  valuta['eur'][1]) ) > 71250 )
		{
			alert("Creditul poate fi de maxim 71.250 EUR!!!");
			return false;
		}
		
		if( ( parseFloat(document.getElementById('txt_imprumut').value) * ( parseFloat(document.getElementById('txt_curs').value) /  valuta['eur'][1]) ) > 0.95 * parseFloat(document.getElementById('txt_valoare_imobil').value) )
		{
			alert("Finantarea este de maxim 95% din valoarea imobilului!!!");
			return false;
		}
	}
	
	
	if(
			(credit[document.getElementById('sel_tip_credit').value]['nume'] == 'Ipotecar')
			|| (credit[document.getElementById('sel_tip_credit').value]['nume'] == 'Ipotecar-bonusat')
			|| (credit[document.getElementById('sel_tip_credit').value]['nume'] == 'Ipotecar-nebonusat')
			|| (credit[document.getElementById('sel_tip_credit').value]['nume'] == 'Ipotecar - Angajati')
			|| (credit[document.getElementById('sel_tip_credit').value]['nume'] == 'Nev.pers.ipoteca')
			|| (credit[document.getElementById('sel_tip_credit').value]['nume'] == 'Nev.pers.ipoteca-bonusat')
			|| (credit[document.getElementById('sel_tip_credit').value]['nume'] == 'Nev.pers.ipoteca-nebonusat')
			|| (credit[document.getElementById('sel_tip_credit').value]['nume'] == 'Nev.pers.ipoteca - Angajati')
	  )
	{
		//alert(LTV[document.getElementById('sel_scoring_client').value][document.getElementById('sel_mediu_imobil').value]);
		//alert( ( parseFloat(document.getElementById('txt_imprumut').value) * ( parseFloat(document.getElementById('txt_curs').value) /  valuta['eur'][1]) ) );
		//alert( LTV[document.getElementById('sel_scoring_client').value][document.getElementById('sel_mediu_imobil').value] * parseFloat(document.getElementById('txt_valoare_imobil').value) / 100 );
		
		if(
				( parseFloat(document.getElementById('txt_imprumut').value) * ( parseFloat(document.getElementById('txt_curs').value) /  valuta['eur'][1]) )
		    > ( LTV[document.getElementById('sel_scoring_client').value][document.getElementById('sel_mediu_imobil').value] * parseFloat(document.getElementById('txt_valoare_imobil').value) / 100 )
		  )
		{
			alert(
			      "Finantarea este de maxim "
			      + (
			         LTV[document.getElementById('sel_scoring_client').value][document.getElementById('sel_mediu_imobil').value]
			         * parseFloat(document.getElementById('txt_valoare_imobil').value)
			         * valuta['eur'][1]
			         / parseFloat(document.getElementById('txt_curs').value)
			         / 100
			        )
			      + " " + document.getElementById('sel_valuta_imprumut').value.toUpperCase()
			     );
			return false;
		}
	}
	
	//pt overdraft standard maxim 3 salarii nete
	if(
			(credit[document.getElementById('sel_tip_credit').value]['nume'] == 'Card overdraft standard')
			&& (credit[document.getElementById('sel_tip_credit').value]['tip_credit'] == 'CO')
		)
	
	{
		if( ((parseFloat(document.getElementById('txt_imprumut').value) *  parseFloat(document.getElementById('txt_curs').value)) /  valuta[document.getElementById('sel_valuta_imprumut').value][1])
				> 3 * (parseFloat(document.getElementById('txt_venituri_ctg_a').value)) )
		{
			alert("Plafonul maxim este de 3 salarii nete!!!");
			return false;
		}
	}
	
	//pt overdraft plan A sau B maxim 3 slarii nete pana la 2500 ron si 6 salarii nete este 2500 ron
	if(
			(credit[document.getElementById('sel_tip_credit').value]['nume'] != 'Card overdraft standard')
			&& (credit[document.getElementById('sel_tip_credit').value]['tip_credit'] == 'CO')
		)
	{
		if( ((parseFloat(document.getElementById('txt_imprumut').value) *  parseFloat(document.getElementById('txt_curs').value)) /  valuta[document.getElementById('sel_valuta_imprumut').value][1])
				> ( ( (parseFloat(document.getElementById('txt_venituri_ctg_a').value) < 2500) || ((credit[document.getElementById('sel_tip_credit').value]['nume']).search("Angajat") >= 0) ) ? 3 : 6) * (parseFloat(document.getElementById('txt_venituri_ctg_a').value)) )
		{
			alert("Plafonul maxim este de " + ( ( (parseFloat(document.getElementById('txt_venituri_ctg_a').value) < 2500) || ((credit[document.getElementById('sel_tip_credit').value]['nume']).search("Angajat") >= 0) ) ? 3 : 6) + " salarii nete!!!");
			return false;
		}
	}
	
	
	//angajati - 100 salarii max dar nu mai mult de 50k/100k
	if((credit[document.getElementById('sel_tip_credit').value]['nume']).search("Angajat") > 0)
	{
		if(
				parseFloat(document.getElementById('txt_imprumut').value)
				>
				100
				* (
					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_curs').value)
		 	)
		 {
		 		alert("Finantarea este de maxim 100 de venituri nete ale salariatului!!!");
		 		return false;
		 }
		 
		 if( (credit[document.getElementById('sel_tip_credit').value]['nume'] == 'Ipotecar - Angajati') )
		 {
		 	if( parseFloat(document.getElementById('txt_imprumut').value) * ( parseFloat(document.getElementById('txt_curs').value) /  valuta['eur'][1]) > 150000)
		 	{
		 		alert("Finantarea este de maxim 150.000 EUR!!!");
		 		return false;
		 	}
		 }
		 else
		 	if( parseFloat(document.getElementById('txt_imprumut').value) * ( parseFloat(document.getElementById('txt_curs').value) /  valuta['eur'][1]) > 50000)
		 	{
		 		alert("Finantarea este de maxim 50.000 EUR!!!");
		 		return false;
		 	}
		 	
		 
	}
	
	
	//pt VISA Gold
	if((credit[document.getElementById('sel_tip_credit').value]['nume']).search("VISA Gold") >= 0)
	{
		var venit_solicitant = 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);
		 
		 var ven_solic_gold = new Array();
		 ven_solic_gold[0] = 750;
		 ven_solic_gold[1] = 2500;
		 ven_solic_gold[2] = 5000;
		 var cred_max_gold = new Array();
		 cred_max_gold[0] = 0;
		 cred_max_gold[1] = 5000;
		 cred_max_gold[2] = 10000;
		 cred_max_gold[3] = 100000;
		 
		 var i;
		 for(i=0; i<ven_solic_gold.length; i++)
		 	if(venit_solicitant * parseFloat(document.getElementById('txt_curs').value)/valuta['eur'][1] < ven_solic_gold[i])
		 		break;
		 
		 if(parseFloat(document.getElementById('txt_imprumut').value) * parseFloat(document.getElementById('txt_curs').value)/valuta['eur'][1] > cred_max_gold[i])
		 {
		 		alert("Plafonul maxim este de " + cred_max_gold[i] + " EUR!!!");
				return false;
		 }
	}
	
  return true;
}


function is_valid(p_elem, p_msg)
{
	if( (isNaN(parseFloat(p_elem.value))) || (parseFloat(p_elem.value) < 0) )
	{
		alert(p_msg);
		p_elem.focus();
		p_elem.select();
		return false;
	}
	 return true;
}
