
// ガイアックスの女王様：オメグのスライドメニュー
// 著作権？　omegu@click ダジョ　この技使った人はリンクしてね〜
position = document.formmenu.position.value;
tbwidth = document.formmenu.tbwidth.value;
tbheight = document.formmenu.tbheight.value;
size = document.formmenu.size.value;
x0 = document.formmenu.x0.value;
y0 = document.formmenu.y0.value;
y1 = document.formmenu.y1.value;
var msg = new Array() ;

menu_status = document.formmenu.mstat.value;
speed = document.formmenu.speed.value;
topcolor = document.formmenu.topcolor.value;
topimage = document.formmenu.topimage.value;
bgcolor = document.formmenu.bgcolor.value;
bgimage = document.formmenu.bgimage.value;
var SW;
var SH;
var DTX=new Array();
var DTY=new Array();
var i = 0;
var j = 0;
var swOn = 0 ;
function menuIni(){
for (i=0;i<document.formmenu.length;i++){
    if (document.formmenu.elements[i].type=="text")
       {msg[j]=document.formmenu.elements[i].value;j++;}
}

if ((size<=3)||(size>=30)){size=14;}
if ((speed<=1)||(speed>100000)){speed=30;}

document.write("<STYLE>");
document.write("span.spanclass {color:#000000;");
document.write("font-size:"+size+" pt; font-weight:bold;}");
document.write("td#td0{background-color:#"+topcolor+"; border:outset 2px;");
document.write("background-image:url("+topimage+");}");
document.write("td#td1{background-color:#"+bgcolor+"; border:outset 2px;");
document.write("background-image:url("+bgimage+");}");
document.write("input#b00{background-color:#"+bgcolor+"; border:outset 1px;");
document.write("background-image:url("+bgimage+");font-color:000000;");
document.write("font-weight:bold; color:000000}");
document.write("</STYLE>");


for(i=0;i<msg.length;i++) {
overLay = 999-i*10;
if (i == 0) {overLay = 999 ;
document.write('<SPAN id=menux class="spanclass" style=position:absolute;z-index:'+overLay+';visibility:visible;top:'+y0+'px;left:'+x0+'px;><table width='+tbwidth+' height='+tbheight+'><tr><td ID=td0><CENTER>'+msg[i]+
'<input type=button id=b00 value="ON/OFF" onClick="moveMenu()"></CENTER>'+
'</td></tr></TABLE></SPAN>'); } else {
document.write('<SPAN id=menux class="spanclass" style=position:absolute;z-index:'+overLay+';visibility:visible;top:'+y0+'px;left:'+x0+'px; onmouseover="showMenu('+i+')"; onmouseout="backMenu('+i+')"; ><table width='+tbwidth+' height='+tbheight+'><tr><td ID=td1>'
+msg[i]+
'</td></tr></TABLE></SPAN>'); }  


}

	SW=document.body.clientWidth;
	SH=document.body.clientHeight;

	for(i=0;i<msg.length;i++){
		DTX[i]=x0;
		DTY[i]=y1;
	}
       if (menu_status!="close") {moveMenu();}

}
var menuNum;
function showMenu(menuNum) {
var hidNum1= menuNum -1 ; if(hidNum1<=0){hidNum1=0;}
var hidNum2= menuNum -2 ; if(hidNum2<=0){hidNum2=0;}
var hidNum3= menuNum -3 ; if(hidNum3<=0){hidNum3=0;}

if ((DTY[menuNum]-DTY[hidNum1])<tbheight) {
   if (hidNum1!=0){
       with(menux[hidNum1]){
       style.visibility= "hidden";
       } 
   }
}
if ((DTY[menuNum]-DTY[hidNum2])<tbheight) {
   if (hidNum2!=0){
       with(menux[hidNum2]){
       style.visibility= "hidden";
       } 
    }
}
if ((DTY[menuNum]-DTY[hidNum3])<tbheight) {
   if (hidNum3!=0){
       with(menux[hidNum3]){
       style.visibility= "hidden";
       } 
    }  
}
}
function backMenu(menuNum) {
var hidNum1= menuNum -1 ; if(hidNum1<=0){hidNum1=0;}
var hidNum2= menuNum -2 ; if(hidNum2<=0){hidNum2=0;}
var hidNum3= menuNum -3 ; if(hidNum3<=0){hidNum3=0;}

       with(menux[hidNum1]){
       style.visibility= "visible";
       }
       with(menux[hidNum2]){
       style.visibility= "visible";
       }
       with(menux[hidNum3]){
       style.visibility= "visible";
       }
}
var i = 0;
function moveMenu() {
if (swOn==0){
          for (i=1;i<msg.length;i++)  { 
 		        with(menux[i]){
                        DTY[i]=eval(DTY[i])+2*i;
                   	style.posTop=DTY[i];
			style.posLeft=DTX[i];
		        }
          }

var SDY = DTY[2] - DTY[1] ; 

if (SDY>=position)
          {clearTimeout(msgTimer);swOn=1;}
     else {msgTimer=setTimeout('moveMenu();',speed);}
     } else {
          for (i=1;i<msg.length;i++)  { 

 		with(menux[i]){
                        DTY[i]=eval(DTY[i])-2*i;
                if (DTY[i]==y1) {
                   	style.posTop=y0;
			style.posLeft=DTX[i]; } else {
                   	style.posTop=DTY[i];
			style.posLeft=DTX[i];
                        }
		}

          }

var SDY = DTY[2] - DTY[1] ; 

if (SDY<=0)
          {clearTimeout(msgTimer);swOn=0;}
     else {msgTimer=setTimeout('moveMenu();',speed);}
     }


}
function stMenu(){
menuIni();
}
stMenu() ;

