TableWidth = 598;
MenuWidth = 0;
MenuHeight = 113;
CurrentMenu = -1;
ImageNum = 14;
ConstMes = '現在作成中です';

EnglishPage = location.pathname.replace('jp', 'en');

CheckBrowzer();

function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function CheckInnerWidth(){
  if (Browzer == 'IE') {
    w = document.body.clientWidth;
  } else if (Browzer == 'NN' || Browzer == 'Opera') {
    w = innerWidth;
  } else {
    w = 0;
  }

  if (w < TableWidth) { MenuWidth = 0; }
  else { MenuWidth = (w - TableWidth)/2; }

  // Hide CurrentMenu
  if (CurrentMenu != -1) {
    MenuWindowHide(CurrentMenu);
    CurrentMenu = -1;
  }
}

function MenuWindowView(id, x) {
  if (document.all) {
    document.all.item(id).style.pixelLeft = MenuWidth + x;
    document.all.item(id).style.visibility = "visible";
  }
}

function MenuWindowHide(id) {
  if (document.all) {
    document.all.item(id).style.visibility = "hidden";
  }
}

function ClickMenu(id, x) {
  if (document.all) {
    if (id == '01') { return true; }

    if (Browzer == 'Opera') { CheckInnerWidth(); }

    if (CurrentMenu != -1) { MenuWindowHide(CurrentMenu); }
    if (CurrentMenu != id) {
      MenuWindowView(id, x);
      CurrentMenu = id;
    } else {
      CurrentMenu = -1;
    }
    if (id != '01') { return false; }
  }
}

function Loading(){
  CheckBrowzer();
  CheckInnerWidth();
  MM_preloadImages('../../image/img_r2_c01_f2.gif','../../image/img_r2_c02_f2.gif','../../image/img_r2_c03_f2.gif','../../image/img_r2_c05_f2.gif','../../image/img_r2_c06_f2.gif','../../image/img_r2_c07_f2.gif','../../image/img_r2_c08_f2.gif','../../image/img_r2_c09_f2.gif');
}

function DispMenu(){
  if (document.all) {
    a = DispMenu.arguments;
    document.write('<div id="'+a[0]+'" style="position: absolute; top: '+MenuHeight+'; visibility: hidden;">');
    document.write('<table border="0" cellspacing="0" cellpadding="4" class="t1">');
    if (a.length == 1) {
      document.write('<tr><td nowrap background="../../image/img_menubg.gif" class="t2">');
      document.write(ConstMes);
      document.write('</td></tr>');
    } else {
      for(i=1; i<(a.length-1); i+=2) {
        document.write('<tr><td nowrap background="../../image/img_menubg.gif" class="t2">');
        document.write('<a href="'+a[i+1]+'">'+a[i]+'</a>');
        document.write('</td></tr>');
      }
    }
    document.write('</table>');
    document.write('</div>');
  }
}

function ChangeImage(){
  ImageName = 'topimg';
  suf = '.gif';
  n = Math.round(ImageNum * Math.random());
  if (n < 10) { n = '0' + n; }
  ImgSrc = ImageName + n + suf;
  document.write('<td colspan="5"><img name="img_r1_c01" src="../../image/'+ImgSrc+'" width="352" height="84" border="0"></td>');
}

function CheckBrowzer() {
  // IE, NN, or Opera

  ver = navigator.appVersion;
  agent = navigator.userAgent;
  dom = ( document.getElementById ) ? true:false;
  ie = ( document.all ) ? true:false;
  nn = ( document.layers ) ? true:false;
  ope = ( agent.indexOf('Opera') > -1 );

  isWin = ( ver.indexOf('Win') > -1 );
  isMac = ( ver.indexOf('Mac') > -1 );

  isOpera6 = ( ope && dom );
  isIe4r = ( !ope && ( agent.indexOf('MSIE') > -1 ) && !dom && ie );
  isIe50 = ( !ope && ( agent.indexOf('MSIE 5.0') > -1 ) && dom );
  isIe55 = ( !ope && ( agent.indexOf('MSIE 5.5') > -1 ) && dom );
  isIe60 = ( !ope && ( agent.indexOf('MSIE 6.0') > -1 ) && dom );
  isNn40 = ( nn && !dom && ( ver.toUpperCase().indexOf('4.0') > -1 ));
  isNn4x = ( nn && !dom && ( parseInt(ver) == 4 ));
  isNn6x = (( parseFloat(ver) >= 5.0 ) && dom );

  exBrows = ( !isOpera6 && !isIe4r && !isIe50 && !isIe55 && !isIe60 && !isNn4x && !isNn6x );

  if (isOpera6) {
    Browzer = 'Opera';
    MenuHeight = MenuHeight - 3;
  } else if (isIe4r || isIe50 || isIe55 || isIe60) {
    Browzer = 'IE';
  } else if (isNn40 || isNn4x || isNn6x) {
    Browzer = 'NN';
  } else {
    Browzer = 'Other';
  }
}
