<!-- Main navbar -->
<?php
	$hide="";
	if (!$this->authentication->is_loggedin()){
		$hide="hide";
	}
	$lang = $this->authentication->get_Language();
	$lang_active=$this->session->userdata('bahasa');
?>
<div class="navbar navbar-default navbar-fixed-top header-highlight">
	<div class="navbar-header">
		<a class="navbar-brand" href="<?=base_url();?>" style="padding:0px;"><img src="<?=img_url('logo_light.png');?>" alt=""></a>
	</div>

	<div class="navbar-collapse collapse" id="navbar-mobile">
		<ul class="nav navbar-nav" style="margin:0px;">
			<li class="upper">
				<a href="<?=base_url();?>" style="top: -4px; padding:5px 10px 0px 0px;"><strong><img src="<?=img_url('logo.png');?>"> <?=$this->authentication->get_Preference('judul_atas');?></strong></a>
			</li>
		</ul>

		<ul class="nav navbar-nav navbar-right">
			<li class="dropdown <?=$hide;?>">
				<a href="#" class="dropdown-toggle" data-toggle="dropdown">
					<i class="icon-bubbles4"></i>
					<span class="visible-xs-inline-block position-right">Messages</span>
					<span class="badge bg-warning-400">2</span>
				</a>
				
				<div class="dropdown-menu dropdown-content width-350">
					<div class="dropdown-content-heading">
						Messages
						<ul class="icons-list">
							<li><a href="#"><i class="icon-compose"></i></a></li>
						</ul>
					</div>

					<ul class="media-list dropdown-content-body">
						<li class="media">
							<div class="media-left">
								<span class="badge bg-danger-400 media-badge">5</span>
							</div>

							<div class="media-body">
								<a href="#" class="media-heading">
									<span class="text-semibold">James Alexander</span>
									<span class="media-annotation pull-right">04:58</span>
								</a>

								<span class="text-muted">who knows, maybe that would be the best thing for me...</span>
							</div>
						</li>

						<li class="media">
							<div class="media-left">
								<span class="badge bg-danger-400 media-badge">4</span>
							</div>

							<div class="media-body">
								<a href="#" class="media-heading">
									<span class="text-semibold">Margo Baker</span>
									<span class="media-annotation pull-right">12:16</span>
								</a>

								<span class="text-muted">That was something he was unable to do because...</span>
							</div>
						</li>

						<li class="media">
							<div class="media-body">
								<a href="#" class="media-heading">
									<span class="text-semibold">Jeremy Victorino</span>
									<span class="media-annotation pull-right">22:48</span>
								</a>

								<span class="text-muted">But that would be extremely strained and suspicious...</span>
							</div>
						</li>

						<li class="media">
							<div class="media-body">
								<a href="#" class="media-heading">
									<span class="text-semibold">Beatrix Diaz</span>
									<span class="media-annotation pull-right">Tue</span>
								</a>

								<span class="text-muted">What a strenuous career it is that I've chosen...</span>
							</div>
						</li>

						<li class="media">
							<div class="media-body">
								<a href="#" class="media-heading">
									<span class="text-semibold">Richard Vango</span>
									<span class="media-annotation pull-right">Mon</span>
								</a>
								
								<span class="text-muted">Other travelling salesmen live a life of luxury...</span>
							</div>
						</li>
					</ul>

					<div class="dropdown-content-footer">
						<a href="#" data-popup="tooltip" title="All messages"><i class="icon-menu display-block"></i></a>
					</div>
				</div>
			</li>
			
			<?php echo _build_menu('atas-kanan');?>
			
			<li class="dropdown language-switch">
				<?php
				$logo='id.png';
				if ($lang_active=='english'){
					$logo='english.png';
				}
				?>
				<a href="#" class="dropdown-toggle" data-toggle="dropdown">
					<img src="<?=img_url('flags/'.$logo);?>" class="position-left" alt="">
					<?=lang('msg_bahasa');?>
					<span class="caret"></span>
				</a>
				
				<ul class="dropdown-menu">
					<!-- User image -->
				  <?php 
					foreach($lang as $row){
						$icon = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
						if ($lang_active==$row['key'])
							$icon = '<i class="icon-checkmark2"></i>';
					?>
					<li>
						<a href="<?php echo base_url('language/' . $row['key'] . '?redirect_to=' . current_url());?>" style="padding-left:10px;">
						<?php echo $icon;?>
						<img src="<?php echo img_url('flags/'.$row['icon']);?>">&nbsp;&nbsp;
						<?php echo $row['title'];?>
						</a>
					</li>
					<?php 
					}
					?>
				</ul>
			</li>
			
			
			<li class="dropdown dropdown-user <?=$hide;?>">
				<a class="dropdown-toggle" data-toggle="dropdown">
					<img src="<?=staft_url($this->authentication->get_Info_User('photo'));?>" />
					<span><?=$this->authentication->get_Info_User('nama_lengkap');?></span>
					<i class="caret"></i>
				</a>
				
				<ul class="dropdown-menu dropdown-menu-right">
					<li><a href="#"><i class="icon-user-plus"></i> My profile</a></li>
					<li><a href="#"><i class="icon-coins"></i> My balance</a></li>
					<li><a href="#"><span class="badge bg-teal-400 pull-right">58</span> <i class="icon-comment-discussion"></i> Messages</a></li>
				</ul>
			</li>
			
			<li class="login bg-warning">
				<?php
				if ($hide=='hide'){
					?>
					<a href="<?=base_url('login');?>" style="color:#fff;"><i class="icon-lock2"></i> Login </a>
					<?php
				}else{
					?>
					<a href="<?=base_url('logout');?>" style="color:#fff;"><i class="icon-switch2"></i> Logout </a>
					<?php
				}?>
			</li>
		</ul>
	</div>
</div>

<!-- /main navbar -->
<script>
	$(function(){
		$(".dropdown-menu > li > a.trigger").on("click",function(e){
			var current=$(this).next();
			var grandparent=$(this).parent().parent();
			if($(this).hasClass('left-caret')||$(this).hasClass('right-caret'))
				$(this).toggleClass('right-caret left-caret');
			grandparent.find('.left-caret').not(this).toggleClass('right-caret left-caret');
			grandparent.find(".sub-menu:visible").not(current).hide();
			current.toggle();
			e.stopPropagation();
		});
		$(".dropdown-menu > li > a:not(.trigger)").on("click",function(){
			var root=$(this).closest('.dropdown');
			root.find('.left-caret').toggleClass('right-caret left-caret');
			root.find('.sub-menu:visible').hide();
		});
	});
</script>