<?

include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
only_reg();
$set['title']='Автосалон';
include_once '../sys/inc/thead.php';
title();
include_once 'glava_gonki.php';
//ОнЛайн Игра Круто гонки от BleIK
//Игра самая лучшая
  include_once'navi.php';
if (isset($_POST['save'])){

if (isset($_POST['avto']) && $_POST['avto']==0)
{
if ($user['money']>=$cena_mashiny0){

$user['avto']=0;
mysql_query("UPDATE `user` SET `avto` = '0' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `money` = '".($user['money']-$cena_mashiny0)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `benzines` = '".($user['benzines']=32)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `conditions` = '".($user['benzines']=100)."' WHERE `id` = '$user[id]' LIMIT 1");

}
}
 
 if ($user['money']>=$cena_mashiny1){
if (isset($_POST['avto']) && $_POST['avto']==1)
{
$user['avto']=1;
mysql_query("UPDATE `user` SET `avto` = '1' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `money` = '".($user['money']-$cena_mashiny1)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `benzines` = '".($user['benzines']=50)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `conditions` = '".($user['benzines']=100)."' WHERE `id` = '$user[id]' LIMIT 1");
}
}



if ($user['money']>=$cena_mashiny2){
if (isset($_POST['avto']) && $_POST['avto']==2)
{
$user['avto']=2;
mysql_query("UPDATE `user` SET `avto` = '2' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `money` = '".($user['money']-$cena_mashiny2)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `benzines` = '".($user['benzines']=65)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `conditions` = '".($user['benzines']=100)."' WHERE `id` = '$user[id]' LIMIT 1");
}
}

if ($user['money']>=$cena_mashiny3){
if (isset($_POST['avto']) && $_POST['avto']==3)
{
$user['avto']=3;
mysql_query("UPDATE `user` SET `avto` = '3' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `money` = '".($user['money']-$cena_mashiny3)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `benzines` = '".($user['benzines']=69)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `conditions` = '".($user['benzines']=100)."' WHERE `id` = '$user[id]' LIMIT 1");
}
}

if ($user['money']>=$cena_mashiny4){
if (isset($_POST['avto']) && $_POST['avto']==4)
{
$user['avto']=4;
mysql_query("UPDATE `user` SET `avto` = '4' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `money` = '".($user['money']-$cena_mashiny4)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `benzines` = '".($user['benzines']=70)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `conditions` = '".($user['benzines']=100)."' WHERE `id` = '$user[id]' LIMIT 1");
}
}

if ($user['money']>=$cena_mashiny5){
if (isset($_POST['avto']) && $_POST['avto']==5)
{
$user['avto']=5;
mysql_query("UPDATE `user` SET `avto` = '5' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `money` = '".($user['money']-$cena_mashiny5)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `benzines` = '".($user['benzines']=74)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `conditions` = '".($user['benzines']=100)."' WHERE `id` = '$user[id]' LIMIT 1");
}
}


if ($user['money']>=$cena_mashiny7){
if (isset($_POST['avto']) && $_POST['avto']==7)
{
$user['avto']=7;
mysql_query("UPDATE `user` SET `avto` = '7' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `money` = '".($user['money']-$cena_mashiny7)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `benzines` = '".($user['benzines']=84)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `conditions` = '".($user['benzines']=100)."' WHERE `id` = '$user[id]' LIMIT 1");
}
}
if ($user['money']>=$cena_mashiny8){
if (isset($_POST['avto']) && $_POST['avto']==8)
{
$user['avto']=8;
mysql_query("UPDATE `user` SET `avto` = '8' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `money` = '".($user['money']-$cena_mashiny8)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `benzines` = '".($user['benzines']=94)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `conditions` = '".($user['benzines']=100)."' WHERE `id` = '$user[id]' LIMIT 1");
}
}
if ($user['money']>=$cena_mashiny9){
if (isset($_POST['avto']) && $_POST['avto']==9)
{
$user['avto']=9;
mysql_query("UPDATE `user` SET `avto` = '9' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `money` = '".($user['money']-$cena_mashiny9)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `benzines` = '".($user['benzines']=100)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `conditions` = '".($user['benzines']=100)."' WHERE `id` = '$user[id]' LIMIT 1");
}
}
if ($user['money']>=$cena_mashiny10){
if (isset($_POST['avto']) && $_POST['avto']==10)
{
$user['avto']=10;
mysql_query("UPDATE `user` SET `avto` = '10' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `money` = '".($user['money']-$cena_mashiny10)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `benzines` = '".($user['benzines']=100)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `conditions` = '".($user['benzines']=100)."' WHERE `id` = '$user[id]' LIMIT 1");
}
}


if (!isset($err))msg("Вы купили новую машину $machine");
}
err();
aut();

echo "<div class='ind4ex'>";

if ($user['avto']==0){
$cena_mashiny_avto = 500;
}
if ($user['avto']==1){
$cena_mashiny_avto = 1000;
}
if ($user['avto']==2){
$cena_mashiny_avto = 2500;
}
if ($user['avto']==3){
$cena_mashiny_avto = 5000;
}
if ($user['avto']==4){
$cena_mashiny_avto = 7000;
}
if ($user['avto']==5){
$cena_mashiny_avto = 12000;
}

if ($user['avto']==7){
$cena_mashiny_avto = 42000;
}
if ($user['avto']==8){
$cena_mashiny_avto = 72000;
}
if ($user['avto']==9){
$cena_mashiny_avto = 74040;
}
if ($user['avto']==10){
$cena_mashiny_avto = 79800;
}


include'sale.php';



?><table class="wdt garage-table">
  <tbody>
    <tr>
      <td align="right" style="padding-top: 10px; padding-right: 10px;">
        <table class="wdt">
          <tbody>
            <tr>
              <td style="vertical-align: top; padding-top: 4px; padding-left: 10px;" align="left" rowspan="4">
																							</td>
              <td align="left" class="white" style="vertical-align: top" width="40%">
                <b><?print $machine;?></b>
              </td>
            </tr>
            <tr>
              <td align="left" class="white" style="font-size: 14px">
                Мощность: 
              <img src='images/power-ico.png'>
                <b class="yellow>"><?echo "".$speed.""; ?>км/ч</b>
              </td>
            </tr>
            <tr>
              <td align="left" class="white" style="font-size: 14px">
                Бензин: 
                <img src='images/ben.png'>
                <b class="yellow" style="color: #000">
                  <span id="FUELTIME">  <?echo "".$user['benzines']."";?>	</span>
                </b>
              </td>
            </tr>
          </tbody>
        </table>
      </td>
    </tr>
    <tr>
      <td align="center" style="padding-bottom: 0px; padding-left: 10px; padding-right: 10px;" valign="bottom">
	  <?if ($user['avto']==100){echo "<center><div class='index'>У вас пока нет машины</div>";}
if ($user['avto']==0){echo "<img  src=\"images/mashine/vaz2107.png\" width='328px'  /><img src='images/neon.png  '/>";}
if ($user['avto']==1){echo "<img src=\"images/mashine/vaz2112.png\" width='328px'  /><img src=\"images/neon.png \"/>";}
if ($user['avto']==2){echo "<img src=\"images/mashine/LanserEvolutionX.png\" width='328px' /><img src=\"images/neon.png \"/>";}
if ($user['avto']==3){echo "<img src=\"images/mashine/Pontiac_Solstice.png\" width='328px'  /><img src=\"images/neon.png \"/>";}
if ($user['avto']==4){echo "<img src=\"images/mashine/BMW_Z4.png\" width='328px'  /><img src=\"images/neon.png \"/>";}
if ($user['avto']==5){echo "<img src=\"images/mashine/TVR_Sagaris.png\" width='328px' /><img src=\"images/neon.png \"/>";}
if ($user['avto']==7){echo "<img src=\"images/mashine/Audi_TT.png\" width='328px' /><img src=\"images/neon.png \"/>";}
if ($user['avto']==8){echo "<img src=\"images/mashine/Bizzarrini.png\" width='328px' /><img src=\"images/neon.png \"/>";}
if ($user['avto']==9){echo "<img src=\"images/mashine/KTM_X-Bow.png\" width='328px' /><img src=\"images/neon.png \"/>";}
if ($user['avto']==10){echo "<img src=\"images/mashine/Ferrari_612_Scaglietti_Hamann.png\" width='328px' />";}?>
</td>
    </tr>
  </tbody>
</table>
<?if ($user['avto']!=100)
{

if (isset($_GET['act']) && $_GET['act']=='delete')
{
echo "<form method=\"post\" class='wdt' action=\"?\">\n";
echo "<center><b>$machine</b> эту машину вы можете продать за $cena_mashiny_avto$<br/>";
echo "<a href=\"?want_to_sell_machine=yes_you_have_successfully_sold_machine\">Продать</a></center><br/>";
echo "</form>\n";
}
echo "</div>";
echo "<div class='wdt black'><center><a  href='nash_avto_salon.php?act=delete'><b>Продать машину</b></a></center></div>";

}





echo "</center>";
echo "<hr/>";

echo"
      <td align=\"left\"><div class=\"wdt black\"><b><a href='avto_salon.php'>Автомобильный салон:</a></b></div></td>";
    echo"  <td align=\"left\"><div class=\"wdt black\"><b><a href='avto_zavod.php'>Автомобильный завод:</a></b></div></td>";


echo "</div>";
include_once '../sys/inc/tfoot.php';
?>