//各種初期設定

//ファイル名を配列化（毎月増える）
filenames = new Array();
filenames[36] = "200404.shtml";
filenames[35] = "200403.shtml";
filenames[34] = "200402.shtml";
filenames[33] = "200401.shtml";
filenames[32] = "200312.shtml";
filenames[31] = "200311.shtml";
filenames[30] = "200310.shtml";
filenames[29] = "200309.shtml";
filenames[28] = "200308.shtml";
filenames[27] = "200307.shtml";
filenames[26] = "200306.shtml";
filenames[25] = "200305.shtml";
filenames[24] = "200304.shtml";
filenames[23] = "200303.shtml";
filenames[22] = "200302.shtml";
filenames[21] = "200301.shtml";
filenames[20] = "200212.shtml";
filenames[19] = "200211.shtml";
filenames[18] = "200210.shtml";
filenames[17] = "200209.shtml";
filenames[16] = "200208.shtml";
filenames[15] = "200207.shtml";
filenames[14] = "200206.shtml";
filenames[13] = "200205.shtml";
filenames[12] = "200204.shtml";
filenames[11] = "200203.shtml";
filenames[10] = "200202.shtml";
filenames[9] = "200201.shtml";
filenames[8] = "200112.shtml";
filenames[7] = "200111.shtml";
filenames[6] = "200110.shtml";
filenames[5] = "200109.shtml";
filenames[4] = "200108.shtml";
filenames[3] = "200107.shtml";
filenames[2] = "200106.shtml";
filenames[1] = "200105.shtml";
filenames[0] = "200104.shtml";

//ブラウザのメジャーバージョン
ver = parseFloat(navigator.appVersion.substring(0,1));

//現在の時間
dd = new Date();
hour = dd.getHours();

//CSSファイル読み替え
if (ver >= 4) {
	os = navigator.platform.substring(0,3);
	osname = new String();
	timetable = new String();
//OSチェック
	if (os == 'Win') {
		osname = 'win';
	} else {
		osname = 'mac';
	}
//時間帯チェック
	if (hour < 3) {
		timetable = 'midnight';
	} else if (hour < 6) {
		timetable = 'night';
	} else if (hour < 8) {
		timetable = 'morning';
	} else if (hour < 17) {
		timetable = 'daytime';
	} else if (hour < 19) {
		timetable = 'evening';
	} else {
		timetable = 'night';
	}
//CSSファイル読込み行
	document.write('<link rel="stylesheet" href="styles-' + osname + '-' + timetable + '.css">');
}

//イメージ先行読込み
MM_preloadImages('image/help_on.gif');

//最新のファイル名（ファイル名配列の最後の値）
last = filenames.length - 1;
latestfile = filenames[last];

//自分自身のファイル名
//URLを取得し、最後の／が何番目の文字かを取得
docURL = new String(document.URL);
doclength = docURL.length;
lastslash = document.URL.lastIndexOf("/",doclength);
//URLを取得し、最後の＃が何番目の文字かを取得
lastsharp = document.URL.lastIndexOf("#",doclength);
//＃が無いの場合は「lastsharp = doclength」とする
if (lastsharp == -1){
	lastsharp = doclength;
}
//URLの最後の／の次から＃の一個前（無い場合は一番最後の文字）までの文字列（ファイル名）を取得
filename = docURL.substring(lastslash+1,lastsharp);
//ディレクトリ指定（ファイル名が空）の場合は「index.html」とする
if (filename == ''){
	filename = 'index.html';
}

//自分自身がファイル名配列の何番目か
filenumber = new Number();
for (i = 0; i < filenames.length; i++) {
	if (filenames[i] == filename){
		filenumber = i;
		break;
	}
}


//カウンター用
function counter() {
	if (filename == latestfile){
//時間帯によるカウンター色の定義
		countercolors = new String();
		if (hour < 3) {
			countercolors = 'FFFFFF,1A255E';
		} else if (hour < 6) {
			countercolors = 'FFC000,333D70';
		} else if (hour < 8) {
			countercolors = '000000,8E89A6';
		} else if (hour < 17) {
			countercolors = '003366,99E6FF';
		} else if (hour < 19) {
			countercolors = '000000,F3AB9E';
		} else {
			countercolors = 'FFC000,333D70';
		}
//カウンターの表示
		document.write('<td width="100"><img src="image/menu-counter_top.gif" width="100" height="12"><br><img src="image/menu-counter_left.gif" width="18" height="14"><img src="http://cgi.dns.ne.jp/cgi-bin/npc.cgi?L=syruthera-diary&W=5&P=ON&DI=2&C='+countercolors+'&INIT=1" width="70" height="14" alt="counter"><img src="image/menu-counter_right.gif" width="12" height="14"><br><img src="image/menu-counter_bottom.gif" width="100" height="14"></td>\n');
	} else {
		document.write('');
	}
}


//このファイルがindex.htmlの場合
//最新ページへジャンプ
function golatest() {
  location.href = latestfile;
}

//５秒後に最新ページへジャンプ
function golatestdiary() {
  setTimeout("golatest()", 5000);
}

//最新ページへジャンプするMETAタグ
function golatestmeta() {
  document.write('<meta http-equiv="refresh" content="5;url=' + latestfile + '">\n');
}

//最新ページへジャンプするリンク
function golatestlink() {
  document.write('<a href="' + latestfile + '">最新の日記へ</a>');
}


//履歴メニュー用
function menutogo(sel) {
	if (sel.options[sel.selectedIndex].value) {
		location.href = sel.options[sel.selectedIndex].value;
	}
}


//履歴プルダウン表示
function linklist() {
	document.write('<select name="select" onChange="menutogo(this)">\n');
	for (i = filenames.length-1; i >= 0; i--) {
		fileyear = filenames[i].substring(0,4) ;
		filemonth = filenames[i].substring(4,6) ;
		if (filename == filenames[i]) {
			document.write('										<option value="' + filenames[i] + '" SELECTED>' + fileyear + '/' + filemonth + '</option>\n');
		} else {
			document.write('										<option value="' + filenames[i] + '">' + fileyear + '/' + filemonth + '</option>\n');
		}
	}
	document.write('									</select>');
}


//「前」のリンクの表示
function prevlink() {
	if (filenumber == 0) {
		document.write('<img src="image/button_prev-inhibit.gif" width="32" height="16" border="0" alt="">');
	} else {
		document.write('<a href="' + filenames[filenumber-1] + '"><img src="image/button_prev.gif" width="32" height="16" border="0" alt="prev"></a>');
	}
}

//「次」のリンクの表示
function nextlink() {
	if (filenumber == filenames.length-1) {
		document.write('<img src="image/button_next-inhibit.gif" width="32" height="16" border="0" ALT="">');
	} else {
		document.write('<a href="' + filenames[filenumber+1] + '#01"><img src="image/button_next.gif" width="32" height="16" border="0" alt="next"></a>');
	}
}

//Dreamweaverもの
function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;	if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	 if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}
