<?php
$CI = & get_instance();
$_c = strtolower($CI->router->fetch_class());
$_a = strtolower($CI->router->fetch_method());
$data = $this->templates->getData();
?>
<header id="header" class="header">
	<nav class="navbar navbar-inverse" role="banner">	
		<div class="container main-menu">
			<div class="navbar-header menu-left">
				<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
						<span class="sr-only">Toggle navigation</span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="<?php echo base_url(); ?>">
					<img class="img-responsive" src="<?php echo base_url(); ?>dist/img/logo/logo_xs.png" />
				</a>
			</div>

			<div class="collapse navbar-collapse navbar-right menu-right">
				<ul class="nav navbar-nav p-xs-3-t">
					<li class="text-xs-center<?php echo ($_c == 'home') ? " active" : ""; ?>"><a href="<?php echo base_url(); ?>"><i class="fa fa-home"></i>&nbsp;Home</a></li>						
					<li class="text-xs-center<?php echo ($_c == 'pricing') ? " active" : ""; ?>"><a href="javascript:void(0);" onclick="return goto('#pricing');">Pricing</a></li>
					<li class="text-xs-center<?php echo ($_c == 'contact') ? " active" : ""; ?>"><a href="javascript:void(0);" onclick="return goto('#contactus');">Contact Us</a></li>
					<li class="text-xs-center<?php echo ($_c == 'registration') ? " active" : ""; ?>"><a href="<?php echo base_url(); ?>registration">Sign Up</a></li>
					<li class="dropdown text-xs-center<?php echo ($_c == 'login') ? " active" : ""; ?>">
						<a href="#" class="dropdown-toggle" data-toggle="dropdown">Login</a>
						<ul class="login-dropdown dropdown-menu">
							<li>
								<?php
								if(isset($data['user']) && $data['user']) {
									?>						
									<div class="box box-flat p-1-y">
										<div class="box-body">											
											<h3 class="m-1-b text-center">Already Logged In</h3>
											<div class="m-1-x">
												<a href="<?php echo base_url(); ?>dashboard" class="btn btn-block btn-success"><i class="fa fa-login"></i>&nbsp;Go to Dashboard</a>
												<a href="<?php echo base_url(); ?>login/logout" class="btn btn-block btn-danger"><i class="fa fa-power-off"></i>&nbsp;Log Out</a>
											</div>
										</div>
									</div>
									<?php
								} else {
									?>
									<form class="form-horizontal registration-form" method="post" action="<?php echo base_url(); ?>login/index" id="login_form">
										<input type="hidden" name="redirect" id="redirect" value="login" />								
										<div class="box box-flat p-1-y">
											<div class="box-body">											
												<div class="form-group p-1-x">
													<label class="col-xs-12 required registration-form-label">Email</label>
													<div class="col-xs-12">
														<input type="text" class="form-control validate[required, custom[email]] registration-form-input" name="useremail" id="email_login_input" />
													</div>
												</div>
												
												<div class="form-group p-1-x">
													<label class="col-xs-12 required registration-form-label">Password</label>
													<div class="col-xs-12">
														<input type="password" class="form-control validate[required] registration-form-input" name="userpassword" id="password_login_input" />
													</div>
												</div>
											</div>
											
											<div class="box-footer p-1-l p-1-r">
												<div class="flex-btn-group">
													<button type="submit" class="btn btn-success"><i class="fa fa-check"></i>&nbsp;Login</button>
												</div>											
												<div class="text-center m-1-t"><a href="<?php echo base_url(); ?>login/forgotpassword">Forgot Password</a></div>
											</div>
										</div>						
									</form>
									<?php
								}
								?>
							</li>
						</ul>
					</li>
				</ul>
			</div>
		</div>
		
		<div class="container social-menu">
			<!--
			<div class="search">
				<form role="form">
					<input type="text" class="search-form" autocomplete="off" placeholder="Search">
					<i class="fa fa-search"></i>
				</form>
			</div>
			-->
			
			<ul class="network">
				<li><a href="https://www.facebook.com/salihinpremier" target="_blank" data-toggle="tooltip" alt="Our Facebook" title="Our Facebook"><i class="fa fa-facebook"></i></a></li>
				<li><a href="https://twitter.com/salihinpremier" target="_blank" data-toggle="tooltip" alt="Our Twitter" title="Our Twitter"><i class="fa fa-twitter"></i></a></li>
				<li><a href="https://www.instagram.com/salihinpremier/" target="_blank" data-toggle="tooltip" alt="Our Instagram" title="Our Instagram"><i class="fa fa-instagram"></i></a></li>
				<li><a href="http://www.salihinpremier.com/" target="_blank" data-toggle="tooltip" alt="Our Website" title="Our Website"><i class="fa fa-globe"></i></a></li>
			</ul>
		</div>
	</nav>
</header>

<script>
$(function() {
	$('form#login_form').off('submit').on('submit',function() {
		
		if ($(this).validationEngine('validate')) {
			var proceed = true;
			
			var email = $.trim(	$('#email_login_input').val()	);
			if(email == "") { proceed =  false; $('#email_login_input').validationEngine('showPrompt', 'Please enter Email', 'load','bottomRight',1); }
			if(!proceed) return false;
			
			var password = $.trim(	$('#password_login_input').val()	);
			if(password == "") { proceed =  false; $('#password_login_input').validationEngine('showPrompt', 'Please enter Password', 'load','bottomRight',1); }
			if(!proceed) return false;
			
			return true;
		} else {
			return false;
		}
		return true;
	});
});
</script>
