
/*********************************************************************
 * クロスブラウザポップアップメニュ−のためのスクリプト
 * popupmenu 0.1  1999.3.14
 * (1997.5版をクロスブラウザ化したものです)
 * 
 * -------------------------------------------------------------------
 * 言語 : JavaScript
 * 対象Browser : Netscape4,6/IE4,5,6
 * 
 * -------------------------------------------------------------------
 * /popupmenutoolホルダを適当な場所にコピーしたうえで
 * <SCRIPT LANGUAGE="JavaScript" src="popupmenutool/pop.js"></SCRIPT>
 * で呼び出してご利用ください。
 * 
 *   書式:
 * 
 *   普通のリンク(Aタグ)の中に

     onMouseOver="pop(  ' メニューラベル名1 => リンク先url1 ;'
                      + ' メニューラベル名2 => リンク先2url ;'
                      + ' メニューラベル名3 => リンク先3url ;'
                      + ' etc...            => etc...        ',event,幅)"

 *   を書き加えてください。
 * 
 *   引数説明:
 * 
 *   ・メニューラベル名=>リンク先url  
 *   
 *   でメニュー1行分のセットです。
 *   これを;(セミコロン)で区切って追加した行数分のメニューが現れます。
 *
 *   ・event  の文字はおまじないだと思ってそのまま書いてください。
 *   ・幅     はメニューの幅をピクセル数で指定します(150とか200など)。
 * 
 * -------------------------------------------------------------------
 * Toshirou Takahshi tato@fureai.or.jp
 * Support http://game.gr.jp/js/
 * DHTMLcross-browser Samples
 * http://www.fureai.or.jp/~tato/DHTML/simple/contents.htm
 * 改造は自由ですがバグやブラウザのバ−ジョンアップへの対応等の
 * 情報には充分注意してご利用ください。
 * 
 */

var pW=128 ;     //popup画像1枚の幅
var pH=16  ;     //popup画像1枚の高さ
var t=2    ;     //文字の上マージン
var menuStoff=20;//メニューラベル位置xオフセット
var toolurl='popupmenutool/'

document.onclick=popoff

msg0="Menu";li0=""
i=0

function Laymk(){
  if(document.all){
    mkLaya0 = "<div id='layA0' style='position:absolute;visibility:hidden'"
    mkLaya0+= "  onMouseOut ='if(window.event.x<=document.all.layA0.style.posLeft){popoff()}'"
    mkLaya0+= ">"
    mkLaya0+= "</div>"
  }

  else if(document.layers){
    mkLaya0 = "<layer name='layA0' visibility='hide' "
    mkLaya0+= "  onMouseOut ='popoff()'"
    mkLaya0+= ">"
    mkLaya0+= "</layer>"
  } 

  else if(document.getElementById){
    mkLaya0 = "<div id='layA0' style='position:absolute;visibility:hidden'"
    mkLaya0+= "  onMouseOut ='if(window.event.x<=parseInt(document.getElementById(\"layA0\").style.left)){popoff()}'"
    mkLaya0+= ">"
    mkLaya0+= "</div>"
  } 

  document.write(mkLaya0)
/*  document.write("<br>")*/
  document.close()

}
if(document.layers || document.all || document.getElementById)Laymk()



function Layoutput(arg,pW){

  var pH=16
  var t=2

  menus=new Array()
  arg.split('\r\n').join()
  lists=arg.split(';')
  
  if(document.layers){

    Laytag = "<layer name='Admyda' visibility='hide'>"
    Laytag+= "<a href='#' name='Admy' style='text-decoration:none'></a>"
    Laytag+= "</layer>"
    
    
    Laytag+= "<layer name='A1' top="+(t+=pH)+" >"
    Laytag+= "<img src='"+toolurl+"popmnb.gif' border=0 width="+pW+" height="+pH+">"
    Laytag+= "</layer>"
    
//    Laytag+= "<layer name='msgA"+i+"'top="+(t+1)+" left=10 width="+pW+" height="+pH+">"
//    Laytag+="<font size=3 color='ffffff'><b>"+msg0+"</b></font>"
//    Laytag+= "</layer>"
    
    
    for(i=0;i<lists.length;i++){
    
      Laytag+= "<layer name='A"+i+"' top="+(t+=pH)+" width="+pW+" height="+pH+">"
      Laytag+="<a href='"+lists[i].split('=>')[1]+"' name='A'"+i+" style='text-decoration:none' "
      Laytag+=" onMouseOver='hanten("+i+")'"
      Laytag+=" onMouseOut='modoshi("+i+")'>"
      Laytag+= "<nobr><img src='"+toolurl+"popof1.gif' border=0 width=2 height="+pH+"><"
      
      if(i==lists.length-1){
        Laytag+= "img src='"+toolurl+"popof2end.gif' border=0 width="+(pW-4)+" height="+pH+"><"
      }else{
        Laytag+= "img src='"+toolurl+"popof2.gif' border=0 width="+(pW-4)+" height="+pH+"><"
      }
      
      Laytag+= "img src='"+toolurl+"popof3.gif' border=0 width=2 height="+pH+"></nobr>"
      //Laytag+= "<img src='"+toolurl+"popof0.gif' border=0 width="+pW+" height="+pH+">"
      Laytag+= "</a></layer>"
      
      Laytag+= "<layer name='msgA"+i+"'top="+(t+1)+" left="+menuStoff+">"
      Laytag+="<a href='"+lists[i].split('=>')[1]+"' name='A'"+i+" style='text-decoration:none' "
      Laytag+=" onMouseOver='hanten("+i+")'"
      Laytag+=" onMouseOut='modoshi("+i+")'>"
      Laytag+="<font size=3 color='green'>"+lists[i].split('=>')[0]+"</font></a>"
      Laytag+= "</layer>"
  
    }
  
  
  } else if( document.all || document.getElementById ){
  
    Laytag = "<div id='A1' style='position:absolute;top:"+(t+=pH)+";width:"+pW+";height:"+pH+"'>"
//    Laytag+= "<img src='"+toolurl+"popmnb.gif' border=0 width="+pW+" height="+pH+">"
//    Laytag+= "</div>"
//    Laytag+= "<div id='msgA"+i+"' style='position:absolute;color:#ffffff;top:"+(t+2)+";left:10;width:"+pW+";height:"+pH+  "'  >"
//   Laytag+="<font size=3 color='#ffffff' style='font-size:12px'><b>"+msg0+"</b></font>"
//    Laytag+= "</div>"
    
    
    for(i=0;i<lists.length;i++){

     
      Laytag+= "<div id='A"+i+"' style='position:absolute;top:"+(t+=pH)+";width:"+pW+";height:"+pH+"'>"
      Laytag+="<a href='"+lists[i].split('=>')[1]+"' name='A'"+i+" style='text-decoration:none' "
      Laytag+=" onMouseOver='hanten("+i+");'"
      Laytag+=" onMouseOut='modoshi("+i+")'>"
      Laytag+= "<nobr><img name='Ai0"+i+"' src='"+toolurl+"popof1.gif' border=0 width=2 height="+pH+"><"
      
      if(i==lists.length-1){
        Laytag+= "img name='Ai1"+i+"' src='"+toolurl+"popof2end.gif' border=0 width="+(pW-4)+" height="+pH+"><"
      }else{
        Laytag+= "img name='Ai1"+i+"' src='"+toolurl+"popof2.gif' border=0 width="+(pW-4)+" height="+pH+"><"
      }
      Laytag+= "img name='Ai2"+i+"' src='"+toolurl+"popof3.gif' border=0 width=2 height="+pH+"></nobr>"
      //Laytag+= "<img name='A"+i+"' src='"+toolurl+"popof0.gif' border=0 width="+pW+" height="+pH+">"
      Laytag+= "</div>"
      
      Laytag+= "<div id='msgA"+i+"' style='position:absolute;top:"+(t+1)+";left:"+menuStoff+";z-index:2'>"
      Laytag+="<a href='"+lists[i].split('=>')[1]+"' name='A'"+i+" style='text-decoration:none' "
      Laytag+=" onMouseOver='hanten("+i+")'"
      Laytag+=" onMouseOut='modoshi("+i+")'>"
      Laytag+="<font size=3 color='green' style='font-size:12px'>"+lists[i].split('=>')[0]+"</font></a>"
      Laytag+= "</div></a>"
	  
    }
  
  
  }


 return Laytag
}


var ex  ;        //メニューボタンにマウスが触った時の座標x
var ey  ;        //メニューボタンにマウスが触った時の座標y
var pname ;      //Bグループのレイヤー名用変数
var hanFlag;     //反転フラグ


   //マウスが触った時と離れている時のpopup画像を読み込む
Popon=new Array()
Popof=new Array()

Popon[0]=new Image();Popon[0].src=""+toolurl+"popon1.gif"
Popof[0]=new Image();Popof[0].src=""+toolurl+"popof1.gif"
Popon[1]=new Image();Popon[1].src=""+toolurl+"popon2.gif"
Popof[1]=new Image();Popof[1].src=""+toolurl+"popof2.gif"
Popon[2]=new Image();Popon[2].src=""+toolurl+"popon3.gif"
Popof[2]=new Image();Popof[2].src=""+toolurl+"popof3.gif"


  //触った画像の反転処理
function hanten(pIndex){
  if(document.layers){
    document.layers['layA0'].document.layers["A"+pIndex].document.images[0].src=Popon[0].src
    document.layers['layA0'].document.layers["A"+pIndex].document.images[1].src=Popon[1].src
    document.layers['layA0'].document.layers["A"+pIndex].document.images[2].src=Popon[2].src
  }
  else if(document.all || document.getElementById){
    document.images["Ai0"+pIndex].src=Popon[0].src
    document.images["Ai1"+pIndex].src=Popon[1].src
    document.images["Ai2"+pIndex].src=Popon[2].src
  }
}

  //反転処理した画像をもとに戻す処理
function modoshi(pIndex){
  if(document.layers){
    document.layers['layA0'].document.layers["A"+pIndex].document.images[0].src=Popof[0].src
    document.layers['layA0'].document.layers["A"+pIndex].document.images[1].src=Popof[1].src
    document.layers['layA0'].document.layers["A"+pIndex].document.images[2].src=Popof[2].src
  }
  else if(document.all || document.getElementById){
    document.images["Ai0"+pIndex].src=Popof[0].src
    document.images["Ai1"+pIndex].src=Popof[1].src
    document.images["Ai2"+pIndex].src=Popof[2].src
  }
}
    //リンク文字に触った(onMouseOver)時にlayA0メニューをshowする
function pop(arg,e,pW,key){

//MacIE4,5バグ 回避
if(document.all && navigator.appVersion.indexOf('Mac')!=-1)return

  if(document.layers || document.all || document.getElementById){

    if(arguments.length==2)pW=128;

    if(document.all){//IE
        var ex=document.body.scrollLeft+event.clientX
        var ey=document.body.scrollTop+event.clientY
		if(key == 1){
			ex = 292;
			ey = 81;
		}else{
			ex = 377;
			ey = 81;
		}		
    }
    else if(document.layers){//MAC
        var ey=e.pageY
        var ex=e.pageX
    }
    else if(document.getElementById){//NS
        var ex=window.scrollX+e.clientX
        var ey=window.scrollY+e.clientY
		if(key == 1){
			ex = 289;
			ey = 89;
		}else{
			ex = 375;
			ey = 89;
		}
    }


    movelayer('layA0',ex-12,ey-18)
    zindexlayer('layA0',100)
    outputLAYER('layA0',Layoutput(arg,pW));
    showlayer('layA0')
  }
}

function popoff(){
  movelayer('layA0',-200,-200) ; 
}

function showlayer(layName){
   if ( document.all )document.all( layName ).style.visibility ='visible'
   else if ( document.layers)document.layers[ layName ].visibility ='show' 
   else if ( document.getElementById )document.getElementById( layName ).style.visibility ='visible'
}

function movelayer(layName,x,y){
    
   if(document.all){
     document.all(layName).style.pixelLeft=x  //IE4用
     document.all(layName).style.pixelTop=y
   }
   else if(document.layers)document.layers[layName].moveTo(x,y)  //NN4用
   else if(document.getElementById){ //NN6,IE5用
     document.getElementById(layName).style.left=x
     document.getElementById(layName).style.top=y
   }
}
function zindexlayer(layName,zindex){
   if(document.getElementById)document.getElementById(layName).style.zIndex=zindex  ///NN6,IE5用
   else if(document.layers)document.layers[layName].zIndex=zindex  //NN4用
   else if(document.all)document.all(layName).style.zIndex=zindex  //IE4用
}
function outputLAYER(layName,html){

    if(document.all){                         //IE用
      document.all(layName).innerHTML=html
    }
    else if(document.layers) {                      //NN用
       with(document.layers[layName].document){
         open()
         write(html)
         close()
      }
    }
    else if(document.getElementById){              //NN6,IE5用
      document.getElementById(layName).innerHTML=html
    }

}
