// mn-sub.js    2005.3.10 // 

icon_back = "mn_back.gif"   // BACK アイコン画像
icon_home = "mn_home.gif"   // HOME アイコン画像
icon_next = "mn_next.gif"   // NEXT アイコン画像

title_back = ""             // BACK ボタン title
title_home = "戻る"         // HOME ボタン title
title_next = ""             // NEXT ボタン title

butn_back = " <<< "         // BACK ボタン文字
butn_home = "Home"          // HOME ボタン文字
butn_next = " >>> "         // NEXT ボタン文字

var ns_ver =" mn-sub   5312a"  

var wtime = 1500       //  close time
var nrdsp = 40         //  連番表示幅

var dat_sum 
var photo_no = 1
var next_back = 0
var blend = 0
var bk_click ="back" , nx_click ="next" , hp_click ="http"
var ret_url = "" 
var e_wipe = 0 ; t_wipe = 0 ; wipe = 0

var topTm = 1
var tm_ph = new Array()
var f_name = new Array()
var f_com1 = new Array()
var f_numb = new Array()
var photo_h = new Array()


/* パソコン情報 */
xpsp2 = 0
strv = navigator.appName.toUpperCase();
if(window.navigator.userAgent.indexOf("SV1") >= 0){xpsp2 = 54}

var sc_width = screen.width 
var sc_height = screen.height

//  sc_height = screen.availHeight
// if(sc_width <= 1024){sc_height = screen.height}

/* サブウインド補正 */
wname = window.name 
if(wname == "fm"){
      if(xpsp2 == 0){moveTo(0,0) ; resizeTo(sc_width,sc_height)}
      if((xpsp2 > 0)&&(sc_width > 1024)){moveTo(0,0) ; resizeTo(sc_width,sc_height)}
}
if(wname == "fn"){moveTo(0,0) ; resizeTo(sc_width,sc_height)}


/* 写真データ読み込み */
function readData(rdtype)
{
   j = 1
   fpd = f_dat.length - 2   
   for(i = 0 ; i < fpd ; i = i + 2){
        f_name[j] = f_dat[i]
        f_com1[j] = f_dat[i+1]
        j++
   }
   dat_sum = j-1

   for(i = 1 ; i <= dat_sum ; i=i+1){
           f_numb[i] = i +"/"+  dat_sum 
   }
   
   str1 = location.search
   if(str1.length == 0){str1 = '?1'}
   photo_no = parseInt(str1.substring(1,str1.length))
   status = ns_ver
}


/* スクロールバー表示 */
function contScrl(color_s1 , color_s2 , color_s3 , scont){
   sc ="<style type='TEXT/CSS'>"
   sc +="BODY{"
   if((sc_width >=1024)&&(scont == 0)){sc +="overflow : hidden;"}
   
   sc +=" scrollbar-base-color:"+color_s2+";"
   sc +=" scrollbar-darkshadow-color:"+color_s2+";"
   sc +=" scrollbar-face-color:"+color_s2+";"
   sc +=" scrollbar-arrow-color:"+color_s1+";"
   sc +=" scrollbar-highlight-color:"+color_s1+";"
   sc +=" scrollbar-3dlight-color:"+color_s3+";"
   sc +=" scrollbar-track-color:"+color_s3+";"
   sc +=" scrollbar-shadow-color:"+color_s3+"};"
   sc +="</style>"
   document.open() ; document.write(sc) ; document.close()
}


/* アイコン表示 */
function dspIcon(pos_top,pos_left,url)
{
    if(url != ""){hp_click = url ; ret_url = url }
    sty=" style='filter:alpha(opacity = 40);-moz-opacity:0.4' "
    s =""
    if(pos_top >= 0){    
        s +="<DIV style='position:absolute ; top:"+pos_top+ " ; left:0 ; z-index=5'>"
        s +="<TABLE width=100% cellpadding=0 cellspacing=0 border=0>"
        s +="<TBODY><TR><TD nowrap align=right>"
    }
    s +="<TABLE width="+pos_left+" cellpadding=0 cellspacing=0 border=0>"
    s +="<TBODY><TR><TD nowrap align=left valign=bottom>"
    s +="<img src='mn_back.gif' border=0  onClick='nextPhoto(bk_click)' name='pback'"+sty+" ID='Icon' title="+title_back+">"
    s +="<img src='mn_home.gif' border=0  onClick='nextPhoto(hp_click)' name='phome'"+sty+"  ID='Icon' title="+title_home+">"
    s +="<img src='mn_next.gif' border=0  onClick='nextPhoto(nx_click)' name='pnext'"+sty+"  ID='Icon' title="+title_next+">"
    s +="</TD>"
    if(nrdsp > 0){dspNumb()}
    s +="</TR></TBODY></TABLE>"
    if(pos_top >= 0){    
        s +="</TD></TR></TBODY></TABLE></DIV>"
    }
    document.open() ; document.write(s) ; document.close()
 
   objp1 = document.images['pback'].style
   objp2 = document.images['phome'].style
   objp3 = document.images['pnext'].style
}


/* 連番表示 */
function dspNumb()
{
    s +="<TD nowrap width="+nrdsp+" align=left valign=bottom>"
    s +="<SPAN ID='numb'>"+f_numb[photo_no]+"</SPAN></TD>"
}


/* アイコン制御 */
function iconContX(icon1,icon2,icon3)
{
// if(icon1 > 0){objp1.visibility = "visible"} else {objp1.visibility = "hidden"}
// if(icon2 > 0){objp2.visibility = "visible"} else {objp2.visibility = "hidden"}
   if(icon3 > 0){objp3.visibility = "visible"} else {objp3.visibility = "hidden"}
  
   if(icon1 > 0){objp1.cursor = "hand"} else {objp1.cursor = "default"}
   if(icon2 > 0){objp2.cursor = "hand"} else {objp2.cursor = "default"}
   if(icon3 > 0){objp3.cursor = "hand"} else {objp3.cursor = "default"}
}


function iconCont(icon1,icon2,icon3)
{
   if(document.all){
        if(icon1 > 0){pback.filters['alpha'].opacity = 100} else {pback.filters['alpha'].opacity = 40}
        if(icon2 > 0){phome.filters['alpha'].opacity = 100} else {ptop.filters['alpha'].opacity = 40}
        if(icon3 > 0){pnext.filters['alpha'].opacity = 100} else {pnext.filters['alpha'].opacity = 40}
   }else{
        if(icon1 > 0){objp1.MozOpacity = 1.0} else {objp1.MozOpacity = 0.4}
        if(icon2 > 0){objp2.MozOpacity = 1.0} else {objp2.MozOpacity = 0.4}
        if(icon3 > 0){objp3.MozOpacity = 1.0} else {objp3.MozOpacity = 0.4}
   }
        if(icon1 > 0){objp1.cursor = "pointer"} else {objp1.cursor = "default"}
        if(icon2 > 0){objp2.cursor = "pointer"} else {objp2.cursor = "default"}
        if(icon3 > 0){objp3.cursor = "pointer"} else {objp3.cursor = "default"}
}


/* 写真表示 */
function dspPhoto(pcon)
{
    if(document.layers){alert("お使いのブラウザでは正しく表示されない場合があります。")}
    next_back = pcon
    mn ="next"
    s  ="<Table cellspacing=0 border=0 cellpadding=0 ID='Pcolor' >"
    s +="<Tbody><Tr><Td nowrap>"
    s +="<Table cellspacing=0 border=0 cellpadding=0 ID='Photo'>"
    s +="<Tbody><Tr><Td nowrap>"
    s +="<img src = "+f_name[photo_no]+" NAME='photo_a' onClick='nextPhoto(nx_click)' "
  
    if(document.all){
         if((blend > 0)||(wipe > 0)){
              if(blend > 0){s +="style='filter:blendTrans(duration="+blend+")'"}
              if(wipe > 0){s +="style='filter:revealTrans(duration="+t_wipe+",transition="+e_wipe+")'"}
         }else{
              if(next_back == 2){s +=" style='filter:alpha(style=2,opacity=100,finishopacity=10,enabled=0)' "}
         }
    }else{
         if(next_back == 2){s +=" style='filter:alpha(opacity = 100);-moz-opacity:1.0' "}
    }
  
    s +="></Td></Tr></Tbody></Table>"
    s +="</Td></Tr></Tbody></Table>"
 
   if((blend > 0)||(wipe > 0)){
       if(photo_no < dat_sum){
           left2 = sc_width - 30
           s +="<DIV style='position:absolute ; top:0 ; left:"+left2+" ; z-index=6'>"
           s +="<img src="+f_name[photo_no+1]+" width=10 height=10 border=0  name='photo2'>"
           s +="</DIV>"
       }
    }
  
    document.open() ; document.write(s) ; document.close()
    if(next_back == 0){iconCont(0,2,3)}
    if(next_back == 1){iconCont(1,2,3)}
    if(next_back == 2){iconCont(0,2,3)}
    if((photo_no > 1)&&(photo_no <= dat_sum)){iconCont(1,2,3)}
    return next_back
}


function startPhoto()
{
  document.getElementById("Photo").style.visibility = 'visible'
}


function preRead()
{
    if(photo_no < dat_sum){
        photo_h[photo_no] = new Image()
        photo_h[photo_no].src = f_name[photo_no]
        document.photo2.src = f_name[photo_no+1] 
    }
}


/* ブレンド効果 */
function blendEffect()
{
    if(document.all){
        photo_a.filters.blendTrans.Apply()
        document.photo_a.src = f_name[photo_no]
        photo_a.filters.blendTrans.Play()
    }
}


/* ワイプ効果 */
function wipeEffect()
{
    if(document.all){
         photo_a.filters.revealTrans.Apply()
         document.photo_a.src = f_name[photo_no]
         photo_a.filters.revealTrans.Play()
    }
}


/* コメント表示 */
function dspComn(cmpos)
{
    s  ="<table cellpadding=0 cellspacing=0 border=0 ID='Comn'><tbody><tr>"
    if(cmpos == 1){
         s +="<td nowrap align=left valign=top>"
    }else{ 
         s +="<td nowrap align=center valign=top>"
    }
    s +="<SPAN ID='tx1'>　</SPAN>"
    s +="</td></tr></tbody></table>"
    document.open() ; document.write(s) ; document.close()
    document.getElementById("tx1").innerHTML = f_com1[photo_no]
}


/* 操作ボタン処理 */
function nextPhoto(np)
{
   if((np =="back")||(np =="next")){ 
        if(np =="back"){
             if(photo_no >= 1){photo_no--}
             if(photo_no < 1){
                  if(next_back == 0){photo_no++}                    // stop
                  if(next_back == 1){photo_no = dat_sum}            // loop
                  if(next_back == 2){photo_no++}                    // close
             }
        }
        
        if(np =="next"){
             if(photo_no <= dat_sum){photo_no++}
             if(photo_no > dat_sum){
                  if(next_back == 0){photo_no--}                    // stop
                  if(next_back == 1){photo_no = 1}                  // loop
                  if(next_back == 2){closePhoto(ret_url,"next") ; return}  // close
             }
             if((blend > 0)||(wipe > 0)){preRead()}
        }

        iconCont(1,2,3) 
        if(next_back == 0){
            if(photo_no <= 1){iconCont(0,2,3)}
            if(photo_no >= dat_sum){iconCont(1,2,0)}
        }

        if(next_back == 2){
            if(photo_no <= 1){iconCont(0,2,3)}
            if(photo_no >= dat_sum){iconCont(1,2,3)}
        }
   }else{
        if(np.length > 6){ret_url = np}
        closePhoto(ret_url,"home") ; return
   }

   if(blend > 0){blendEffect()}
   if(wipe > 0){wipeEffect()}
   if((blend == 0)&&(wipe == 0)){document.photo_a.src = f_name[photo_no] }

   document.getElementById("tx1").innerHTML = f_com1[photo_no]
   if(nrdsp >0){chText(f_numb[photo_no],'numb')}
   status = ""
}


/* ブレンド設定 */
function blendPhoto(bld)
{    
   if(document.all){
       if(bld > 0){blend = bld} else {blend = 0} 
   } 
}


/* ワイプ設定 */
function wipePhoto(we,wt)
{    
   if(document.all){
        wipe = 1 
        e_wipe = we ; t_wipe = wt
   }
}


/* 最終写真後の処理 */
function closePhoto(ret_url,nxthome)
{    
    if(window.name == ""){
         if(ret_url == ""){
             if(history.length == 0){
                   return
              }else{
                   javascript:history.back()
              } 
         }else{
              location.href = ret_url
         }
    }else{
         if(document.all){
                if((next_back == 2)&&(nxthome == "next")){
                      photo_a.filters.alpha.enabled = 1
                      photo_a.filters.alpha.Apply()
                      document.photo_a.src = f_name[photo_no-1]
                      photo_a.filters.alpha.Play()
                      setTimeout("javascript:close()", wtime)
                }else{
                     javascript:close()
                }
         }else{
                if((next_back == 2)&&(nxthome == "next")){


                     setTimeout("javascript:close()", wtime)
                }else{
                     javascript:close()
                }
        }
    }
}


/* 写真  コメント書き換え */
function chgPhoto(chg)
{
   photo_no = chg
   iconCont(1,2,3)
   if(photo_no == 1){iconCont(0,2,3)}
   if(photo_no == dat_sum){iconCont(1,2,0)}
   if(blend > 0){blendEffect()}
   if(wipe > 0){wipeEffect()}
   if((blend == 0)&&(wipe == 0)){document.photo_a.src = f_name[photo_no] }

   document.getElementById("tx1").innerHTML = f_com1[photo_no]
   if(nrdsp == 1){chText(f_numb[photo_no] ,'numb')}
   if((blend > 0)||(wipe > 0)){preRead()}
}


function chText(txt,id) 
{
    if(document.getElementById){
        obj = document.getElementById(id);
        obj.childNodes[0].nodeValue = txt;
    }
}


/* サムネイル設定 */
function setThmb(top_n , last_n)
{
    if(top_n < last_n){
         topTm = top_n
    }else{
         topTm = -1*top_n
    }
}


/* サムネイル表示 */
function dspThmb(row_n , col_n , rcw)
{
    for(i = 1 ; i <= dat_sum ; i = i + 1){
        tm0 = f_name[i]
        tm1 = tm0.indexOf(".",0)
        tm2 = tm0.substr(0,tm1)
        tm3 = tm0.substr(tm0.length-4,4)
        tm_ph[i] = tm2 + "s" + tm3
    }

    if(topTm < 0){
         topm = 0 ; topTm = -1*topTm
    }else{
         topm = 1
    }
    s ="<DIV>"
    s +="<TABLE cellpadding="+rcw+" cellspacing=0 border=0><TBODY>"
    for(i = 1 ; i <= row_n ; i = i + 1){
    s +="<TR>"    
        for(j = 1 ; j <= col_n ; j = j + 1){
            s +="<TD align=center valign=top>"
            s +="<a href='javascript:chgPhoto("+topTm+")' onfocus='this.blur()'>"
            s +="<IMG src="+tm_ph[topTm]+" border=0 ID='Thmb'></a>"
            s +="</TD>"   
            if(topm == 1){topTm++}else{topTm--}
        
        }
    s +="</TR>"
    }
    s +="</TBODY></TABLE></DIV>"
    document.open() ; document.write(s) ; document.close()
}


