{include file="$gentemplates/$header_tpl"}
<div class="profile_general_table">
<div>
	{$form.hiddens}
	{$lang.payment.toptext}<br />
        	
	<h3 class="p-b5">{$lang.payment.select_group}</h3>
	
	<p>	{$lang.payment.aval_groups}:<br/></p>
	<form name="groups_form" id="groups_form" action="{$site_root}/{$seo.payment}?sel=save_1" method="post">
		<div style="display:table; width:100%;">
		{foreach from=$group_diff.diff_modules key=key item=item}
			{if $key == $groups_info[$key].group_id}
				<div class="float_left">
					<input id="inp_group_id{$key}" type="radio" name="group" value="{$key}" onclick="initPeriods({$key});">
					<label for="inp_group_id{$key}">{$groups_info[$key].name}</label>&nbsp;&nbsp;
				</div>
			{/if}
		{/foreach}</div>
		{foreach from=$groups_info item=group}
			<div id="block_{$group.group_id}" class="div_periods">
				{if !$group.is_free}
					<br /><p>{$lang.payment.member_period}:</p>
					<div style="display:table; width:100%;">
					{foreach from=$group.periods item=period}
						<div class="float_left">
							<input class="float_left" onchange="select_period(this.value);" id="inp_period_id{$period.period_id}" type="radio" name="period_id" value="{$period.period_id}">
							<label for="inp_period_id{$period.period_id}">
								<span class="float_left">&nbsp;</span>
								<span class="float_left">{$period.amount}&nbsp;{$lang.pays.periods[$period.period]}</span>
								<span class="float_left">&nbsp;-&nbsp;</span>
								<span class="float_left">{$period.cost}&nbsp;</span>
								<span class="float_left">{$data.account_currency}</span>
							</label>&nbsp;&nbsp;
						</div>
					{/foreach}
					</div>
				{else}
					<br /><p>{$lang.payment.free_group}</p>
				{/if}
				<p style="margin-top: 10px;">
					<input type="submit" class="big_button" value="{$lang.payment.buy_now}">
				</p>
			</div>
		{/foreach}
	</form>
	
	<h3 class="p-b5">{$lang.payment.features}</h3>
	<div class="contant" style="margin-bottom:10px;">
		<dl style="overflow:hidden;">
			<dt class="first" style="width:28%;"><b>{$lang.payment.activities}</b></dt>
			{foreach name=gd from=$group_diff.diff_modules key=group_id item=item}
			<dt {if $smarty.foreach.gd.last}class="last"{/if} style="width:{if $smarty.foreach.gd.last}{$group_diff.width_diff_modules-1}{else}{$group_diff.width_diff_modules}{/if}%;text-align: center;"><b>{$group_diff.groups_names[$group_id].name}</b></dt>
			{/foreach}
		</dl>

		{foreach from=$group_diff.diff_perm_ids item=perm_id}
		<dl class="dl_line" style="overflow:hidden;">
			<dd style="width:28%;">
				<span class="float_left" style="width:83%;">{$group_diff.perm_descr[$perm_id].name}</span>
				<div class="tool_tip float_right"><label title="{$group_diff.perm_descr[$perm_id].comment}"><a class="question_icon">&nbsp;</a></label></div>
			</dd>
			{foreach name=gd from=$group_diff.diff_modules key=group_id item=item}
			<dd style="text-align: center;width:{if $smarty.foreach.gd.last}{$group_diff.width_diff_modules}{else}{$group_diff.width_diff_modules}{/if}%;">
				{if $perm_id == 8}
					{if $group_diff.diff_perm[$group_id][$perm_id]}<a class="ok_icon">&nbsp;</a>{else}<a class="ok_icon_bad">&nbsp;</a>{/if}
				{else}
					<b>                                    
					{if isset($group_diff.diff_perm[$group_id][$perm_id])}
						{$group_diff.diff_perm[$group_id][$perm_id]}
					{else}
						{if $perm_id eq 1 && $group_diff.gr_module[$group_id][17] eq 0}
							0
						{else}    
							{$lang.payment.unlimited}
						{/if}
					{/if}
					</b>
				{/if}
			</dd>
			{/foreach}
		</dl>
		{/foreach}

		{foreach from=$group_diff.modules_weights item=module_id}
		{if $module_id==17 && $use_mailbox==0}
		{else}
		<dl class="dl_line" style="overflow:hidden;">
			<dd style="width:28%;">
				<span class="float_left" style="width:83%;">{$group_diff.modules_info[$module_id].name}</span>
				<div class="tool_tip float_right"><label title="{$group_diff.modules_info[$module_id].comment}"><a class="question_icon">&nbsp;</a></label></div>
			</dd>
			{counter assign=td_counter start=1 print=false}
			{foreach from=$group_diff.diff_modules key=group_id item=modules}
			{counter}
			<dd style="text-align: center; width:{if $smarty.foreach.gd.last}{$group_diff.width_diff_modules}{else}{$group_diff.width_diff_modules}{/if}%;">
				{if $modules[$module_id]}<a class="ok_icon">&nbsp;</a>{else}<a class="ok_icon_bad">&nbsp;</a>{/if}
			</dd>
			{/foreach}
		</dl>
		{/if}
		{/foreach}
		<dl onclick="initSameModules(1);return false;" id="tr_show_same_modules" style="display:table;width:100%;" class="dl_line">
			<dd colspan="{$td_counter}" class="view_all" style="display:table;width:100%;float:none;margin-top:-12px;cursor:pointer;">
				<div class="float_left" style="padding-top:8px;"><a style="cursor:pointer;" onclick="initSameModules(1);return false;" ><b>{$lang.payment.expand_activities}</b></a></div>
				<div class="float_right"><a class="arr-down-icon float_right" onclick="initSameModules(1);return false;">&nbsp;</a></div>
			</dd>
		</dl>
		{foreach from=$group_diff.similar_perm_ids item=perm_id}
		<dl class="same_modules" style="overflow:hidden;">
			<dd style="width:28%;">
				<span class="float_left" style="width:83%;">{$group_diff.perm_descr[$perm_id].name}</span>
				<div class="tool_tip float_right"><label title="{$group_diff.perm_descr[$perm_id].comment}"><a class="question_icon">&nbsp;</a></label></div>
			</dd>
			{foreach name=gd from=$group_diff.diff_modules key=group_id item=item}
				<dd style="text-align: center;width:{if $smarty.foreach.gd.last}{$group_diff.width_diff_modules}{else}{$group_diff.width_diff_modules}{/if}%;">
					{if $perm_id == 8}
						<a class="ok_icon">&nbsp;</a>
					{else}
						<b>
						{if isset($group_diff.similar_perm[$group_id][$perm_id]) && $group_diff.similar_perm[$group_id][$perm_id]}
							{$group_diff.similar_perm[$group_id][$perm_id]}
						{else}
							{$lang.payment.unlimited}
						{/if}
						</b>
					{/if}
				</dd>
			{/foreach}
		</dl>
		{/foreach}
		{foreach from=$group_diff.same_modules item=module_id}
			<dl class="same_modules" style="overflow:hidden;">
				<dd style="width:28%;">
					<span class="float_left" style="width:83%;">{$group_diff.modules_info[$module_id].name}</span>
					<div class="tool_tip float_right" onmouseover="$(this).tooltip();"><label title="{$group_diff.modules_info[$module_id].comment}"><a class="question_icon">&nbsp;</a></label></div>
				</dd>
				{foreach from=$group_diff.diff_modules item=item}
					<dd style="text-align: center;width:{if $smarty.foreach.gd.last}{$group_diff.width_diff_modules}{else}{$group_diff.width_diff_modules}{/if}%;"><a class="ok_icon">&nbsp;</a></dd>
				{/foreach}
			</dl>
		{/foreach}
		<dl onclick="initSameModules(0);return false;" id="tr_hide_same_modules" style="display:table;width:100%;cursor:pointer;" class="dl_line">
			<dd colspan="{$td_counter}" class="view_all" style="display:table;width:100%;margin-top:-12px;">
				<div class="float_left" style="padding-top:8px;"><a style="cursor:pointer;" onclick="initSameModules(0);return false;" ><b>{$lang.payment.collapse_activities}</b></a></div>
				<div class="float_right"><a class="arr-up-icon float_right" onclick="initSameModules(0);return false;">&nbsp;</a></div>
			</dd>
		</dl>
	</div>
				
	<form name="bottom_groups_form" id="bottom_groups_form" action="{$site_root}/{$seo.payment}?sel=save_1" method="post">
		<p>{$lang.payment.aval_groups}:</p>
		<div style="display:table;width:100%;">
		{foreach from=$group_diff.diff_modules key=key item=item}
			{if $key == $groups_info[$key].group_id}
				<div class="float_left">
					<input id="bottom_inp_group_id{$key}" type="radio" name="group" value="{$key}" onclick="initPeriods({$key});">
					<label for="bottom_inp_group_id{$key}">{$groups_info[$key].name}</label>&nbsp;&nbsp;
				</div>
			{/if}
		{/foreach}
		</div>
		{foreach from=$groups_info item=group}
			<div id="bottom_block_{$group.group_id}" class="div_periods">					
				{if !$group.is_free}
				<br /><p>{$lang.payment.member_period}:</p>
				<div style="display:table;width:100%;">
				{foreach from=$group.periods item=period}
					<div class="float_left">
						<input class="float_left" onchange="select_period(this.value);" id="bottom_inp_period_id{$period.period_id}" type="radio" name="period_id" value="{$period.period_id}">
						<label for="bottom_inp_period_id{$period.period_id}">
							<font class="float_left">&nbsp;</font>
							<font class="error_msg float_left">{$period.amount}&nbsp;{$lang.pays.periods[$period.period]}</font>
							<font class="float_left">&nbsp;-&nbsp;</font>
							<font class="float_left">{$period.cost}&nbsp;</font>
							<font class="float_left">{$data.account_currency}</font>
						</label>&nbsp;&nbsp;
					</div>
				{/foreach}
				</div>
				{else}
				<font class="text">{$lang.payment.free_group}</font>
				{/if}
				<p style="margin-top: 10px;">
					<input type="submit" class="big_button" value="{$lang.payment.buy_now}">
				</p>		
			</div>
		{/foreach}
	</form>
</div>				
	<script type="text/javascript">
		{literal}
		$(document).ready(function(){
			$('.tool_tip').tooltip();
		});
		initSameModules(0);

		$('#bottom_groups_form').find("input[name=group]:first").attr("checked",true);
		$('#groups_form').find("input[name=group]:first").attr("checked",true);

		group_id = $("input[name=group]:first").val();
		initPeriods(group_id);

		function initSameModules(status){
			if (status){
				$(".same_modules").show();
				$("#tr_show_same_modules").hide();
				$("#tr_hide_same_modules").show();
			}else{
				$(".same_modules").hide();
				$("#tr_show_same_modules").show();
				$("#tr_hide_same_modules").hide();
			}
		}

		function initPeriods(group_id){
			$(".div_periods").hide();

			$("input[name=period_id]").attr("checked",true);
			
			$("#block_"+group_id).show();
			$("#block_"+group_id+" input[name=period_id]:first").attr("checked",true);

			$("#bottom_block_"+group_id).show();
			$("#bottom_block_"+group_id+" input[name=period_id]:first").attr("checked",true);

			$('#inp_group_id'+group_id).attr("checked",true);
			$('#bottom_inp_group_id'+group_id).attr("checked",true);
		}

		function select_period(value){
			if(value == undefined){
				return;
			}
			$('.div_periods').find('input[value="'+value+'"]').attr('checked', true)
		}
		{/literal}
	</script>
{include file="$gentemplates/$footer_tpl"}