// main_mf2.js   2004.3.7

// 表示モード  fmode
var fr_suisho = 1
var fr_ouban = 2
var fr_gentei = 3
var fr_nashi = 4
var fr_gazou = 5

// コメント位置   com_p
var cm_nashi = 0
var cm_shita = 1
var cm_soto = 2
var cm_uwe = 3 

// 操作ボタン   bottom
var moji = 1
var gazou = 2

// ｎｅｘｔ動作  fnext
var fn_auto = 1
var fn_end = 2
var fn_close = 3


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


function frameDatas()
{
    font_size = dat_s1[1] 
    color11 = dat_s1[2]
    color12 = dat_s1[3]
    color13 = dat_s1[4] 
    color14 = dat_s1[5]
    border11 = dat_s1[6]
    border12 = dat_s1[7]
    border13 = dat_s1[8]
    border14 = dat_s1[9]
    cell_sp4 = dat_s1[10]
    border16 = dat_s1[11]
    link_next = dat_s1[12]
    link_back = dat_s1[13]
    link_close = dat_s1[14]
    link_null = dat_s1[15]
    icon_close = dat_s1[16]
    icon_next = dat_s1[17]
    icon_back = dat_s1[18]
    icon_blank = dat_s1[19]
    chr_close = dat_s1[20]
    chr_next = dat_s1[21]
    chr_back = dat_s1[22]
    bk_color = dat_s1[23]
}


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(bottom == moji){
       chText(link_next,'tx_next')
       chText(link_back,'tx_back')
    }else{
       document.icon_b.src=icon_back
       document.icon_n.src=icon_next
    }
    
    fend = f_cnt[photo_no]
    photo_no++
    if((fend < 0)||(photo_no > dat_sum)){
        if(fnext == fn_auto){
           javascript:close()
        }else{
           photo_no--
           if(bottom == moji){
                chText(link_null,'tx_next')
           }else{
                document.icon_n.src=icon_blank
           }
        }
    }
    document.photo_a.src = f_name[photo_no]
    if (com_p > 0){chText(f_alt[photo_no],'tx1')}
}


function Photo_back()
{
    if(bottom == moji){
       chText(link_next,'tx_next')
       chText(link_back,'tx_back')
    }else{
       document.icon_b.src=icon_back
       document.icon_n.src=icon_next
    }
    
    photo_no--
    fend = f_cnt[photo_no]
    if((fend <= 0)||(photo_no == 0)){
        if(fnext == fn_auto){
            javascript:close()
        }else{
            photo_no++
            if(bottom == moji){
               chText(link_null,'tx_back')
            }else{
               document.icon_b.src=icon_blank
            }
        } 
    }
    document.photo_a.src = f_name[photo_no]
    if (com_p > 0){chText(f_alt[photo_no],'tx1')}
}


function Read_pd()
{
   f_dat = window.opener.Photo_datas()
   var j = 1
   fd = f_dat.length -12   
   for(i = 0 ; i < fd ; 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  

   fmode = f_dat[fd]
   
   ftype = f_dat[fd+1]
   bottom = f_dat[fd+2]
   com_p = f_dat[fd+3]
   hofst  = f_dat[fd+4]
   link_vpos = f_dat[fd+5]

   link_hpos = f_dat[fd+6]
   mt_image = f_dat[fd+7]
   mt_color = f_dat[fd+8]
   tx_color = f_dat[fd+9]
   link_color = f_dat[fd+10]
   debg = f_dat[fd+11]

   if((fmode >= 0)&&(fmode <= 9)){fnext = fn_auto} 
   if((fmode >= 10)&&(fmode <= 19)){
       fnext = fn_end
       fmode = fmode -10
   } 
   if((fmode >= 20)&&(fmode <= 29)){
       link_hpos = link_hpos + 20
       fnext = fn_close
       fmode = fmode - 20
   }
}

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

function Sub_mf()
{
    frameDatas()
    fend = 0
    photo_no = window.opener.imgNo(img)
    photo_adrs = f_name[photo_no]
    cmt = f_alt[photo_no]
	d_width = screen.width
    d_height = screen.height

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


// スクロールバー制御

    scr = " link="+link_color+" vlink="+link_color+" alink="+link_color+ " topmargin=0 leftmargin=0 marginheight=0 marginwidth=0 "
    if((d_width >= 1024)&&(netscape == 0)){scr = scr + "scroll=no"}

// フレーム各部のサイズ

	table_1w = 1024 ; table_1h = 768
	if(d_width < 1024){
		if((fmode == fr_suisho)||(fmode == fr_gentei)){
			table_1w = 800 ; table_1h = 600
		}
	}
	if (fmode == fr_nashi){table_1h = 730}
	if ((netscape == 1)||(d_width < 1024)){table_1w = table_1w - 20}
	table_1h = table_1h - hofst
    if (fmode == fr_gazou){table_1w = 1024 ; table_1h = 768}
    if (com_p == cm_soto){table_1h = table_1h - 30}

     border1 = border11
     if(d_width < 1024){
         link_vpos = link_vpos - 3
         border12 = Math.round(border12 * 0.8)
         border13 = Math.round(border13 * 0.8)
    }

    border123 = border12 + border13
    if(ftype <= 1){
         border2 = border12 
         border3 = border13 
    }
    if((ftype > 1)&&(ftype < 10)){
         border2 = Math.ceil(border12 / (ftype - 0.5))
         border3 = Math.ceil(border13 / (ftype - 0.5))
    }
    if(ftype > 10){
         border2 = Math.round((border12 / border123) * ftype)
         border3 = Math.round((border13 / border123) * ftype)
    }
    cell_pd4 = border14
    border4 = border16

    if (fmode == fr_nashi){
        border1 = 0 ; border2 = 0 ; border3 = 0 ; boder4 =0 ; cell_pd4 = 0
        mt_color = "#000000" ; mt_image = "" ; color14 ="#000000"
    }
    if (fmode == fr_gazou){
        border1 = 0 ; border2 = 0 ; border3 = 0
    }
    
    
    table_2w = table_1w - border2 - border2
    table_2h = table_1h - border2 - border2
    table_3w = table_2w - border3 - border3
    table_3h = table_2h - border3 - border3

// リンク文字位置

   if(d_width <= 1024){
       link_hp = d_width - link_hpos 
   }else{
       link_hp = d_width/2 + 512 - link_hpos 
   }
   if((netscape == fn_auto)||(d_width < 1024)){link_hp = link_hp - 20}
   if(debg == 1){link_hp = link_hp - 70}
   if(link_vpos >= 40){link_vpos = 40}

   if (version < 5){com_p = cm_nashi}

   if(fmode == fr_gentei){com_p = cm_uwe} 
   if(fmode == fr_nashi){com_p = cm_soto}
   if(fmode == fr_gazou){com_p = cm_shita}

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

   if (fmode > 0){
       Dsp_m1()
       document.open()
       document.write(s)
       document.close()
   }
}



function Dsp_m1()
{
	s ="<body bgcolor="+bk_color+" text="+tx_color + scr+">"
    if (fmode != fr_gentei){
        if(fnext == fn_close){Dsp_link0()} else {Dsp_link1()}
    }

	s +="<CENTER><TABLE width="+table_1w+" height="+table_1h+" cellspacing=0 cellpadding=0  bordercolor="+color11+" border="+border1+">"
    s +="<TBODY><TR><TD nowrap align='center' valign='middle' bgcolor="+color12+">"
    if (fmode == fr_gentei){link_gentei()}

    s +="<table bgcolor="+color13+" width="+table_2w+" height="+table_2h+" cellspacing=0  cellpadding=0 border=0>"
    s +="<tbody><tr><td align=center valign=middle>"

    s +="<Table bgcolor="+mt_color+" width="+table_3w+" height="+table_3h+" cellspacing=0 cellpadding=0 border=0 background="+mt_image+">"
    s +="<tbody><tr><td align=center valign=middle>"
    if (com_p == cm_shita){s +="　<br>"}

    s +="<table cellspacing="+cell_sp4+" cellpadding="+cell_pd4+" border="+border4 +">"
    s +="<tbody><tr><td align=center valign=middle bgcolor="+color14+">"
    if(fnext == fn_close){
        s +="<a href='javascript:close()'>"
        s +="<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()'>"
             s +="<IMG SRC = "+f_name[photo_no]+" NAME='photo_a' border=0></a>"
        }
    }
    s +="</td></tr></tbody></table>"
    if(com_p == cm_shita){
         s +="<font size="+font_size+">"
         s +="<SPAN ID='tx1'>"+f_alt[photo_no]+"</SPAN></font>"
    }
   
    s +="</Td></tr></tbody></table>"
    s +="</td></tr></tbody></table>"
    if(com_p == cm_uwe){
         s +="<big>　</big><font size="+font_size+" color="+link_color+">"
         s +="<SPAN ID='tx1'>"+f_alt[photo_no]+"</SPAN></font>"
    }

	s +="</TD></TR></TBODY></TABLE>"
    if (com_p == cm_soto){com_soto()}
    s +="</CENTER>"
}


function link_gentei()
{
   if(bottom == gazou){
       s +="<DIV align='right'>"
       s +="<a href='javascript:Photo_back()'>"
       s +="<img src="+icon_back+" border=0 NAME='icon_b' title="+chr_back+"></a>"
       s +="<a href='javascript:close()'>"
       s +="<img src="+icon_close+" border=0  NAME='icon_c' title="+chr_close+"></a>"
       s +="<a href='javascript:Photo_next()'>"
       s +="<img src="+icon_next+" border=0  NAME='icon_n' title="+chr_next+"></a>&nbsp;&nbsp;</DIV>"
   }
      
   if(bottom == moji){
       s +="<DIV align='right'>"
       s +="<font size=3><tt>&nbsp;&nbsp;"
       s +="<a href='javascript:Photo_back()' title="+chr_back+">"
       s +="<SPAN ID='tx_back'>"+link_back+"</SPAN></a>&nbsp;"
       s +="<a href='javascript:close()' title="+chr_back+">"+link_close+"</a>&nbsp;"
       s +="<a href='javascript:Photo_next()' title="+chr_next+">"
       s +="<SPAN ID='tx_next'>"+link_next+"</SPAN></a></tt></font>&nbsp;&nbsp;</DIV>"
   }
}


function com_soto()
{
    s +="<TABLE width="+table_1w+" height="+cell_sp4+" cellpadding=0 cellspacing=0 border=0>"
    s +="<TBODY><TR><TD></TD></TR></TBODY></TABLE>" 
    s +="<TABLE width="+table_1w+" cellpadding=5 cellspacing=0 border=0><TBODY>"
    s +="<TR><TD nowrap align='center' bgcolor="+tx_color+">"
    s +="<font size ="+font_size+" color="+link_color+">"
    s +="<SPAN ID='tx1'>"+f_alt[photo_no]+"</SPAN></font>"
    s +="</TD></TR></TBODY></TABLE>"
}


function Dsp_link1()
{
   if (bottom == gazou){
       s +="<DIV STYLE='position:absolute; top:"+link_vpos+"; left:"+link_hp+"'>"
       s +="<a href='javascript:Photo_back()'>"
       s +="<img src="+icon_back+" border=0 NAME='icon_b' title="+chr_back+"></a>"
       s +="<a href='javascript:close()'>"
       s +="<img src="+icon_close+" border=0 NAME='icon_c' title="+chr_close+"></a>"
       s +="<a href='javascript:Photo_next()'>"
       s +="<img src="+icon_next+" border=0 NAME='icon_n' title="+chr_next+"></a></DIV>"
   }

   if (bottom == moji){
       s +="<DIV STYLE='position:absolute; top:"+link_vpos+"; left:"+link_hp+"'>"
       s +="<font size=3><tt>&nbsp;&nbsp;"
       s +="<a href='javascript:Photo_back()' title='back'>"
       s +="<SPAN ID='tx_back'>"+link_back+"</SPAN></a>"
       s +="&nbsp;<a href='javascript:close()'>"+link_close+"</a>&nbsp;"
       s +="<a href='javascript:Photo_next()' title='next'>"
       s +="<SPAN ID='tx_next'>"+link_next+"</SPAN></a>&nbsp;&nbsp;</tt></font></DIV>"
   }
}


function Dsp_link0()
{
   if(bottom == gazou){
       link_hp = link_hp + 100
       s +="<DIV STYLE='position:absolute; top:"+link_vpos+"; left:"+link_hp+"'>"
       s +="<a href='javascript:close()'>"
       s +="<img src="+icon_close+" border=0  NAME='icon_c' title="+chr_close+"></a></DIV>"
   }

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







// *** main-mf2 ***

var errchk = 0
function Photo_datas()
{
    imax = fdat.length
    k = 1
    for(i = 0 ; i < imax - 12 ; i = i + 3){
        f_dat[i] = fdat[i] 
        chk = Math.abs(fdat[i])
        if(chk != k){
            errchk = 1
            alert('写真データを確認してください '+k)
        }
        f_dat[i+1] = fdat[i+1] 
        f_dat[i+2] = fdat[i+2] 
        k++
    }

    for(i = imax-12 ; i < imax ; i = i + 1){
        f_dat[i] = fdat[i] 
    }

    mode = f_dat[i-12]
    if ((mode > 0)&&(mode < 30)){
        icons = fdat[i-10]
        fmd = fdat[i-1]
    }else{
        fmd = 9
        errchk = 2
        alert('データを確認してください')
    }
    return(f_dat)
}


var imgs , img 
function fuldsp(ims)
{
    imgs = ims
    if (errchk == 0){
       photono = imgNo(img)
       if (fmd == 0){window.open(subfile,"photon","fullscreen=1,scrollbars=1")}
       if (fmd != 0){window.open(subfile,"photon","channelmode=1,fullscreen=1,scrollbars=1")}
    }
}    


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

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()
}


function DspMsg2(cr)
{
    s ="<TBODY><TR><TD nowrap align='left'>"
    s +="<P style='line-height:110%'><SMALL>"
    if (mode < 20){  
        s +="写真をクリックし、ご覧ください。各ページの［ → ］または写真の<BR>"
        if(icons == 2){
            s +="クリックで順に表示され、［ ↑ ］ をクリックすると閉じて戻ります。<BR>"
        }else{
            s +="クリックで順に表示され、［"+cr+"］をクリックすると閉じて戻ります。<BR>"
        }
    }else{
        s +="写真をクリックし、ご覧ください。各ページの写真、または<BR>"
        if(icons == 2){
            s +="［ ↑ ］ をクリックすると閉じて戻ります。<BR>"
        }else{
            s +="［"+cr+"］ をクリックすると閉じて戻ります。<BR>"
        }
    }
    s +="キーボードの［Ａｌｔ］と共に［Ｆ４］を押しても閉じます。"
    s +="</SMALL></P></TD></TR></TBODY>"

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