{include file="$admingentemplates/admin_top.tpl"}
<div class="back">
    <a href="{$site_url}{$site_root}/admin/admin_modules.php">{$lang.button.back}</a>
</div>
<div class="cr"></div>
<div class="show_help" style="display: none;">&nbsp;</div>
<div class="red_header">{$lang.admin_games.razdel_name}</div>
<div class="cr">&nbsp;</div>
<div class="help_text" style="display:block;">
    <div class="close_help">
        <img src="{$site_root}{$template_root}/images/close_help.png" alt="">
    </div>
    <div class="help_body">
        <span class="help_title">{$lang.help}:</span>{$help.admin_games_orders_help}
    </div>
</div>
<div class="cr">&nbsp;</div>
<ul class="tabs">
    <li>
        <a href="admin_games.php">{$lang.admin_market.sales_games}</a>
    </li>
    <li>
        <a href="admin_games.php?sel=orders">{$lang.admin_games.orders_list}</a>
    </li>
	<li>
        <a class="current">{$lang.admin_menu.aff_settings}</a>
    </li>
</ul>
<div class="user_operation_line" style="margin-bottom:0px;">
	<div onclick="javascript: document.location.href='{$file_name}?sel=edit_game'" class="uol_item">
		<div class="uol_in_item">{$lang.admin_games.games_add}</div>
	</div>	
</div>
<div id="games_settings_div">
	<div class="panel_section">
		<div class="panel_content">
			<div style="padding:10px 0; height:15px; display:none;" id="info"></div>					
			<div style="padding:5px 0px;display:table;">				
				<div style="float:left;margin-top:7px;width:150px;" class="text"><b>{$lang.admin_games.games_use_paid}</b></div>
				<div style="margin-top:-3px;float:left;margin-top:4px;">
					<input type="checkbox" name="use_paid_service" id="use_paid_service" value="1" {if $games_settings.use_paid eq 1}checked{/if}>
				</div>				
			</div>
			
			<div id="period">
				<div style="padding:5px 0;display:table;">
					<div class="text" style="float:left;width:150px;padding-top:7px;"><b>{$lang.admin_games.games_period_paid}:</b></div>
					<div style="float:left;width:85px;"><input {if $games_settings.use_paid eq 0}disabled="disabled"{/if} type="text" name="period_day" id="period_day" size="10" value="{$games_settings.period}"></div>
					<div style="float:left;padding-top:7px;" class="text">{$lang.pays.periods.day}</div>
				</div>
				<div style="padding:5px 0;display:table;">
					<div class="text" style="float:left;width:150px;padding-top:7px;"><b>{$lang.admin_games.games_period_price}:</b></div>
					<div style="float:left;width:85px;"><input {if $games_settings.use_paid eq 0}disabled="disabled"{/if} type="text" name="price" id="price" size="10" value="{$games_settings.price}"></div>
					<div style="float:left;padding-top:7px;" class="text">{$cur}</div>
				</div>
			</div>
		</div>
	</div>
	<div><a class="admin_button_major" onclick="SavePaid();" style="margin-top:5px;">{$lang.button.save}<span>&nbsp;</span></a></div>
	
</div>
<script language="JavaScript" type="text/javascript">
{literal}
function Edit(id) {
	$("#err"+id).html('');
	$("#"+id).hide();
	$("#edit_"+id).show();
}
function Save(id) {
	if ($("#edit_name_"+id).val() == '') {
	} else {
		ajaxLoadingImage(1, 'err'+id);
		$("#err"+id).show(100);
		name = $("#edit_name_"+id).val();
		$.post("{/literal}{$file_name}{literal}",{sel:'add_category', id_category:id,name:name}, 
			function(data){
				if (data == '1') {
					ShowAjaxError('{/literal}{$lang.admin_games.category_edit_err_exist}{literal}', '', 'error');
				} else {
					ShowAjaxError(data, '', 'success');
					$("#"+id+" a").text(name);
					$("#edit_"+id).delay(4000).hide(100);
					$("#"+id).delay(4000).show(10);
				}
				
			}
		);
	}
}
function SavePaid() {
	var paid_value;
	var price = 0;
	var period_day = 0;
	if ($('#use_paid_service').is(':checked')) {
			paid_value = 1;
			price = $('#price').val();
			period_day = $('#period_day').val();
	} else {
			paid_value = 0;
	}
	ajaxLoadingImage(1, 'info');
	$('#info').show();
	$.post('admin_games.php',{sel:'use_paid',value:paid_value,price:price,period_day:period_day,ajax:'1'},
		function(data){
			ajaxLoadingImage(0, 'info'),
			ShowAjaxError(data, '', 'success');
			//$('#info').html('<div class=\"fl\"><div class=\"error_box_blue\" style=\"font-weight: bold;\" >'+data+'</div></div>').fadeIn(500).delay(2000).fadeOut(500)
		}
	);
}
$(document).ready(function() {	
	//if close button is clicked
	$('.window .close').live("click",function (e) {
		//Cancel the link behavior
		$('#mask, .window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});			
	$('#use_paid_service').click(function(){
		var paid_value;
		if ($('#use_paid_service').is(':checked')) {
			paid_value = 1;
			//$('#period').show();
			$('#period_day').removeAttr("disabled");
			$('#price').removeAttr("disabled");
		} else {
			paid_value = 0;
			//$('#period').hide();
			$('#period_day').attr("disabled", "disabled");
			$('#price').attr("disabled", "disabled");
		}
		}
	);
});
//select all the a tag with name equal to modal
function Delete(id) {
		str_html = "<div align=\"right\"><a href=\"#\"class=\"close\" ><img border=\"0\" src=\"{/literal}{$site_root}{$admin_theme_path}{literal}/images/window-close.png\"></a></div>";
		str_html = str_html+"<div id=\"answ\" style=\"padding-top:35px;width:100%\">";
		str_html = str_html+"<div align=\"center\">{/literal}{$lang.admin_games.category_delete}{literal}</div>";
		str_html = str_html+"<div style=\"padding-top:40px;\"><div align=\"right\" style=\"padding-right:50px;width:45%;float:left;\"><a href=\"{/literal}{$file_name}{literal}?sel=delete_category&id_category="+id+"&page={/literal}{$page}{literal}\">{/literal}{$lang.admin_games.games_delete_yes}{literal}</a></div>";
		str_html = str_html+"<div align=\"left\" style=\"padding-left:50px;\"><a href=\"#\"class=\"close\">{/literal}{$lang.admin_games.games_delete_no}{literal}</a></div>";
		str_html = str_html+"</div></div>";
	
		$("#dialog").html(str_html);
		$("#dialog").css("height","200px"),
		$("#dialog").css("width","400px"),
		ShowPopup();
}
function ShowPopup() {
	//e.preventDefault();
	//Get the A tag
	var id = '#dialog';
	
	//Get the screen height and width
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();
	
	//Set heigth and width to mask to fill up the whole screen
	$('#mask').css({'width':maskWidth,'height':maskHeight});
		
	//transition effect		
	$('#mask').fadeIn(500);	
	$('#mask').fadeTo("fast",0.8);	
	
	//Get the window height and width
	var winH = $(window).height();
	var winW = $(window).width();
              
	//Set the popup window to center
	$(id).css('top',  winH/2-$(id).height()/2);
	$(id).css('left', winW/2-$(id).width()/2);
	
	//transition effect
	$(id).fadeIn(500); 
}
{/literal}
</script>
{include file="$admingentemplates/admin_bottom.tpl"}