//記録成績画面で選択された年の画面に遷移する。
function getYear(){
	var url = document.getElementById("selectYear").value;
	window.location.href = url;
}

//記録成績画面に遷移した際にセレクトボックスの値を設定する。
function setYear(){
	var url = window.location.pathname;
	document.getElementById("selectYear").value = url;
}

//レース写真拡大表示ポップアップ
function dispRacePhoto(url){
	window.open(url, "_blank", "width=640,height=480,menubar=no");
}

//フォトギャラリーの左パーツセレクトボックスで選択されたカテゴリ画面に遷移する
function getCategory() {
	
	// セレクトボックスの選択した値を習得
	var s_year = document.getElementById("selectYear").value;
	var s_month = document.getElementById("selectMonth").value;
	
	var sendurl = "";
	
	// 指定年「すべて」が選択されていて かつ 指定月に「指定なし」を選択
	//     カテゴリ「すべて」ページへ遷移
	// 指定月「指定なし」以外が選択されていて かつ 指定年に「すべて」以外を選択
	//     指定年指定月のカテゴリページへ遷移
	// 上記以外はエラーメッセージを表示
	if(s_year == "listall") {
		if(s_month == "none") {
			sendurl = "/take/cs/gallery/" + s_year + "/1.htm";
		} else {
			document.getElementById("error-message").innerHTML = "表示年を選択してください。";
		}
	} else {
		if(s_month != "none") {
			sendurl = "/take/cs/gallery/list/" + s_year + "" + s_month + "/1.htm";
		} else {
			document.getElementById("error-message").innerHTML = "表示月を選択してください。";
		}
	}

	// 遷移先URLが設定されている場合は画面遷移
	if(sendurl != "") window.location.href = sendurl;
	
	return false;
}

// フォトギャラリー左パーツのセレクトボックスの初期選択状態を設定
function setCategory() {

	// ロケーションパスを取得し、配列を生成
	var patharray = window.location.pathname.split("/");
	
	// パスからカテゴリ部分を取得
	// 例)
	// /take/cs/gallery/list/200802/1.htm → 200802
	// /take/cs/gallery/listall/1.htm     → listall
	
	var category = patharray[patharray.length -2];
	
	// カテゴリ「すべて」の場合はデフォルト選択状態のままにする
	if(category == "listall") {
		return false;
	}
	
	if(category.length > 6) {
		if(category_id != "") {
			category = category_id;
		}
	}
	
	// カテゴリを年と月に分割
	var categoryYYYY = category.substring(0,4);
	var categoryMM = category.substring(4,6);
	
	// 年と月にそれぞれ設定
	document.getElementById("selectYear").value = categoryYYYY;
	document.getElementById("selectMonth").value = categoryMM;
	
	return false;
}

window.onload = setCategory;