//********************************Author:Marianne Angelides**************************************************
//*********************************Date: 9 February 2009********************************************************

// JavaScript Document

//copying the client currency to insert it into other currency fields


function MM_popupMsg(msg) { //v1.0
  alert(msg);
}

function editValue(source_id, dest_id, dest2_id) {
var selectVar = document.getElementById(source_id).selectedIndex;
var indexVal = document.getElementById(source_id).options[selectVar].text;

//var valueVal = indexVal.text;
//alert(valueVal);
var dl = document.getElementById(dest_id); 
dl.value=indexVal; 
var el = document.getElementById(dest2_id); 
el.value=indexVal; 
}

function copyIt(field1, field2) {
var selectVar = document.getElementById(field1).selectedIndex;
var indexVal = document.getElementById(field1).options[selectVar].text;
if(selectVar == 0) {
	indexVal = "";
}
//var valueVal = indexVal.text;
//alert(valueVal);
var dl = document.getElementById(field2); 
dl.value=indexVal; 
}

//function to get value of selected field
function getSelectedValue(field) {
var selectVar = document.getElementById(field).selectedIndex;
var indexVal = document.getElementById(field).options[selectVar].text;
//alert(indexVal);

return indexVal
}

//function to get selected currency code value 
/***
function getSelectedCurrency(currencyVal)
{
	if (document.getElementById('bank_currency').value != "") {
			var currencyCode = getSelectedValue(currencyVal);
			clientToLoanConversion();
				
			findInterestRateCurrency('../includes/db_Procs.php?bankID=' +  document.getElementById('bank_name').value  + '&procName=findInterestRate' + '&currencyCode=' + currencyCode)
	
		//setTimeout(function(){populateSingleInputText('exchange_rate', document.getElementById('bank_currency').value);}, 30);
			
	} else {
		
		populateSingleInputText('loanMaxInstallCurr', '');
		populateSingleInputText('maximum_instalments_loan', '');
		populateSingleInputText('interest_rate', '');
		populateSingleInputText('exchange_rate', '');		
		
	}
	
	
}
***/

//alpha
function getSelectedCurrency(interestRateID, currencyText)
{
	
	if (document.getElementById('bank_currency').value != "") {
			var currencyCode = getSelectedValue(currencyText);
			currencyCode = currencyCode.substring(0,3);
			var interestCode = interestRateID;
			//clientToLoanConversion();
			///moved to ajax.js findInterestRateCurrency()
				
			findInterestRateCurrency('../includes/db_Procs.php?bankID=' +  document.getElementById('bank_name').value  + '&procName=findInterestRate' + '&interestRateCode=' + interestCode)
	
		//setTimeout(function(){populateSingleInputText('exchange_rate', document.getElementById('bank_currency').value);}, 30);
			
	} else {
		
		populateSingleInputText('loanMaxInstallCurr', '');
		populateSingleInputText('maximum_instalments_loan', '');
		populateSingleInputText('interest_rate', '');
		populateSingleInputText('exchange_rate', '');		
		
	}
	
	
}


//alpha

function populateSingleInputText(inField, inVal) {
	document.getElementById(inField).value = inVal;	
	
}

function hideDiv(field)
{
	document.getElementById(field).innerHTML = '';	
	
}



/*************************************End:Marianne Angelides**************************************************/