/*
ファンクション作成時の定型
//-- [処理の題名]
//コメント行（最後尾に編集者と編集日を入れること）
funtcion hoge(){
}
*/


////-- ランダムID生成用
////Breeze上では利用しないのでコメントアウト 20091005 izumo
//function GetRandom(){
//    var i;
//    var str = "";
//    var charList = "UIcvSD1mOPA3ajk4FGbnHe8rtyKLJqZX6w9uQhEf2gTYioR7pBlzxCVW0sdN5M";
//    var num = charList.length;
//    var len = 12;
//
//    for(i = 0; i < len; i++){
//        str += charList.charAt(Math.floor(Math.random() * num));
//    }
//    return str;
//
//}

//-- formの送信先確定とサブミット用
//ランダム値のファンクションをコメントアウトしたので処理を停止させました 20091005 izumo
function SetAction(act){
    document.main_form.action = act;
    document.main_form.submit();
}

//-- keyのセット
function SetKey(val,name){
    if(name){
        document.main_form.elements[name].value = val;
    }else{
        document.main_form.key.value = val;
    }
}

//-- keyのセット後にサブミット処理
function SetKeyAction(act,val,name){
    SetKey(val,name);
    SetAction(act);
}

//-- 確認アラート表示
function ConfSetAction(act) {
  if( confirm('処理を実行してもよろしいでしょうか？') ){
      SetAction(act);
  }else{
//    alert('キャンセルされました');
  }
}

////-- 確認アラート表示
////KeyをセットしたいならSetKeyで先にセットしてください。
////その方が名前とか指定できるから 20091005 izumo
//function ConfSetKeyAction(act,val) {
//  if( confirm('処理を実行してもよろしいでしょうか？') ){
//    SetKey(val);
//    SetAction(act);
//  }else{
////    alert('キャンセルされました');
//  }
//}

//-- フォームエンコードタイプ
//エンコードタイプを追加する用 20091005 izumo
function SetEnctype(){
    document.main_form.encoding = "multipart/form-data";
}

//----------------------------------------------------------顧問作成分
function openHelpWindow(url ,name ,features)
{
    //window.open(url ,name ,features);
}

function show(inputData) {

    var objID=document.getElementById( "layer_" + inputData );
    var buttonID=document.getElementById( "category_" + inputData );
    if(objID.className=='close') {
        objID.style.display='block';
        objID.className='open';
    }else{
        objID.style.display='none';
        objID.className='close';
    }

}
//----------------------------------------------------------顧問作成分


//**** アンケート作成画面用JS ここから ****//
function m_aqPgCtrl(num) {
    if(document.getElementById("type["+num+"]").value == 0) {
        document.getElementById("choice_count["+num+"]").disabled = true;

        while(num <= 10) {
            num = num+1;
            if (document.getElementById("type["+num+"]") != null) {
              document.getElementById("type["+num+"]").disabled = true;
              document.getElementById("required_flg["+num+"]").disabled = true;
              document.getElementById("choice_count["+num+"]").disabled = true;
            }
        }
    } else {
        if(document.getElementById("type["+num+"]").value == 4) {
            document.getElementById("choice_count["+num+"]").disabled = true;
        } else {
            document.getElementById("choice_count["+num+"]").disabled = false;
        }

        num = num+1;

        if(num <= 10 && document.getElementById("type["+num+"]") != null) {
          document.getElementById("type["+num+"]").disabled = false;
          document.getElementById("required_flg["+num+"]").disabled = false;
        }
    }
}

function m_aqPgReset(){

    document.getElementById("answer_cnt[1]").disabled = true;

    for(i=2;i<11;i++){
        document.getElementById("type["+i+"]").disabled = true;
        document.getElementById("required_flg["+i+"]").disabled = true;
        document.getElementById("choice_count["+i+"]").disabled = true;
    }

    for(i=11;i<21;i++){
        document.getElementById("type["+i+"]").disabled = true;
        document.getElementById("required_flg["+i+"]").disabled = true;
        document.getElementById("choice_count["+i+"]").disabled = true;
        document.getElementById("ques["+i+"]").style.display ='none';
    }
}

function m_aqPgCtrlHiddenElements(num){
    if(9<num && num<20){
        if(document.getElementById("type["+num+"]").value==0){
            document.getElementById("ques["+(num+1)+"]").style.display ='none';
        }else{
            document.getElementById("ques["+(num+1)+"]").style.display ='table-row';
        }
    }
}
//**** アンケート作成画面用JS ここまで ****//

//**** 基本情報設定画面用JS ここから ****//
function acinfoCtrl(num){
    if(document.getElementById("input_type["+num+"]").value==0){
        //設問なしを選択
        document.getElementById("required_flg["+num+"]").disabled = true;
        //document.getElementById("default_flg["+num+"]").disabled = true;
        document.getElementById("answer_cnt["+num+"]").disabled = true;

        while(num<3){
            //設問なしを選択時、以降の設問を無効にする
            num = num+1;
            document.getElementById("input_type["+num+"]").disabled = true;
            document.getElementById("required_flg["+num+"]").disabled = true;
            //document.getElementById("default_flg["+num+"]").disabled = true;
            document.getElementById("answer_cnt["+num+"]").disabled = true;
        }
    }else if(document.getElementById("input_type["+num+"]").value==1 || document.getElementById("input_type["+num+"]").value==2) {
        //設問を選択
        //チェックボックス・セレクトボックス選択時
        document.getElementById("required_flg["+num+"]").disabled = false;
        //document.getElementById("default_flg["+num+"]").disabled = false;
        document.getElementById("answer_cnt["+num+"]").disabled = false;

        //一つ下の設問を有効にする
        num = num+1;
        if(num<=3){
            document.getElementById("input_type["+num+"]").disabled = false;
            //チェックボックス・セレクトボックス選択時
            //document.getElementById("required_flg["+num+"]").disabled = false;
            //document.getElementById("default_flg["+num+"]").disabled = false;
            //document.getElementById("answer_cnt["+num+"]").disabled = false;
        }
    } else {
        // チェック・ラジオ以外を選択
        document.getElementById("required_flg["+num+"]").disabled = false;
        //document.getElementById("default_flg["+num+"]").disabled = true;
        document.getElementById("answer_cnt["+num+"]").disabled = true;

        //一つ下の設問を有効にする
        num = num+1;
        if(num<=3){
            document.getElementById("input_type["+num+"]").disabled = false;
            //チェックボックス・セレクトボックス選択時
            //document.getElementById("required_flg["+num+"]").disabled = true;
            //document.getElementById("default_flg["+num+"]").disabled = true;
            //document.getElementById("answer_cnt["+num+"]").disabled = true;
        }
    }
}

function acinfoReset(){

    document.getElementById("q_num[1]").disabled = true;

    for(i=2;i<=6;i++){
        document.getElementById("type["+i+"]").disabled = true;
        document.getElementById("must_value["+i+"]").disabled = true;
        document.getElementById("ini_value["+i+"]").disabled = true;
        document.getElementById("q_num["+i+"]").disabled = true;
    }

    for(i=11;i<=12;i++){
        document.getElementById("type["+i+"]").disabled = true;
        document.getElementById("must_value["+i+"]").disabled = true;
        document.getElementById("ini_value["+i+"]").disabled = true;
        document.getElementById("q_num["+i+"]").disabled = true;
        document.getElementById("ques["+i+"]").style.display ='none';
    }
}

function acinfoCtrlHiddenElements(num){
//    if(7<=num && num<=12){
//        if(document.getElementById("type["+num+"]").value==0){
//            document.getElementById("ques["+(num+1)+"]").style.display ='none';
//        }else{
//            document.getElementById("ques["+(num+1)+"]").style.display ='table-row';
//        }
//    }
}

//**** 基本情報設定画面用JS ここまで ****//

//**** 返答メール作成画面用JS ここから ****//
//リストより選択されたメールから本文を表示する
function SetReply(val){
    //メール本文を設定
    var tmp_reply_subject = document.getElementById("sel_reply_subject_" + val).value;
    var tmp_reply_body1 = document.getElementById("sel_reply_body1_" + val).value;
    var tmp_reply_body2 = document.getElementById("sel_reply_body2_" + val).value;
    var tmp_reply_url   = document.getElementById("sel_reply_url" + val).value;
    var index  = document.getElementById("sel_reply_id").selectedIndex;
    var tmp_reply_name  = document.getElementById("sel_reply_id").options[index].text;

    document.getElementById("reply_subject").value = tmp_reply_subject;
    document.getElementById("reply_body1").value = tmp_reply_body1;
    document.getElementById("reply_body2").value = tmp_reply_body2;
    document.getElementById("reply_url").value   = tmp_reply_url;
    document.getElementById("reply_name").value   = tmp_reply_name;

//alert(val);
/*
    //フッターIDを設定
    var reply_fid = document.getElementsByName("sel_footer_id")[0];
    var tmp_reply_fid = "reply_fid" + val;
    tmp_reply_fid = document.getElementsByName(tmp_reply_fid)[0];

    if(tmp_reply_fid.value == ""){
        tmp_reply_fid.value = 1;
    }
    reply_fid.value = tmp_reply_fid.value;

    //フッター本文を設定
    //var reply_fbody = document.getElementsByName("footer_body")[0];
    //var tmp_reply_fbody = "reply_fbody" + val;
    //tmp_reply_fbody = document.getElementsByName(tmp_reply_fbody)[0];
    //reply_fbody.value = tmp_reply_fbody.value;
    var fbody = document.getElementsByName("footer_body")[0];
    var tmp_fbody = "sel_footer_body" + reply_fid.value;
    tmp_fbody = document.getElementsByName(tmp_fbody)[0];

    fbody.value = tmp_fbody.value;

*/
}

//リストより選択されたフッターからフッター内容を表示する
function SetFooter(val){
    //フッター内容を表示するテキストエリア
    var footer_body  = document.getElementsByName("footer_body")[0];
    var tmp_footer_body = "sel_footer_body" + val;
    tmp_footer_body = document.getElementsByName(tmp_footer_body)[0];
    footer_body.value = tmp_footer_body.value;

}

//選択されたリストの名前を取得する
function GetFooterName(form){

    //メール選択
    //選択された項目番号
    var index = form.sel_reply_id.selectedIndex;
    //表示されているテキスト
    var str = form.sel_reply_id.options[index].text;
    form.reply_name.value = str;

    //フッター選択
    //選択された項目番号
    var index = form.sel_footer_id.selectedIndex;
    //表示されているテキスト
    var str = form.sel_footer_id.options[index].text;
    form.footer_name.value = str;
}
//**** 返答メール作成画面用JS ここまで ****//

//**** エリアグループ情報登録画面 ****//
//選択されたリストの名前を取得する
function GetAreaGroupName(form){

    //選択された項目番号
    var index = form.sel_ag.selectedIndex;
    //表示されているテキスト
    var str = form.sel_ag.options[index].text;

    form.ar_ag_id.value = form.sel_ag.options[index].value;
    form.ar_ag_name.value = str;
}

function SetAreaGroupReset(){

    up_flg      = document.getElementsByName("up_flg")[0];
    ag_id       = document.getElementsByName("ag_id")[0];
    ag_name     = document.getElementsByName("ag_name")[0];
    ag_sort_no  = document.getElementsByName("ag_sort_no")[0];
    ag_disabled = document.getElementsByName("ag_disabled")[0];

    up_flg.value      = '0';
    ag_id.value       = '';
    ag_name.value     = '';
    ag_sort_no.value  = '';
    ag_disabled.value = '1';

}

function SetAreaGroupDisabled(){

    var chk_ag_disabled = document.getElementsByName("chk_ag_disabled")[0];
    var ag_disabled = document.getElementsByName("ag_disabled")[0];

    if(chk_ag_disabled.checked){
        ag_disabled.value = 0;
    }else{
        ag_disabled.value = 1;
    }
//alert('tes' + ag_disabled.value);
}

//**** エリアグループ情報登録画面 ****//

//**** エリア情報登録画面用JS ここから ****//
//リストより選択されたエリアからエリア内容を取得する
function SetSelArea(val){
    var ar_id       = document.getElementsByName("ar_id")[0];
    var ar_name     = document.getElementsByName("ar_name")[0];
    var ar_sort_no  = document.getElementsByName("ar_sort_no")[0];
    var sel_ag      = document.getElementsByName("sel_ag")[0];
    var chk_ar_disabled = document.getElementsByName("chk_ar_disabled")[0];
    var ar_disabled = document.getElementsByName("ar_disabled")[0];

    var up_flg       = document.getElementsByName("up_flg")[0];

    var tmp_ar_id      = "ar_id"      + val;
    var tmp_ar_name    = "ar_name"    + val;
    var tmp_ar_sort_no = "ar_sort_no" + val;
    var tmp_ar_ag_id   = "ar_ag_id"   + val;
    var tmp_ar_disabled = "ar_disabled"   + val;

    tmp_ar_id       = document.getElementsByName(tmp_ar_id)[0];
    tmp_ar_name     = document.getElementsByName(tmp_ar_name)[0];
    tmp_ar_sort_no  = document.getElementsByName(tmp_ar_sort_no)[0];
    tmp_ar_ag_id    = document.getElementsByName(tmp_ar_ag_id)[0];
    tmp_ar_disabled = document.getElementsByName(tmp_ar_disabled)[0];


    ar_id.value       = tmp_ar_id.value;

    ar_name.value     = tmp_ar_name.value;
    ar_sort_no.value  = tmp_ar_sort_no.value;

    if(tmp_ar_disabled.value == 1){
        chk_ar_disabled.checked = false;
        ar_disabled.value = 1;
    }else{
        chk_ar_disabled.checked = true;
        ar_disabled.value = 0;
    }

    for(var i=0;i<sel_ag.length;i++){
        if(sel_ag.options[i].value == tmp_ar_ag_id.value){
            sel_ag.options[i].selected=true;
        }
    }


    var up_flg       = document.getElementsByName("up_flg")[0];
    up_flg.value = 1;

}

function SetSelAreaGroup(val){
//alert(val);
    var ag_id       = document.getElementsByName("ag_id")[0];
    var ag_name     = document.getElementsByName("ag_name")[0];
    var ag_sort_no  = document.getElementsByName("ag_sort_no")[0];
    var chk_ag_disabled = document.getElementsByName("chk_ag_disabled")[0];
    var ag_disabled = document.getElementsByName("ag_disabled")[0];

    var up_flg       = document.getElementsByName("up_flg")[0];

    var tmp_ag_id      = "ag_id"      + val;
    var tmp_ag_name    = "ag_name"    + val;
    var tmp_ag_sort_no = "ag_sort_no" + val;
    var tmp_ag_disabled = "ag_disabled"   + val;

//alert(tmp_ag_name);

    tmp_ag_id       = document.getElementsByName(tmp_ag_id)[0];
    tmp_ag_name     = document.getElementsByName(tmp_ag_name)[0];
    tmp_ag_sort_no  = document.getElementsByName(tmp_ag_sort_no)[0];
    tmp_ag_disabled = document.getElementsByName(tmp_ag_disabled)[0];

//alert(tmp_ag_name.value);


    ag_id.value       = tmp_ag_id.value;

    ag_name.value     = tmp_ag_name.value;
    ag_sort_no.value  = tmp_ag_sort_no.value;

    if(tmp_ag_disabled.value == 1){
        chk_ag_disabled.checked = false;
        ag_disabled.value = 1;
    }else{
        chk_ag_disabled.checked = true;
        ag_disabled.value = 0;
    }

    var up_flg       = document.getElementsByName("up_flg")[0];
    up_flg.value = 1;

}

function SetDisabled(){

    var chk_ar_disabled = document.getElementsByName("chk_ar_disabled")[0];
    var ar_disabled = document.getElementsByName("ar_disabled")[0];

    if(chk_ar_disabled.checked){
        ar_disabled.value = 0;
    }else{
        ar_disabled.value = 1;
    }
}

function SetAreaReset(){

    up_flg      = document.getElementsByName("up_flg")[0];
    ar_id       = document.getElementsByName("ar_id")[0];
    ar_name     = document.getElementsByName("ar_name")[0];
    ar_sort_no  = document.getElementsByName("ar_sort_no")[0];
    ar_ag_id    = document.getElementsByName("ar_ag_id")[0];
    ar_ag_name  = document.getElementsByName("ar_ag_name")[0];
    ar_disabled = document.getElementsByName("ar_disabled")[0];
    sel_ag      = document.getElementsByName("sel_ag")[0];

    up_flg.value      = '0';
    ar_id.value       = '';
    ar_name.value     = '';
    ar_sort_no.value  = '';
    ar_ag_id.value    = '';
    ar_ag_name.value  = '';
    ar_disabled.value = '1';
    sel_ag.options[0].selected = true;

}
//**** エリア情報登録画面用JS ここまで ****//

//**** アクセス状況詳細表示JS ここから ****//
function showLines(clsnm){

    var test = getElementsByClass(clsnm);
    i = 0;
    for (var i = 0; i < test.length; i++) {
        if(test[i].style.display == ''){
            test[i].style.display = 'none';
        }else{
            test[i].style.display = '';
        }
    }
}

function getElementsByClass(classnm) {
    var clnm = ' ' + classnm + ' ';
    var all = document.getElementsByTagName('*');
    var elements = new Array();
    for (var i = 0; i < all.length; i++) {
        if (0 <= (' ' + all[i].className + ' ').indexOf(clnm)) {
            elements[elements.length] = all[i];
        }
    }
    return elements;
}
//**** アクセス状況詳細表示JS ここまで ****//


//**** DM配信画面用JS ここから ****//
//表示・非表示切替
function changeViewArea(viewObj,inputObj) {
  if(viewObj.style.display=='none'){
    viewObj.style.display='';
    inputObj.style.display='none';
  }else{
    viewObj.style.display='none';
    inputObj.style.display='';
  }
}
//確認アラート表示
function ConfSetKeyAction_DM(act,val,btnSTR) {
  if( confirm(btnSTR) ){
    SetKeyAction(act,val);
  }
}
function ConfSetAction_withMSG(act,strmsg) {
  if( confirm(strmsg) ){
    SetAction(act);
  }
}
//SELECTタグ(MULTIPLE属性有)選択チェック
//（全選択を選択なしとみなすます）
function SelPrmChk(selObj){
  var i;
  var cnt = 0;
  for(i = 0; i < selObj.options.length; i++)
  {
    if (selObj.options[i].selected){cnt += 1;}
  }
  if(cnt==0 || cnt==selObj.options.length){
    return false;
  }else{
    return true;
  }
}

//エリアグループの選択に応じてエリア選択用コントロールの表示を制御
function AreaInputCtrl() {
  var selObj = document.getElementById("areag");
  var i;
  var cnt = 0;

  for(i = 0; i < selObj.options.length; i++)
  {
    if (selObj.options[i].selected){cnt += 1;}
  }
  if(cnt){
    for(i = 0; i < selObj.options.length; i++)
    {
      if (selObj.options[i].selected){
        document.getElementById("area["+(selObj.options[i].value)+"]").style.display ='inline';
      }else{
        document.getElementById("area["+(selObj.options[i].value)+"]").style.display ='none';
      }
    }
  }else{
    for(i = 0; i < selObj.options.length; i++)
    {
      document.getElementById("area["+(selObj.options[i].value)+"]").style.display ='inline';
    }
  }
}

//エリアグループ条件表示
function AreagViewEdit() {
  var txtObj = document.getElementById("areagView");
  var selObj = document.getElementById("areag");
  if(SelPrmChk(selObj)){
    txtObj.innerHTML=getSelectedValue(selObj);
  }else{
    txtObj.innerHTML="";
  }
}

//エリア条件表示
function AreaViewEdit() {
  var txtObj = document.getElementById("areaView");
  var grpObj = document.getElementById("areag");
  var gsel = SelPrmChk(grpObj);
  var selObj;
  var sep = "";
  var tmp = "";
  var rtn = "";
  var i;
  var j;
  var cnt=0;
  var gcnt=0;
  //全エリア条件が全選択状態の場合、選択なし状態とみなす。
  if(gsel==false){
    for(i = 0; i < grpObj.options.length; i++){
      selObj = document.getElementById("area["+(grpObj.options[i].value)+"]");
      cnt=0;
      for(j = 0; j < selObj.options.length; j++)
      {
        if (selObj.options[j].selected){cnt += 1;}
      }
      if(cnt==selObj.options.length){
        gcnt+=1;
      }
    }
    if(gcnt==grpObj.options.length){
      txtObj.innerHTML="";
      return;
    }
  }
  for(i = 0; i < grpObj.options.length; i++){
    if (gsel && grpObj.options[i].selected){
      selObj = document.getElementById("area["+(grpObj.options[i].value)+"]");
      if(SelPrmChk(selObj)){
        rtn += sep + getSelectedValue(selObj);
        sep = "　";
      }
    }else{
      if(gsel==false){
        selObj = document.getElementById("area["+(grpObj.options[i].value)+"]");
        tmp=getSelectedValue(selObj);
        if(tmp>""){
          rtn += sep + tmp;
          sep = "　";
        }
      }
    }
  }
  txtObj.innerHTML=rtn;
}

//選択項目の表示部分取得
function getSelectedValue(selObj) {
  var sep = "";
  var rtn = "";
  var i;
  for(i = 0; i < selObj.options.length; i++)
  {
    if (selObj.options[i].selected){
      rtn += sep + selObj.options[i].text;
      sep = "　";
    }
  }
  return rtn;
}

//リストより選択されたフッターからフッター内容を表示する(DM用)
function SetDMFooter(val){
    var elmStr = "ft_elm[" + val + "]";
    var ftObj = document.getElementsByName(elmStr);
    var ftStr = ftObj[0].value;
    document.getElementsByName("footerBody")[0].value = ftStr;

}
//**** DM配信画面用JS ここまで ****//


//チェックボックス一括チェック
function checkAll(objAll){
    // 全ての要素に対して
    for(var i=0;i<document.main_form.length;i++){
        //チェックボックスであれば
        if(document.main_form[i].type=="checkbox"){
            document.main_form[i].checked = objAll.checked;
        }
    }
}


//チェックボックス一括チェック
function checkArea(obj){
    // 全ての要素に対して
    for(var i=0;i<document.main_form.length;i++){
        //チェックボックスであれば
        var className = "area" + String(obj.value);
        if(document.main_form[i].type=="checkbox" && document.main_form.elements[i].className == className){
            document.main_form[i].checked = obj.checked;
        }
    }
}


//ヘルプオープン
function openForwardWindow_mb(theURL,winName,wi,he)
{
  var features = new String("");
  if(wi=="" || wi==null){
    wi = 600;
  }
  if(he=="" || he==null){
    he = 580;
  }
  features = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+wi+',height='+he;
  window.open(theURL,winName,features);
}

//----------------------------------------------------------
// 可変項目　動的画面プレビュー

// プレビューウィンドウへ値を渡す
function setPrev(id)
{

    // IDをJqueryでいけるようにエスケープ
    repId = replaceId(id);
    // IDをプレビューのIDに修正する
    preId = chgId(repId);

    if (document.getElementById(id).type == 'radio') {
        radioData = $("input[name=" + repId + "]:checked").val()
        $("input[name=" + preId + "]").val(radioData);
    } else {
        // 該当IDの値を取得する
        text = $("#"+ repId).val();
        // プレビューに表示する
        $("#"+ preId).text(text);
    }

    radioData = $("input[@name=" + repId + "]:checked").val();

}

// IDをJQueryで使えるように変換する
function replaceId(id)
{
    id = id.replace(/\[/g, '\\[');
    id = id.replace(/\]/g, '\\]');

    return id
}

// IDをプレビューウインドウ用変更する
function chgId(id)
{
    preId = 'pre_' + id;
    return preId;
}


// ここまで
//----------------------------------------------------------

//----------------------------------------------------------
// 管理画面：会員変更　お問合せウインドウのオープンクローズ

/*
function csm_hist_win(eid,i) {
  var aid = eid+"_all";
  if(i==0){
    csm_hist(aid,'0');
    csm_hist(eid,'1');
  }else{
    csm_hist(eid,'0');
    csm_hist(aid,'1');
  }
}
*/

// 返信ウインドウの現在の状態を取得
function csm_hist_re(eid) {
  if(document.getElementById(eid).style.display=='none'){
    csm_hist(eid,'0');
  }else{
    csm_hist(eid,'1');
  }
}

// 返信ウインドウの表示・非表示
function csm_hist(n,k){
  if(k==0){
    document.getElementById(n).style.display = '';
  }else{
    document.getElementById(n).style.display = 'none';
  }
}

// ここまで
//----------------------------------------------------------

//----------------------------------------------------------
// 管理画面：DMフッターのAjax
function getFooter() {

    // 選択された署名のIDを取得する
    var footerId = $("#footerId").val();

    // IDが空の場合は値を空にして処理を終了する
    if (footerId == '') {
        $("#mailFooter").html('');
        return true;
    }

    $.ajax({
        type: "GET",
        url: "./adminIndex.php?act=Cmn_Admin_Ajax_GetFooter",
        data: {"id":footerId},
        dataType: "json",
        cache:false,
        success: function(data, status){
            $('textarea#mailFooter').val(data.body);
        },
        error: function(XMLHttpRequest, status, errorThrown){

        }
    });
    $("#footerId").val('');
}

// 管理画面：空メールのAjax
function getBlankMail() {

    // 選択された空メールのIDを取得する
    var id = $("#id").val();

    $.ajax({
        type: "GET",
        url: "./adminIndex.php?act=Cmn_Admin_BlankMail_GetBlankMail",
        data: {"id":id},
        dataType: "json",
        cache:false,
        success: function(data, status){
            var name = document.createElement('input');
            name.type = 'hidden';
            name.name = 'name';
            if(data.name!=''){
                name.value = data.name;
            }else{
                name.value = '';
            }
            document.forms[0].appendChild(name);
            $("#name").html(name);

            var subject = document.createElement('input');
            subject.type = 'text';
            subject.name = 'subject';
            if(data.subject!=''){
                subject.value = data.subject;
            }else{
                subject.value = '';
            }
            document.forms[0].appendChild(subject);
            $("#subject").html(subject);

            $("#body").val(data.body);
        },
        error: function(XMLHttpRequest, status, errorThrown){
        }
    });
}

// 管理画面：自動返信メールのAjax
function getReplyMail() {

    // 選択された空メールのIDを取得する
    var id = $("#id").val();

    $.ajax({
        type: "GET",
        url: "./adminIndex.php?act=Cmn_Admin_ReplyMail_GetReplyMail",
        data: {"id":id},
        dataType: "json",
        cache:false,
        success: function(data, status){
            var name = document.createElement('input');
            name.type = 'hidden';
            name.name = 'name';
            if(data.name!=''){
                name.value = data.name;
            }else{
                name.value = '';
            }
            document.forms[0].appendChild(name);
            $("#name").html(name);

            var subject = document.createElement('input');
            subject.type = 'text';
            subject.name = 'subject';
            if(data.subject!=''){
                subject.value = data.subject;
            }else{
                subject.value = '';
            }
            document.forms[0].appendChild(subject);
            $("#subject").html(subject);

            $("#bodyUp").val(data.bodyUp);
            $("#bodyBottom").val(data.bodyBottom);
            $("#mailFooter").val(data.footerBody);
            var url = document.createElement('input');
            url.type = 'hidden';
            url.name = 'url';
            if(data.name!=''){
                url.value = data.url;
            }else{
                url.value = '';
            }
            document.forms[0].appendChild(url);
            $("#url").html(data.url);
            $("#urlhidden").html(url);
        },
        error: function(XMLHttpRequest, status, errorThrown){
        }
    });
}




// ここまで
//----------------------------------------------------------

//----------------------------------------------------------
//以降CQSM関連
//-- CQSMhiddenタグ生成用 20091203 izumo
function CqsmMakeHiddenTag(name,value,formname){
    var q = document.createElement('input');

    q.type = 'hidden';
    q.name = name;
    q.value = value;

    if (formname) {
         document.forms[formname].appendChild(q);
    } else {
         document.forms[0].appendChild(q);
    }
}
//-- CQSMヘッダメニュー用 20091130 izumo
function DisabledSetAction(act){
  //メニュー用サブミットを初期化してからプロック送信
  var max = document.main_form.elements.length;
  for(var i=0;i<max;i++){
    document.main_form.elements[i].disabled = true;
  }
  //初期化用フラグを生成して投げる
  CqsmMakeHiddenTag('set_head_menu','new','main_form');
  SetAction(act);
}

//-- DIVタグの表示・非表示用 20091005 izumo
function display_trans_viwe(name) {
  if(document.getElementById(name).style.display == "none"){
    document.getElementById(name).style.display = "block";
  }else{
    document.getElementById(name).style.display = "none";
  }
}

//-- DIVタグの表示・非表示用 20091005 izumo
function menu(cname,rname) {
  var id = new String("");
  var sub = new String("");
  var max = 0;

  //ラジオボタンを全て解除
  if (document.main_form.elements[rname]) {
      max = document.main_form.elements[rname].length;
  } else {
      max = 0;
  }
  for(var i=0;i<max;i++){
    document.main_form.elements[rname][i].checked=false;
  }

  //DIVタグの非表示化
  if (document.main_form.elements[cname]) {
      max = document.main_form.elements[cname].length;
  } else {
      max = 0;
  }
  for (var j=0;j<max;j++) {
    sub = document.main_form.elements[cname][j].value;
    if(document.getElementById(sub)){
      document.getElementById(sub).style.display = "none";
    }
  }

  //選択中のカテゴリ内容の表示
  id = document.main_form.elements[cname].value;
  document.getElementById(id).style.display = "block";
}

//-- チェックボックスの一括チェック（名称を指定してのチェック）
//類似物としてcheckAllというものとcheckAreaがあるので以後の打ち合わせ時に確認要 20091005 izumo
function check_box_true(){
  for(var i=0;i<document.main_form.length;i++){
       if(document.main_form[i].type == "checkbox"){
          document.main_form.elements[i].checked = true;
       }
  }
}

//-- ポップアップ用
//ポップアップ用 20091021 izumo
function openForwardWindow_mb(theURL,winName,wi,he)
{
  openNewWindow(theURL,winName,wi,he);
}
function openNewWindow(theURL,winName,wi,he)
{
  var features = new String("");
  if(wi=="" || wi==null){
    wi = 600;
  }
  if(he=="" || he==null){
    he = 580;
  }
  features = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+wi+',height='+he;
  window.open(theURL,winName,features);
}

//-- 後から書き直しが必要（こんな専用関数はいらない）
function display_viwe(i){
var count = 0;
var name = 'category[]';
var n;

  document.main_form.elements["dust"].checked = false;
  document.main_form.elements["notre"].checked = false;
  count = document.main_form.elements[name].length;
  for(n=0;n<count;n++){
    document.main_form.elements[name][n].checked = false;
  }

  document.getElementById(0).style.display = "none";
  document.getElementById(1).style.display = "none";
  document.getElementById(2).style.display = "none";
  if(i == "0"){
    document.getElementById(0).style.display = "block";
  }
  if(i == "1"){
    document.getElementById(1).style.display = "block";
  }
  if(i == "2"){
    document.getElementById(2).style.display = "block";
  }
}

//----------------------------------------------------------
// 管理画面：ページ編集のAjax
function searchFileList(selectedDir, pageType) {
    var getUrl = "adminIndex.php?act=Cmn_Admin_MobilePageUpdate_SearchFileList";
    if (pageType == 2) {
        getUrl = "adminIndex.php?act=Cmn_Admin_PcPageUpdate_SearchFileList";
    }
    $.ajax({
        type: "GET",
        data: {"selectedDir":selectedDir},
        cache:false,
        dataType: "json",
        url: getUrl,
        success: function(data, status){
            $("#fileList").html(data);
            WordBreak.breakAll();
        },
        error: function(httpStatus, e){
        //alert("HTTP Status:"+httpStatus.status+"\n"+httpStatus.statusText+"\nError:"+e);
        }
    });


}


// 管理画面TOPの右側に表示する集計用
function searchTotal(setData) {
    $.ajax({
        type: "GET",
        url: "adminIndex.php?act=Cmn_Admin_Analysis_SearchAccess",
        data: {"name":setData},
        cache:false,
        dataType: "text",
        success: function(data){
            $("#access").html(data);
            //document.getElementById('access').innerHTML = data;
        },
        error: function(httpStatus, e){
            // alert("HTTP Status:"+httpStatus.status+"\n"+httpStatus.statusText+"\nError:"+e);
        }

    });
}


//管理画面TOPの中央に表示するお知らせ
function getNews() {
    $.ajax({
        type: "GET",
        url: "adminIndex.php?act=Cmn_Admin_Ajax_GetNews",
        cache:false,
        dataType: "text",
        success: function(data){
            $("#news").html(data);
        },
        error: function(httpStatus, e){
            // alert("HTTP Status:"+httpStatus.status+"\n"+httpStatus.statusText+"\nError:"+e);
        }

    });
}

// 特価情報の一覧を取得
function dispSpecialPrice() {
    var id = $('#shopId').val();

    $.ajax({
        type: "GET",
        url: "./adminIndex.php?act=Cmn_Admin_Ajax_GetSpecialPriceList",
        data: {"id":id},
        cache:false,
        dataType: "json",
        success: function(data, status){
            $("div#fileList").html(data);
        },
        error: function(httpStatus, e){
            //alert("HTTP Status:"+httpStatus.status+"\n"+httpStatus.statusText+"\nError:"+e);
        }
    });
}

//週末つれつれ大予想の一覧を取得
function dispWeekendForecast() {
    var id = $('#shopId').val();

    $.ajax({
        type: "GET",
        url: "./adminIndex.php?act=Cmn_Admin_Ajax_GetWeekendForecastList",
        data: {"id":id},
        cache:false,
        dataType: "json",
        success: function(data, status){
            $("div#fileList").html(data);
        },
        error: function(httpStatus, e){
            //alert("HTTP Status:"+httpStatus.status+"\n"+httpStatus.statusText+"\nError:"+e);
        }
    });
}

// 釣り広辞苑の画面作成を取得
function dispDictionary() {
    var id = $('#funcId').val();

    $.ajax({
        type: "GET",
        url: "./adminIndex.php?act=Cmn_Admin_Ajax_GetDictionaryList",
        data: {"id":id},
        cache:false,
        dataType: "json",
        success: function(data, status){
            $("div#fileList").html(data);
        },
        error: function(httpStatus, e){
            //alert("HTTP Status:"+httpStatus.status+"\n"+httpStatus.statusText+"\nError:"+e);
        }
    });
}

// 釣果レポートの一覧を取得
function dispReport(pageID) {
    var id = $('#id').val();

    $.ajax({
        type: "GET",
        url: "./adminIndex.php?act=Cmn_Admin_Ajax_GetReportList",
        data: {"id":id, "pageID":pageID},
        cache:false,
        dataType: "json",
        success: function(data, status){
            $("div#fileList").html(data);
        },
        error: function(httpStatus, e){
            //alert("HTTP Status:"+httpStatus.status+"\n"+httpStatus.statusText+"\nError:"+e);
        }
    });
}

//ユーザー側特価情報の一覧を取得
function dispUserSpecialPrice() {
    $.ajax({
        type: "GET",
        url: "/?act=Cmn_User_Ajax_GetSpecialPriceList",
        cache:false,
        dataType: "json",
        success: function(data) {
            $("div#specialPrice").html(data);
        },
        error: function(httpStatus, e){
           //alert("HTTP Status:"+httpStatus.status+"\n"+httpStatus.statusText+"\nError:"+e);
        }
    });
}
//ユーザー側セール情報の一覧を取得
function dispUserSaleCampaign() {
    $.ajax({
        type: "GET",
        url: "/?act=Cmn_User_Ajax_GetSalesCampaignList",
        cache:false,
        dataType: "json",
        success: function(data){
            $("div#saleCampaign").html(data);
        },
        error: function(httpStatus, e){
            //alert("HTTP Status:"+httpStatus.status+"\n"+httpStatus.statusText+"\nError:"+e);
        }
    });
}
//ユーザー側週末つれつれ大予想の一覧を取得
function dispUserWeekendForecast() {
    $.ajax({
        type: "GET",
        url: "?act=Cmn_User_Ajax_GetWeekendForecast",
        cache:false,
        dataType: "json",
        success: function(data){
            $("td#weekendForecas").html(data);
        },
        error: function(httpStatus, e){
            //alert("HTTP Status:"+httpStatus.status+"\n"+httpStatus.statusText+"\nError:"+e);
        }
    });
}
//ユーザー側イベント一覧を取得
function dispUserEvent() {
    $.ajax({
        type: "GET",
        url: "?act=Cmn_User_Ajax_GetEventList",
        cache:false,
        dataType: "json",
        success: function(data){
        $("div#event").html(data);
    },
    error: function(httpStatus, e){
        //alert("HTTP Status:"+httpStatus.status+"\n"+httpStatus.statusText+"\nError:"+e);
    }
    });
}
//ユーザー側新製品情報一覧を取得
function dispUserNewProduct() {
    $.ajax({
        type: "GET",
        url: "?act=Cmn_User_Ajax_GetNewProductList",
        cache:false,
        dataType: "json",
        success: function(data){
        $("div#product").html(data);
    },
    error: function(httpStatus, e){
        //alert("HTTP Status:"+httpStatus.status+"\n"+httpStatus.statusText+"\nError:"+e);
    }
    });
}
//最新釣果情報一覧を取得
function dispUserChoka(key,shop) {

    if (key == undefined) {
        key = 0;
    }
    if (shop == undefined) {
        shop = 0;
    }

    var cs = document.createElement("link");
    cs.rel="stylesheet";
    cs.href="/top.css";
    cs.type="text/css";
    $("head").append(cs);

    fileName = "choka_tab0" + key + ".gif";
    $("#topL02 .choka_kiji #nav a").css("background-image","url(?act=Cmn_User_FileContents&file=/img/" + fileName + ")");
    $("#topL02 .choka_kiji #nav ").css("background-image","url(?act=Cmn_User_FileContents&file=/img/" + fileName + ")");

    $.ajax({
        type: "GET",
        url: "?act=Cmn_User_Ajax_GetChokaList",
        data: {"key":key,"shop":shop},
        cache:false,
        dataType: "text",
        success: function(data){
            $("div#choka").html(data);
        },
        error: function(httpStatus, e){
            //alert("HTTP Status:"+httpStatus.status+"\n"+httpStatus.statusText+"\nError:"+e);
        }
    });
}

//動画集一覧取得
function videoList() {
    var id = $('#shopId').val();

    $.ajax({
        type: "GET",
        url: "./adminIndex.php?act=Cmn_Admin_Ajax_GetReportList",
        data: {"id":id, "pageID":pageID},
        cache:false,
        dataType: "json",
        success: function(data, status){
            $("div#fileList").html(data);
        },
        error: function(httpStatus, e){
            //alert("HTTP Status:"+httpStatus.status+"\n"+httpStatus.statusText+"\nError:"+e);
        }
    });
}


function canTimeInput() {

    var timing = $('input[name="timing"]:checked').val();
    if (timing == 2) {
        $('#time').show();
    }else{
        $('#time').hide();
    }
}

function dmSearchCriticalItem(){

    if($('#criticalItem').css('display') == 'block'){
        $('#criticalItem').hide();
    }else{
        $('#criticalItem').show();
    }
}


//店舗別に表示内容を変える
function getEachShopData(url,setData) {
    $.ajax({
        type: "GET",
        url: "adminIndex.php?act=Cmn_Admin_" + url,
        data: {"id":setData},
        cache:false,
        dataType: "text",
        success: function(data){
            $("#getdata").html(data);
            //document.getElementById('access').innerHTML = data;
        },
        error: function(httpStatus, e){
            // alert("HTTP Status:"+httpStatus.status+"\n"+httpStatus.statusText+"\nError:"+e);
        }

    });
}

//リンク集の一覧を取得(管理側)
function dispLinkCollection() {
    var id = $('#classId').val();

    $.ajax({
        type: "GET",
        url: "./adminIndex.php?act=Cmn_Admin_Ajax_GetLinkCollectionList",
        data: {"id":id},
        cache:false,
        dataType: "text",
        success: function(data){
            $("div#fileList").html(data);
        },
        error: function(httpStatus, e){
            //alert("HTTP Status:"+httpStatus.status+"\n"+httpStatus.statusText+"\nError:"+e);
        }
    });

}

//DM署名の一覧を取得(管理側)
function dispDmFooter() {
    var position = $('#position').val();

    $.ajax({
        type: "GET",
        url: "./adminIndex.php?act=Cmn_Admin_Ajax_GetDmFooterList",
        data: {"position":position},
        cache:false,
        dataType: "text",
        success: function(data){
            $("div#footerList").html(data);
        },
        error: function(httpStatus, e){
            //alert("HTTP Status:"+httpStatus.status+"\n"+httpStatus.statusText+"\nError:"+e);
        }
    });
}

// 部品リストを取得
function dispItemList(no) {
    var itemCategoryId = $('#itemCategoryId'+no).val();
    if (itemCategoryId == '') {
        for (i=1 ; i<=3; i++) {
            $option = new Array();
            $("#itemId" + i + no).empty();
            $option.push('<option value="">----</option>');
            $("#itemId" + i + no).append($option.join());
        }
        
        no = Number(no)+1;
        for (i=no ; i<=15; i++) {
            $("#trNo" + i).hide();
        }
        return
    }
    $.ajax({
        type: "GET",
        url: "./adminIndex.php?act=Cmn_Admin_Ajax_GetItemList",
        data: {"id":itemCategoryId},
        cache:false,
        dataType: "json",
        success: function(data){
            for (i=1 ; i<=3; i++) {
                $option = new Array();
                $("#itemId" + i + no).empty();
                $option.push('<option value="">----</option>');
                if (data != null) {
                    for (j = 0; j<data.length; j++) {
                        $option.push('<option value="' + decodeURIComponent(data[j].id) + '">' + decodeURIComponent(data[j].no) + '</option>');
                    }
                }
                $("#itemId" + i + no).append($option.join());
            }
            no = Number(no)+1;
            $("#trNo" + no).show();
        }, 
        error: function(httpStatus, e){
            //alert("HTTP Status:"+httpStatus.status+"\n"+httpStatus.statusText+"\nError:"+e);
        }
    });

}

//DMヘッダーの一覧を取得(管理側)
function dispDmHeader() {
    var position = $('#position').val();
    $.ajax({
        type: "GET",
        url: "./adminIndex.php?act=Cmn_Admin_Ajax_GetDmHeaderList",
        data: {"position":position},
        cache:false,
        dataType: "text",
        success: function(data){
            $("div#headerList").html(data);
        },
        error: function(httpStatus, e){
            //alert("HTTP Status:"+httpStatus.status+"\n"+httpStatus.statusText+"\nError:"+e);
        }
    });
}

