var flag=0;


function MenuMouseOn(id)
{
if (id!="0")
	{	flag=1;
		//document.getElementById("left"+id).className="MenuLeft";
		document.getElementById(id).className="MenuOn";
		//document.getElementById("right"+id).className="MenuRight";
		    }

}
function MenuMouseOff(id)
{
	if (id!="0")
	{
		flag=0;
		//document.getElementById("left"+id).className="menu";
		document.getElementById(id).className="menu";
		//document.getElementById("right"+id).className="menu";
	}
}

function LightButtom()
{
	if ((flag==0) )

	{
	 	document.getElementById("left0").className="MenuLeft";
		document.getElementById("0").className="MenuCenter";
		document.getElementById("right0").className="MenuRight";
	}
}

function ap(k,s,m)
{
	var is,ret,ps,sk;
	ps=parseInt(s);
	sk=parseInt(k);
	ps=ps/1200;
 	ret=(sk*ps);

 	ret=ret/(step(1+ps,m)-1);
	return ret;
}

function step(ch,st)
{
	var j,i,tmp,ist;
	tmp=1;
	j=parseFloat(ch);
    ist=parseInt(st);

	for (i=0; i<ist; i++)
	{
		tmp*=j;
	}
	tmp=1/tmp;
	return tmp;

}

function open_form(form)
{
	if (document.openform[0].checked)
		window.location="/ru/main-form.html";
	if (document.openform[1].checked)
		window.location="/ru/main-form.html";
	if (document.openform[2].checked)
		window.location="/ru/main-refunding.html";
	if (document.openform[3].checked)
		window.location="/ru/main-business.html";
}

function open_form_main(form)
{
	if (document.mainform[0].checked)
	{		window.location="/ru/main-form.html";
	}
	else
	{
		if (document.mainform[1].checked)
		{
			window.location="/ru/main-form.html";
		}
		else
		{	if (document.mainform[2].checked)
			{				window.location="/ru/main-refunding.html";
			}
			else
			{				if (document.mainform[3].checked)
				{					window.location="/ru/main-business.html";
				}
				else
				{					window.location="/ru/main-form.html";
				}
			}
		}
	}
}

function calculation()
{//     var monthpay,i,tmp;
//     monthpay=2*(document.calcu.summa.value/document.calcu.stavka.value/12*100);
//	 for (i=0; i<document.calcu.time.value; i++)
//		tmp=document.calcu.summa.value/document.calcu.stavka.value/12*100
	var msg1, msg2;
	if ((document.calcu.time.value<10000)&&(document.calcu.time.value>=0) &&
		(document.calcu.stavka.value<10000)&&(document.calcu.stavka.value>=0) &&
		(document.calcu.summa.value<100000000)&&(document.calcu.summa.value>=0)
		)
	{
	msg1=(ap(document.calcu.summa.value,document.calcu.stavka.value,document.calcu.time.value)*-1);
	msg2=(ap(document.calcu.summa.value,document.calcu.stavka.value,document.calcu.time.value)/6*-10)
		if ((!isNaN(msg1)) && (!isNaN(msg2))&& (msg2!=-Infinity) && (msg1!=-Infinity) && (msg2!=Infinity) && (msg1!=Infinity) )
		{		document.calcu.monthpay.value=Math.round(msg1);
		    document.calcu.money.value=Math.round(msg2);
		    document.calcu.text_money.value="Необходимый доход";
		    document.calcu.text_monthpay.value="Ежемесячный платеж:";
		    document.getElementById("send_print").style.display="";
		}
		else
		{
			document.calcu.monthpay.value="";
		    document.calcu.money.value="";
		    document.calcu.text_money.value="не корректны";
		    document.calcu.text_monthpay.value="Значения";
		     document.getElementById("send_print").style.display="none";
		}
	}
	else
	{		document.calcu.monthpay.value="";
	    document.calcu.money.value="";
	    document.calcu.text_money.value="не корректны";
	    document.calcu.text_monthpay.value="Значения";
	     document.getElementById("send_print").style.display="none";
	}

}
  /*
function mainmenu(id)
{
    var i;
    var j;

	document.getElementById('id1').style.display = 'none';
	document.getElementById('id2').style.display = 'none';
	document.getElementById('id3').style.display = 'none';
	document.getElementById('id4').style.display = 'none';
	document.getElementById('id5').style.display = 'none';
	document.getElementById('id6').style.display = 'none';
	document.getElementById('id7').style.display = 'none';
	document.getElementById('id8').style.display = 'none';
	document.getElementById('id9').style.display = 'none';
	document.getElementById('id10').style.display = 'none';
	document.getElementById('id11').style.display = 'none';
	document.getElementById('id12').style.display = 'none';
	document.getElementById('id13').style.display = 'none';
	document.getElementById('id14').style.display = 'none';
	document.getElementById('id15').style.display = 'none';
	document.getElementById('id16').style.display = 'none';


	   if (!((document.mainform[0].checked) ||(document.mainform[1].checked) ||(document.mainform[2].checked) ||(document.mainform[3].checked) ))
				document.mainform[0].checked=true;
 	for (i=1; i<21; i+=5)
	{
		if (document.mainform[i].checked)
		{
			if (!((document.mainform1[0].checked) ||(document.mainform1[1].checked) ||(document.mainform1[2].checked) ||(document.mainform1[3].checked) ||(document.mainform1[4].checked)))
					document.mainform1[0].checked=true;
	     	if (document.mainform1[0].checked)
			{
				document.getElementById('id'+(1+i)).style.display = 'block';
			}
			if (document.mainform1[1].checked)
			{
				document.getElementById('id'+(2+i)).style.display = 'block';
			}
			if (document.mainform1[2].checked)
			{
				document.getElementById('id'+(3+i)).style.display = 'block';
			}
			if (document.mainform1[3].checked)
			{
				document.getElementById('id'+(4+i)).style.display = 'block';
			}
			if (document.mainform1[4].checked)
			{
				document.getElementById('id'+(5+i)).style.display = 'block';
			}
		}
	}


}
        */
