var NAVI_HEIGHT = 110;
var MENU_HEIGHT = 23.0;
var COMMAND_MODE = false;
var ID_chapter = "";
var ID_title = "";
var ID_item = "";
var timerID_menu;
var timerID_body;
var timerID_select;
var timerID_update;
var ID_select;
var startFil;
var ID_menu;
var ID_update;
var ffSCROLL = true;
var ffHIDE_MENU = get_cookie('@HIDE_MENU_INDEX');

function MM_doctype() {
  alert(document.documentMode);
}

function MM_init(xxx) {
  if(xxx=='') {return;}
  startFil = xxx;
  timerID_body = setInterval('MM_init_body()', 50);
}

function MM_init_body() {
try {
  if(parent.fbody.document.readyState == 'complete') {
    parent.fbody.location.replace(startFil);
    clearInterval(timerID_body);
  }
} catch(e) {
}
}

function MM_title() {
try {
  if(top.fbody.document.readyState == 'complete') {
    top.document.getElementById('header').innerHTML = ID_title;
  }
} catch(e) {
}
}

function MM_index(xxx) {
  ID_menu = xxx;
  timerID_menu = setInterval('MM_index_sub()', 50);
}

function MM_index_sub() {
try {
  if(top.fbody.document.readyState == 'complete') {
    MM_index_main(ID_menu);
    clearInterval(timerID_menu);
  }
} catch(e) {
}
}

function MM_index_main(xxx) {
try {
  var url = top.fbody.document.URL;
  var tmpID;
  if(url.indexOf("file://") >= 0) {
    tmpID = url.substring(url.lastIndexOf("\\") + 1, url.length);
  } else {
    tmpID = url.substring(url.lastIndexOf("/") + 1, url.length);
  }
  var pp = tmpID.indexOf("#top");
  if(pp >= 0) {
    tmpID = tmpID.substring(0, pp);
  }
  if(xxx!=top.findex.MENU_ID) {
    var mmm = '_fmenu';
    mmm = mmm + '_' + xxx;
    mmm = mmm + '.htm';
    top.findex.location.replace(mmm);
    ID_chapter = "";
    ID_item = "";
  } else {
    MM_indexById(tmpID, true);
    MM_title();
  }
} catch(e) {
}
ffSCROLL = true;
}

function UpdateMenus(xxx) {
  ID_update = xxx;
  timerID_update = setInterval('UpdateMenus_sub()', 50);
}

function UpdateMenus_sub() {
try {
  if(parent.fbody.document.readyState == 'complete') {
    resizeme();
    var url = top.fbody.document.URL;
    var tmpID;
    if(url.indexOf("file://") >= 0) {
      tmpID = url.substring(url.lastIndexOf("\\") + 1, url.length);
    } else {
      tmpID = url.substring(url.lastIndexOf("/") + 1, url.length);
    }
    MM_indexById(tmpID, true);
    MM_title();
    UpdateNavi(ID_update);
    clearInterval(timerID_update);
  }
} catch(e) {
}
}

function MM_next() {
  if(COMMAND_MODE) {
    COMMAND_MODE = false;
    MM_next_chapter();
    return;
  }
  var fDone = false;
  var tmp_element;
  var tmpfil = '';
  var tmpID = ID_item.toLowerCase();
  var pp = tmpID.indexOf("#");
  if(pp >= 0) {
    tmpID = tmpID.substring(0, pp);
  }
  for (i = top.findex.files.length - 1 ; i > 0 ; i--) {
    if(top.findex.files[i].indexOf(':') >= 0) {
      continue;
    }
    if(tmpID == top.findex.files[i].toLowerCase()) {
      break;
    }
    tmpfil = top.findex.files[i];
  }
  if(tmpfil != '') {
    try {
    tmp_element = top.findex.document.getElementById(tmpfil);
    tmpfil = tmp_element.id;
    fDone = true;
    } catch(e) {
    }
    if(fDone !=true) {
    try {
    tmp_element = top.findex.document.getElementById(tmpfil + '#MN01');
    tmpfil = tmp_element.id;
    } catch(e) {
    }
    }
    try {
    top.fbody.location = tmpfil;
    } catch(e) {
    }
  }
}

function MM_back() {
  if(COMMAND_MODE) {
    COMMAND_MODE = false;
    MM_back_chapter();
    return;
  }
  var fDone = false;
  var tmp_element;
  var tmpfil = '';
  var tmpID = ID_item.toLowerCase();
  var pp = tmpID.indexOf("#");
  if(pp >= 0) {
    tmpID = tmpID.substring(0, pp);
  }
  for (i = 0 ; i < top.findex.files.length - 1 ; i++) {
    if(top.findex.files[i].indexOf(':') >= 0) {
      continue;
    }
    if(tmpID == top.findex.files[i].toLowerCase()) {
      break;
    }
    tmpfil = top.findex.files[i];
  }
  if(tmpfil != '') {
    try {
    tmp_element = top.findex.document.getElementById(tmpfil);
    tmpfil = tmp_element.id;
    fDone = true;
    } catch(e) {
    }
    if(fDone != true) {
    try {
    tmp_element = top.findex.document.getElementById(tmpfil + '#MN01');
    tmpfil = tmp_element.id;
    } catch(e) {
    }
    }
    try {
    top.fbody.location = tmpfil;
    } catch(e) {
    }
  }
}

function MM_next_chapter() {
try {
  var count = 0;
  for (i = 0; i < top.findex.files.length - 1 ; i++) {
    pp = top.findex.files[i].indexOf(':');
    if(pp >= 0) {
      count = eval(top.findex.files[i].substr(0, pp));
      if (count > eval(ID_chapter)) {
        top.fbody.location = top.findex.files[i + 1];
        break;
      }
    }
  }
} catch(e) {
}
}

function MM_back_chapter() {
try {
  var count = 0;
  for (i = top.findex.files.length - 1 ; i >= 0 ; i--) {
    pp = top.findex.files[i].indexOf(':');
    if(pp >= 0) {
      count = eval(top.findex.files[i].substr(0, pp));
      if (count < eval(ID_chapter)) {
        top.fbody.location = top.findex.files[i + 1];
        break;
      }
    }
  }
} catch(e) {
}
}

function MM_here() {
  var pos = -1;
try {
  var fullname = top.fbody.location.href;
  var filarray = fullname.split('/');
  var filename = filarray[filarray.length - 1];
  filarray = filename.split('#');
  filename = filarray[0];
  for (i = 0; i < top.findex.files.length ; i++) {
    pp = top.findex.files[i].indexOf(':');
    if(pp >= 0) {
    ID_chapter = top.findex.files[i].substr(0, pp);
    ID_title = top.findex.files[i].substr(pp + 1);
    }
    if(filename.toLowerCase() == top.findex.files[i].toLowerCase()) {
    pos = i;
    break;
    }
  }
} catch(e) {
}
  return pos;
}

function MM_indexById(mmID, flag) {
  var pp = mmID.indexOf("#top");
  if(pp >= 0) {
    mmID = mmID.substring(0, pp);
  }
  var fDone = false;
  var prev_element;
  var pp;
  var ccElement;
  var element;
  if(ID_chapter > 0) {
    try {
    prev_element = top.findex.document.getElementById(ID_chapter);
    prev_element.className = 'Chapter';
    fDone = true;
    } catch(e) {
    }
  }
  if(ID_item != '') {
    fDone = false;
    try {
    prev_element = top.findex.document.getElementById(ID_item);
    prev_element.className = prev_element.className.substr(0,5);
    fDone = true;
    } catch(e) {
    }
    if (fDone != true) {
      try {
      prev_element = top.findex.document.getElementById(ID_item + '#MN01');
      prev_element.className = prev_element.className.substr(0,5);
      fDone = true
      } catch(e) {
      }
    }
    if (fDone != true) {
      try {
      prev_element = top.findex.document.getElementById(ID_item + '#MN0001');
      prev_element.className = prev_element.className.substr(0,5);
      fDone = true
      } catch(e) {
      }
    }
  }
  if(ffSCROLL == true) {
    MM_here();
  } else {
    MM_here2(mmID);
  }
  fDone = false;
  ID_item = mmID;
  try {
    element=top.findex.document.getElementById(ID_chapter);
    element.className = element.className + 'Point';
    element=top.findex.document.getElementById(ID_item);
    element.className = element.className + 'Point';
    fDone = true;
    MM_scrollIntoView(element);
  } catch(e) {
  }
  if (fDone != true) {

    pp = ID_item.indexOf("#MN");
    if(pp >= 0) {
      ID_item = ID_item.substring(0, pp + 5);
    }

    try {
      element=top.findex.document.getElementById(ID_item);
      element.className = element.className + 'Point';
      fDone = true;
      MM_scrollIntoView(element);
    } catch(e) {
    }
  }
  if (fDone != true) {

    pp = ID_item.indexOf("#MN");
    if(pp >= 0) {
      ID_item = ID_item.substring(0, pp);
    }

    try {
      element=top.findex.document.getElementById(ID_item + '#MN01');
      element.className = element.className + 'Point';
      fDone = true;
      MM_scrollIntoView(element);
    } catch(e) {
    }
  }
  if (fDone != true) {
    try {
      element=top.findex.document.getElementById(ID_item + '#MN0001');
      element.className = element.className + 'Point';
      fDone = true;
      MM_scrollIntoView(element);
    } catch(e) {
    }
  }
  if (fDone != true) {
    try {
      element=top.findex.document.getElementById(ID_item);
      element.className = element.className + 'Point';
      MM_scrollIntoView(element);
    } catch(e) {
    }
  }
  try {
    top.if_navi.focus();
  } catch(e) {
  }
}

function MM_here2(fullname) {
try {
  var filarray = fullname.split('#');
  var filename = filarray[0];
  for (var i = 0; i < top.findex.files.length ; i++) {
    pp = top.findex.files[i].indexOf(':');
    if(pp >= 0) {
    ID_chapter = top.findex.files[i].substr(0, pp);
    ID_title = top.findex.files[i].substr(pp + 1);
    }
    if(filename.toLowerCase() == top.findex.files[i].toLowerCase()) {
    break;
    }
  }
} catch(e) {
}
}

function set_cookie(cname, cvalue) {
  var cookie_data = cname + "=" + escape(cvalue) + "; " + "path=/";
  document.cookie = cookie_data;
}

function get_cookie(cname) {
  var cookie_data = document.cookie + "; ";
  for (var i=0; i<cookie_data.length; i++) {
    var j = cookie_data.indexOf(";", i);
    var tmpStr = cookie_data.substring(i, j);
    var k = tmpStr.indexOf("=", 0);
    if (tmpStr.substring(0, k) == cname) {
      return unescape(tmpStr.substring(k+1, j));
    }
  }
  return("");
}

function MM_do_logo() {
  var str = get_cookie('@MANUAL_TITLE');
  if(str=='') {
    str = 'VCC-XXX';
  }
  document.write(str);
}

function resizeme() {
try {
  var pp = top.findex.MENU_ID;
  var rrr = submenu[pp].length - 1;

  var hhh = document.body.clientHeight;
  var www = document.body.clientWidth;
  if(hhh==0) {
    hhh = document.documentElement.clientHeight;
    www = document.documentElement.clientWidth;
  }

  var menu_height = (rrr + 1) * MENU_HEIGHT + 4;
  var yyy = 50;
  var h_index = hhh - yyy;
  var w_index = Math.floor(www * 21 / 100);

  if(ffHIDE_MENU != '') {w_index = 0;}

  var h_body = hhh - NAVI_HEIGHT;
  var w_body = www - w_index;

  top.document.getElementById('if_navi').style.width = " " + www + "px";

  top.document.getElementById('if_top').style.left = " " + w_index + "px";
  top.document.getElementById('if_top').style.width = " " + w_body + "px";

  top.document.getElementById('if_index').style.top = " " + yyy + "px";
  top.document.getElementById('if_index').style.width = " " + w_index + "px";
  top.document.getElementById('if_index').style.height = " " + h_index + "px";

  top.document.getElementById('if_body').style.left = " " + w_index + "px";
  top.document.getElementById('if_body').style.width = " " + w_body + "px";
  top.document.getElementById('if_body').style.height = " " + h_body + "px";

  top.document.getElementById('_fbody').style.width = " " + w_body + "px";
  top.document.getElementById('_fbody').style.height = " " + h_body + "px";

  top.document.getElementById('_findex').style.width = " " + w_index + "px";
  top.document.getElementById('_findex').style.height = " " + h_index + "px";

} catch(e) {
}
}

function MM_select(mmID) {
try {
  ID_select = mmID;
  timerID_select = setInterval('MM_select_sub()', 50);
  ffSCROLL = false;
  top.fbody.location = mmID;
} catch(e) {
}
}

function MM_select_sub() {
try {
  if(top.findex.document.readyState == 'complete') {
    MM_indexById(ID_select, false);
    clearInterval(timerID_select);
  }
} catch(e) {
}
}

function MM_go(mmm) {
try {
  for(;;) {
  if(document.readyState == 'complete') {
    top.fbody.location.reload(mmm);
    return;
  }
  }
} catch(e) {
}
}

function UpdateNavi(ID) {
try {
  ID += 1;
  for(i = 1 ; i <= submenu.length ; i++) {
    mmID = 'navi_' + i;
    top.document.getElementById(mmID).className = 'cat0';
  }
  mmID = 'navi_' + ID;
  top.document.getElementById(mmID).className = 'cat1';
} catch(e) {
}
}

function MM_menu_show(flg) {
try {
  var str = get_cookie('@HIDE_MENU_INDEX');
  if((flg==0)&&(str!='')) {return;}
  if((flg==1)&&(str=='')) {return;}
  if(flg==0) {
    top.document.getElementById('if_index').style.display = 'none';
    ffHIDE_MENU = 'yes';
    set_cookie('@HIDE_MENU_INDEX', 'yes');
  } else {
    top.document.getElementById('if_index').style.display = 'block';
    ffHIDE_MENU = '';
    set_cookie('@HIDE_MENU_INDEX', '');
  }
  resizeme();
} catch(e) {
}
}

function MM_scrollIntoView(em) {
  var command = IsInWindow(em);
  if(command < 0) {
    em.scrollIntoView(true);
  } else if (command > 0) {
    em.scrollIntoView(false);
  }
}

function IsInWindow(em) {
  var command = 0;
	var view = top.document.getElementById('if_index');
  try {
    var pos_yy = em.offsetTop;
    var tmpElement = em;
    for(;;) {
      if(tmpElement.tagName.toUpperCase()=='BODY') {
      break;
      }
      tmpElement = tmpElement.offsetParent;
      pos_yy += tmpElement.offsetTop;
    }
  } catch(e) {
  }
  var view_top = parent._findex.document.body.scrollTop;
  var view_bottom = view_top + view.offsetHeight;
  if(pos_yy < view_top) {
    command = -1;
  } else if (pos_yy > view_bottom) {
    command = 1;
  }
  return command;
}


