﻿var yamalist = new Array("111009","110925","110828","110812","110723","110522","110520","110504","110503","100919","100813","100718","100709","100708","091012","091011","090719","090503","080415","080413","080409","070924","070811","070613","070520","070503","070429","070318","070304","061103","061022","061015","061009","060923","060903","060820","060716","060325","060304","060211","051120","051105","051030","051013","051001","050917","050828","050820","050814","050807","050805","050723","050722","050717","050628","050625","050517","050503","041128","041114","041024","041017","041011","040807","040723","040718","040501","040413","040227","040201","031123","031102","031027","030810","030802","030801","030629","030622","030525","030502","021023","021017","021005","020921","020831","020804","020602","011202","011125","011123","011111","011027","011014","010923","010825");
var walklist = new Array("110604","070412c","070412b","070412a","061016","061012","061011c","061011b","061011a","060928","060922","060921","060915","060913","060629","060627","060621","060620","060617","060616","060613","050614","050527","050520","050421","050414","041220","041210","041130","041109","040916","040915","040901","040829","040828","040722","040715","040714","040706","040702","040701","040629","040628","040623","040616","040615","040612","040604","040511","040507","040505","020815");
var tabilist = new Array("070605","070604","070603","070602","070601","070531","070530","070529","070528","070527","070526","070525","070524","070523","070522","070521","070413","070412","070411","070410","070405","070404","070403","061113","061112","061111","061110","061109","061108","061107","061106","061105","061104","061103","061102","061101","061031","061030","061029","061028","061027","061022","061020","061019","061018","061017","061016","061015","061014","061013","061012","061011","061010","061009","061008","061007","061006","061005","061004","061003","061002","061001","060930","060929","060928","060927","060926","060925","060924","060923","060922","060921","060920","060919","060918","060917","060916","060915","060914","060913","060912","060911","060910","060909","060908","060907","060906","060905","060904","060903","060902","060901","060831","060830","060829","060828","060827","060826","060825","060824","060823","060822","060821","060820","060819","060807","060806","060805","060804","060802","060801","060731","060730","060728","060727","060726","060724","060713","060711","060708","060706","060704","060703","060702","060618","060615","060612");
var yskilist = new Array("950508","930320","920603","920503","900603","900527","900526","900506","900304","900303","880616","880615","880501","880416","880328","870601","870330","860413","850322","830503");
var nikilist = new Array("111017","110907","110906","110829","110816","110719","110715","110524","091125","090707","090704","090517","090514","090417","090227","090224","090221","090219");

var str  = location.pathname;
var regexp = /\D{5}\d{6}[abc]?/;
var result = str.match(regexp) + "";
var regexp1 = /\w{4}/;
var regexp2 = /\d{6}[abc]?/;
var group   = result.match(regexp1) + "";			// グループ名取得
var strDate = result.match(regexp2) + "";			// 日付フォルダ名取得
var myYear  = Number(strDate.substr(0,2));			//　年取得（2桁）
var myMonth = Number(strDate.substr(2,2));			//　月取得
var myDay   = Number(strDate.substr(4,2));			//　日取得

if (myYear > 60) {									//　4桁年に変換
	myYear += 1900;
} else {
	myYear += 2000;
}

var list;
if (group == "yama") list = yamalist;
if (group == "walk") list = walklist;
if (group == "yski") list = yskilist;
if (group == "tabi") list = tabilist;
if (group == "niki") list = nikilist;

var listlen = list.length;

for (var i=0; i<listlen; i++) {
	if (Number(list[i].substr(0,2)) > 60) {
		list[i] = "19" + list[i];
	} else {
		list[i] = "20" + list[i];
	}
}
list = list.sort();						//　日付リストを昇順にソート　

var pos;
for (var i=0; i<listlen; i++) {
	if (strDate == list[i].substr(2)) {
		pos = i;
		break;
	}
}

function dispCalendar() {
	var lastDay = new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
	var strWeek = new Array("日","月","火","水","木","金","土");
	var calDate = new Array(38);
	var myDate  = new Date();				// 日付オブジェクトを生成

	myDate.setYear(myYear);					// 指定年を取得
	myDate.setMonth(myMonth-1);				// 指定月を取得

	if (((myYear % 4 == 0) && (myYear % 100 != 0)) || (myYear % 400 == 0)) lastDay[2]++;	//　2月を29日にする
	myDate.setDate(1);						// 日付を１日にする
	var offset = myDate.getDay();			// その月の1日の曜日取得（暦の開始曜日＝offset）

	var i, j, d, str1, str2;
	var str3 = '&lt;&lt;';
	var str4 = '&gt;&gt;';


	for (i=0; i<=38; i++) calDate[i] = "　";						//　カレンダー全セルにスペース設定
	for (i=1; i<=lastDay[myMonth]; i++) calDate[i+offset-1] = i;	//　カレンダー日付設定
	calDate[myDay+offset-1] = '<a href="../'+strDate+'/index.html"><u><b>'+calDate[myDay+offset-1]+'</b></u></a>';

	if (pos >= 0 && pos < listlen) {
		i = 1;
		while (pos+i < listlen) {				//　同月の山行日後方検索
			str1 = list[pos+i].substr(2);
			str2 = strDate;
			if (str1.substr(0,4) == str2.substr(0,4)) {
				d = Number(str1.substr(4,2));
				calDate[d+offset-1]='<a href="../'+str1+'/index.html"><u><b>'+calDate[d+offset-1]+'</b></u></a>';
			} else {
				break;
			}
			i++;
		}
		i = 1;
		while (pos-i >= 0) {				//　同月の山行日前方検索
			str1 = list[pos-i].substr(2);
			str2 = strDate;
			if (str1.substr(0,4) == str2.substr(0,4)) {
				d = Number(str1.substr(4,2));
				calDate[d+offset-1]='<a href="../'+str1+'/index.html"><u><b>'+calDate[d+offset-1]+'</b></u></a>';
			} else {
				break;
			}
			i++;
		}
		i = 1;
		while (pos+i < listlen) {				//　後方月の山行日検索
			str1 = list[pos+i].substr(2);
			str2 = strDate;
			if (str1.substr(0,4) != str2.substr(0,4)) {
				str4 = '<a href="../'+str1+'/index.html"><b>&gt;&gt;</b></a>';
				break;
			}
			i++;
		}
		i = 1;
		while (pos-i >= 0) {				//　前方月の山行日検索
			str1 = list[pos-i].substr(2);
			str2 = strDate;
			if (str1.substr(0, 4) != str2.substr(0, 4)) {
				str3 = '<a href="../'+str1+'/index.html"><b>&lt;&lt;</b></a>';
				break;
			}
			i++;
		}
	}
	with (document) {						//　カレンダー描画
		write('<table id="javacal"><tr>');
		write('<td align="right">' + str3 + '</td>');
		write('<td height="20" colspan="5">' + myYear + '年' + myMonth + '月</td>');			//　年月書き出し
		write('<td align="left">' + str4 + '</td></tr><tr>');
		for (i=0; i<7; i++) write('<td>',strWeek[i],'</td>');								//　曜日書き出し
		write('</tr>');
		for (i = 0; i < 38; i++) {
			write('<td>'+calDate[i]+'</td>');
			if (i % 7 == 6) write('</tr><tr>');
		}
		write('</tr></table>');
	}
}


function bifoDate() {
	var j = pos-1;
	if (j>=0 && j<listlen) {
		document.write('<a href="../'+list[j].substring(2)+'/index.html"><b>&lt;&lt;</b></a>');
	} else {
		document.write("&lt;&lt;");
	}
}
function nextDate() {
	var j = pos + 1;
	if (j >= 0 && j < listlen) {
		document.write('<a href="../'+list[j].substring(2)+'/index.html"><b>&gt;&gt;</b></a>');
	} else {
		document.write("&gt;&gt;");
	}
}

function bifoDate2() {
	var j = pos - 1;
	if (j >= 0 && j < listlen) {
		document.write('<a href="../'+list[j].substring(2)+'/index.html">&lt;&lt; 前記事（'+list[j].substr(2,2)+'/'+ list[j].substr(4,2)+'/'+ list[j].substr(6,2)+'）</a>');
	}
}
function nextDate2() {
	var j = pos + 1;
	if (j >= 0 && j < listlen) {
		document.write('<a href="../'+list[j].substring(2)+'/index.html">後記事（'+list[j].substr(2,2)+'/'+ list[j].substr(4,2)+'/'+ list[j].substr(6,2)+'） &gt;&gt;</a>');
	}
}

function archive() {
	var i, n, myYear1, myYear2, dateStr, str1, str2;
	with (document) {						//　年別アーカイブ描画
		write('<ul>');
		n = 0;
		myYear1 = list[0].substr(0, 4);
		dateStr = list[0].substr(2, 6);
		write('<li><a href=../' + dateStr + '/index.html>' + myYear1 + '年');
		for (i = 1; i < listlen; i++) {
			myYear2 = list[i].substr(0,4);
			n++;
			if (myYear1 != myYear2) {
				write(' （' + n + '）</a></li>');
				dateStr = list[i].substr(2);
				write('<li><a href=../' + dateStr + '/index.html>' + myYear2 + '年');
				myYear1 = myYear2;
				n = 0;
			}
		}
		write(' （' + (n+1) + '）</a></li></ul>');
	}
}

function archive2() {
	var str1 = list[0];
	myMemo = 0;
	var arclist = new Array();

	var j = 0;
	for (var i = 1; i < listlen; i++) {
		str2 = list[i];
		if (str1.substr(0,4) != str2.substr(0,4)) {
			arclist[j] = str2;
			str1 = str2;
			j++;
		}
	}
//	arclist.reverse();							//　年別リストを逆順（降順）にする

	with (document) {							//　年別アーカイブ描画
		write('<ul>');
		for (i = 0; i < j; i++) {
			str1 = arclist[i];
			myYear = Number(str1.substr(0, 2));
			myMonth= Number(str1.substr(2, 2));
			if (myYear > 60) {					//　4桁年に変換
				myYear += 1900;
			} else {
				myYear += 2000;
			}

			if (myMemo == 0) {
				write('<li><a href=../' + arclist[i] + '/index.html>' + myYear + '年' + myMonth + '月</a>　');
				myMemo = myYear;
			} else {
				if (myMemo != myYear) {
					write('</li><li><a href=../' + arclist[i] + '/index.html>' + myYear + '年' + myMonth + '月</a>　');
					myMemo = myYear;
				} else {
					write('<a href=../' + arclist[i] + '/index.html>' + myMonth + '月</a>　');
				}
			}
		}
		write('</li></ul>');
	}
}

var OnOff = true;
function cameraicon() {
	OnOff ? OnOff=false : OnOff=true;
	if (!OnOff) {
		top.map.displayLayer('*.*.P1',0);
	} else {
 		top.map.displayLayer('*.*.P1',1);
	}
}

var MapCh = true;
function mapchange() {
	MapCh ? MapCh=false : MapCh=true;
	if (!MapCh) {
		prmSCL=100000;
		top.map.setMapCenter(prmX,prmY,prmSCL);
		top.map.openMap();
		top.map.ChangeRasterMap(1);
	} else{ 
		prmSCL=15000;
		top.map.setMapCenter(prmX,prmY,prmSCL);
		top.map.openMap();
 		top.map.ChangeRasterMap(0);
	}
	top.map.openMap();
}

function move(url) {
	location.href = url;
}	
