<?php

//session_start();
if(isset($_SESSION['login'],$_SESSION['job_type'],$_SESSION['user_id']) && $_SESSION['login'] == TRUE && $_SESSION['job_type'] == 1)
{
   header("Location: ".BASE_URL.ADMIN_FOLDER."/users_admin/add"); 
    exit;
}
?>
<section class="wrapper">
<div class="container">
<div class="row">
                                <form class="login" method="post">
                                      <fieldset>
                                        <legend class="legend">
                                          Admin Login
                                        </legend>
                                          <div class="messageStatus"></div>
                                                     <div class="input">
                                                        <input type="text" name="email" placeholder="Email"  />
                                                      <span><i class="fa fa-envelope-o"></i></span>
                                                    </div>
                                                    <div class="input">
                                                        <input type="password" name="password" placeholder="Password"  />
                                                      <span><i class="fa fa-lock"></i></span>
                                                    </div>
                                                    <button type="submit" name="adminLogin" class="submit"><i class="fa fa-long-arrow-right"></i></button>                                           
                                      </fieldset>
                                      <div class="feedback">
                                        login successful <br />
                                        redirecting...
                                      </div>   
                                </form>
</div>  
</div>

        </section>
        <!--[if lt IE 9]>
        <script src="js/html5shiv.min.js"></script>
        <script src="js/respond.min.js"></script>
        <![endif]-->
       

            <script type="text/javascript">
$( ".input" ).focusin(function() {
  $( this ).find( "span" ).animate({"opacity":"0"}, 200);
});

$( ".input" ).focusout(function() {
  $( this ).find( "span" ).animate({"opacity":"1"}, 300);
});

  $(".login").submit(function(){
      var formData = $(this).serialize();
      var allData = formData + '&action=login';
                    $.ajax({
                    url: "",
                    type:"POST",
                    data: allData, // Data sent to server, a set of key/value pairs (i.e. form fields and values)
                    beforeSend:function(){
                    },
                    statusCode: {
                     404: function() {
                       alert( "page not found" );
                      },
                      },
                      success:function(valdata) {
                         var da = jQuery.parseJSON(valdata);
                        if(da['status'] == "success")
                        {
                              $(this).find(".submit i").removeAttr('class').addClass("fa fa-check").css({"color":"#fff"});
                              $(".submit").css({"background":"#2ecc71", "border-color":"#2ecc71"});
                              $(".feedback").show().animate({"opacity":"1", "bottom":"-25px"}, 400);
                              $("input").css({"border-color":"#2ecc71"});
                            window.setTimeout(function(){window.location.href = "<?php echo BASE_URL."home/index" ?>";}, 2000);
                        }else{
                            $(".messageStatus").html(da['message']);
                        }
                      }
                });
                return false;
	          
                });          
    

    </script>

</body>
</html>