		platStrah1Perc=0.5; //Процентная ставка по страхованию имущества
		platStrah2Perc=0.5; //Процентная ставка по страхованию жизни
		platStrah3Perc=0.5; //Процентная ставка по страхованию титула
		
		//Округление числа ch до e знаков после запятой
		function MyRound(ch, e){
			res="";
			ch=ch.toString();
			for(x=0; x<ch.length; x++)
				if(ch.charAt(x)=='.'){
					res=res+ch.substr(x, e+1);
					if(ch.charAt(x+e+2)*10/10>=5)	
						ch[x+e+1]=ch.charAt(x+e+1)+1;
					return res*10/10;
				}
				else
					res=res+ch.substr(x, 1);
			return res*10/10;
		}
		
		//Обработчик события onKeyPress для текстовых полей, дающий возможность вводить только целые числа
		function KeyPressINT(evt){
			window.status=evt.keyCode;
			if (!(((evt.keyCode>=1) && (evt.keyCode<=31)) || ((evt.keyCode>=48) && (evt.keyCode<=57))))
				return false;
			return true;
		}
		
		//Обработчик события onKeyPress для текстовых полей, дающий возможность вводить числа с плавающей точкой
		function KeyPressFLOAT(evt){
			window.status=evt.keyCode;
			if (!((((evt.keyCode>=1) && (evt.keyCode<=31)) || ((evt.keyCode>=48) && (evt.keyCode<=57))) || (String.fromCharCode(evt.keyCode)=='.')))
				return false;
			return true;
		}
		
		function rub2dollar(rubElem, courseElem, dollarElem){
			if(courseElem.value!=0){
				courseElem.style.backgroundColor='white';
				dollarElem.value=MyRound(rubElem.value/courseElem.value, 3);
			}
			else{
				courseElem.style.backgroundColor='red';
				courseElem.focus();
			}
		}
		
		function dollar2rub(dollarElem, courseElem, rubElem){
			if(courseElem.value>0){
				courseElem.style.backgroundColor='white';
				rubElem.value=MyRound(dollarElem.value*courseElem.value, 3);
			}
			else{
				courseElem.style.backgroundColor='red';
				courseElem.focus();
			}
		}
		
		function year2month(yearElem, monthElem){
			monthElem.value=yearElem.value*12;
		}
		
		function month2year(monthElem, yearElem){
			yearElem.value=MyRound(monthElem.value/12, 3);
		}
		
		//Вычисляем кредит
		function MakeCredit(creditPercElem, monthElem, rubElem, resDiv){
			//Проверяем все ли данные указаны
			//Процент по кредиту
			if(creditPercElem.value<=0){
				creditPercElem.style.backgroundColor='red';
				creditPercElem.focus();
			}
			else{
				creditPercElem.style.backgroundColor='white';
			}
			
			//Срок кредита
			if(monthElem.value<=0){
				monthElem.style.backgroundColor='red';
				monthElem.focus();
			}
			else{
				monthElem.style.backgroundColor='white';
			}
			
			//Заявленная стоимость кредита
			if(rubElem.value<=0){
				rubElem.style.backgroundColor='red';
				rubElem.focus();
			}
			else{
				rubElem.style.backgroundColor='white';
			}
			
			platMonth=rubElem.value*((creditPercElem.value/100/12)/(1-Math.pow((1+(creditPercElem.value/100/12)), -(monthElem.value-3)))); //20649.80; //Ежемесячный платеж по ссуде !!!
			platStrah1=rubElem.value*1.1*(platStrah1Perc/100)/12; //Платеж по страхованию имущества
			platStrah2=rubElem.value*1.1*(platStrah2Perc/100)/12; //Платеж по страхованию жизни
			platStrah3=rubElem.value*1.1*(platStrah3Perc/100)/12; //Платеж по страхованию титула
			platStrahAll=platStrah1+platStrah2+platStrah3; //ИТОГО страховые платежи
			platMonthAll=platMonth+platStrahAll; //ИТОГО ежемесячный платеж
			resDiv.innerHTML='<b>Результат:</b><br />'+
			'Ежемесячный платеж:'+MyRound(platMonthAll, 0);
		}
	
		//Вычисляем обратный кредит
		function MakeCreditR(creditPercElem, monthElem, platMonthAll, resDiv){
			//Проверяем все ли данные указаны
			//Процент по кредиту
			if(creditPercElem.value<=0){
				creditPercElem.style.backgroundColor='red';
				creditPercElem.focus();
			}
			else{
				creditPercElem.style.backgroundColor='white';
			}
			
			//Срок кредита
			if(monthElem.value<=0){
				monthElem.style.backgroundColor='red';
				monthElem.focus();
			}
			else{
				monthElem.style.backgroundColor='white';
			}
			
			//Полный ежемесячный платеж
			if(platMonthAll.value<=0){
				platMonthAll.style.backgroundColor='red';
				platMonthAll.focus();
			}
			else{
				platMonthAll.style.backgroundColor='white';
			}
			
			rubElem=platMonthAll.value/((1.1/12)*(platStrah1Perc/100+platStrah2Perc/100+platStrah3Perc/100)+((creditPercElem.value/100/12)/(1-Math.pow(1+(creditPercElem.value/100/12), -(monthElem.value-3)))));
			
			platStrah1=rubElem*1.1*(platStrah1Perc/100)/12; //Платеж по страхованию имущества
			platStrah2=rubElem*1.1*(platStrah2Perc/100)/12; //Платеж по страхованию жизни
			platStrah3=rubElem*1.1*(platStrah3Perc/100)/12; //Платеж по страхованию титула
			platStrahAll=platStrah1+platStrah2+platStrah3; //ИТОГО страховые платежи
			platMonth=platMonthAll.value-platStrahAll;//Ежемесяный платеж по кредиту
			
			
			resDiv.innerHTML='<b>Результат:</b> '+
			'<BR>Возможная сумма кредита: '+MyRound(rubElem, 0);
		}
