

var CGI_REF = 'http://www.ovo-m.jp/cgi-bin/aj.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 CloseHelp() {
  document.getElementById('help-box').style.display = 'none';
}




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

function DelAlertProducts(uri,num){

  if ( confirm("商品バリエーション及び、顧客別商品データも削除されます。\n " + "本当に削除しますか? \n") ) {
  
    var myAjax = new Ajax.Updater(
      ('aj-del-' + num),
      uri,
      { method: 'get' }
    );
  }
  else {
   return false;
  }
}

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

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


function DelAlertPrSKU(uri,num){

  if ( confirm("商品SKUレコードを削除します。\n 本当に削除しますか? \n") ) {

    var myAjax = new Ajax.Updater(
      ('aj-del-' + num),
      uri,
      { method: 'get' }
    );
  }
  else {
   return false;
  }
}


function DelAlertFsysdata(uri,num){
/* 商品バリエーション登録マスタの削除 */

  if ( confirm("商品バリエーションの登録を削除します。\n 本当に削除しますか? \n") ) {

    var myAjax = new Ajax.Updater(
      ('aj-del-' + num),
      uri,
      { method: 'get' }
    );
  }
  else {
   return false;
  }
}








/* ヘルプウインドー表示 汎用 */
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 BtnOn(btnID) {
  document.getElementById(btnID).style.backgroundColor = '#3168A6';
  document.getElementById(btnID).style.color = '#fff';
}
function BtnOff(btnID) {
  document.getElementById(btnID).style.backgroundColor = '#D6E3F2';
  document.getElementById(btnID).style.color = '#444';
}
*/



/* ホテルを選択すると施設のセレクトリストが変わる */
function GetSelectUnit(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' });
}




/* 顧客検索 */
function GetSelectCustomer(op,op2) {

  uri  = CGI_REF + '?SM=aj_select_custcode&amp;keywd=' + op + '&SESID='+ op2;
  new Ajax.Updater('cust_select',uri,{method: 'get'});
}

/* 小分類リスト取得 */
function GetCustScllist(op,op2,op3) {
  /* op = 中分類コード : op2 = SESID : op3 = 顧客コード */

  uri = CGI_REF + '?SM=aj_cust_scllist&mclsf_id=' + op + '&SESID='+ op2 + '&cust_code=' + op3;
  new Ajax.Updater('aj-center',uri,{method: 'get'});
}

/* 商品リスト取得 */
function GetCustPrlist(op,op2,op3) {
  /* op = 小分類コード : op2 = SESID : op3 = 顧客コード */

  uri = CGI_REF + '?SM=aj_cust_prlist&sclsf_id=' + op + '&SESID='+ op2 + '&cust_code=' + op3;
  new Ajax.Updater('aj-sub',uri,{method: 'get'});
}

/* 商品SKUリスト取得 */
function GetCustSkulist(op,op2,op3) {
  /* op = 商品コード : op2 = SESID : op3 = 顧客コード */

  uri = CGI_REF + '?SM=aj_cust_skulist&pr_code=' + op + '&SESID='+ op2 + '&cust_code=' + op3;
  new Ajax.Updater('aj-variation',uri,{method: 'get'});
}

/* 顧客別商品変更フォーム */
function GetCustPrform(op,op2,op3,op4) {
  /* op =商品コード : op2 = オプションコード : op3 = SESID : op4 = 顧客コード */

  uri = CGI_REF + '?SM=aj_custpr_crrform&pr_code=' + op + '&pr_opcd=' + op2 + '&SESID='+ op3 + '&cust_code=' + op4;
  new Ajax.Updater('aj-form',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 SetCustProducts(op) {
  /* op = SESID */

  var uri = CGI_REF;
  var targetID = 'aj-form';
  var param = Form.serialize("custpr_form");

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

/* 顧客別商品削除 */
function DelCustProducts(op) {
  /* op = SESID */

  var uri = CGI_REF;
  var targetID = 'aj-form';
  var param = Form.serialize("custpr_delform");

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


function NewProductsCheck() {

//  if ( document.ProductsForm.new_flg.checked ) {
  if ( document.getElementById('new_flg').checked ) {
    document.getElementById('new_fr_y').disabled = false;
    document.getElementById('new_fr_m').disabled = false;
    document.getElementById('new_fr_d').disabled = false;
    document.getElementById('new_to_y').disabled = false;
    document.getElementById('new_to_m').disabled = false;
    document.getElementById('new_to_d').disabled = false;
    document.getElementById('new_fr_y').style.backgroundColor='#fff';
    document.getElementById('new_fr_m').style.backgroundColor='#fff';
    document.getElementById('new_fr_d').style.backgroundColor='#fff';
    document.getElementById('new_to_y').style.backgroundColor='#fff';
    document.getElementById('new_to_m').style.backgroundColor='#fff';
    document.getElementById('new_to_d').style.backgroundColor='#fff';
  }
  else {
    document.getElementById('new_fr_y').disabled = true;
    document.getElementById('new_fr_m').disabled = true;
    document.getElementById('new_fr_d').disabled = true;
    document.getElementById('new_to_y').disabled = true;
    document.getElementById('new_to_m').disabled = true;
    document.getElementById('new_to_d').disabled = true;
    document.getElementById('new_fr_y').style.backgroundColor='#bbb';
    document.getElementById('new_fr_m').style.backgroundColor='#bbb';
    document.getElementById('new_fr_d').style.backgroundColor='#bbb';
    document.getElementById('new_to_y').style.backgroundColor='#bbb';
    document.getElementById('new_to_m').style.backgroundColor='#bbb';
    document.getElementById('new_to_d').style.backgroundColor='#bbb';
  }
}

function NewPrCk() {
    if ( document.ProductsForm.new_flg.checked ) {
    document.getElementById("new-more").style.display = 'block';
  }
  else {
    document.getElementById("new-more").style.display = 'none';
  }
}



function ValidProductsCheck() {

  if ( document.getElementById('valid_flg').checked ) {
    document.getElementById('valid_fr_y').disabled = false;
    document.getElementById('valid_fr_m').disabled = false;
    document.getElementById('valid_fr_d').disabled = false;
    document.getElementById('valid_to_y').disabled = false;
    document.getElementById('valid_to_m').disabled = false;
    document.getElementById('valid_to_d').disabled = false;
    document.getElementById('valid_fr_y').style.backgroundColor='#fff';
    document.getElementById('valid_fr_m').style.backgroundColor='#fff';
    document.getElementById('valid_fr_d').style.backgroundColor='#fff';
    document.getElementById('valid_to_y').style.backgroundColor='#fff';
    document.getElementById('valid_to_m').style.backgroundColor='#fff';
    document.getElementById('valid_to_d').style.backgroundColor='#fff';
//    document.getElementById("valid-tr").style.visibility = 'visible';
//  document.getElementById("valid-tr").style.display = 'block';
  }
  else {
    document.getElementById('valid_fr_y').disabled = true;
    document.getElementById('valid_fr_m').disabled = true;
    document.getElementById('valid_fr_d').disabled = true;
    document.getElementById('valid_to_y').disabled = true;
    document.getElementById('valid_to_m').disabled = true;
    document.getElementById('valid_to_d').disabled = true;
    document.getElementById('valid_fr_y').style.backgroundColor='#bbb';
    document.getElementById('valid_fr_m').style.backgroundColor='#bbb';
    document.getElementById('valid_fr_d').style.backgroundColor='#bbb';
    document.getElementById('valid_to_y').style.backgroundColor='#bbb';
    document.getElementById('valid_to_m').style.backgroundColor='#bbb';
    document.getElementById('valid_to_d').style.backgroundColor='#bbb';
//    document.getElementById("valid-tr").style.visibility = 'hidden';
//    document.getElementById("valid-tr").style.display = 'none';
  }
}

function ValidPrCk() {
  if ( document.ProductsForm.valid_flg.checked ) {
    document.getElementById("valid-more").style.display = 'block';
  }
  else {
    document.getElementById("valid-more").style.display = 'none';
  }
}


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';
  //  document.getElementById('shinfo').innerHTML = '';
  //  document.getElementById('shwarn').innerHTML = '';
}


