<?php
  session_start();
  if(isset($_SESSION['LOGIN_STATUS']) && !empty($_SESSION['LOGIN_STATUS'])){
      //header('location:Pages/dashboard.php');
  }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Login</title>
<link rel='stylesheet' type='text/css' href='css/fonts.googleapis.com/css_cd14c140.css' />
<!-- Bootstrap CSS -->
<link rel="stylesheet" type="text/css" href="./vendor/bootstrap/css/bootstrap.min.css" />
<!-- Theme CSS -->
<link rel="stylesheet" type="text/css" href="./css/vendor.css" />
<link rel="stylesheet" type="text/css" href="./css/theme.css" />
<link rel="stylesheet" type="text/css" href="./css/utility.css" />
<link rel="stylesheet" type="text/css" href="./css/custom.css" />
</head>

<body class="minimal login-page">


<div id="main">
  <div id="content">
    <div class="row">
      <div id="page-logo"> &nbsp; <!--<img src="./img/logos/logo-white.png" class="img-responsive" alt="logo" />--> </div>
    </div>
    <div class="row">
      <div class="panel-bg">
        <div class="panel">
          <div class="panel-heading"> <span class="panel-title"> <span class="glyphicon glyphicon-lock text-purple2"></span> Login </span> <span class="panel-header-menu pull-right mr15 text-muted fs12">New Limara</span></div>
          <div class="panel-body">
     
            <div class="form-group">
              <span class="text-center center" style="color:red !important ; padding:10px; text-align:center;" id="errorMessage"></span>
            </div>
            
            
            
            
            <div class="form-group">
              <div class="input-group"> <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span> </span>
                <input type="text" class="form-control" name="uname" id="uname" placeholder="User Name" autocomplete="off" />
              </div>
            </div>
            <div class="form-group">
              <div class="input-group"> <span class="input-group-addon"><span class="glyphicon glyphicon-link"></span> </span>
                <input type="password" class="form-control" name="password" id="password" placeholder="Password" autocomplete="off" />
              </div>
            </div>
          </div>
          <div class="panel-footer"> <span class="text-muted fs12 lh30"><a>Welcome</a></span> 
          
         
          <a class="btn btn-sm bg-purple2 pull-right" href="" id="loginvalid"><i class="fa fa-home"></i> Login</a>
            <div class="clearfix"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<div class="overlay-black"></div>

</body>
<script type="text/javascript" src="./vendor/jquery/jquery-1.11.1.min.js"></script> 
<script type="text/javascript" src="./vendor/jquery/jquery_ui/jquery-ui.min.js"></script> <!-- Bootstrap --> 
<script type="text/javascript" src="./vendor/bootstrap/js/bootstrap.min.js"></script> 
<!-- Page Plugins --> 
<script type="text/javascript" src="./vendor/plugins/backstretch/jquery.backstretch.min.js"></script> 
<!-- Theme Javascript --> 
<script type="text/javascript" src="./js/utility/spin.min.js"></script> 
<script type="text/javascript" src="./js/utility/underscore-min.js"></script> 
<script type="text/javascript" src="./js/main.js"></script> 
<script type="text/javascript" src="./js/ajax.js"></script> 
<script type="text/javascript" src="./js/custom.js"></script> 
<script type="text/javascript">
jQuery(document).ready(function () {
	  
	 "use strict";

     // Init Theme Core 	  
     Core.init();

     // Enable Ajax Loading 	  
     Ajax.init();
	 
	 // Init Full Page BG(Backstretch) plugin
  	 $.backstretch("./img/stock/splash/2.jpg");



});
</script>

<script type="text/javascript">


$('#loginvalid').on('click', function (e) {
    e.preventDefault();
    var uname=$('#uname').val();
      var password=$('#password').val();

      var dataString = 'uname='+ uname + '&password='+ password;
      $("#flash").show();
      $("#flash").fadeIn(400).html('<img src="image/loading.gif" />');
      $.ajax({
      type: "POST",
      url: "controler/login_auth.php",
      data: dataString,
      cache: false,
      success: function(result){
        console.log(result);
               var result=trim(result);
               $("#flash").hide();
               if(result==='correct'){
                     window.location='/Pages/dashboard.php';
               }else{
                     $("#errorMessage").html(result);
               }
      }
      });
});
function validLogin(){
      var uname=$('#uname').val();
      var password=$('#password').val();

      var dataString = 'uname='+ uname + '&password='+ password;
      $("#flash").show();
      $("#flash").fadeIn(400).html('<img src="image/loading.gif" />');
      $.ajax({
      type: "POST",
      url: "controler/login_auth.php",
      data: dataString,
      cache: false,
      success: function(result){
        console.log(result);
               var result=trim(result);
               $("#flash").hide();
               if(result==='correct'){
                     window.location='Pages/dashboard.php';
               }else{
                     $("#errorMessage").html(result);
               }
      }
      });
}

function trim(str){
     var str=str.replace(/^\s+|\s+$/,'');
     return str;
}
</script>

</html>