<html xmlns="http://www.w3.org/1999/xhtml">
	<head>

	</head>
	<body>
		<?php
			$Start = 1953519.71;
			$Target = round($Start*0.75, 2);
			$Big_Step = round($Start*0.05, 2);
			$Small_Step = round($Start*0.005, 2);
			$_POST['current'] = str_replace(",", ".", $_POST['current']);
			$_POST['current'] = str_replace(" ", "", $_POST['current']);
			if($_POST['current']){
				$Current = $_POST['current'];
			}else{
				$Current = $Start;
			}
			$Big_Steps = floor(($Current - $Target)/$Big_Step);
			$Dif = ($Current - $Target) - $Big_Step*$Big_Steps;
			$Small_Steps = floor($Dif/$Small_Step);
			$Win = round(100*($Current - $Target)/$Start, 1);
			$Trg = round($Current - $Start*($Win/100), 2);
			for(;;){
				$Trg = round($Current - $Start*($Win/100), 2);
				if($Trg <= $Target){
					$Win -= 0.1;
				}
				if($Trg >= ($Target + $Small_Step)){
					$Win += 0.1;
				}
				if($Trg > $Target && $Trg < ($Target + $Small_Step)){
					break;
				}
			}
		?>
		<form method = "post">
			<table align="center" cellspacing = "5">
				<tr>
					<td>Старт</td><td><?php echo $Start; ?></td>
				</tr>
				<tr>
					<td>Цель</td><td><?php echo $Target; ?></td>
				</tr>
				<tr>
					<td>Текущая</td><td><?php echo $Current; ?></td>
				</tr>
				<tr>
					<td>Шагов по 5%</td><td><?php echo $Big_Steps; ?></td>
				</tr>
				<tr>
					<td>Шагов по 0.5%</td><td><?php echo $Small_Steps; ?></td>
				</tr>
				<tr>
					<td>Победная ставка</td><td><?php echo $Win; ?></td>
				</tr>
				<tr>
					<td>Новая сумма</td><td><input type = "text" name = "current" size = "12"/></td>
				</tr>
				<tr>
					<td></td><td><input type = "submit" value = "Пересчитать"/></td>
				</tr>
				<tr>
					<td></td><td><?php echo str_replace(".", ",", $Trg); ?></td>
				</tr>
			</table>
		</form>
	</body>
</html>