<!-- user navigation bar -->

<div id="user_navbar" {if $languages|@count > 1}class="languages-bar"{/if}>
	{include file='blocks'|cat:$smarty.const.RL_DS|cat:'lang_selector.tpl'}

	{if $isLogin}
		<div class="account-container">
			<a title="{$lang.account_area}" class="account" href="javascript:void(0)">{$isLogin}<span></span></a>
			<ul class="menu hide">
				{foreach from=$account_menu item='mItem'}
					{if $mItem.Key == 'my_messages' && !$config.messages_module}{else}
						<li>
							<a {if $page == $mItem.Path}class="active"{/if} title="{$mItem.title}" href="{if $mItem.Page_type == 'external'}{$mItem.Controller}{else}{$rlBase}{if $config.mod_rewrite}{if $mItem.Path != ''}{$mItem.Path}.html{$mItem.Get_vars}{/if}{else}{if $mItem.Path != ''}?page={$mItem.Path}{$mItem.Get_vars|replace:'?':'&'}{/if}{/if}{/if}">{$mItem.name}</a>
							{if $mItem.Key == 'my_messages' && $new_messages}
								<a title="{$lang.new_message_available|replace:'[count]':$new_messages}" class="note" href="{$rlBase}{if $config.mod_rewrite}{if $mItem.Path != ''}{$mItem.Path}.html{/if}{else}{if $mItem.Path != ''}?page={$mItem.Path}{/if}{/if}"><img class="envelop" src="{$rlTplBase}img/blank.gif" alt="" /></a>
							{/if}
						</li>
					{/if}
				{/foreach}
				
				<li><a title="{$lang.title_logout}" href="{$rlBase}{if $config.mod_rewrite}{$pages.login}.html?action=logout{else}?page={$pages.login}&amp;action=logout{/if}">{$lang.logout}</a></li>
				
				{rlHook name='tplAfterAccountMenu'}
			</ul>
		</div>
		
		<script type="text/javascript">
		{literal}
		var user_menu = false;
		
		$(document).ready(function(){
			$('#user_navbar a.account').click(function(){
				if ( !user_menu )
				{
					$(this).addClass('active');
					$('#user_navbar ul.menu').show();
					
					user_menu = true;
				}
				else
				{
					$(this).removeClass('active');
					$('#user_navbar ul.menu').hide();
					
					user_menu = false;
				}
			});
		});
		
		$(document).click(function(event){
			if ( !$(event.target).parent().hasClass('account') && !$(event.target).hasClass('account') )
			{
				$('#user_navbar ul.menu').hide();
				$('#user_navbar a.account').removeClass('active');
				user_menu = false;
			}
		});
		
		{/literal}
		</script>
	{else}
		{if $loginAttemptsLeft > 0 && $config.security_login_attempt_user_module && $loginAttemptsMess && $pageInfo.prev == 'login'}
			<div class="attention">
				{$loginAttemptsMess}
			</div>
		{elseif $loginAttemptsLeft <= 0 && $config.security_login_attempt_user_module}
			<div class="attention">
				{assign var='periodVar' value=`$smarty.ldelim`period`$smarty.rdelim`}
				{assign var='replace' value='<b>'|cat:$config.security_login_attempt_user_period|cat:'</b>'}
				{assign var='regReplace' value='<span class="red">$1</span>'}
				{$lang.login_attempt_error|replace:$periodVar:$replace|regex_replace:'/\[(.*)\]/':$regReplace}
			</div>
		{/if}
		<form {if $loginAttemptsLeft <= 0 && $config.security_login_attempt_user_module}onsubmit="return false;"{/if} name="userbar_login" action="{$rlBase}{if $config.mod_rewrite}{$pages.login}.html{else}?page={$pages.login}{/if}" method="post">
		    <input type="hidden" name="action" value="login" />
		    
		    <input {if $loginAttemptsLeft <= 0 && $config.security_login_attempt_user_module}disabled="disabled" class="disabled"{/if} type="text" name="username" maxlength="25" value="{if $smarty.post.username}{$smarty.post.username}{else}{$lang.username}{/if}" />
		    <input {if $loginAttemptsLeft <= 0 && $config.security_login_attempt_user_module}disabled="disabled" class="disabled"{/if} type="password" name="password" maxlength="25" value="{if $lang.password}{$lang.password}{/if}" />
		    
		    <input {if $loginAttemptsLeft <= 0 && $config.security_login_attempt_user_module}disabled="disabled" class="disabled"{/if} type="submit" value="&nbsp;" title="{$lang.login}" />
	    </form>
	    <table class="nav">
	    <tr>
	    	<td class="lalign"><a title="{$lang.create_account}" class="blue_11" href="{$rlBase}{if $config.mod_rewrite}{$pages.registration}.html{else}?page={$pages.registration}{/if}">{$lang.registration}</a></td>
	    	<td class="ralign"><span class="dark_11">{$lang.forgot_pass}</span> <a title="{$lang.remind_pass}" class="blue_11" href="{$rlBase}{if $config.mod_rewrite}{$pages.remind}.html{else}?page={$pages.remind}{/if}">{$lang.remind}</a></td>
	    </tr>
	    </table>
		
	   <script type="text/javascript">
		var userbar_form_username = "{$lang.username}";
		var userbar_form_password = "{$lang.password}";
		{literal}
		
		$(document).ready(function(){
			$('form[name=userbar_login] input[name=username]').focus(function(){
				if ( $(this).val() == userbar_form_username )
				{
					$(this).val('');
				}
			}).blur(function(){
				if ( $(this).val() == '' )
				{
					$(this).val(userbar_form_username);
				}
			});
			$('form[name=userbar_login] input[name=password]').focus(function(){
				if ( $(this).val() == userbar_form_password )
				{
					$(this).val('');
				}
			}).blur(function(){
				if ( $(this).val() == '' )
				{
					$(this).val(userbar_form_password);
				}
			});
		});
		
		{/literal}
		</script>
	{/if}
	
	{rlHook name='tplUserNavbar'}
</div>

<!-- user navigation bar end -->