
function runApp () {
  booter.run(1);
  if (booter.result == 0) {
    alert( "アプリ起動が却下されました。" );
  }
  if (booter.result == 1) {
    alert( "アプリ起動が承認されました。" );
  }
  if (booter.result == 2) {
    GoInstall();
    // alert( "レジストリキーが存在しません。" );
  }
  if (booter.result == 3) {
    GoInstall();
    // alert( "実行ファイルが存在しません。" );
  }
  AppLog();
}

function runAppWithoutConfirm () {

  var res;
  jQuery.post("/api/validate.php",function(res){
    if (res == 0) {
        GoError();
        return;
    } else {
      booter.run(0);
      if (booter.result == 2) {
        GoInstall();
        return;
        // alert( "レジストリキーが存在しません。" );
      }
      if (booter.result == 3) {
        GoInstall();
        return;
        // alert( "実行ファイルが存在しません。" );
      }
      AppLog();
    }
  });

}

function installCheck () {
  booter.check();
  if (booter.result == 1) {
    alert( "アプリはインストールされています。" );
  }
  if (booter.result == 2) {
    alert( booter.errmsg );
    //alert( "レジストリキーが存在しません。" );
  }
  if (booter.result == 3) {
    alert( booter.errmsg );
    //alert( "実行ファイルが存在しません。" );
  }
}

function GoInstall () {
  location.href = '/guide/about_dl.html';
}

function GoError () {
  location.href = '/top.html';
}

function AppBoot () {
  if ( typeof( booter ) == 'undefined' ) {
    alert( 'ゲームの実行は Microsoft Windows および Internet Explorer6.0 以後のブラウザで可能です。' );
  }
  else {
    runAppWithoutConfirm();
  }
}

function AppLog () {
  jQuery( '#log' ).html( '<img src="/gamestart.php" />' );
}

