/* --------------------------*/
/* メニュー　表示スクリプト  */
/* --------------------------*/
/*  ＜使用方法＞             */
/*  1.メニューに追加したい項目を項目配列(arItems)に追加します。　                                   */
/*  　配列の設定内容は配列のコメントに記載されている順で設定します。   　                           */
/*  サブ項目(メニューの下に表示される項目)がある場合は、任意の配列を作成し追加します。            */
/*  新規に配列を作成した場合は、arIndex配列に項目配列の添字を追加します。                         */
/*  既にサブ項目の配列がある場合は、その配列に項目を追加してください。 　　　　　                 */
/*  ＜注意＞                 */
/*  メニュー情報を追加し保存したら、ＵＴＦ−８変換で変換し追加した配列部分だけをutf_menu.jsに　   */
/*  追加し保存をします。utf_menu.jsファイルでは関数内に独自の処理が入っているため、別名保存は　   */
/*  しないで下さい。utf_menu.jsファイルはＭａｃのＩＥ４で使用しています。                         */


/* フォルダ指定文字列 */
var addpos = '';

/* 項目配列(url, 項目名) */
var arItems = new Array();
  arItems[0] = new Array("topics.html", "Topics");
  arItems[1] = new Array("gallery_r.html", "Gallery R");
  arItems[2] = new Array("gallery_k.html", "Gallery K");
  arItems[3] = new Array("aboutus.html", "About Us");
  arItems[4] = new Array("link.html",    "Link"); 
  arItems[5] = new Array("contact.html", "Contact");

var arIndex = new Array("1", "2", "3");

/* gallery配列(url, 項目名) */
/* ()空 = 区切り線          */
var arGallery = new Array();
    arGallery[0]  = new Array("gallery_r.html", "ギャラリーR Top");
    arGallery[1]  = new Array();
    arGallery[2]  = new Array("gallery/shuraku.html",     "日本の集落");
    arGallery[3]  = new Array("gallery/satojapan.html",   "日本の里");
    arGallery[4]  = new Array("gallery/yosijima.html",    "吉島家住宅");
    arGallery[5]  = new Array("gallery/southitaly.html",  "南イタリアの集落");
    arGallery[6]  = new Array("gallery/genryu.html",      "源流から海まで");
    arGallery[7]  = new Array("gallery/sanyoso.html",    "三養荘");
    arGallery[8]  = new Array("gallery/yamamura.html", "旧山邑邸");
    arGallery[9]  = new Array("cgi/myonichikan.cgi?id=0", "明日館");
    arGallery[10]  = new Array("gallery/nihonnoie.html", "日本の家に逢いたい");

var arGallery2 = new Array();
    arGallery2[0] = new Array("gallery_k.html", "ギャラリーK Top");
    arGallery2[1] = new Array();
    arGallery2[2] = new Array("gallery/tedukuri.html",    "手作り写真");
    arGallery2[3] = new Array("gallery/berg.html",   "Ｂｅｒｇ邸");
    arGallery2[4] = new Array("gallery/naoi.html",   "Ｎ邸");
    arGallery2[5] = new Array("cgi/houjo.cgi?id=0", "Ｓｉｅｇｆｒｉｅｄａ");
    arGallery2[6] = new Array("gallery/daichido.html", "大地堂の眼");

/* aboutus配列(url, 項目名) */
var arProfile = new Array();
  arProfile[0]  = new Array("aboutus.html", "About Us");
  arProfile[1]  = new Array("aboutus/works_0.html", "Works");

/* ----------------------------------------------------------------- */
/* メニュー　書き出し関数 */
function writeMenu(flg){
  addpos = '';
  if(flg==1)  addpos = '../';
  var html = '';
  html += '  <table border="0" cellpadding="0" cellspacing="0" width="800px" align="center" bgcolor="#ffffff"> ';
  html += '    <tr><td class="fmBase" height="29px" width="100%"><img src="'+ addpos +'image/null.gif"></td><td class="fmBase" width="1px"><img src="'+ addpos +'image/null.gif"></td><td class="fmBase" width="1px"><img src="'+ addpos +'image/null.gif"></td><td class="fmBase" width="1px"><img src="'+ addpos +'image/null.gif"></td></tr>';
  html += '    <tr><td class="fmDark" width="100%" height="1px" colspan="4"><img src="'+ addpos +'image/null.gif"></td></tr>';
  html += '    <tr><td class="fmDark" width="100%" height="1px" colspan="4"><img src="'+ addpos +'image/null.gif"></td></tr>';
  html += '    <tr><td class="fmDark" width="100%" height="1px" colspan="4"><img src="'+ addpos +'image/null.gif"></td></tr>';
  html += '  </table>';
  html += '  <div class="menuon" id="menuimg"><img src="'+ addpos +'image/menu_on.gif"></div>';
  html += '  <!-- メニュー　項目名 -->';
  html += '  <div class="menuitem">';
  html += '    <table border="0" cellpadding="0" cellspacing="0" width="100%" align="center>';
  html += '      <tr>';
  html += '        <td valign="top">';
  html += '          <table border="0" cellpadding="0" cellspacing="0" width="800px" align="center"><tr>';
  
  for(var i=0; i < arItems.length; i++){
    html += '          <td class="menustr" id="itm' + i + '" width="85px" nowrap><a href="'+ addpos + arItems[i][0] +'" onMouseOver="mouseon('+ i +');" onMouseOut="mouseout('+ i +');"><div class="items">'+ arItems[i][1] +'</div></a></td>';
    html += '          <td class="menustr" id="menuline" width="1px">｜</td>';
  }         

  html += '            <td id="alRight" id="menuline"><a href="'+ addpos +'index.html"><img src="'+ addpos +'image/atelier_r.gif" alt="Homeへ" border="0"></a></td>';
  html += '          </tr></table>';
  html += '        </td>';
  html += '      </tr>';
  html += '    </table>'; 
  html += '  </div>';

  writeHtml('menubar', html);
}
/* サブメニュー(gallery)　書き出し関数 */
function writeSubMenu(){
  var html ='';
  for(var j = 0; j < arIndex.length; j++){
    if(j == 0)      html = writeSubTable(arGallery); 
    else if(j == 1) html = writeSubTable(arGallery2); 
    else            html = writeSubTable(arProfile);
    writeHtml('submenu' + arIndex[j], html);  
  }
}
function writeSubTable(ar){
  var html ='';
  html += '  <table border="1" cellpadding="1" cellspacing="1" width="1px" align="left">';
  html += '    <tr id="submenu"><td id="submenu">';
  html += '      <table border="0" cellpadding="3" cellspacing="3" align="left">';
    
  for(var i = 0; i < ar.length; i++){
   if(ar[i].length < 1) html += '    <tr><td class="submenustr" nowrap><hr></hr></td></tr>';
   else                 html += '    <tr><td class="submenustr" nowrap><a href="'+ addpos + ar[i][0] +'">'+ ar[i][1] +'</a></td></tr>';
  }

  html += '      </table>';
  html += '    </td></tr>';
  html += '  </table>';

  return html;
}
/* 書き出し関数 */
function writeHtml(nm, html){

  if (document.all) {                // IE
    document.all(nm).innerHTML = html;

  }else if(document.getElementById){ // Mozilla 5( NN6 )
    document.getElementById(nm).innerHTML = html;
  }else if (document.layers) {
    with (document.layers[nm]) {     // NN
      document.open();
      document.write(html);
      document.close();
    }
  }
}
/* メニュー選択 */
function mouseon(index){

  var divst = document.all?document.all('menuimg').style:
             (document.getElementById?document.getElementById('menuimg').style:
             (document.layers?document.layers['menuimg']:  null));

  if(divst){
     var id = index;
     if(id > 9) id = index / 10; 
	if(document.layers)	{
		var w=innerWidth;
		var h=innerHeight;
	}else{
		var w=document.body.offsetWidth;
		var h=document.body.offsetHeight;
	}
	var mw = (w / 2) - 415;
     if(mw < 1) mw = 0; 
     var leftpos = (id * 100) + mw;
     if(document.getElementById && !document.all){ leftpos += 10; }

     divst.left  = leftpos;
     divst.visibility = 'inherit';
     divst.zIndex = 1;

    if(id==1 || id==10) isDiv('submenu1', 0, leftpos - 5);
    if(id==2 || id==20) isDiv('submenu2', 0, leftpos - 5);
    if(id==3 || id==30) isDiv('submenu3', 0, leftpos - 5);  
  }
}
/* メニュー非選択 */
function mouseout(id){
  isDiv('menuimg', 1, 0); 
  if(id==1 || id==10) isDiv('submenu1', 1, 0);
  if(id==2 || id==20) isDiv('submenu2', 1, 0);
  if(id==3 || id==30) isDiv('submenu3', 1, 0);
}
/* レイヤー表示関数 */
function isDiv(nm, flg, leftpos){
  var divst = document.all?document.all(nm).style:
             (document.getElementById?document.getElementById(nm).style:
             (document.layers?document.layers[nm]:  null));

  if(divst){
    if(flg == 0){
      divst.visibility = 'visible';
      divst.left = leftpos + 'px';
    }else{
      divst.visibility = 'hidden';    
    }
  }
}
/* (メイン)インデックス書き出し関数 */
function htmlSubTitleStr(index, col, flg, w){
  var str = "";
  var add = "";
  if(flg == 1) add = "../";
  str += '<table border="0" cellpadding="0" cellspacing="1" width="'+ w +'" align="center" bgcolor="#ffffff"><tr><td>';
  str += '  <table border="0" cellpadding="0" cellspacing="1"  align="left">';
  str += '  <tr>';
  str += '  <td id="alLeft" width="1px"><img src="'+ add +'image/mark_'+ col +'.gif"></td>';
  str += '  <td id="alLeft" width="150px">';
  str += '    <table border="0" cellpadding="1" cellspacing="1" width="100%">';
  str += '    <tr><td class="idtitle" id="alCenter" nowrap="nowrap">'+ index +'</td></tr>';
  str += '    </table>';
  str += '  </td>';
  str += '  <td id="alLeft" width="1px"><img src="'+ add +'image/mark_'+ col +'.gif"></td>';
  str += '  </tr>';
  str += '  </table>';
  str += '</td></tr></table>';
  str += '';

  return str;
}
function htmlSubTitle(index, col, add){
  var str = htmlSubTitleStr(index, col, add, '800px');
  document.write(str);
}
function htmlSubTitleEx(index, col, add, w){
  var str = htmlSubTitleStr(index, col, add, w);
  document.write(str);
}

