
//設定データ分解
w_time=aut*1000;
md=mado+",,,,";
wh=md.split(",");
win_w=wh[0]*1;win_h=wh[1]*1;win_ww=win_w;win_hh=win_h;
win_color=wh[2];
if(wh[5]==""){button_dt=1}else{button_dt=wh[5]*1;}
type_dt="button";if(button_dt==0){type_dt="hidden";}
lake_url=dt[0];
if(!lake_url){
lake_url="./";
}
//ＣＰＵセット
cp0=getCookie("lake_cpu");
cpu=cp0*1;
if(cpu<1){cpu=2;}


lake_tim=(cpu+1)*2;
mac=navigator.appVersion.indexOf("Mac");

//ＣＯＯＫＥ
function getCookie(key){
	tmp=document.cookie+";";
	tmp1=tmp.indexOf(key,0);
	if(tmp1!=-1){
		tmp=tmp.substring(tmp1,tmp.length);
		start=tmp.indexOf("=",0)+1;
		end=tmp.indexOf(";",start);
		return(unescape(tmp.substring(start,end)));
	}
	return("");
}

function setCookie(key,val){
	tmp=key+"="+escape(val)+";";
	tmp+="expires=Fri,31-Dec-2030 23:59:59; ";
	document.cookie=tmp;
}




//ＣＰＵ変更

function chgCpu(p){
cpu=p*1;
lake_tim=(cpu+1)*2;
setCookie("lake_cpu",cpu);
menu_go();
}

//ＣＰＵボタン
function cpu_button(){
document.write('    <select name="cpu_sel" onChange="chgCpu(this.value)" >');
cp1="0.2G,0.5G,1.0G,3.0G,5.0G".split(",");
for(i=0;i<=4;i++){
d="";if(i==cpu){d="selected";}
document.write('<option value="'+i+'" '+d+'>CPU:'+cp1[i]);
}
document.write('</select>');
}
//流れ
function changeUd(w){
ud_dt=document.myform.ud_value.value*1;
ud_dt += w;

if(ud_dt<-9){ud_dt=-9;}
if(ud_dt>9){ud_dt=9;}
document.frame_1.changPhase(ud_dt);
document.myform.ud_value.value=ud_dt;
}

///////波の変更////////
//波長
function changeStrength(w){
strength_dt=document.myform.strength_value.value*1;
strength_dt += w;
if(strength_dt<0){strength_dt=0;}
if(strength_dt>10){strength_dt=10;}
if(nav=="M"){
document.frame_1.document.myimg.filters["wave"].strength = strength_dt;
}
document.myform.strength_value.value=strength_dt;
}

//波数
function changeFreq(w){
freq_dt=document.myform.freq_value.value*1;
freq_dt+=w;
if(freq_dt<0){freq_dt=0;}
if(freq_dt>99){freq_dt=99;}
if(nav=="M"){
document.frame_1.document.myimg.filters["wave"].freq=freq_dt;
}
document.myform.freq_value.value=freq_dt;
}
//輝度
function changeLight(w){
light_dt=document.myform.light_value.value*1;
light_dt+=w;
if(light_dt<0){light_dt=0;}
if(light_dt>1<0){light_dt=10;}
if(nav=="M"){
document.frame_1.document.myimg.filters["wave"].lightstrength=light_dt;
}
document.myform.light_value.value=light_dt;
}
//波変更ボタン
function button_set(){
//type_dt="button";
document.write('<input type=',type_dt,' value="荒" onclick="changeStrength(1)" style="width:24">\n');
document.write('<input type=',type_dt,' value="',strength_dt,'" name="strength_value" size=1 style="width:18;">\n');

document.write('<input type=',type_dt,' value="静" onclick="changeStrength(-1)" style="width:24">\n');
document.write('　<input type=',type_dt,' value="長" onclick="changeFreq(-5)" style="width:24">\n');
document.write('<input type=',type_dt,' value="',freq_dt,'" name="freq_value" style="width:24">\n');

document.write('<input type=',type_dt,' value="細" onclick="changeFreq(+5)" style="width:24">\n');
document.write('　<input type=',type_dt,' value="濃" onclick="changeLight(1)" style="width:24">\n');
document.write('<input type=',type_dt,' value="',light_dt,'" name="light_value" style="width:18">\n');

document.write('<input type=',type_dt,' value="薄" onclick="changeLight(-1)" style="width:24">\n');
document.write('　<input type=',type_dt,' value="↑" onclick="changeUd(+1)" style="width:24">\n');
document.write('<input type=',type_dt,' value="',ud_dt,'" name="ud_value" style="width:24">\n');

document.write('<input type=',type_dt,' value="↓" onclick="changeUd(-1)" style="width:24">\n');

}


//サムネル
function midasi(){
nav=navigator.appName.substring(0,1);
nav_ver=navigator.appVersion;
nav_sv=nav_ver.indexOf("Windows NT 5.1; SV1");

ee=Math.ceil(n/8);
document.write('<table border="0" cellpadding=2>');
for(i=1;i<=n;i++){
dd=dt[i].split(",");
d1=(dd[1]+";;").split(";");
if(dd[0]==""){dd[0]=d1[0];}
if((i-1)%ee==0){document.write('<tr>');}
document.write('<td align=center><img src="',lake_url,dd[0],'" name="mihon',i,'" height=60 border=1 onClick="chg(',i,')" style="cursor:hand;border-color:#ffffff"></td>'); 
if((i)%ee==0){document.write('</tr>');}
}
document.write('</tr></table>');
}
//}

//サムネール仕上げ
sum_w=80;
function wh_chack(){
for(i=1;i<=n;i++){
sn_l=document.images["mihon"+i].width;
sn_h=document.images["mihon"+i].height;

if(sn_l>sum_w){
ssh=(80/sn_l)*sn_h;
document.images["mihon"+i].width=80;
document.images["mihon"+i].height=ssh;

}
}
}
//自動スライド
at_flg=0;
function at(){
if(at_flg==0){
document.myform.sld.value="スライドショー停止";
at_flg=1;

end_no=dt_no;
at_sub();
}else{
document.myform.sld.value="スライドショー開始";
at_flg=0;
clearTimeout(at_tim);
}
}

function at_sub(){
if(dt_no>n){dt_no=1;}
	lake_dt=dt[dt_no];
	win_set();
	www=html_set();
	document.frame_1.document.open();
	document.frame_1.document.write(www);
	document.frame_1.document.close();
if(win_w<img_w){win_ww=img_w+8;}else{win_ww=win_w;}
if(win_h<lake_h){win_hh=lake_h+8;}else{win_hh=win_h;}
document.getElementById("f1").style.width=win_ww;
document.getElementById("f1").style.height=win_hh+40;


	dt_no++;
	if(dt_no>n){
		dt_no=1;
	}


at_tim=setTimeout("at_sub()",w_time);
}


function chg(p){

dt_no=p*1;
menu_go();
}





///レイアウト

function lake_write(){

if(lake_img==""){
	index_type="2134".split("");
}else{
	if(maquee_iti==1 || maquee_iti==3 || maquee_iti==5){
		index_type="1423".split("");
	}else{
		index_type="1234".split("");
	}
}
//背景
vv=('<table border=0 cellpadding=0><tr><td><table border=1 cellpadding=0><tr><td>');;

vv+=('<div id="lake_win" style="position:relative;width:'+img_w+';height:'+lake_h+';overflow:hidden;">\n');
vv+=('<div id="back_win" style="position:absolute;top:0;left:0;width:'+img_w+';height:'+lake_h+';z-index:'+index_type[0]+';"><img src="'+lake_url+back_img+'" galleryimg="no"></div>\n');

//水面
if(lake_img==""){
vv+=('<div id="nami_win" style="position:absolute;top:'+lake_top+';left:0;width:'+img_w+';height:'+img_h+';background:url('+lake_url+back_img+');filter:flipH(enabled=0) flipV(enabled='+lake_hv+');z-index:'+index_type[1]+'">\n');

}else{
vv+=('<div id="nami_win" style="position:absolute;top:'+lake_top+';left:0;width:'+img_w+';height:'+img_h+';filter:flipH(enabled=0) flipV(enabled='+lake_hv+');z-index:'+index_type[1]+'">\n');
}
if(maquee_iti ==3){
vv+=('<img src="'+lake_src.src+'" name="myimg" galleryimg="no" border=0 style="filter:wave(add=0,freq=0,lightstrength=0,phase=0,strength=0)">\n');

}else{
vv+=('<img src="'+lake_src.src+'" name="myimg" galleryimg="no" border=0 style="filter:wave(add='+add_dt+',freq='+freq_dt+',lightstrength='+light_dt+',phase='+phase_dt+',strength='+strength_dt+')">\n');

}
vv+=('</div>\n');

//前景
//front_w=0;front_h=0;
if(front_img!=""){
//	front_src=new Image();front_src.src=lake_url+front_img;
//	front_w=front_src.width;front_h=front_src.height;

		vv+=('<div id="front_win" style="position:absolute;top:'+y_dt+';left:'+x_dt+';filter:flipH(enabled=0) flipV(enabled=0);z-index:'+index_type[2]+'">\n');
	if(maquee_iti >=2){
		vv+=('<img src="'+lake_url+front_img+'" name="myimg3" galleryimg="no" border=0  style="filter:wave(add='+add_dt+',freq='+freq_dt+',lightstrength='+light_dt+',phase='+phase_dt+',strength='+strength_dt+')">\n');

	}else{
		vv+=('<img src="'+lake_url+front_img+'" name="myimg3" galleryimg="no" border=0 style="filter:wave(add=0,freq=0,lightstrength=0,phase=0,strength=0)">\n');
	}
		vv+=('<span style="color=#'+front_color+';font-size:'+front_size+';'+style_html[front_style]+'">'+front_txt+'</span></div>');
	fh=0;fv=0;
	if(maquee_type==4){
		if(maquee_no<3){
			fv=1;
		}else{
			fh=1;
		}
	}

		vv+=('<div id="front_win2" style="position:absolute;top:'+img_w+';left:'+x_dt+';filter:flipH(enabled='+fh+') flipV(enabled='+fv+');z-index:'+index_type[3]+'">\n');
	if(maquee_iti >=2){
		vv+=('<img src="'+lake_url+front_img+'" name="myimg4" galleryimg="no" border=0  style="filter:wave(add='+add_dt+',freq='+freq_dt+',lightstrength='+light_dt+',phase='+phase_dt+',strength='+strength_dt+')">\n');
	}else{
		vv+=('<img src="'+lake_url+front_img+'" name="myimg4" galleryimg="no" border=0 style="filter:wave(add=0,freq=0,lightstrength=0,phase=0,strength=0)">\n');

	}
		vv+=('<span style="color=#'+front_color+';font-size:'+front_size+';'+style_html[front_style]+'">'+front_txt+'</span></div>');
}else{
		vv+=('<div id="front_win" style="position:absolute;top:'+y_dt+';left:'+x_dt+';filter:flipH(enabled=0) flipV(enabled=0);z-index:'+index_type[2]+'">\n');
		vv+=('<span style="color=#'+front_color+';font-size:'+front_size+';'+style_html[front_style]+'">'+front_txt+'</span></div>');
		vv+=('<div id="front_win2" style="position:absolute;top:'+y_dt+';left:'+x_dt+';filter:flipH(enabled=0) flipV(enabled=0);z-index:'+index_type[2]+'">\n');
		vv+=('<span style="color=#'+front_color+';font-size:'+front_size+';'+style_html[front_style]+'">'+front_txt+'</span></div>');

}
//
vv+=('</div></td></tr></table></td></tr><tr><td style="font-size:'+wh[3]+';color:'+wh[4]+';text-align:center;">');
vv+=(com_dt+'</td></tr></table>');

return vv;
}
/////

function html_set(){
if(back_img==""){return;}
ww="";
ww+='<html>\n<head>\n';
ww+='<title>QponLake</title>\n';
ww+='<META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">\n';
ww+='<META http-equiv="Content-Style-Type" content="text/css">\n';
ww+='<scr';
ww+='ipt language="javascript">';
ww+='lake_dt="'+lake_dt+'";\n';
ww+='lake_url="'+lake_url+'";\n';
ww+='lake_time='+lake_tim+';\n';
///ww+='lake_flg='+lake_flg+';\n';
ww+='img_w='+img_w+';\n';
ww+='img_h='+img_h+';\n';
ww+='front_w='+front_w+';\n';
ww+='front_h='+front_h+';\n';
ww+='lake_tim='+lake_tim+';\n';
ww+='</scr';ww+='ipt>';
ww+='<scr';
ww+='ipt language="javascript" src="http://www2a.biglobe.ne.jp/~qpon/lake/q_lake400.js"></scr';
ww+='ipt>';

ww+='</head>\n';
ww+='<body bgcolor='+win_color+' scroll=no style="margin:0;" onLoad="lake_start();focus();">\n';
v=lake_write();
ww+=v;
ww+='</body>\n';
ww+='</html>\n';
ww+='<!---->\n';

return ww;
}

//メニュー切り替え
function menu_go(){

lake_dt=dt[dt_no];


win_set();
www=html_set();
document.frame_1.document.open();
document.frame_1.document.write(www);
document.frame_1.document.close();
if(win_w<img_w){win_ww=img_w+8;}else{win_ww=win_w;}
if(win_h<lake_h){win_hh=lake_h+8;}else{win_hh=win_h;}
document.getElementById("f1").style.width=win_ww;
document.getElementById("f1").style.height=win_hh+40;

//document.getElementById("com_text").innerHTML=com_dt;
}
function win_reset(){
if(img_w>0){return;}
img_w=back_src.width;img_h=back_src.height;lake_h=img_h;
if(lake_img==""){
lake_h=img_h*1.3;
}
if(win_w<img_w){win_ww=img_w+8;}else{win_ww=win_w;}
if(win_h<lake_h){win_hh=lake_h+8;}else{win_hh=win_h;}
document.getElementById("f1").style.width=win_ww;
document.getElementById("f1").style.height=win_hh+40;

}
//データセット
function win_set(){
style_html=",text-align:left;writing-mode:tb-rl;".split(",");

lake_dt=dt[dt_no]+",,,,,,,,,,,,,,,,,,,,,,,,,,,,";
maq=",up,down,left,right".split(",");
maq_l=",height,height,width,width".split(",");

/////初期データ
//  0サムネール],1全景,2水面,3波数,4波長,5輝度,6コメント,7流速方向,8前景,9Ｘ座標,10Ｙ座標,11MAQUEE方式,12移動方向,13スピード,14移動長さ,15重ね順,16前景テキスト]//

dd=lake_dt.split(",");
d1=(dd[1]+";;").split(";");

if(dd[0]=""){
dd[0]=d1[0];
}
back_img=d1[0];
//back_img=dd[1];
back_src=new Image();back_src.src=lake_url+back_img;
if(d1[1]==""){
img_w=back_src.width;img_h=back_src.height;
back_src.onload=win_reset;
}else{
img_w=d1[1]*1;img_h=d1[2]*1;
}
sum_img=dd[0];
ud_dt=dd[7]*1;//流速・方向
freq_dt=dd[3]*1;//波数
strength_dt=dd[4]*1;//波長
light_dt=dd[5]*1;//輝度
add_dt=0;
phase_dt=0;

lake_img=dd[2];lake_top=0;lake_h=img_h;lake_hv=0;

if(lake_img==""){
lake_top=img_h-5;lake_h=img_h*1.3;lake_hv=1;
lake_src=new Image();lake_src.src=back_src.src;
}else{
lake_src=new Image();lake_src.src=lake_url+lake_img;
}
com_dt=dd[6];
d2=(dd[8]+";;").split(";");
front_img=d2[0];
front_h=0;front_w=0;
if(front_img!=""){
front_src=new Image();front_src.src=lake_url+front_img;
if(d2[1]==""){
front_w=front_src.width;front_h=front_src.height;
}else{
front_w=d2[1]*1;front_h=d2[2]*1;
}
}
tim_dt=lake_tim;//10;
tim_dd=Math.ceil(1000/tim_dt);
if(dd[9]==""){x_dt=1;}else{x_dt=dd[9]*1;}
if(dd[10]==""){y_dt=1;}else{y_dt=dd[10]*1;}
xx_dt=x_dt;yy_dt=y_dt;
if(dd[11]==""){maquee_type=0;}else{maquee_type=dd[11]*1;}

if(dd[12]==""){maquee_no=0;}else{maquee_no=dd[12]*1;}
mq="0,0;0,-1;0,+1;-1,0;+1,0;-1,-1;+1,-1;-1,0;+1,0".split(";");
mqq=mq[maquee_no].split(",");
maquee_ud=mqq[1]*1;maquee_rl=mqq[0]*1;
//if(maquee_no%2==0){maquee_xy=1;}else{maquee_xy=-1;}

if(dd[13]==""){maquee_spd=0;}else{maquee_spd=dd[13]*(10/tim_dt);}
if(dd[14]==""){maquee_mov=0;}else{maquee_mov=dd[14]*1;}
if(dd[15]==""){maquee_iti=0;}else{maquee_iti=dd[15]*1;}
front_txt=dd[16];
front_txt_dt=(front_txt.split("<br>")).join("\n");
if(dd[17]==""){front_color="000000";}else{front_color=dd[17];}
if(dd[18]==""){front_size="24";}else{front_size=dd[18];}
if(dd[19]==""){front_style=0;}else{front_style=dd[19]*1;}

}


//フレーム
function frame_write(){
document.write('<table border=0><tr><td>');
document.write('<iframe id="f1" width=700 height=500 name="frame_1" frameborder=0></iframe>');
document.write('</td></tr></table>');
}

document.write('<table bgcolor='+wh[2]+'><tr><td>');
document.write('<table cellpadding= 15 border=0><tr><form name="myform"><td width=200 align=center>');
dt_no=1;
document.write('<input type=button value="スライドショー開始" name="sld" onClick="at()"><br>');
document.write('</td><td>')
win_set();
button_set();

cpu_button();
document.write('</td></form></tr>');
document.write('<tr><td align=center valign=top>');


midasi();

document.write('</td><td valign=top>');
frame_write();
document.write('</td></tr></table>');
document.write('</td></tr><tr><td align=right><a href="http://www2a.biglobe.ne.jp/~qpon/js/index.htm?http://www2a.biglobe.ne.jp/~qpon/lake/q_lake400_b.htm" target="_qpon"><font size=1 color='+wh[4]+'>システム提供：ＱＰＯＮ</font></a>'); 

document.write('</td></tr></table>');
wh_chack();chg(1);
