{include file="$gentemplates/$header_tpl"}
	<div>
	<div style="width:100%;overflow:hidden;">
		<dl>
        	<dt style="width:40%" align="{$default_left}">
				<h2>{$lang.games.header}</h2>
        	</dt>
        	<dt style="width:60%" valign="top">
        	{if $games_settings.use_paid eq '1'}
				<div class="iyf_head" style="text-align:{$default_right}" id="period"></div>
			{/if}
        	</dt>
        </dl>
    </div>
    </div>
	<div class="content content_adult_2" style="margin: 0px; padding: 15px;">
		<div style="margin: 0px; padding: 0px;">
		<div style="width:100%;">
		<dl align="{$default_left}">
			<dt style="width:100%">
				<h3 class="p-b5" style="width:100%;">{$games.name}</h3>
			</dt>
		</dl>
		<dl>
			<dd valign="top" align="center">
				<div style="padding:20px 0px;">
				{$games.code}
				</div>
				{if $games.description || $games.instruction}
				<div align="{$default_left}" id="description" class="text" style="padding:5px 0px 10px 10px;width:680px;display:none;">
				{if $games.description}
					<div>
						<b>{$lang.games.description}:</b><br>{$games.description}
				</div>
				{/if}
				{if $games.instruction}
					<div>
						<b>{$lang.games.instruction}:</b><br>{$games.instruction}
				</div>
				{/if}
				</div>
				<div align="{$default_left}" style="width:680px;">
					<a style="cursor:pointer;" id="desc_show">{$lang.games.description_show}&nbsp;<img border="0" src="{$site_root}{$template_root}{$template_images_root}/{if $color_theme eq 'gay'}arrows_down_blue.png{else}arrow_down.png{/if}" alt=""></a>
					<a style="cursor:pointer;display:none;" id="desc_hide">{$lang.games.description_hide}&nbsp;<img border="0" src="{$site_root}{$template_root}{$template_images_root}/{if $color_theme eq 'gay'}arrows_up_blue.png{else}arrow_up.png{/if}" alt=""></a>
				</div>
				{/if}
			</dd>
		</dl>
		</div>
		</div>
	</div>
	<div style="padding:6px;">
	</div>
	<div class="content content_adult_2 comments" style="margin: 0px; padding: 15px;">
		<div align="{$default_left}">
				<h3 class="p-b5">{$lang.games.comment}</h3>
		</div>
		<div id="comments" align="center">
			{foreach item=item name=comm from=$games_comments}
			<div id="{$smarty.foreach.comm.iteration}" class="comment_wrapper" align="{$default_left}" style="width:680px;overflow:hidden;margin-bottom:10px;">
				<div class="comments_left" style="float:{$default_left};">
					<a class="imgcanvas_container" href="viewprofile.php?id={$item.id}">
						<img class="imgcanvas" src="{$item.icon}" alt="">
					</a>
				</div>
				<div class="comments_right float_left" id="info_{$smarty.foreach.comm.iteration}">
					<a class="float_left" href="viewprofile.php?id={$item.id}">{$item.name}</a>
					<span class="float_left">&nbsp;&nbsp;{$item.date_add}&nbsp;&nbsp;</span>
						{if $item.delete_link}&nbsp;&nbsp;
						<a style="cursor:pointer;" class="float_left" onclick="Delete({$item.id_comment},{$smarty.foreach.comm.iteration});">{$button.delete}</a>
						{/if}
						<br/>
					{$item.comment}
				</div>
				<div class="clear">&nbsp;
				</div>
			</div>
			{/foreach}
		</div>
		<div style="padding-top:5px;" align="center">
			<div style="width:100%;overflow:hidden;">
				<div align="{$default_left}" style="width:100%; float:{$default_left};">
					<h3 class="p-b5">{$lang.games.add_comment}</h3>
				</div>
				<div>
				<div id="all_comment" align="{$default_right}" style="display:none;">
				<a href="games.php?sel=all_com&amp;id_game={$game_id}" target="_blank">{$lang.games.view_more}</a></div>
			</div>
			</div>
			<div style="margin: 0px; padding-top: 10px;width:720px;" align="center">
				<div class="content_alloc classfields">
				<textarea style="width:712px;resize: none;" name="message" id="message" rows="4" onkeyup="BadWords('message');textchange2()" ></textarea>
                <div id="bad_div_message" class="bad_div"></div>	
				<div style="margin: 10px 2px; text-align: right; display: table; width: 100%;">
				<div class="float_right" style="margin-top:9px;margin-right:7px;" id="count_sym2">256</div>
				<script>{literal}
					function textchange2() {
						var count = 256;
						$('#count_sym2').text(count);
						a = $('#message').val().length;
						if (a > count) {
							$('#message').val($('#message').val().substring(0, count));
						}
						a = $('#message').val().length;
						$('#count_sym2').text(count - a);
						if (a > count){
							$('#message').css("disabled", "disabled");
						}
					}
				{/literal}</script>
			
                <div style="height: 16px; width: 10px;" class="icon_smail_for_comment float_left" onclick="return displaySmileLayer();"></div>
                
    			<div id=smiles class="smiles" style="display:none; left: 264px; width: 255px;bottom:-10px;">                                   
    				<ul>
					{section name=sm loop=$smiles}
						{if $use_default_smiles eq '1'}
					<li><a style="cursor:pointer;" onclick="document.getElementById('message').value=document.getElementById('message').value+'{$smiles[sm].value}'; document.getElementById('smiles').style.display = 'none';"><img src="{$site_root}{$template_root}/emoticons/{$smiles[sm].file}" class="smile_icon" alt=""></a></li>
						{else}
						<li><a style="cursor:pointer;" onclick="document.getElementById('message').value=document.getElementById('message').value+'{$smiles[sm].value}'; document.getElementById('smiles').style.display = 'none';"><img src="{$site_root}/uploades/smiles/{$smiles[sm].file}" class="smile_icon" alt=""></a></li>
						{/if}
					{/section}
					</ul>
    			</div>
            	</div>
			</div>
			</div>
			<div>
				<div style="float:left;"><input type="button" class="button" onclick="Send();" value="{$lang.button.send}"></div>
				<div id="info"></div>
            </div>
		</div>
	</div>
<script type="text/javascript">
{literal}
total = {/literal}{$smarty.foreach.comm.total}{literal};
if (total > 9) $("#all_comment").show();
insert = 1;
function Send() {
	comment=$("#message").val();
	var count = 256;
	$('#count_sym2').text(count);
	if (comment != "") {
		ajaxLoadingImage(1, 'info');
		$.post("games.php",{sel: "add_comment_game", comment:comment, game_id:{/literal}{$game_id}{literal}, insert:insert},
			function(data){
				if (data == '1') {
					ShowAjaxError('{/literal}{$lang.err.badword_finding_15}{literal}', '', 'success');
					//$("#info").html("<font class='error_msg'>* {/literal}{$lang.err.badword_finding_15}{literal}<\/font>");
				} else {
					ajaxLoadingImage(0, 'info');
					if(total == 0 && insert == 1) {
						$("#comments").html(data);
						total++;
					} else {
						if(total-insert == 9) {$("#all_comment").show();$("#"+total).remove();total--;}
						$('#'+insert).before(data);
						insert--;
					}
				}
			}
		);
		$("#message").val('');
	}
}
function Delete(id_comment, id_div) {
	ajaxLoadingImage(1, id_div);
	$.post("games.php",{sel:"delete_comment_game", id_comment:id_comment},
		function(data){
			ajaxLoadingImage(0, id_div);
			$("#"+id_div).hide();
		}
	);
}
$(document).ready(function() {
	$('#desc_show').click(function () {
	$('#description').toggle();
	$('#desc_show').hide();
	$('#desc_hide').show();
	});
	$('#desc_hide').click(function () {
	$('#description').toggle();
	$('#desc_hide').hide();
	$('#desc_show').show();
	});
	$('.window #close').live("click", function (e) {
		document.location.href='games.php';
});
	$('#mask').click(function () {
		document.location.href='games.php';
	});
});

{/literal}
{if $paid eq 1 && $games_settings.use_paid eq '1'}
{literal}
setInterval (function(){GetTime();}, 60000);
$(window).load(function () {
	GetTime();
});
function GetTime() {
	$.post("games.php",{sel:"get_time"},
		function(data){
			if (data != '0') {
				$("#period").html(data);
			} else {
				Play();
			}
		}
	);
}
function Play() {
	id = {/literal}{$game_id}{literal};
	id_category = {/literal}{$id_category}{literal};
	if($('.window').css("display") == 'block') return;
	launchWindow(SITE_ROOT+"/games.php",'sel=get_popup&id_category='+id_category+'&id_game='+id,470,240,1);
}
{/literal}
{/if}
{literal}
function displaySmileLayer()
{
	if (document.getElementById('smiles').style.display == 'none') {
		document.getElementById('smiles').style.display = 'inline-block';
	} else {
		document.getElementById('smiles').style.display = 'none';
	}
	return false;
}

{/literal}
</script>
{include file="$gentemplates/$footer_tpl"}