<?php
	ob_start("ob_gzhandler");
	require("packages/require_login.php");
  include("controller/controller_activate.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-weight: bold;font-size: 18px;">Activate Your Account</p>

    <form action="<?=$path['login-activate'];?>?action=activate" enctype="multipart/form-data" method="post" onsubmit="return validateForm();">
      <div class="form-group has-feedback">
        <input type="password" id="input-password" class="form-control" placeholder="Password" name="password">
        <span class="glyphicon glyphicon-lock form-control-feedback"></span>
        <div id="error-password" class="error-text"></div>
      </div>
      <div class="form-group has-feedback">
        <input type="password" id="input-repassword" class="form-control" placeholder="Re-Type Password" name="repassword">
        <span class="glyphicon glyphicon-lock form-control-feedback"></span>
        <div id="error-repassword" class="error-text"></div>
      </div>
      <div class="row">
        <div class="col-xs-12 text-right">
          <input type="hidden" name="email" value="<?=$detail[0]['admin_email'];?>">
          <input type="hidden" name="name" value="<?=$detail[0]['admin_name'];?>">
          <input type="hidden" name="token" value="<?=$detail[0]['admin_token'];?>">
          <button type="submit" class="btn btn-primary btn-flat">Activate Account</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 password = $("#input-password").val();
            var repassword = $("#input-repassword").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(password != ""){
                $("#error-password").html("");
                $("#error-password").hide();
                $("#input-password").removeClass("input-error");
            } else {
                $("#error-password").show();
                $("#error-password").html("<i class='fa fa-warning'></i> This field is required.");
                $("#input-password").addClass("input-error");
                $("#input-password").focus();
                return false;
            }
            if(repassword != ""){
                $("#error-repassword").html("");
                $("#error-repassword").hide();
                $("#input-repassword").removeClass("input-error");
            } else {
                $("#error-repassword").show();
                $("#error-repassword").html("<i class='fa fa-warning'></i> This field is required.");
                $("#input-repassword").addClass("input-error");
                $("#input-repassword").focus();
                return false;
            }
            if(password == repassword){
                $("#error-repassword").html("");
                $("#error-repassword").hide();
                $("#input-repassword").removeClass("input-error");
            } else {
                $("#error-repassword").show();
                $("#error-repassword").html("<i class='fa fa-warning'></i> Re-Type Password Not Match.");
                $("#input-repassword").addClass("input-error");
                $("#input-repassword").focus();
                return false;
            }
        }
    </script>
</body>
</html>
