if (!admin) var admin = {};
if (!admin.script) admin.script = {};

var as = admin.script;

as.getUserInfo = function (userPk) {
  location.href = '/accounts/custom_admin/getUserInfo?user-pk=' + userPk
};

as.returnUserList = function () {
  location.href = '/accounts/custom_admin/userList'
};

as.signUpCheck = function() {
  var password = document.getElementById('password').value;
  var passcheck = document.getElementById('passcheck').value;
  var regExp = /[0-9a-zA-Z][_0-9a-zA-Z-]*@[_0-9a-zA-Z-]+(\.[_0-9a-zA-Z-]+){1,2}$/;
  // password repeat check
  if(password !== passcheck) {
    alert('password를 다시 확인 해 주세요');
    return false;
  }

  if(!($('input[name=user-email]').val()).match(regExp)) {
    alert("이메일 형식이 맞지 않습니다.");
    $('input[name=user-email]').focus();
    return false;
  }
};

as.deleteUser = function (userPk) {
  location.href = '/accounts/custom_admin/deleteUser?user-pk=' + userPk;
};

as.returnCompanyList = function () {
  location.href = '/company'
};

as.getCompanyInfo = function (companyPk) {
  location.href = '/company/info?company-pk=' + companyPk
};

as.deleteCompany = function (companyPk) {
  location.href = '/company/' + companyPk + '/delete'
};

as.productSearchCategory = function () {
  var season = $('select[name=season]').val();
  var style = $('select[name=style]').val();
  var target = $('select[name=product_type]');
  console.log(season, style);
  if(season === 'winter') {
      if(style === 'training') {
          target.html('');
          target.append('<option value="">복종선택</option>'+
            '<option value="shirts">상의</option>'+
            '<option value="pants">하의</option>>');
      }else if(style === 'formal'){
          target.html('');
          target.append('<option value="">복종선택</option>'+
            '<option value="jacket">자켓</option>'+
            '<option value="vest">조끼</option>'+
            '<option value="shirts">셔츠</option>'+
            '<option value="pants">바지</option>'+
            '<option value="skirt">치마</option>'+
            '<option value="one-piece">원피스</option>'+
            '<option value="overall">오버롤</option>'+
            '<option value="dress">드레스</option>'+
            '<option value="acc">악세서리</option>');
      }else{
          target.html('');
          target.append('<option value="">복종선택</option>');
      }
  }else if(season === 'summer') {
      if(style === 'training') {
          target.html('');
          target.append('<option value="">복종선택</option>'+
            '<option value="shirts">상의</option>'+
            '<option value="pants">하의</option>>');
      }else if(style === 'formal'){
          target.html('');
          target.append('<option value="">복종선택</option>'+
            '<option value="shirts">셔츠</option>'+
            '<option value="pants">바지</option>'+
            '<option value="skirt">치마</option>'+
            '<option value="acc">악세서리</option>');
      }else{
         target.html('');
         target.append('<option value="">복종선택</option>');
      }
  }
};

as.returnSmartKindergartenList = function () {
  location.href = '/kindergarten/custom_admin/change_list/';
};