// cauth(cookie認証)によるユーザ認証判定をおこなう

var cauth = ""; // ユーザ認証済みであればcauthに認証情報が入っている

// ユーザ認証済みの場合にみtextを出力する
function ifAuthWrite(text) {

  initAuth();

  // cauthの内容が空でなければユーザ認証済み
  if ((cauth != undefined) && (cauth != "undefined") && (cauth != "")) {
    // 会員問い合わせのボタンを表示する
    document.open();
    document.write(text);
    document.close();
  }
}

// ユーザ認証済み *でない* 場合にみtextを出力する
function ifNonAuthWrite(text) {

  initAuth();

  // cauthの内容が空でなければユーザ認証済み
  if ((cauth == undefined) || (cauth == "undefined") || (cauth == "")) {
    // 会員問い合わせのボタンを表示する
    document.open();
    document.write(text);
    document.close();
  }
}

// ユーザ認証済みかの初期化処理
function initAuth() {
  // 登録されているcookieからcauthを取得する
  if (document.cookie) {
    var cookies = document.cookie.split("; ");
    for (var i = 0; i < cookies.length; i++) {
      var str = cookies[i].split("=");
      if (str[0] == "cauth") {
        cauth = unescape(str[1]);
        break;
      }
    }
  }
}

//window.onload = initAuth;

