<?php
	ob_start("ob_gzhandler");
	require("packages/require_login.php");
  include("controller/controller_forget.php");
?>
<!DOCTYPE html>
<html>
<head>
  	<title><?=$title['login'];?></title>
  	<?php include("packages/head-login.php");?>
</head>
<body class="hold-transition login-page bg-login" style="background-image: url('<?=$global['absolute-url'].'img/cms-bg.jpg';?>');">
<div class="login-box">
  <div class="login-logo">
    <a href="<?=$global['absolute-url'];?>">
      <img src="<?php echo $global['logo'];?>" alt="logo" style="height: 50px;">
      <!-- Administrator -->
    </a>
  </div>
  <!-- /.login-logo -->
  <div class="login-box-body" style="box-shadow: 0 0 10px #5d5d5d;border-radius: 10px;">
    <p class="login-box-msg" style="font-size: 18px;font-weight: bold;">Forget Password</p>

    <form action="<?=$path['login-forget'];?>?action=forget" enctype="multipart/form-data" method="post" onsubmit="return validateForm();">
      <div class="form-group has-feedback">
        <input type="text" class="form-control" id="input-email" placeholder="Email Address" name="email">
        <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
        <div id="error-email" class="error-text"></div>
      </div>
      <div class="row">
        <!-- /.col -->
        <div class="col-sm-6 col-xs-12 xs-down10">
          <a href="<?=$path['login'];?>" class="btn btn-default btn-block btn-flat">
              <i class="fa fa-arrow-left"></i> Back
          </a>
        </div>
        <div class="col-sm-6 col-xs-12">
          <button type="submit" class="btn btn-primary btn-block btn-flat">Send Reset Code</button>
        </div>
        <!-- /.col -->
      </div>
    </form>

  </div>
  <!-- /.login-box-body -->
</div>
<!-- /.login-box -->

<?php include("packages/footer-login.php");?>
    <script type="text/javascript">
       $(document).ready(function() {
            <?php if($message != "") { ?>
            //use session here for alert success/failed
            var alertText = "<?=$message;?>";
                <?php if($alert != "success"){ ?>
                errorAlert(alertText);// error alert
                <?php } else { ?>
                successAlert(alertText);// success alert
                <?php } ?>
            <?php } ?>
        });
        function validateForm(){
            var email = $("#input-email").val();

            var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
            var numFormat = /^\+?[\d+ ]*$/;
            var urlFormat = /^HTTP|HTTP|http(s)?:\/\/(www\.)?[A-Za-z0-9]+([\-\.]{1}[A-Za-z0-9]+)*\.[A-Za-z]{2,40}(:[0-9]{1,40})?(\/.*)?$/;

            if(email != ""){
                if(email.match(mailformat)){
                    $("#error-email").html("");
                    $("#error-email").hide();
                    $("#input-email").removeClass("input-error");
                } else {
                    $("#error-email").show();
                    $("#error-email").html("<i class='fa fa-warning'></i> Incorrect email format.");
                    $("#input-email").addClass("input-error");
                    $("#input-email").focus();
                    return false;
                }
            } else {
                $("#error-email").show();
                $("#error-email").html("<i class='fa fa-warning'></i> This field is required.");
                $("#input-email").addClass("input-error");
                $("#input-email").focus();
                return false;
            }
        }
    </script>
</body>
</html>