
var CGI_REF  = 'http://www.oishiihotel.jp/cgi-bin/aj.cgi';
var CGI_SREF = 'https://www.oishiihotel.jp/cgi-bin/aj.cgi';
var CGI_REF2 = 'http://www.oishiihotel.jp/cgi-bin/wsys.cgi';

function DetailWindow(uri){
  win=window.open( uri,"subwin","scrollbars=yes,width=400,height=600,top=0,left=0");
}

function DetailWindow2(uri){
  win=window.open( uri,"subwin","scrollbars=yes,width=500,height=600,top=0,left=0");
}

function DetailWindow3(uri){
  win=window.open( uri,"subwin","scrollbars=yes,width=400,height=450,top=0,left=0");
}

function DetailWindow4(uri){
  win=window.open( uri,"subwin","scrollbars=yes,width=470,height=600,top=0,left=0");
}

function DetailWindow5(uri){
  win=window.open( uri,"subwin","scrollbars=yes,width=600,height=800,top=0,left=0");
}

function DetailWindow6(uri){
  win=window.open( uri,"subwin","scrollbars=yes,width=800,height=800,top=0,left=0");
}

function DetailWindow7(uri){
  win=window.open( uri,"subwin","scrollbars=yes,width=700,height=600,top=0,left=0");
}

function DetailWindow8(uri){
  win=window.open( uri,"subwin","scrollbars=yes,width=1200,height=800,top=0,left=0");
}

function CloseHelp() {
  document.getElementById('help-box').style.display = 'none';
}


function DelAlert(){
  if ( confirm("本当に削除しますか? \n") ){
    return true;
  }else{
    return false;
  }
}


function RePrint() {
  location.reload();
}


function showRes(oj) {
  $('').innerHTML = '削除しました';
}


/* ヘルプウインドー表示 汎用 */
function viewHelp(uri,hgt) {

  /*  hgtの指定は IE対策 */
  document.getElementById('help-box').style.display = 'block';
  document.getElementById('help-box').style.height = hgt;
  
  /* 背景の色はCSSで変更した方がよいので、この行コメントアウトの予定  */
  document.getElementById('help-box').style.backgroundColor = 'pink';

  M2AjaxUpdater(uri,'help-box');

}


/* 汎用A-Jax アップデーター */
function M2AjaxUpdater(uri,IDname){
/* uri => 実行するAjaxサーバスクリプト IDname => 書き換える要素につけたIDの名前 */

  new Ajax.Updater(IDname,uri,{ method: 'get' });

}


/* フォーム変更用 A-Jax アップデーター */
function FormView(uri,IDname){
/* uri => 実行するAjaxサーバスクリプト IDname => 書き換える要素につけたIDの名前 */

  M2AjaxUpdater(uri,IDname);

  document.getElementById('acform').style.display = 'block';
  document.getElementById('shform').style.display = 'none';

}


/* リスト変更用 A-Jax アップデーター */
function ListChange(uri,IDname,btnID,num){
/* uri => 実行するAjaxサーバスクリプト IDname => 書き換える要素につけたIDの名前
   btnID => 色を変更する当該ボタンのID名   num => ボタン数                */

  M2AjaxUpdater(uri,IDname);

  /* change list menu => clm */

  for ( i=1; i<=num; i++ ) {
    var clmID = 'clm' + i;
  
    if ( i == btnID ) {
     document.getElementById(clmID).style.backgroundColor = '#3168A6';
      document.getElementById(clmID).style.color = '#fff';
//      document.getElementById(clmID).className = 'now';
    }
    else {
      document.getElementById(clmID).style.backgroundColor = '#D6E3F2';
      document.getElementById(clmID).style.color = '#444';
//       document.getElementById(clmID).className = f;
    }
  }
}


/* リスト表示 A-Jax アップデーター */
function ListPrint(uri,IDname){

  /* uri => 実行するAjaxサーバスクリプト IDname => 書き換える要素につけたIDの名前 */

  M2AjaxUpdater(uri,IDname);
}


/* ホテルを選択すると施設のセレクトリストが変わる */
function GetSelectUnit(op1,op2){
  uri  = CGI_SREF + '?SM=aj_unit&amp;MD=selectstr&amp;hid=' + op1 + '&amp;SESID='+ op2 ;
  new Ajax.Updater('unit_select',uri,{method: 'get' });
}

function GetSelectUnit2(op1,op2){
  uri  = CGI_REF + '?SM=aj_unit&amp;MD=selectstr&amp;hid=' + op1 + '&amp;SESID='+ op2 ;
  new Ajax.Updater('unit_select',uri,{method: 'get' });
}

/* jQuery版 */
function GetSelectUnit3(op1,op2){
  uri  = CGI_SREF + '?SM=aj_unit&amp;MD=selectstr&amp;hid=' + op1 + '&amp;SESID='+ op2 ;
  $('div#unit_select').load(uri);
}

/* 施設が有料契約済みかどうかでフォームの動作を変える */
function CheckReserve1(op1,op2){
  uri  = CGI_REF + '?SM=aj_news&amp;MD=reserve_check1&amp;uid=' + op1 + '&amp;SESID='+ op2 ;
  new Ajax.Updater('rf',uri,{method: 'get' });
}

function CheckReserve2(op1,op2){
  uri  = CGI_REF + '?SM=aj_news&amp;MD=reserve_check2&amp;uid=' + op1 + '&amp;SESID='+ op2 ;
  new Ajax.Updater('ru',uri,{method: 'get' });
}

function CheckReserve3(op1,op2,op3){
  uri  = CGI_REF + '?SM=aj_news&amp;MD=reserve_check3&amp;uid=' + op1 + '&amp;SESID='+ op2 + '&amp;op=' + op3;
  new Ajax.Updater('t1',uri,{method: 'get' });
}

function CheckReserve4(op1,op2,op3){
  uri  = CGI_REF + '?SM=aj_news&amp;MD=reserve_check4&amp;uid=' + op1 + '&amp;SESID='+ op2 + '&amp;op=' + op3;
  new Ajax.Updater('c1',uri,{method: 'get' });
}

function CheckReserve5(op1,op2,op3){
  uri  = CGI_REF + '?SM=aj_news&amp;MD=reserve_check3&amp;uid=' + op1 + '&amp;SESID='+ op2 + '&amp;op=' + op3;
  new Ajax.Updater('t2',uri,{method: 'get' });
}

function CheckReserve6(op1,op2,op3){
  uri  = CGI_REF + '?SM=aj_news&amp;MD=reserve_check4&amp;uid=' + op1 + '&amp;SESID='+ op2 + '&amp;op=' + op3;
  new Ajax.Updater('c2',uri,{method: 'get' });
}

function CheckReserve7(op1,op2,op3){
  uri  = CGI_REF + '?SM=aj_news&amp;MD=reserve_check3&amp;uid=' + op1 + '&amp;SESID='+ op2 + '&amp;op=' + op3;
  new Ajax.Updater('t3',uri,{method: 'get' });
}

function CheckReserve8(op1,op2,op3){
  uri  = CGI_REF + '?SM=aj_news&amp;MD=reserve_check4&amp;uid=' + op1 + '&amp;SESID='+ op2 + '&amp;op=' + op3;
  new Ajax.Updater('c3',uri,{method: 'get' });
}


/* A-jaxによる 非同期 Submit 汎用関数 */
function M2AjSubmit(FormId,targetID) {
  /* FormId = フォームID  targetId = 書き換える要素のID  */

  var uri = CGI_REF;
  var param = Form.serialize(FormId);
  var myAjax = new Ajax.Updater(
                                 targetID,
                                 uri,
                                 {method: 'post', parameters: param}
                               );
}


function ACFormOn() {
  document.getElementById('acform').style.display = 'block';
  document.getElementById('shform').style.display = 'none';
  document.getElementById('add').style.backgroundColor = '#3168A6';
  document.getElementById('add').style.color = '#fff';
  document.getElementById('sh').style.backgroundColor = '#D6E3F2';
  document.getElementById('sh').style.color = '#444';
  //  document.getElementById('addinfo').innerHTML = '';
  // document.getElementById('addwarn').innerHTML = '';
}

function ACFormOnLoad() {
  document.getElementById('acform').style.display = 'block';
  document.getElementById('shform').style.display = 'none';
  document.getElementById('add').style.backgroundColor = '#3168A6';
  document.getElementById('add').style.color = '#fff';
  document.getElementById('sh').style.backgroundColor = '#D6E3F2';
  document.getElementById('sh').style.color = '#444';
}

function ACFormColorOff() {
  document.getElementById('add').style.backgroundColor = '#D6E3F2';
  document.getElementById('add').style.color = '#444';
  document.getElementById('sh').style.backgroundColor = '#D6E3F2';
  document.getElementById('sh').style.color = '#444';
}

function ShFormOn() {
  document.getElementById('acform').style.display = 'none';
  document.getElementById('shform').style.display = 'block';
  document.getElementById('add').style.backgroundColor = '#D6E3F2';
  document.getElementById('add').style.color = '#444';
  document.getElementById('sh').style.backgroundColor = '#3168A6';
  document.getElementById('sh').style.color = '#fff';
}


/* 公開ページ トップページ 「ホテル別プランランキング」部分で使用 */
function GetPlanRanking(op1,op2){
  uri  = CGI_REF + '?SM=aj_news_alog&hid=' + op1 + '&SESID='+ op2 ;
  $('div#side-ranking').load(uri);
}


/* WEB予約 空席検索 人数によって空席カレンダーを変更する */
function ChangeCalendar(op1,op2,op3,op4){
  uri  = CGI_REF2 + '?SM=aj_reserve3_cal&nid=' + op1 + '&reserve_date=' + op2 + '&reserve_qty=' + op3 + '&SESID='+ op4;
  $('div#calendar').load(uri);
}

