﻿var eImage = new Image();
eImage.src='/image/e.png';
var cImage = new Image();
cImage.src='/image/c.png';

function loadCodeFilter(){
  var vb = $.cookie('vbCode');
  if (vb != null) {
    FilterCode('vb', ToggleDisplay(vb));
  }
  var cs = $.cookie('csCode');
  if (cs != null) {
    FilterCode('cs', ToggleDisplay(cs));
  }
}
function ToggleDisplay(display){
  if (display == 'none') {
    return ''
  }else {
    return 'none'
  }
}
function FilterCode(lang, beforeDisplay){
  if (beforeDisplay == '') {
    $.cookie(lang + 'Code','none',{expires:180,path:'/'});
    HideCodeBox(lang);
    for (subIndex = 0; subIndex < 100; subIndex++){
      var codeBox = document.getElementById(lang + 'CodeBox' + subIndex);
      if (codeBox == null){
        return
      }
      HideCodeBox(lang, subIndex);
    }
  }else if (beforeDisplay == 'none') {
    $.cookie(lang + 'Code','',{expires:180,path:'/'});
    ShowCodeBox(lang);
    for (subIndex = 0; subIndex < 100; subIndex++){
      var codeBox = document.getElementById(lang + 'CodeBox' + subIndex);
      if (codeBox == null){
        return
      }
      ShowCodeBox(lang, subIndex);
    }
  }
}
function ShowCodeBox(lang, subIndex){
  var codeBox
  if (subIndex == null){
    codeBox = document.getElementById(lang + 'CodeBox');
  } else {
    codeBox = document.getElementById(lang + 'CodeBox' + subIndex);
  }
  if (codeBox != null){
    codeBox.style.display = '';
    var langCheckBox = document.getElementById(lang + 'CheckBox');
    langCheckBox.checked='checked';
  }
}
function HideCodeBox(lang, subIndex){
  var codeBox
  if (subIndex == null){
    codeBox = document.getElementById(lang + 'CodeBox');
  } else {
    codeBox = document.getElementById(lang + 'CodeBox' + subIndex);
  }
  if (codeBox != null){
    codeBox.style.display = 'none';
    var langCheckBox = document.getElementById(lang + 'CheckBox');
    langCheckBox.checked='';
  }
}
function ExpandCollapse(itemId){
  var section = document.getElementById(itemId + 'Section');
  if (section.style.display == '') {
    section.style.display = 'none';
    var img = document.getElementById(itemId + 'Image');
    img.src = cImage.src;
    img.alt = '縮小されたイメージ';
  }else if (section.style.display == 'none') {
    section.style.display = '';
    var img = document.getElementById(itemId + 'Image');
    img.src = eImage.src;
    img.alt = '展開されたイメージ';
  } 
}