// main_mf.js   2004.2.29

var wofst = 0         //   横幅補正
var txleft = 0        // コメント位置 (com_p=2) 
var txtop = 20        // コメント位置 (com_p=2)

var m23_width = 980
var m23_height = 700

var f_cnt = new Array()
var f_name = new Array()
var f_alt = new Array()
var f_dat = new Array()

function Photo_datas()
{
   for(i = 0 ; i < 6 ; i = i + 1){
       f_dat[i] = fdat[i] 
   }
   
   for(i = 6 ; i < fdat.length - 3 ; i = i + 3){
      p = Math.abs(3 * fdat[i]) + 3
      f_dat[p] = fdat[i] 
      f_dat[p+1] = fdat[i+1]
      f_dat[p+2] = fdat[i+2]
   }
   return(f_dat)
}


var imgs , img 
function fuldsp(ims)
{
    imgs = ims
    photono = Imgno(img)
    if (fdat[0] == 0){window.open(subfile,"photon","fullscreen=1,scrollbars=1")}
    if (fdat[0] == 1){window.open(subfile,"photon","channelmode=1,fullscreen=1,scrollbars=1")}
    if (fdat[0] == 2){
         wsw = screen.availWidth
         hsh = screen.availHeight
         window.open(subfile,"photon","width="+wsw+",height="+hsh+",scrollbars=1,left=0,top=0")
    }
    if (fdat[0] == 3){window.open(subfile,"photon","channelmode=1,scrollbars=1")}
    if (fdat[0] == 4){window.open(subfile,"photon","fullscreen=1,scrollbars=1")}
    if (fdat[0] == 5){window.open(subfile,"photon","fullscreen=1,scrollbars=1")}
}


function Imgno(img)
{
    img = imgs
    return(img)
}

function chText(text,id) 
{
    if(document.getElementById){
         obj = document.getElementById(id);
         obj.childNodes[0].nodeValue = text;
    }
}


function getBrowserVersion()
{
    str   = navigator.appName.toUpperCase();
    version = 0;
    appVer  = navigator.appVersion;
    if (str.indexOf("NETSCAPE") >= 0){
        s = appVer.indexOf(" ",0);
        version = eval(appVer.substring(0,s));
        if (version >= 5){version++}
    }
    if (str.indexOf("MICROSOFT") >= 0){
        appVer = navigator.userAgent;
        sv = appVer.indexOf("MSIE ",0) + 5;
        ev = appVer.indexOf(";",sv);
        version = eval(appVer.substring(sv,ev));
     }
     return version;
}

function Photo_next()
{

    if((fmode != 1)&&(link_null != 'gif')){
       chText(link_next,'tx4')
       chText(link_back,'tx2')
    }
    fend = f_cnt[photo_no]
    photo_no++
    if((fend < 0)||(photo_no > dat_sum)){
        if(fnext == 1){
           javascript:close()
        }
        else{
           photo_no--
           if((fmode !=1)&&(link_null != 'gif')){chText(link_null,'tx4')}
        }
    }
    document.photo_a.src = f_name[photo_no]
    if ((version >= 5)&&(comnt>0)){chText(f_alt[photo_no],'tx1')}
}


function Photo_back()
{
    if(link_null != 'gif'){
       chText(link_next,'tx4')
       chText(link_back,'tx2')
    }
    photo_no--
    fend = f_cnt[photo_no]
    if((fend <= 0)||(photo_no == 0)){
        if(fnext == 1){
            javascript:close()
        }
        else{
            photo_no++
            if(link_null != 'gif'){
               chText(link_null,'tx2')
            }
        } 
    }
    document.photo_a.src = f_name[photo_no]
    if ((version >= 5)&&(comnt > 0)){chText(f_alt[photo_no],'tx1')}
}


function Read_pd()
{
   f_dat = window.opener.Photo_datas()
   fmode = f_dat[0]
   ftype = f_dat[1]
   max_w = f_dat[2]
   com_p = f_dat[3]
   hofst  = f_dat[4]
   fnext = f_dat[5]
   var j = 1
   for(i = 6 ; i < f_dat.length ; i = i + 3){
        f_cnt[j] = f_dat[i]
        f_name[j] = f_dat[i+1]+".jpg"
        f_alt[j] = f_dat[i+2]+"　　　　"
        j++
   }
   dat_sum = j-1  
   if (com_p == 2){com_p = 5}
} 

// *** 写真とフレーム表示 ***

function Sub_mf()
{
   fend = 0
   photo_no = window.opener.Imgno(img)
   photo_adrs = f_name[photo_no]
   cmt = f_alt[photo_no]

   display_width = screen.width
   display_height = screen.height

   if(navigator.appName == 'Netscape'){ntsp = 1} else {ntsp = 0} 
   getBrowserVersion()

// スクロールバー制御

   scr = "scroll=no"
   if(display_width < 1024){
       if((max_w > 640)||(display_width < 800)){scr = ""}
   }

// フレームサイズ

   if((display_width >= 1024)||(max_w > 640)){
       fwh = 1024 - wofst
       fht = 766 - hofst
   } 
   else{
       fwh = 800 - wofst
       fht = 596 - hofst
   }

   if ((ntsp == 1)||(scr == "")){
       fwh = fwh - 20
       fht = fht - 20
   }
   
   if (version < 5){fht = fht - 20}
   if(max_w == 0){
       fwh = 1024 - wofst
       fht = 768 - hofst
   }
   if (fmode == 5){
      if(display_width >= 1024){
          fwh= 1000 ; fht=764}
      else{
          fwh= 780 ; fht=596
      }
   }

// フレーム各部の幅

   border1 = border11
   border4 = Math.abs(border14)
   if((ftype == 0)||(ftype == 5)){
         border2 = border12 
         border3 = border13 
   }
   else{
         border2 = Math.ceil(border12 / (ftype + 0.5))
         border3 = Math.ceil(border13 / (ftype + 0.5))
   }

   border44 = 0
   if (border14 < 0){border44 = 1}

   if (fmode == 4){
       border1 = 0
       border2 = 0 
       border3 = 0 
   }

// フレーム各部の寸法

   fwh2 = fwh - border2 - border2
   fht2 = fht - border2 - border2
   fwh4 = fwh2 - border3 - border3
   fht4 = fht2 - border3 - border3

// リンク文字位置

   if(display_width <= 1024){
       link_hp = display_width - link_hpos 
   }
   else{
       link_hp = display_width/2 + 512 - link_hpos 
   }

   if((ntsp == 1)||(scr == "")){link_hp = link_hp - 20}

   link_ttl = 0
   if(link_null == '+gif'){link_null = 'gif' ; link_ttl = 1}

// コメント表示の有無

   comnt = 0
   if ((version >= 5)&&(com_p > 0)){comnt = 1}
   cmw = fwh * com_w

   if(link_vpos >= 40){link_vpos=40}
 
   if (fmode == 0){Dsp_m01()}  // 標準フレーム付き表示
   if (fmode == 1){Dsp_m01()}  // windows アイコン付き
   if (fmode == 2){Dsp_m23()}  // タイトルバー付き
   if (fmode == 3){Dsp_m23()}  // チャンネルモード
   if (fmode == 4){Dsp_m01()}  // フレーム無し表示
   if (fmode == 5){Dsp_m05()}  // シンプルモード

   document.open()
   document.write(s)
   document.close()
}


function Dsp_m01(){
    s ="<body bgcolor="+bk_color+" text="+tx_color+" link="+link_color+" vlink="+link_color+" alink="+link_color+" topmargin=0 leftmargin=0 marginheight=0 marginwidth=0 "+scr+">"

   if(fmode != 1){
        if(fnext == 0){
            Dsp_link0()
        } 
        else{
           Dsp_link1()
        }
   }
   s +="<CENTER><TABLE width="+fwh+" height="+fht+" cellspacing=0 cellpadding=0  bordercolor="+color11+" border="+border1+"><TBODY><TR><TD align='center' valign='middle' bgcolor="+color12+">"

   if ((comnt == 1)&&(com_p == 4)){s +="　<br>"}
   s +="<table bgcolor="+color13+" width="+fwh2+" height="+fht2+" cellspacing=0  cellpadding=0 border=0><tbody><tr><td align=center valign=middle>"
   s +="<Table bgcolor="+mt_color+" width="+fwh4+" height="+fht4+" cellspacing=0 cellpadding=0 border=0 background="+mt_image+"><tbody><tr><td align=center valign=middle >"

   if ((comnt == 1)&&(com_p >= 5)){s +="　<br>"}
   if(com_p != 1){  
       s +="<table cellspacing="+border15+" cellpadding="+border4+" border="+border44+" ><tbody><tr><td align=center valign=middle bgcolor="+color14+">"
   }
   else{
       s +="<table cellspacing=0 cellpadding="+border4+" border="+border44+" ><tbody><tr><td align=center valign=middle bgcolor="+color14+">"
   }
 
   if(fnext == 0)
   {
        s +="<a href='javascript:close()'><IMG SRC = "+f_name[photo_no]+" NAME='photo_a' border=0></a>"
   }
   else
   {
       if (version >= 5){
         s +="<img src = "+f_name[photo_no]+" NAME='photo_a' onClick='Photo_next()'>"
       }
       else{
           s +="<a href='javascript:Photo_next()'><IMG SRC = "+f_name[photo_no]+" NAME='photo_a' border=0></a>"
       }
   }

   s +="</td></tr></tbody></table>"

   if (comnt == 1){
         if(com_p == 3){s +="<br><SPAN STYLE= background:"+tx_bg1+" ID='tx1'>"+f_alt[photo_no]+"</SPAN>"
         }
         if(com_p == 5){s +="<SPAN STYLE= background:"+tx_bg1+" ID='tx1'>"+f_alt[photo_no]+"</SPAN>"
         }
   }
   s +="</Td></tr></tbody></table>"
   s +="</td></tr></tbody></table>"

  if ((comnt == 1)&&(com_p == 4)){
     s +="<big>　</big><SPAN STYLE= background:"+tx_bg1+" ID='tx1'>"+f_alt[photo_no]+"</SPAN>"
  }
  s +="</TD></TR></TBODY></TABLE>"

  if ((comnt == 1)&&(com_p == 1)){
      s +="<TABLE width="+cmw+" height="+border15+" cellpadding=0 cellspacing=0 border=0><TBODY>"
      s +="<TR><TD></TD></TR></TBODY></TABLE>" 
      s +="<TABLE width="+cmw+" cellpadding=5 cellspacing=0 border=0><TBODY>"
      s +="<TR><TD nowrap align='center' bgcolor="+tx_bg1+">"
      s +="<SPAN ID='tx1'>"+f_alt[photo_no]+"</SPAN>"
      s +="</TD></TR></TBODY></TABLE>"
  }
  s +="</CENTER>"
}


function Dsp_link1()
{
   if ((link_null == 'gif')&&(link_ttl == 1)){
       s +="<DIV STYLE='position:absolute; top:"+link_vpos+"; left:"+link_hp+"'>"
       s +="<a href='javascript:Photo_back()'><img src="+link_back+" border=0 title='前の写真'></a>"
       s +="<a href='javascript:close()'><img src="+link_close+" border=0 title='写真一覧'></a>"
       s +="<a href='javascript:Photo_next()'><img src="+link_next+" border=0 title='次の写真'></a></DIV>"
   }
   
   if ((link_null == 'gif')&&(link_ttl == 0)){
       s +="<DIV STYLE='position:absolute; top:"+link_vpos+"; left:"+link_hp+"'>"
       s +="<a href='javascript:Photo_back()'><img src="+link_back+" border=0></a>"
       s +="<a href='javascript:close()'><img src="+link_close+" border=0></a>"
       s +="<a href='javascript:Photo_next()'><img src="+link_next+" border=0></a></DIV>"
   }
    
   if (link_null != 'gif'){
       s +="<DIV STYLE='position:absolute; top:"+link_vpos+"; left:"+link_hp+"'><SPAN STYLE='background:"+link_bg+"'><font size=3><tt>&nbsp;&nbsp;"
       s +="<a href='javascript:Photo_back()' title='back'><SPAN ID='tx2'>"+link_back+"</SPAN></a>"
       s +="&nbsp;<a href='javascript:close()'>"+link_close+"</a>&nbsp;"
       s +="<a href='javascript:Photo_next()' title='next'><SPAN ID='tx4'>"+link_next+"</SPAN></a>&nbsp;&nbsp;</tt></font></SPAN></DIV>"
   }
}


function Dsp_link0()
{
   if (link_null == 'gif'){
      link_hp = link_hp + 100
      s +="<DIV STYLE='position:absolute; top:"+link_vpos+"; left:"+link_hp+"'>"
      s +="<a href='javascript:close()'><img src="+link_close+" border=0></a></DIV>"
   }
   else{

      s +="<DIV STYLE='position:absolute; top:"+link_vpos+"; left:"+link_hp+"'><SPAN STYLE='background:"+link_bg+"'>"
      s +="<font size=3><tt>"+link_null+"&nbsp;"
      s +="<a href='javascript:close()'>&nbsp;"+link_close+"&nbsp;</a>"+link_null+"&nbsp;</tt></font></SPAN></DIV>"
   }
}


function Dsp_link21()
{
    s +="<SPAN STYLE='background:"+link_bg+"'><font size=3><tt>&nbsp;&nbsp;"
    s +="<a href='javascript:Photo_back()' title='back'><SPAN ID='tx2'>"+link_back+"</SPAN></a>"
    s +="&nbsp;<a href='javascript:close()'>"+link_close+"</a>&nbsp;"
    s +="<a href='javascript:Photo_next()' title='next'><SPAN ID='tx4'>"+link_next+"</SPAN></a></tt></font></SPAN>"
}


function Dsp_link20()
{
    s +="<SPAN STYLE='background:"+link_bg+"'>"
    s +="<font size=3><tt>"+link_null+"&nbsp;"
    s +="<a href='javascript:close()'>&nbsp;"+link_close+"&nbsp;</a>"+link_null+"&nbsp;</tt></font></SPAN>"
}


function Dsp_m05()
{
   s ="<body bgcolor="+bk_color+" text="+tx_color+" link="+link_color+" vlink="+link_color+" alink="+link_color+" topmargin=0 leftmargin=0 marginheight=0 marginwidth=0>"
   s +="<CENTER><TABLE width="+fwh+" height="+fht+" cellspacing=0 cellpadding=0  bordercolor="+color11+" border="+border1+"><TBODY><TR><TD nowrap align='center' valign='middle' bgcolor="+color12+">"
   s +="<DIV align='right'><big>　</big><SPAN STYLE='background:"+link_bg+"'><font size=3><tt>&nbsp;&nbsp;"
   s +="<a href='javascript:Photo_back()' title='back'><SPAN ID='tx2'>"+link_back+"</SPAN></a>"
   s +="&nbsp;<a href='javascript:close()'>"+link_close+"</a>&nbsp;"
   s +="<a href='javascript:Photo_next()' title='next'><SPAN ID='tx4'>"+link_next+"</SPAN></a>&nbsp;&nbsp;</tt></font></SPAN></DIV>"
   s +="<table bgcolor="+color13+" width="+fwh2+" height="+fht2+" cellspacing=0  cellpadding=0 border=0><tbody><tr><td align=center valign='middle'>"
   s +="<Table bgcolor="+mt_color+" width="+fwh4+" height="+fht4+" cellspacing=0 cellpadding=0 border=0 background="+mt_image+"><tbody><tr><td align=center valign=middle >"
   s +="<table cellspacing="+border15+" cellpadding="+border4+" border="+border44+" ><tbody><tr><td align=center valign=middle bgcolor="+color14+">"

   if (version >= 5){
       s +="<img src = "+f_name[photo_no]+" NAME='photo_a' onClick='Photo_next()'>"
   }
   else{
       s +="<a href='javascript:Photo_next()'><IMG SRC = "+f_name[photo_no]+" NAME='photo_a' border=0></a>"
   }
  s +="</td></tr></tbody></table></Td></tr></tbody></table></td></tr></tbody></table>"
 
  if (comnt == 1){
     s +="<big>　</big><SPAN STYLE= background:"+tx_bg1+" ID='tx1'>"+f_alt[photo_no]+"</SPAN>"
  }
  else{s+="　<br>"}
  s +="</TD></TR></TBODY></TABLE><br><br><br><br><br></CENTER>"
}



function Dsp_m23()
{
   if((fmode == 2)||(fmode == 3)){
       m_width = m23_width
       m_height = m23_height
   }
   s ="<body background="+mt_image+" bgcolor="+mt_color+" text="+tx_color+" link="+link_color+" vlink="+link_color+" alink="+link_color+ " topmargin=3 marginheight=3 onBlur='focus()'>"
   s +="<center><TABLE width="+m_width+" height="+m_height+" cellspacing=0 cellpadding=0 border=0><TBODY>"
   s +="<TR><TD align='right' valign='top'>"
  
   if(fmode != 1){ 
        if (fnext == 0){Dsp_link20()} else {Dsp_link21()}
   }
   s +="</TD></TR><TR><TD align='center' valign='top'>"
   s +="<table cellspacing=5 cellpadding="+border4+" border=0><tbody><tr><td align=center valign=middle bgcolor="+color14+">"
   s +="<a href='javascript:Photo_next()'><IMG SRC = "+f_name[photo_no]+" NAME='photo_a' border=0></a>"
   s +="</td></tr></tbody></table></TD></TR>"
   s +="<TR><TD align='center' valign='bottom'>"
   
   if (comnt == 1){s +="<SPAN ID='tx1'>"+f_alt[photo_no]+"</SPAN>"}
   s +="<BR></TD></TR></TBODY></TABLE></center>"
}


function Dspsm1_11()
{
    Photo_datas()
    var s_name = new Array()
    var j = 1
    for(i = 6 ; i < f_dat.length ; i = i + 3){
         s_name[j] = f_dat[i+1]+"s.jpg"
         j++
    }
    
    s ="<TABLE cellpadding="+cell_p+" cellspacing=0 border=0><TBODY>"
    k=1
    s +="<TR><TD rowspan=3 colspan=3><A href='javascript:fuldsp("+ k +")'>"
    s +="<IMG src="+s_name[k]+" width="+w_sm1+" height="+h_sm1+" border=0></A></TD>"

    for(j = 1 ; j < 4 ; j = j + 1){
        for(i = 1 ; i < 3 ; i = i + 1){
            k++
            s += "<TD><A href='javascript:fuldsp("+ k +")'>"
            s +="<IMG src="+s_name[k]+" width="+w_sm2+" height="+h_sm2+" border=0></A></TD>"
        }
        s +="</TR><TR>"
    }
    for(i = 1 ; i < 6 ; i = i + 1){
        k++
        s += "<TD><A href='javascript:fuldsp("+ k +")'>"
        s +="<IMG src="+s_name[k]+" width="+w_sm2+" height="+h_sm2+" border=0></A></TD>"
    } 
    s +="</TR></TBODY></TABLE>"

    document.open()
    document.write(s)
    document.close()
}


function Dspsm1_8()
{
    Photo_datas()
    var s_name = new Array()
    var j = 1
    for(i = 6 ; i < f_dat.length ; i = i + 3){
         s_name[j] = f_dat[i+1]+"s.jpg"
         j++
    }
    
    s ="<TABLE cellpadding="+cell_p+" cellspacing=0 border=0><TBODY>"
    k=1
    s +="<TR><TD rowspan=2 colspan=2><A href='javascript:fuldsp("+ k +")'>"
    s +="<IMG src="+s_name[k]+" width="+w_sm1+" height="+h_sm1+" border=0></A></TD>"

    for(j = 1 ; j < 3 ; j = j + 1){
        for(i = 1 ; i < 3 ; i = i + 1){
            k++
            s += "<TD><A href='javascript:fuldsp("+ k +")'>"
            s +="<IMG src="+s_name[k]+" width="+w_sm2+" height="+h_sm2+" border=0></A></TD>"
        }
        s +="</TR><TR>"
    }
    for(i = 1 ; i < 5 ; i = i + 1){
        k++
        s += "<TD><A href='javascript:fuldsp("+ k +")'>"
        s +="<IMG src="+s_name[k]+" width="+w_sm2+" height="+h_sm2+" border=0></A></TD>"
    } 
    s +="</TR>"
    s +="</TBODY></TABLE>"

    document.open()
    document.write(s)
    document.close()
}
