





var flashString="";
var timer;
var timer2;
var id;

/* Open Popup Window */
function openPopup(targetUrl)
{
 fenster=window.open(targetUrl, 'Popup', 'width=600,height=720,toolbar=yes,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
 fenster.focus();
}
function openApprovalPopup( targetUrl )
{
 fenster=window.open( targetUrl, 'Popup', 'width=755,height=760,toolbar=yes,location=no,directories=no,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
 fenster.focus();
}


// Flash Calculators: 
// preset values of Flash Calculator
function presetCalculator(Amount,Term, monthlyRate){
//		alert("Amount in presetCalculator:"+Amount);
//		alert("Term in presetCalculator:"+Term);
		flashString = "amount="+Amount+"&term="+Term+"&monthlyRate="+monthlyRate;
//		alert("flashString in presetCalculator = "+flashString);
		document.getElementById("Amount").value = Amount;
		document.getElementById("Term").value = Term;
		document.getElementById("monthlyRate").value = monthlyRate;
}


// Flash Calculators: 
// builds URL with GET parameters (Amount / Term) for the receiving page to put the slide controls in the same position
function submitFlashData(url){
	var Amount = document.getElementById("Amount").value;
	var Term = document.getElementById("Term").value;
	var monthlyRate = document.getElementById("monthlyRate").value;
	
	url = url + "?Amount=" + Amount + "&Term="+ Term + "&monthlyRate="+ monthlyRate;
//	alert ("Amount in submitFlashData:"+Amount);
//	alert ("Term in submitFlashData:"+Term);
//	alert ("URL built in submitFlashData:"+url);
	document.location.href= url;
}

// Flash Calculators: 
// writes HIDDEN fields into the product page
// these hidden fields are used to transfer Amount & Term to the full calculator at http://www.finansbank.de/finansbank/germany/german/consumer_banking/loans/personal/calculator/payments/index.jsp
function transferData(Amount,Term, monthlyRate){
//	alert ("Amount in transferData:"+Amount);
//	alert ("Term in transferData:"+Term);
	document.getElementById("Amount").value = Amount;
	document.getElementById("Term").value = Term;
	document.getElementById("monthlyRate").value = monthlyRate;
	document.getElementById("Installment").value = monthlyRate;
//	alert ("Amount in transferData:"+Amount);
//	alert ("Term in transferData:"+Term);
}

// Flash Calculators: 
// reads GET parameters from URL (Amount / Term) to put the slide controls in the same position as before selected by the user
function receiveGetString(){
	query = self.location.search;
	sammlung = new Array();

	if (query != ''){

		query = query.substr(1, query.length - 1);
		query = query.replace(/%26/,'&');
		teile = query.split('&');
	
		for (i = 0; i < teile.length; i++){
			teile[i] = teile[i].split('=');
			sammlung[teile[i][0]] = teile[i][1];
		}
		Amount = teile[0][1];
		Term = teile[1][1];
		monthlyRate = teile[2][1];
//		alert("Amount in receiveGetString:"+Amount);
//		alert("Term in receiveGetString:"+Term);
		transferData(Amount,Term, monthlyRate);
		flashString = "amount=" + Amount + "&term="+ Term + "&monthlyRate="+ monthlyRate;
//		alert("flashString in receiveGetString:"+flashString);
	}else{
		presetCalculator(10000,60,190);
	}
}

/* Preload Images for Mouse overs in Navi */
function loadImg() {
	var img = new Array('nav_consumer_banking.gif','nav_consumer_banking_over.gif','nav_consumer_banking_active.gif','nav_corporate_banking.gif','nav_corporate_banking_over.gif','nav_corporate_banking_active.gif','nav_bank_relations.gif','nav_bank_relations_over.gif','nav_bank_relations_active.gif','nav_intermediaries.gif','nav_intermediaries_over.gif','nav_intermediaries_active.gif','nav_about_us.gif','nav_about_us_over.gif','nav_about_us_active.gif','nav_representations.gif','nav_representations_over.gif','nav_representations_active.gif','nav_financial_info.gif','nav_financial_info_over.gif','nav_financial_info_active.gif');
	document.preload = new Array();
	
	if(document.images)	{
		//alert(img.length);
		for(var i=0; i<img.length; i++){
			//alert(img[i]);
			document.preload[i] = new Image();
			document.preload[i].src = fb_resources + "/pics/" + fb_country + "/" + fb_language + "/" + img[i];
		}
	}
}

// 1st level mouseover
function mOver() {
	var e = this.id;
	var pic = document.getElementById(e+"Img");
	var picId = pic.id;
	if(document.getElementById(pic.id)) {
		if(picId.indexOf("Active")==-1) {
			if (pic.src.substring(pic.src.length-9,pic.src.length) != "_over.gif") {
					pic.src = pic.src.substring(0,pic.src.length-4)+"_over.gif";
			}
		}
	}
}

// 1st level mouseout
function mOut() {
	closeAllSubnavs();
	//alert(this.id);
	var e = this.id;
	var pic = document.getElementById(e+"Img");
	var picId = pic.id;
	if(document.getElementById(pic.id)) {
		if(picId.indexOf("Active")==-1) {
			pic.src = pic.src.substring(0,pic.src.length-9)+".gif";
		}
	}
}

// close all subnavs and open the one required
function openSubnav() {
	clear_Timeout();
	var d = document.getElementById('s'+this.id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
	if (d) {d.style.display='block';}
}

// close specific subnav
function closeSubnav(object) {
	//alert(object.id);
	var e = (object)? object.id : this.id;
	var dd = document.getElementById(e);
	
	dd.style.display = '';
	
}

// close all subnavs
function closeAllSubnavs(){
	var dds = document.getElementsByTagName("dd");
	for(var i = 0; i < dds.length; i++) {
		closeSubnav(dds[i]);
	}
}

// close all subnavs after a certain time
// e.g. mouse leaves 2nd level nav without going over 3rd level 
function closeSubnavTimer(){
	if (timer2) window.clearTimeout(timer2);
	timer2 = window.setTimeout("closeAllSubnavs()",100);
}

// close specific subnav after a certain time 
// eg mouse leaves 3rd level nav
function start_Timeout(){
	id = this.id;
	if (timer) window.clearTimeout(timer);
	timer = window.setTimeout("closeSubnav(this)",100);
}

// clear timeouts to avoid closing of navs
function clear_Timeout(){
	if (timer) window.clearTimeout(timer);
	if (timer2) window.clearTimeout(timer2);
}


function init() {
	try {
		initLinkEventsMainNav();
		loadImg(); // preload images of nav
		AddLogo();
	} catch(e) {
		/* ignore */
	}
}

function initLinkEventsMainNav() {
	// All tags of type 'a'
	// in nav
	var navId = document.getElementById("nav");
	var elems = navId.getElementsByTagName('a');
	// behaviour of links in nav 1st level
	for(var i = 0; i < elems.length; i++) {
		if (elems[i].href) {
			//alert('initLinkElements: elems[' + i + '].href=' + elems[i].href);
			elems[i].onmouseover = mOver;
			elems[i].onmouseout = mOut;
		}
	}
}

function initLinkEvents() {
	// All tags of type 'a'
	// in nav
	var navId = document.getElementById("nav");
	var elems = navId.getElementsByTagName('a');
	var dts = document.getElementsByTagName("dt");
	var dds = document.getElementsByTagName("dd");
	
	// behaviour of links in nav 1st level
	for(var i = 0; i < elems.length; i++) {
		if (elems[i].href) {
			//alert('initLinkElements: elems[' + i + '].href=' + elems[i].href);
			elems[i].onmouseover = mOver;
			elems[i].onmouseout = mOut;
		}
	}
	// behaviour of nav 2nd level
	for(var j = 0; j < dts.length; j++) {
		dts[j].onmouseout = closeSubnavTimer;
		dts[j].onmouseover = openSubnav;
	}
	// behaviour of nav 3rd level
	for(var k = 0; k < dds.length; k++) {
		dds[k].onmouseout = start_Timeout;
		dds[k].onmousemove = clear_Timeout;
	}
}

function popup_print(url) {
 fenster=window.open(url, "drucken", "width=900,height=500,resizable=no,scrollbars=yes,menubar=yes,toolbar=yes");
 fenster.focus();
 return false;
}


var sfHover = function() {
	if(document.getElementById("ulSubnav")){
	var sfEls = document.getElementById("ulSubnav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

window.onload = init;

function show3rdMenu(id)
{
	var menu3rd = document.getElementById(id);
	if( menu3rd != null )
	{
		menu3rd .style.display = "block";
	}
}
function hide3rdMenu(id)
{
	var menu3rd = document.getElementById(id);
	if( menu3rd != null )
	{
		menu3rd .style.display = "none";
	}
}

function toggle_div(object){
	for (var i=1;i<5;i++){
		if (document.getElementById(object.id)!=document.getElementById('produkt_menu_'+i)){
			document.getElementById('produkt_menu_'+i+'_div').style.display='none';
		  	document.getElementById('produkt_menu_'+i).className="menu_head";
		}
		else {
		document.getElementById(object.id+'_div').style.display='block';
		document.getElementById(object.id).className="menu_head_active";
		
		}
	}
}

function popupIB(url)
  {
      window.open(url, 'win1','status=1,left=0,top=0,width=800,height=600');
  }





function show(obj){
		var objID = document.getElementById(obj);
		 objID.style.display = "block";
}

function hide(obj){
		var objID = document.getElementById(obj);
		 objID.style.display = "none";
}


function show_hide(obj){
		var objID = document.getElementById(obj);
		//alert(obj[i]);
		if (objID.style.display !="block"){
			objID.style.display = "block";
		}
		else
			{objID.style.display = "none";
		}
}

function subscribe2Newsletter(email) {
   openPopup(fb_siteroot + fb_language + '/about/news/newsletter/subscribe.html?e=' + email);	
}

function subscribe2NewsletterDE(email) {
   openPopup('http://newsletter.finansbank.de/reg.php?EMAIL=' + email);
}



//////  Self Approval Form function

  function getNumber(pText) {
    vText = pText.toString();
    vNumber = "";
    for (i=0; i<vText.length; i=i+1) {
      vC = vText.charAt(i)
      if ( (vC == "0") || (vC == "1") || (vC == "2") || (vC == "3") || (vC == "4") || (vC == "5") ||
           (vC == "6") || (vC == "7") || (vC == "8") || (vC == "9") || (vC == ".") ) {
        vNumber = vNumber + vC;
     }
    }
    return vNumber;
  }

  function formatCurrency( num ) {
    var isNegative = false;
    num = getNumber(num);
    if( isNaN( num ) ) {
      num = "0";
    }
    if ( num < 0 ) {
      num = Math.abs( num );
      isNegative = true;
    }
    cents = Math.floor( ( num * 100 + 0.5 ) % 100 );
    num = Math.floor( ( num * 100 + 0.5 ) / 100 ).toString();
    if ( cents < 10 ) {
      cents = "0" + cents;
    }
    for ( i = 0; i < Math.floor( ( num.length - ( 1 + i ) ) / 3 ); i++) {
      num = num.substring( 0 ,num.length - ( 4 * i + 3 ) ) + ',' + num.substring( num.length - ( 4 * i + 3 ) );
    }

    var result = num + '.' + cents;
    if ( isNegative ) {
      result = "-" + result;
    }
    return result;
  }

  function numChange (pTextBox) {
    pTextBox.value = formatCurrency(pTextBox.value);
    return true;
  }

  function ComboVal(pCombo) {
    return pCombo.options[pCombo.selectedIndex].value;
  }

  function qaResult () {
    v_12_Mo_Multer = 21804.95/250000;
    v_24_Mo_Multer = 11363.92/250000;
    v_36_Mo_Multer = 7891.88/250000;
    v_48_Mo_Multer = 6162.08/250000;
    v_60_Mo_Multer = 5129.13/250000;
    v_CNP = document.forms[0].p_CNP.value;
    v_Now = new Date();
    v_Birth_Date = new Date(v_CNP.charAt(1)+v_CNP.charAt(2), v_CNP.charAt(3)+v_CNP.charAt(4), v_CNP.charAt(5)+v_CNP.charAt(6));
    v_Age = (v_Now - v_Birth_Date) / (1000*60*60*24*365.25);
    v_Marital_Status = ComboVal(document.forms[0].p_marital);
    v_No_Of_Persons = ComboVal(document.forms[0].p_no_of_per);
    v_Rez_Status = ComboVal(document.forms[0].p_rez_status);
    v_Proffesion = ComboVal(document.forms[0].p_prof);
    v_Net_Income = getNumber(document.forms[0].p_income.value);
    v_Other_Inst = getNumber(document.forms[0].p_other_inst.value);
    v_Guarantor_Income = getNumber(document.forms[0].p_guarantor.value);
    v_Car_Value = getNumber(document.forms[0].p_Car_Value.value);
    v_Second_Hand = ComboVal(document.forms[0].p_Second_Hand);
    v_Year = ComboVal(document.forms[0].p_Prod_Year);
    v_Km = getNumber(document.forms[0].p_Km.value);
    v_Months = ComboVal(document.forms[0].p_Months);
    v_DP = getNumber(document.forms[0].p_Dp.value);
    v_Exchange_Rate = 35000;
    if (v_Car_Value == 0 ) { v_DP_Perc = 0 }
    else { v_DP_Perc = v_DP / v_Car_Value * 100; }
    v_Risk = v_Car_Value - v_DP;
    v_Total_Income = eval(v_Guarantor_Income) + eval(v_Net_Income)
    if ( v_Months == 12 ) { v_Installment = v_12_Mo_Multer * v_Risk; }
    if ( v_Months == 24 ) { v_Installment = v_24_Mo_Multer * v_Risk; }
    if ( v_Months == 36 ) { v_Installment = v_36_Mo_Multer * v_Risk; }
    if ( v_Months == 48 ) { v_Installment = v_48_Mo_Multer * v_Risk; }
    if ( v_Months == 60 ) { v_Installment = v_60_Mo_Multer * v_Risk; }
    v_Inc_On_Inst = ( v_Total_Income ) / ( v_Installment * v_Exchange_Rate );
    if ( v_Inc_On_Inst == "Infinity" ) { v_Inc_On_Inst = 0; }
    v_Point = 0;
    if ( v_Second_Hand == "N" ) {
      if ( v_Risk > 0 && v_Risk <= 20000) {
        if ( v_DP_Perc >= 10 && v_DP_Perc <  15 ) { v_Point = v_Point +  47; }
        if ( v_DP_Perc >= 15 && v_DP_Perc <  20 ) { v_Point = v_Point + 141; }
        if ( v_DP_Perc >= 20 && v_DP_Perc <  25 ) { v_Point = v_Point + 235; }
        if ( v_DP_Perc >= 25 && v_DP_Perc <  30 ) { v_Point = v_Point + 329; }
        if ( v_DP_Perc >= 30 && v_DP_Perc <  35 ) { v_Point = v_Point + 424; }
        if ( v_DP_Perc >= 35 && v_DP_Perc <  40 ) { v_Point = v_Point + 470; }
        if ( v_DP_Perc >= 40 && v_DP_Perc <  45 ) { v_Point = v_Point + 470; }
        if ( v_DP_Perc >= 45 && v_DP_Perc <  50 ) { v_Point = v_Point + 470; }
        if ( v_DP_Perc >= 50 && v_DP_Perc == 50 ) { v_Point = v_Point + 470; }
      } else {
        if ( v_DP_Perc >= 10 && v_DP_Perc <  15 ) { v_Point = v_Point +  47; }
        if ( v_DP_Perc >= 15 && v_DP_Perc <  20 ) { v_Point = v_Point + 110; }
        if ( v_DP_Perc >= 20 && v_DP_Perc <  25 ) { v_Point = v_Point + 173; }
        if ( v_DP_Perc >= 25 && v_DP_Perc <  30 ) { v_Point = v_Point + 236; }
        if ( v_DP_Perc >= 30 && v_DP_Perc <  35 ) { v_Point = v_Point + 299; }
        if ( v_DP_Perc >= 35 && v_DP_Perc <  40 ) { v_Point = v_Point + 362; }
        if ( v_DP_Perc >= 40 && v_DP_Perc <  45 ) { v_Point = v_Point + 424; }
        if ( v_DP_Perc >= 45 && v_DP_Perc <  50 ) { v_Point = v_Point + 470; }
        if ( v_DP_Perc >= 50 && v_DP_Perc == 50 ) { v_Point = v_Point + 470; }
      }
    } else {
      if ( v_Risk > 0 && v_Risk <= 20000) {
        if ( v_DP_Perc >= 20 && v_DP_Perc <  25 ) { v_Point = v_Point +  47; }
        if ( v_DP_Perc >= 25 && v_DP_Perc <  30 ) { v_Point = v_Point + 141; }
        if ( v_DP_Perc >= 30 && v_DP_Perc <  35 ) { v_Point = v_Point + 235; }
        if ( v_DP_Perc >= 35 && v_DP_Perc <  40 ) { v_Point = v_Point + 329; }
        if ( v_DP_Perc >= 40 && v_DP_Perc <  45 ) { v_Point = v_Point + 424; }
        if ( v_DP_Perc >= 45 && v_DP_Perc <  50 ) { v_Point = v_Point + 470; }
        if ( v_DP_Perc >= 50 && v_DP_Perc == 50 ) { v_Point = v_Point + 470; }
      } else {
        if ( v_DP_Perc >= 20 && v_DP_Perc <  25 ) { v_Point = v_Point +  47; }
        if ( v_DP_Perc >= 25 && v_DP_Perc <  30 ) { v_Point = v_Point + 110; }
        if ( v_DP_Perc >= 30 && v_DP_Perc <  35 ) { v_Point = v_Point + 173; }
        if ( v_DP_Perc >= 35 && v_DP_Perc <  40 ) { v_Point = v_Point + 236; }
        if ( v_DP_Perc >= 40 && v_DP_Perc <  45 ) { v_Point = v_Point + 299; }
        if ( v_DP_Perc >= 45 && v_DP_Perc <  50 ) { v_Point = v_Point + 362; }
        if ( v_DP_Perc >= 50 && v_DP_Perc == 50 ) { v_Point = v_Point + 424; }
      }
    }
    if ( v_Inc_On_Inst >= 2 && v_Inc_On_Inst <  3 ) { v_Point = v_Point +  80; }
    if ( v_Inc_On_Inst >= 3 && v_Inc_On_Inst <= 4 ) { v_Point = v_Point + 100; }
    if ( v_Inc_On_Inst >  4                       ) { v_Point = v_Point + 120; }
    if ( v_Inc_On_Inst <  2                       ) { v_Point = v_Point - 110; }
    if ( v_Net_Income >=  2500000 && v_Net_Income < 10000000 ) { v_Point = v_Point +  16; }
    if ( v_Net_Income >= 10000000 && v_Net_Income < 15000000 ) { v_Point = v_Point +  45; }
    if ( v_Net_Income >= 15000000 && v_Net_Income < 20000000 ) { v_Point = v_Point +  64; }
    if ( v_Net_Income >= 20000000 && v_Net_Income < 30000001 ) { v_Point = v_Point +  84; }
    if ( v_Net_Income >= 30000001                            ) { v_Point = v_Point + 100; }
    if ( v_Guarantor_Income > 0 ) { v_Point = v_Point + 90; }
    if ( v_Guarantor_Income == ""  ||
         v_Guarantor_Income == " " ||
         v_Guarantor_Income == ""  ||
         v_Guarantor_Income == 0    )  { v_Point = v_Point + 45; }
    if ( v_Rez_Status == 13 ) { v_Point = v_Point + 59; }
    if ( v_Rez_Status == 14 ) { v_Point = v_Point + 66; }
    if ( v_Rez_Status == 15 ) { v_Point = v_Point + 73; }
    if ( v_Rez_Status == 16 ) { v_Point = v_Point + 80; }
    if ( v_Rez_Status == 17 ) { v_Point = v_Point + 21; }
    if ( v_Rez_Status == 18 ) { v_Point = v_Point + 45; }
    if ( v_Proffesion == 19 ) { v_Point = v_Point + 70; }
    if ( v_Proffesion == 20 ) { v_Point = v_Point + 52; }
    if ( v_Proffesion == 21 ) { v_Point = v_Point + 21; }
    if ( v_Months == 12 ) { v_Point = v_Point + 60; }
    if ( v_Months == 24 ) { v_Point = v_Point + 60; }
    if ( v_Months == 36 ) { v_Point = v_Point + 50; }
    if ( v_Months == 48 ) { v_Point = v_Point + 40; }
    if ( v_Months == 60 ) { v_Point = v_Point + 20; }
    if ( v_Marital_Status == 5 ) { v_Point = v_Point + 33; }
    if ( v_Marital_Status == 6 ) { v_Point = v_Point + 50; }
    if ( v_Marital_Status == 7 ) { v_Point = v_Point + 21; }
    if ( v_Age >= 18 && v_Age <= 30 ) { v_Point = v_Point + 12; }
    if ( v_Age >= 31 && v_Age <= 40 ) { v_Point = v_Point + 24; }
    if ( v_Age >= 41 && v_Age <= 50 ) { v_Point = v_Point + 30; }
    if ( v_Age >= 51 && v_Age <= 65 ) { v_Point = v_Point + 15; }
    if ( v_No_Of_Persons ==  8 ) { v_Point = v_Point + 12; }
    if ( v_No_Of_Persons ==  9 ) { v_Point = v_Point + 20; }
    if ( v_No_Of_Persons == 10 ) { v_Point = v_Point + 14; }
    if ( v_No_Of_Persons == 11 ) { v_Point = v_Point +  6; }
    if ( v_No_Of_Persons == 12 ) { v_Point = v_Point +  0; }
    if ( v_Point < 470 ) { v_Result = "Not Approved"; } else { v_Result = "Approved"; }
    if ( v_Risk > 50000 ) { v_Result = "Not Approved"; }
    if ( v_Second_Hand == "Y" && v_DP_Perc < 30 ) { v_Result = "Not Approved"; }
    if ( v_Second_Hand == "Y" && v_Months > 36) { v_Result = "Not Approved"; }
    if ( v_Km > 100000 ) { v_Result = "Not Approved"; }
    if ( v_DP_Perc < 10 ) { v_Result = "Not Approved"; }
    if ( v_DP_Perc > 50 ) { v_Result = "Not Approved"; }
    if ( v_Net_Income < 2500000 ) { v_Result = "Not Approved"; }
    if ( fb_language == "ro" ) {
      if ( v_Result == "Approved" ) { v_Result = "Aprobat"; } else {  v_Result = "Neaprobat"; }
    }
    document.forms[0].p_Result.value = v_Result;
    document.forms[0].p_Score.value  = v_Point;
    return true;
  }

//////  End of Self Approval Form function

//////  Corporate Self Approval Form function

function qaResultCorp () {                                                                                    
    v_12_Mo_Multer = 21804.95/250000;
    v_24_Mo_Multer = 11363.92/250000;
    v_36_Mo_Multer = 7891.88/250000;
    v_48_Mo_Multer = 6162.08/250000;
    v_60_Mo_Multer = 5129.13/250000;
    v_Exchange_Rate = 35000;
    v_Point = 0;
    // AGE POINTS
    v_Now = new Date();
    v_Set_Mon = ComboVal(document.forms[0].p_Set_Mon);
    v_Set_Year = document.forms[0].p_Set_Year.value;
    v_Set_Date = new Date(v_Set_Year, v_Set_Mon, 15 );
    v_Age = ( v_Now - v_Set_Date ) / ( 1000 * 60 * 60 * 24 * 365 );
    if ( v_Age <   1               ) { v_Point = v_Point +  0 }
    if ( v_Age >=  1 && v_Age <  3 ) { v_Point = v_Point + 12 }
    if ( v_Age >=  3 && v_Age <  8 ) { v_Point = v_Point + 15 }
    if ( v_Age >=  8 && v_Age < 15 ) { v_Point = v_Point + 24 }
    if ( v_Age >= 15               ) { v_Point = v_Point + 30 }
    // OVER DUE DEBTS POINTS
    v_Overdue_Debts = getNumber(document.forms[0].p_Overdue_Debts.value);
    if ( v_Overdue_Debts ==  0                                ) { v_Point = v_Point + 20 }
    if ( v_Overdue_Debts >   0    && v_Overdue_Debts <   5000 ) { v_Point = v_Point + 14 }
    if ( v_Overdue_Debts >=  5000 && v_Overdue_Debts <  20000 ) { v_Point = v_Point + 10 }
    if ( v_Overdue_Debts >= 20000 && v_Overdue_Debts <= 50000 ) { v_Point = v_Point +  6 }
    if ( v_Overdue_Debts >  50000                             ) { v_Point = v_Point +  0 }
    // QUICK RATIO POINTS
    v_Ratio = ComboVal(document.forms[0].p_Liq);
    if ( v_Ratio == 1 ) { v_Point = v_Point +  0 }
    if ( v_Ratio == 2 ) { v_Point = v_Point + 21 }
    if ( v_Ratio == 3 ) { v_Point = v_Point + 33 }
    if ( v_Ratio == 4 ) { v_Point = v_Point + 50 }
    // MONTHS POINTS 
    v_Months = ComboVal(document.forms[0].p_Months);
    if ( v_Months == 12 ) { v_Point = v_Point + 60; } 
    if ( v_Months == 24 ) { v_Point = v_Point + 60; } 
    if ( v_Months == 36 ) { v_Point = v_Point + 50; } 
    if ( v_Months == 48 ) { v_Point = v_Point + 40; } 
    if ( v_Months == 60 ) { v_Point = v_Point + 20; } 
    // GUARANTOR PRESENTED
    v_Endorsee_CUI = document.forms[0].p_Endorser_cui.value
    if ( v_Endorsee_CUI == "" ) { v_Point = v_Point + 45; } else { v_Point = v_Point + 90; }
    // SECTOR POINTS
    v_Sector = ComboVal(document.forms[0].p_Sector);
    if ( v_Sector == "P" ) { v_Point = v_Point + 61; } 
    if ( v_Sector == "T" ) { v_Point = v_Point + 30; } 
    if ( v_Sector == "S" ) { v_Point = v_Point + 52; } 
    // AVERAGE TURNOVER POINTS
    v_Turn1 = getNumber(document.forms[0].p_Turnover_1.value);
    v_Turn2 = getNumber(document.forms[0].p_Turnover_2.value);
    v_Turn3 = getNumber(document.forms[0].p_Turnover_3.value);
    v_Average_Turn = ( 0.5 * v_Turn3 / 35000 + 0.3 * v_Turn2 / 40039 + 0.2 * v_Turn1 / 39338 ) * 1000
    v_End_Turn1 = getNumber(document.forms[0].p_End_Turnover_1.value);
    v_End_Turn2 = getNumber(document.forms[0].p_End_Turnover_2.value);
    v_End_Turn3 = getNumber(document.forms[0].p_End_Turnover_3.value);
    v_End_Average_Turn = ( 0.5 * v_End_Turn3 / 35000 + 0.3 * v_End_Turn2 / 40039 + 0.2 * v_End_Turn1 / 39338 ) * 1000
    if ( v_Average_Turn >=  10000 && v_Average_Turn <  50000 ) { v_Point = v_Point +  25 }
    if ( v_Average_Turn >=  50000 && v_Average_Turn < 100000 ) { v_Point = v_Point +  40 }
    if ( v_Average_Turn >= 100000 && v_Average_Turn < 200000 ) { v_Point = v_Point +  60 }
    if ( v_Average_Turn >= 200000 && v_Average_Turn < 500000 ) { v_Point = v_Point +  85 }
    if ( v_Average_Turn >= 500000                            ) { v_Point = v_Point + 120 }
    // AVERAGE CHANGE OF TURN OVER POINTS
    v_Turn_Change1 = v_Turn2 / v_Turn1;
    v_Turn_Change2 = v_Turn3 / v_Turn2;
    v_Change_Avg = ( v_Turn_Change1 + v_Turn_Change2) / 2;
    v_Change_Avg = ( v_Change_Avg - 1 ) * 100;
    if ( v_Change_Avg <  -50 && v_Change_Avg < -1000000 ) { v_Point = v_Point - 100 }
    if ( v_Change_Avg >= -50 && v_Change_Avg < -15 ) { v_Point = v_Point -  20 }
    if ( v_Change_Avg >= -15 && v_Change_Avg <  -5 ) { v_Point = v_Point +   0 }
    if ( v_Change_Avg >=  -5 && v_Change_Avg <   5 ) { v_Point = v_Point +  30 }
    if ( v_Change_Avg >=   5 && v_Change_Avg <  15 ) { v_Point = v_Point +  60 }
    if ( v_Change_Avg >=  15 && v_Change_Avg <  50 ) { v_Point = v_Point + 100 }
    if ( v_Change_Avg >=  50 && v_Change_Avg < 1000000 ) { v_Point = v_Point + 158 }
    // DOWNPAYMENT
    v_DP = getNumber(document.forms[0].p_Dp.value);
    v_Second_Hand = ComboVal(document.forms[0].p_Second_Hand);
    v_Car_Value = getNumber(document.forms[0].p_Car_Value.value);
    if (v_Car_Value == 0 ) { v_DP_Perc = 0 }
    else { v_DP_Perc = v_DP / v_Car_Value * 100; }
    v_Risk = eval(v_Car_Value) - eval(v_DP);
    if ( v_Second_Hand == "N" ) {
      if ( v_Risk > 0 && v_Risk <= 20000) { 
        if ( v_DP_Perc >= 10 && v_DP_Perc <  15 ) { v_Point = v_Point +  47; }
        if ( v_DP_Perc >= 15 && v_DP_Perc <  20 ) { v_Point = v_Point + 141; }
        if ( v_DP_Perc >= 20 && v_DP_Perc <  25 ) { v_Point = v_Point + 235; }
        if ( v_DP_Perc >= 25 && v_DP_Perc <  30 ) { v_Point = v_Point + 329; }
        if ( v_DP_Perc >= 30 && v_DP_Perc <  35 ) { v_Point = v_Point + 424; }
        if ( v_DP_Perc >= 35 && v_DP_Perc <  40 ) { v_Point = v_Point + 470; }
        if ( v_DP_Perc >= 40 && v_DP_Perc <  45 ) { v_Point = v_Point + 470; }
        if ( v_DP_Perc >= 45 && v_DP_Perc <  50 ) { v_Point = v_Point + 470; }
        if ( v_DP_Perc >= 50 && v_DP_Perc == 50 ) { v_Point = v_Point + 470; }
      } else {  
        if ( v_DP_Perc >= 10 && v_DP_Perc <  15 ) { v_Point = v_Point +  47; }
        if ( v_DP_Perc >= 15 && v_DP_Perc <  20 ) { v_Point = v_Point + 110; }
        if ( v_DP_Perc >= 20 && v_DP_Perc <  25 ) { v_Point = v_Point + 173; }
        if ( v_DP_Perc >= 25 && v_DP_Perc <  30 ) { v_Point = v_Point + 236; }
        if ( v_DP_Perc >= 30 && v_DP_Perc <  35 ) { v_Point = v_Point + 299; }
        if ( v_DP_Perc >= 35 && v_DP_Perc <  40 ) { v_Point = v_Point + 362; }
        if ( v_DP_Perc >= 40 && v_DP_Perc <  45 ) { v_Point = v_Point + 424; }
        if ( v_DP_Perc >= 45 && v_DP_Perc <  50 ) { v_Point = v_Point + 470; }
        if ( v_DP_Perc >= 50 && v_DP_Perc == 50 ) { v_Point = v_Point + 470; }
      } 
    } else { 
      if ( v_Risk > 0 && v_Risk <= 20000) { 
        if ( v_DP_Perc >= 20 && v_DP_Perc <  25 ) { v_Point = v_Point +  47; }
        if ( v_DP_Perc >= 25 && v_DP_Perc <  30 ) { v_Point = v_Point + 141; }
        if ( v_DP_Perc >= 30 && v_DP_Perc <  35 ) { v_Point = v_Point + 235; }
        if ( v_DP_Perc >= 35 && v_DP_Perc <  40 ) { v_Point = v_Point + 329; }
        if ( v_DP_Perc >= 40 && v_DP_Perc <  45 ) { v_Point = v_Point + 424; }
        if ( v_DP_Perc >= 45 && v_DP_Perc <  50 ) { v_Point = v_Point + 470; }
        if ( v_DP_Perc >= 50 && v_DP_Perc == 50 ) { v_Point = v_Point + 470; }
      } else {  
        if ( v_DP_Perc >= 20 && v_DP_Perc <  25 ) { v_Point = v_Point +  47; }
        if ( v_DP_Perc >= 25 && v_DP_Perc <  30 ) { v_Point = v_Point + 110; }
        if ( v_DP_Perc >= 30 && v_DP_Perc <  35 ) { v_Point = v_Point + 173; }
        if ( v_DP_Perc >= 35 && v_DP_Perc <  40 ) { v_Point = v_Point + 236; }
        if ( v_DP_Perc >= 40 && v_DP_Perc <  45 ) { v_Point = v_Point + 299; }
        if ( v_DP_Perc >= 45 && v_DP_Perc <  50 ) { v_Point = v_Point + 362; }
        if ( v_DP_Perc >= 50 && v_DP_Perc == 50 ) { v_Point = v_Point + 424; }
      } 
    }
    // AVERAGE TURNOVER COVERAGE ON RISK 
    v_Tot_Avg_Turn = eval(v_Average_Turn) + eval(v_End_Average_Turn);
    v_Current_Risk = getNumber(document.forms[0].p_Current_Risk.value);
    v_Coef =  v_Tot_Avg_Turn / ( v_Risk + eval(v_Current_Risk));
    if ( v_Coef >= 2 && v_Coef <  3 ) { v_Point = v_Point +  80 }
    if ( v_Coef >= 3 && v_Coef <= 4 ) { v_Point = v_Point + 100 }
    if ( v_Coef >  4                ) { v_Point = v_Point + 120 }
    if ( v_Coef <  2                ) { v_Point = v_Point -  49 }
    v_Year = ComboVal(document.forms[0].p_Prod_Year);
    v_Km = getNumber(document.forms[0].p_Km.value);
    if ( v_Months == 12 ) { v_Installment = v_12_Mo_Multer * v_Risk; }
    if ( v_Months == 24 ) { v_Installment = v_24_Mo_Multer * v_Risk; }
    if ( v_Months == 36 ) { v_Installment = v_36_Mo_Multer * v_Risk; }
    if ( v_Months == 48 ) { v_Installment = v_48_Mo_Multer * v_Risk; }
    if ( v_Months == 60 ) { v_Installment = v_60_Mo_Multer * v_Risk; }
    if ( v_Point < 470 ) { v_Result = "Not Approved"; } else { v_Result = "Approved"; }
    if ( v_Risk > 50000 ) { v_Result = "Not Approved"; }
    if ( v_Second_Hand == "Y" && v_DP_Perc < 30 ) { v_Result = "Not Approved"; }
    if ( v_Second_Hand == "Y" && v_Months > 36) { v_Result = "Not Approved"; } 
    if ( v_Km > 100000 ) { v_Result = "Not Approved"; } 
    if ( ( v_Overdue_Debts / v_Turn3 ) > 0.3 ) { v_Result = "Not Approved"; }
    if ( fb_language == "ro" ) {
      if ( v_Result == "Approved" ) { v_Result = "Aprobat"; } else {  v_Result = "Neaprobat"; }
    } 
    document.forms[0].p_Result.value = v_Result;
    document.forms[0].p_Score.value  = v_Point;
    return true;
  }

//////  End of Corporate Self Approval Form function

