// main_mf.js   2004.2.7

wofst = 0         //   横幅補正

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] == 5)
    {
         lsw = screen.availWidth - fdat[2] - 20
         window.open(subfile,"photon","width="+fdat[2]+",height="+fdat[3]+",scrollbars=0,left="+lsw+", top=2")
    }
}


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()
{
    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--
               chText(link_null,'tx4')
           } 
    }
    document.photo_a.src = f_name[photo_no]
    if ((version >= 5)&&(fnext>0)){chText(f_alt[photo_no],'tx1')}
    
}


function Photo_back()
{
    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++
            chText(link_null,'tx2')
        } 
    }
    document.photo_a.src = f_name[photo_no]
    if ((version >= 5)&&(fnext > 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]
   max_h = 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  
} 


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.heigth

   if(display_width >= 1024)
   {
       fwh = 1024 - wofst
       fht = 768 - hofst
   } 
   else
   {
       fwh = 800 - wofst
       fht = 600 - hofst
   }

   ntsp = 0
   if(navigator.appName == 'Netscape'){ntsp=1} 
   getBrowserVersion()

   if (ntsp == 1)
   {
       fwh = fwh - 20
       fht = fht - 20
   }

   if (version < 5){fht = fht - 20}
 
   if(ftype < 1)
   {
         border1 = border11
         border2 = border12 
         border3 = border13 
         border4 = border14
   }
   else
   {
         border1 = border11
         border2 = Math.ceil(border12 / (ftype+0.5))
         border3 = Math.ceil(border13 / (ftype+0.5))
         border4 = border14
   }

   scr = "scroll=no"
   if(display_width < 1024)
   {
       if((max_w > 640)||(max_h>480)){scr = ""}
   }
   
   if(display_width <= 1024)
   {
       link_hp = (display_width + fwh)/2 - link_hpos 
   }
   else
   {
       link_hp = display_width/2 + 512 - link_hpos 
   }

   if((ntsp == 1)||(display_width < 1024)){link_hp = link_hp - 20}
   if((fmode == 1)&&(ntsp == 0)){link_hp = link_hp - 80}

   fwh2 = fwh - border2 - border2
   fht2 = fht - border2 - border2
   fwh4 = fwh2 - border3 - border3
   fht4 = fht2 - border3 - border3

   comnt = 0
   if ((version >= 5)&&((max_w + max_h) > 0)){comnt = 1}
   
   if (fmode < 2)
   {
      if (fnext == 0)
         {Dsp_m10()}
      else
         {Dsp_m0()}
   }

   if ((fmode == 2)||(fmode == 3)){Dsp_m3()}
   if (fmode > 3){Dsp_m5()}
   
   document.open()
   document.write(s)
   document.close()
}


function Dsp_m0()
{
    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+">"
 
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+">"
  
   s +="<table bgcolor="+color13+" width="+fwh2+" height="+fht2+" cellspacing=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){s +="　<br>"}
  
   s +="<table cellspacing="+border15+" 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>\n"
  
   if (comnt == 1){s +="<SPAN ID='tx1'>"+f_alt[photo_no]+"</SPAN>"}
  
   s +="</Td></tr></tbody></table>"
   s +="</td></tr></tbody></table>"
   s +="</TD></TR></TBODY></TABLE></CENTER>"
}


function Dsp_link1()
{
    s +="<DIV STYLE='position:absolute; top:"+link_vpos+"; left:"+link_hp+"'><SPAN STYLE='background:"+link_bg+"'><font size=3><tt>&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>"
    s +="&nbsp:</tt></font></SPAN></DIV>"
}


function Dsp_link0()
{
    s +="<DIV STYLE='position:absolute; top:"+link_vpos+"; left:"+link_hp+"'><font size=3><tt>"
    s +="&nbsp;<a href='javascript:close()'>"+link_close+"</a>&nbsp;"
    s +="</tt></font></DIV>"
 }









function Dsp_m3()
{
   s ="<body background="+mt_image+" bgcolor="+mt_color+" text="+tx_color+" link="+tx_color+" vlink="+tx_color+" alink="+tx_color+ " topmargin=3 marginheight=3 onBlur='focus()'>"
   s +="<center><TABLE width='100%' cellspacing=0 cellpadding=0 border=0><TBODY>"
   s +="<TR><TD align='right' valign='top'>"
   s +="<font size=3><a href='javascript:Photo_back()' title='back'>&nbsp;"+link_back+"</a>&nbsp;&nbsp;"
   s +="<a href='javascript:close()'>&nbsp;"+link_close+"</a>&nbsp;&nbsp;"
   s +="<a href='javascript:Photo_next()' title='next'>&nbsp;"+link_next+"&nbsp;</a></font>"
   
   s +="</TD></TR>"
   s +="<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='top'>"
   if (comnt == 1){s +="<SPAN ID='tx1'>"+f_alt[photo_no]+"</SPAN>"}
   s +="</TD></TR></TBODY></TABLE></center>"
}


function Dsp_m5()
{
   s ="<body background="+mt_image+" bgcolor="+mt_color+" text="+tx_color+" link="+tx_color+" vlink="+tx_color+" alink="+tx_color+ " topmargin=3 marginheight=3 onBlur='focus()'>"
   s +="<center><TABLE width='100%' height='100%'><TBODY>"
   s +="<TR><TD align='right' valign='top'>"
   if(fnext > 0)
   { 
  
      s +="<font size=3><a href='javascript:Photo_back()' title='back'>&nbsp;"+link_back+"</a>&nbsp;&nbsp;"
      s +="<a href='javascript:close()'>&nbsp;"+link_close+"</a>&nbsp;&nbsp;"
      s +="<a href='javascript:Photo_next()' title='next'>&nbsp;"+link_next+"&nbsp;</a></font>"
  
   }
   s +="<br></TD></TR>"
   s +="<TR><TD align='center' valign='middle'>"
   s +="<table cellspacing=5 cellpadding="+border4+" border=0><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 alt='close'></a>"
   }
   else
   {
       s +="<a href='javascript:Photo_next()'><IMG SRC = "+f_name[photo_no]+" NAME='photo_a' border=0 alt='next'></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 Dsp_m10()
{
   s ="<body bgcolor="+bk_color+" text="+tx_color+" topmargin=0 leftmargin=0 marginheight=0 marginwidth=0 "+scr+">"
   s +="<center><TABLE width="+fwh+" height="+fht+" cellspacing=0 cellpadding=0  bordercolor="+color11+" border="+border1+">"
   s +="<TBODY><TR><TD align='center' valign='middle' bgcolor="+color12+">"
   s +="<table bgcolor="+color13+" width="+fwh2+" height="+fht2+" cellspacing=0  border=0>"
   s +="<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+">"
   s +="<tbody><tr><td align=center valign=middle >"
   if (comnt == 1){s +="　<br>"}
   s +="<table cellspacing=5 cellpadding="+border4+" border=0 >"
   s +="<tbody><tr>\n"
   s +="<td align=center valign=middle bgcolor="+color14+">"
   s +="<a href='javascript:close()'><IMG SRC = "+f_name[photo_no]+" NAME='photo_a' border=0></a>"
   s +="</td></tr></tbody></table>\n"
   if (comnt == 1){s +="<SPAN ID='tx1'>"+f_alt[photo_no]+"</SPAN>"}
   s +="</td></tr></tbody></table>"
   s +="</td></tr></tbody></table>"
   s +="</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>"
    s += "<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>"
    s +="</TBODY></TABLE>"

    document.open()
    document.write(s)
    document.close()
}
