<?
session_start();
if(!isset($_SESSION['uid'])) { die(); }
include('config.php');
include('functions.php');

if($_GET['go_home'] == 1) {
  mysql_query("UPDATE `users`,`online` SET `users`.`room` = '2702',`online`.`room` = '2702' WHERE `online`.`id` = `users`.`id` AND `online`.`id` = '{$_SESSION['uid']}' ;");
  header('location: city.php');
}

?>
<html>
<head>
  <title>404</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta http-equiv="content-language" content="ru" />
  <link rel="stylesheet" href="css/main.css" />
  <link rel="stylesheet" href="css/tooltip.css" />
  <link rel="stylesheet" href="css/jquery.plugins.css" />
  <script src="js/jquery-1.7.2.min.js"></script>
  <script src="js/tooltip.js"></script>
  <script src="js/jquery.plugins.js"></script>
  <script>$(function() { $(".loc").tipTip({maxWidth: "auto", edgeOffset: 0, fadeIn: 300, fadeOut: 500}); });</script>
  <script>function growl(title, color, message, stycky) { if(!stycky) { stycky = false; } if(!color) { color = 'Red'; } $.jGrowl(message, { header: '<img src="/i/jgrowl_moover.png" class="jgrowl-moover" title="Передвинуть" style="cursor: pointer;" /> <font style="color: '+color+';">'+title+'</font>', sticky: stycky, glue: 'before' }); }</script>
  <script>$(document).ready(function() { $('#wishFormBox').hide(); $('#slide').toggle(function() { $(this).siblings('#wishFormBox').fadeIn('slow'); showWishForm(); }, function() { $(this).siblings('#wishFormBox').fadeOut('slow'); return false; }); });</script>
  <style>
    #takebtn_3135 { position: absolute; width: 40px; height: 25px; left: 215px; top: 193px; border: none; background: url(i/fountain_gold.png) no-repeat; cursor: pointer;}
    .pagination { margin: 0; padding: 0; }
    .pagination li { display: inline; padding: 1px 0px 0px 4px; margin-right: -1px; }
    .pagination li a { text-decoration:none; color: rgb(89, 141, 235); }
    .pagination li:hover { color: #CFF; }
    .pagination li.active { color: #333; }
  </style>
  <script>
  function load_winers() {
    $('#monetWinnersBox').load('ajax/fontan_luck.php?do=load_winers&hash=<?=md5($user['login'].'|'.$user['id']);?>&allList=0');
  }
  function showWishForm() {
    $('#wishFormBox').load('ajax/fontan_luck.php?do=showPanel&hash=<?=md5($user['login'].'|'.$user['id']);?>');
  }
  function wish(tekst) {
    var tekst = encodeURI(tekst);
    var uid = <?=(int)$user['id'];?>;
    $('#curehp').load('ajax/fontan_luck.php?do=wish&hash=<?=md5($user['login'].'|'.$user['id']);?>&tekst='+tekst+'&uid='+uid);
  }
  function curehp() {
    var uid = <?=(int)$user['id'];?>;
    $('#curehp').load('ajax/fontan_luck.php?do=cureHps&hash=<?=md5($user['login'].'|'.$user['id']);?>&uid='+uid);
  }
  function throwingcoin() {
    var uid = <?=(int)$user['id'];?>;
    $('#curehp').load('ajax/fontan_luck.php?do=giveCoin&hash=<?=md5($user['login'].'|'.$user['id']);?>&uid='+uid);
  }
  function load_wishs(p) {
    if(!p) { p = 1; }
    var uid = <?=(int)$user['id'];?>;
    $('#load').load('ajax/fontan_luck.php?do=loadWishs&hash=<?=md5($user['login'].'|'.$user['id']);?>&page='+p+'&uid='+uid);
  }
  function howMuch() {
    $('#val').load('ajax/fontan_luck.php?do=howMuch');
  }
  function tryGet() {
    var uid = <?=(int)$user['id'];?>;
    $('#curehp').load('ajax/fontan_luck.php?do=tryGet&hash=<?=md5($user['login'].'|'.$user['id']);?>&uid='+uid);
  }
  </script>
</head>
<body>
<b style="background: rgb(226, 224, 224);">
  <div id="curehp"></div>
  <div id="ajaxContainer" style="display: none;"></div>
  
  <div class="contentContainer">
  <div class="buttonContainer">

<h3>Фонтан удачи</h3>

<table border="0" height="378" width="794">
<tr><td height="374" width="456" rowspan="2" style="vertical-align: top">
    <?=nick::id($user['id'])->full()?>
    <br>
Выпив живительной воды из фонтана можно восстановить свои силы.<br />
<strong><small><font color="green">Персонажи до 7 уровня включительно могут восстанавливать здоровье бесплатно.</font></small></strong>
<br /><br />
<input type="button" onclick="curehp();" value="Испить водички" />&nbsp;
<input type="button" onclick="throwingcoin();" value="Бросить монетку" />&nbsp;
<script type="text/javascript">$(document).ready(function() { $('#wishFormBox').hide(); $('#slide').toggle(function() { $(this).siblings('#wishFormBox').fadeIn('slow'); showWishForm(); }, function() { $(this).siblings('#wishFormBox').fadeOut('slow'); return false; }); });</script>
<input type="button" id="slide" value="Загадать желание" />
<hr>

<div id="wishFormBox"></div>
<div id="load"><script>load_wishs();</script></div>

</td><td height="25" width="328">
<p align="right">
<input type="button" onclick="location.href='?';" value="Обновить" />
<input type="button" onclick="location.href='?go_home=1';" value="Вернуться" /><br /><br />
<div id="xyz" align=right style="font-size: 9pt;">Монет в фонтане: <span id="val"><script>howMuch();</script></span></div>
</td></tr><tr>
<td height="343" width="328">
<div style="width: 322px; height: 300px; float: right; position: relative; zoom:1; overflow: hidden; background: url(i/fountain.png) no-repeat;">
<button id="takebtn_3135" title="Попробовать достать монеты" onclick="if(confirm('Рискуете получить тяжелую травму на 15 минут, уверены что хотите попробовать достать монеты?')) { tryGet(); }"></button>
</div></td></tr></table>

<div id="monetWinnersBox">
<script>load_winers();</script>
</div>
<script>
$(document).ready(function() {
  $.jGrowl.defaults.closerTemplate = '<div style="text-align: center; cursor: pointer;"><b>[ Закрыть ]</b></div>';
  $.jGrowl.defaults.closeTemplate  = '<img src="i/clear.gif" alt="x" title="Закрыть" />';

  $('body').delegate('div#jGrowl .jgrowl-moover', 'click', function() {
   var j = $(this).closest('div#jGrowl');
   var c = j.hasClass('top-right') ? 'top-left' : 'top-right';
   j.removeClass('top-left top-right').addClass(c);
  });
  
  $("#load").on("click", ".pagination a", function (e) {
	var page = $(this).attr("data-page");
    var uid = <?=(int)$user['id'];?>;
	$('#load').load('ajax/fontan_luck.php?do=loadWishs&hash=<?=md5($user['login'].'|'.$user['id']);?>&page='+page+'&uid='+uid);
  });
  
  $("#load").on("click", ".deleted", function (e) {
    var id = $(this).attr("id");
    var uid = <?=(int)$user['id'];?>;
    $('#load').load('ajax/fontan_luck.php?do=deleteWishs&hash=<?=md5($user['login'].'|'.$user['id']);?>&uid='+uid+'&id='+id);
  });
});
</script>
</body>
</html>