document.onmousemove=mouseMove;

var pset=new Array();
var stay=new Array();

pday=0;

function upday_w(){
for(var i in pset){
if(pday<pset[i][7])pday=pset[i][7];
 }
wupday=Math.floor(pday/10000)+'年'+Math.floor((pday%10000)/100)+'月'+pday%100+'日';
document.getElementById("upday").innerHTML=wupday;
}

//初期表示
function first_set(){
var redata=location.search.substring(1);//受信データ
if(redata!=''){
 redata=unescape(redata);
 data=redata.split('&');
 wsp(data[0],data[1]);
 }
}

//更新情報
var lasty=2008;
var lastm="08";
var lastd="02";
var news="写真追加しました";


//宿泊データ
stay['noudou']=new Array();
stay['twan']=new Array("（旅館）岡野屋旅館");
stay['siroiwa']=new Array("（旅館）海舟","（キャンプ場）白岩崎キャンプ場");
stay['kaisui']=new Array("（旅館）花月","（民宿）大漁丸");
stay['magarisaki']=new Array();
stay['tsiro']=new Array("（民宿）一休","（旅館）三文字屋","（旅館）富久屋旅館");
stay['nisikawati']=new Array();
stay['myouken']=new Array();
//stay['']=new Array();


bw=0;bh=0;plw=0;plh=0;
palt="";
var hellow="ご来館ありがとうございます";
todyD=lasty;
if(lastm<10)todyD=todyD+'0'+lastm;
else todyD=todyD+''+lastm;
if(lastd<10)todyD=todyD+'0'+lastd;
else todyD=todyD+''+lastd;

//ご挨拶
function hello(){
dateObj=new Date();
time=dateObj.getHours();
if(time>=18||time<1)document.getElementById("he1").innerHTML="こんばんは　"+hellow;
if(time>=1&&time<5)document.getElementById("he1").innerHTML="こんばんは　深夜の"+hellow;
if(time>=5&&time<11)document.getElementById("he1").innerHTML="おはようございます　"+hellow;
if(time>=11&&time<18)document.getElementById("he1").innerHTML="こんにちは　"+hellow;
}

//更新日
function modd(){
document.write('<div id="modf">');
document.write('更新情報:　');
document.write(lasty+'年'+lastm+'月'+lastd+'日');
document.write('　');
 //--更新情報--
document.write(news);
document.write('</div>');
}

//初期設定
function photoN(){
 //Firefox
if(navigator.userAgent.indexOf("Firefox")!=-1){
document.getElementById("pl1").style.position="fixed";
document.getElementById("pclr").style.position="fixed";
}
 //NEW表示
for(var pno in pset){
 if(pset[pno][1]!=''&&pset[pno][7]>=eval(todyD)){
  document.getElementById(pset[pno][1]+"-n").style.display="inline";
  }
 }
}

//スクロール　トップ
function scrollt(){
topy=document.body.scrollTop;
document.getElementById("pl1").style.top=topy+"px";
document.getElementById("pclr").style.top=topy+"px";
}

//マウス 移動
function mouseMove(e){
var x;
var y;
if(e){x=e.pageX;y=e.pageY;}
else if(event){x=event.clientX+document.body.scrollLeft;y=event.clientY+document.body.scrollTop;}
document.getElementById("pi").style.top=y+5+'px';
document.getElementById("pi").style.left=x+10+'px';
}

//地図表示
function bfn(){
document.getElementById("photof").style.display="none";
}

//写真一覧表示
function wsp(ino,sel){
psset="";
ppset="";
for(var i in pset){
if(sel==pset[i][ino]){
 if((pset[i][6]/pset[i][5])>=0.5)psset+='<img src="ps/'+pset[i][2]+'" galleryImg="no" onClick="plv('+i+')"; onMouseOver="pinfon('+i+');" onMouseOut="pinfoff();" />';
 else ppset+='<img src="ps/'+pset[i][2]+'" class="sphoto" galleryImg="no" onClick="plv('+i+')"; onMouseOver="pinfon('+i+');" onMouseOut="pinfoff();" />';
 }
 }
document.getElementById("ps").innerHTML=psset;
document.getElementById("pp").innerHTML=ppset;
document.getElementById("photof").style.display="block";
}

//写真一覧表示
function wnewp(){
psset="";
ppset="";
for(var i in pset){
if(pday==pset[i][7]){
 if((pset[i][6]/pset[i][5])>=0.5)psset+='<img src="ps/'+pset[i][2]+'" galleryImg="no" onClick="plv('+i+')"; onMouseOver="pinfon('+i+');" onMouseOut="pinfoff();" />';
 else ppset+='<img src="ps/'+pset[i][2]+'" class="sphoto" galleryImg="no" onClick="plv('+i+')"; onMouseOver="pinfon('+i+');" onMouseOut="pinfoff();" />';
 }
 }
document.getElementById("ps").innerHTML=psset;
document.getElementById("pp").innerHTML=ppset;
document.getElementById("photof").style.display="block";
}

//説明文表示
function pinfon(inn){
document.getElementById("pi").innerHTML=pset[inn][0]+' '+pset[inn][8]+'KB 【クリックで拡大】';
document.getElementById("pi").style.display="block";
}
//説明文非表示
function pinfoff(){
document.getElementById("pi").style.display="none";
}

//説明文表示
function plcon(){
document.getElementById("pi").innerHTML='クリックで閉じます';
document.getElementById("pi").style.display="block";
}
//説明文非表示
function plcoff(){
document.getElementById("pi").style.display="none";
}

//拡大写真表示
function plv(pno){
 bw=Math.floor(window.innerWidth);
 if(isNaN(bw))bw=Math.floor(window.document.body.clientWidth);
 if(isNaN(bw))bw=Math.floor(screen.width*0.9);
 else if(bw>=screen.width)bw=Math.floor(screen.width*0.9);
 bh=Math.floor(window.innerHeight);
 if(isNaN(bh))bh=Math.floor(window.document.body.clientHeight);
 if(isNaN(bh))bh=Math.floor(screen.height*0.75);
 else if(bh>=screen.height)bh=Math.floor(screen.height*0.7);
 
 bw=bw-18;
 bh=bh-2;

 plw=pset[pno][5];
 plh=pset[pno][6];

 if(plw<=bw&&plh<=bh){pw=plw;ph=plh;}
 else {
  wratio=bw/plw;
  hratio=bh/plh;
  if(hratio<=wratio){pw=Math.floor(plw*hratio);ph=bh;pt=0;document.getElementById("phfull").style.display='none';}
  else              {pw=bw;ph=Math.floor(plh*wratio);pt=Math.floor((bh-ph)/2);document.getElementById("phfull").style.display='block';}
  }
 document.getElementById("pl1").style.height=bh+'px';
 document.getElementById("pct1").width=pw;
 document.getElementById("pct1").height=ph;
 document.getElementById("pct1").style.marginTop=pt+'px';
 document.getElementById("pct1").src="pl/"+pset[pno][2];
 document.getElementById("pclr").innerHTML=pset[pno][0];
 if(pset[pno][1]!=0)document.getElementById("pclr").innerHTML+=' '+pset[pno][1]+'月撮影';
 document.getElementById("pclr").innerHTML+="<span class='lpc'> クリックで閉じます</span><a href='pl/"+pset[pno][2]+"' target='_blank'>別ウィンドで表示</a>";
 document.getElementById("pclr").style.visibility="visible";
 document.getElementById("pl1").style.visibility="visible";
}

//縦拡大
function phb(inn){
if(inn.innerHTML=='拡大'){
 hratio=bh/plh;
 pw=Math.floor(plw*hratio);ph=bh;pt=0;
 document.getElementById("phfull").innerHTML='縮小';
 }
else{
 wratio=bw/plw;
 pw=bw;ph=Math.floor(plh*wratio);pt=Math.floor((bh-ph)/2);
 document.getElementById("phfull").innerHTML='拡大';
 }
document.getElementById("pct1").width=pw;
document.getElementById("pct1").height=ph;
document.getElementById("pct1").style.marginTop=pt+'px';
}

//拡大写真非表示
function plc(){
 document.getElementById("pct1").src="image/loading.jpg";
document.getElementById("pclr").innerHTML="";
document.getElementById("pl1").style.visibility="hidden";
document.getElementById("pclr").style.visibility="hidden";
 document.getElementById("pct1").width=10;
 document.getElementById("pct1").height=10;
document.getElementById("pi").innerHTML='';
document.getElementById("phfull").style.display='none';
document.getElementById("phfull").innerHTML='拡大';
}

