document.write("<script language='javascript' type='text/javascript' src='/result/js/option.js'></script>");
	
// 路線会社一覧を更新
//document.getElementById("line_company_select").innerHTML = sCompany;
/*
var option_value = "";
$.post("/php/MakeSelectOption.php", { "linecompany" : "true" }, function(data){
	if( data.length > 0 ){
		option_value  = "<select id='line_company' size='1' onChange='Line_FindLine()' style='width:115px'>";
		option_value += "<option value=''>路線会社を選択</option>";
		option_value += data;
		option_value += "</select>";
		document.getElementById("line_company_select").innerHTML = option_value;
	}
});
*/

// 路線名を更新
function Line_FindLine(){
	var linecompany = document.getElementById('line_company').value;
	document.getElementById("line_line_select").innerHTML = aLine[linecompany];
/*
	var option_value = "";
	var linecompany = document.getElementById('line_company').value;
	$.post("/php/MakeSelectOption.php", { "linecompanyid" : linecompany }, function(data){
		if (data.length>0){
			option_value  = "<select id='line_line' size='1' style='width:150px'>";
			option_value += "<option value=''>路線名を選択</option>";
			option_value += data + "</select>";
			document.getElementById("line_line_select").innerHTML = option_value;
		}
	});
*/
}

// 市区を更新
function Area_FindCity(){
	var prefecture = document.getElementById('area_prefecture').value;
	document.getElementById("area_city_select").innerHTML = "<select id='area_city' size='1' style='width:170px'>" + aCity[prefecture].substring(aCity[prefecture].indexOf(">"));
}

// 路線検索
function LineSearch(){
	
	var sTargetLocation = "";
	var sResultPHP = "";
	var aCnt = [ 0, '' ];
	var bNeedCheck = false;
	
	var sRet = SetParticularCondition(aCnt);
	
	if( aCnt[0] == 0 ){		// 静的ページへ移動
		if( document.getElementById("line_line").value != "" ){		// 路線検索のとき
			sTargetLocation = "/result/station/" + document.getElementById("line_line").value + "_result01.html";
			//sResultPHP = "/result/result.php?mode=line&tab=2&comp=" + document.getElementById("line_company").value + "&line=" + document.getElementById("line_line").value;
			//bNeedCheck = true;
		}
		else{		// 全塾表示（条件なし）
			sTargetLocation = "/result/cram/result01.html";
		}
	}
	else if( aCnt[0] == 1 ){		// 静的ページへ移動（こだわり条件あり）
		var sPath = "";
		if( aCnt[1].indexOf("di") == -1 ){
			sPath = "particular";
		}
		else{
			sPath = "direction";
		}
		if( document.getElementById("line_line").value != "" ){		// 路線検索のとき
			sTargetLocation = "/result/" + sPath + "/" + aCnt[1] + "_" + document.getElementById("line_line").value + "_result01.html";
			sResultPHP = "/result/result.php?mode=line&tab=2&comp=" + document.getElementById("line_company").value + "&line=" + document.getElementById("line_line").value + sRet;
			bNeedCheck = true;
		}
		else{		// こだわり検索のとき
			sTargetLocation = "/result/" + sPath + "/" + aCnt[1] + "_result01.html";
			sResultPHP = "/result/result.php?mode=par&tab=1" + sRet;
			bNeedCheck = true;
		}
	}
	else{	// 動的ページへ移動
		if( document.getElementById("line_line").value != "" ){		// 路線検索のとき
			sTargetLocation = "/result/result.php?mode=line&tab=2&comp=" + document.getElementById("line_company").value + "&line=" + document.getElementById("line_line").value + sRet;
		}
		else{		// こだわり検索のとき
			sTargetLocation = "/result/result.php?mode=par&tab=1" + sRet;
		}
	}
	if( bNeedCheck == false ){
		self.location = sTargetLocation;
	}
	else if( sTargetLocation != "" ){
		$.post("/php/CheckFileExist.php", { "location" : sTargetLocation }, function(data){
			if (data.length>0){
				self.location = sTargetLocation;
			}
			else{	// 該当なしページへ（動的ページで0件を表示する）
				self.location = sResultPHP;
			}
		});
	}
	else{	// 該当なしページへ（動的ページで0件を表示する）
		self.location = sResultPHP;
	}
	
}

// 地域検索
function AreaSearch(){
	
	var sTargetLocation = "";
	var sResultPHP = "";
	var aCnt = [ 0, '' ];
	var bNeedCheck = false;
	
	var sRet = SetParticularCondition(aCnt);
	
	if( aCnt[0] == 0 ){		// 静的ページへ移動
		if(( document.getElementById("area_prefecture").value != "" ) && ( document.getElementById("area_city").value == "" )){		// 都県検索のとき
			sTargetLocation = "/result/area/" + document.getElementById("area_prefecture").value + "_result01.html";
		}
		else if(( document.getElementById("area_prefecture").value != "" ) && ( document.getElementById("area_city").value != "" )){		// 市区検索のとき
			sTargetLocation = "/result/area/" + document.getElementById("area_city").value + "_result01.html";
			//sResultPHP = "/result/result.php?mode=city&tab=1&pre=" + document.getElementById("area_prefecture").value + "&city=" + document.getElementById("area_city").value;
			//bNeedCheck = true;
		}
		else{		// 全塾表示（条件なし）
			sTargetLocation = "/result/cram/result01.html";
		}
	}
	else if( aCnt[0] == 1 ){		// 静的ページへ移動（こだわり条件あり）
		var sPath = "";
		if( aCnt[1].indexOf("di") == -1 ){
			sPath = "particular";
		}
		else{
			sPath = "direction";
		}
		if(( document.getElementById("area_prefecture").value != "" ) && ( document.getElementById("area_city").value == "" )){		// 都県検索のとき
			sTargetLocation = "/result/" + sPath + "/" + aCnt[1] + "_" + document.getElementById("area_prefecture").value + "_result01.html";
			sResultPHP = "/result/result.php?mode=pre&tab=1&pre=" + document.getElementById("area_prefecture").value + sRet;
			bNeedCheck = true;
		}
		else if(( document.getElementById("area_prefecture").value != "" ) && ( document.getElementById("area_city").value != "" )){		// 市区検索のとき
			sTargetLocation = "/result/" + sPath + "/" + aCnt[1] + "_" + document.getElementById("area_prefecture").value + "_" + document.getElementById("area_city").value + "_result01.html";
			sResultPHP = "/result/result.php?mode=city&tab=1&pre=" + document.getElementById("area_prefecture").value + "&city=" + document.getElementById("area_city").value + sRet;
			bNeedCheck = true;
		}
		else{		// こだわり検索のとき
			sTargetLocation = "/result/" + sPath + "/" + aCnt[1] + "_result01.html";
			sResultPHP = "/result/result.php?mode=par&tab=1" + sRet;
			bNeedCheck = true;
		}
	}
	else{	// 動的ページへ移動
		if(( document.getElementById("area_prefecture").value != "" ) && ( document.getElementById("area_city").value == "" )){		// 都県検索のとき
			sTargetLocation = "/result/result.php?mode=pre&tab=1&pre=" + document.getElementById("area_prefecture").value + sRet;
		}
		else if(( document.getElementById("area_prefecture").value != "" ) && ( document.getElementById("area_city").value != "" )){		// 市区検索のとき
			sTargetLocation = "/result/result.php?mode=city&tab=1&pre=" + document.getElementById("area_prefecture").value + "&city=" + document.getElementById("area_city").value + sRet;
		}
		else{		// こだわり検索のとき
			sTargetLocation = "/result/result.php?mode=par&tab=1" + sRet;
		}
	}
	if( bNeedCheck == false ){
		self.location = sTargetLocation;
	}
	else if( sTargetLocation != "" ){
		$.post("/php/CheckFileExist.php", { "location" : sTargetLocation }, function(data){
			if (data.length>0){
				self.location = sTargetLocation;
			}
			else{	// 該当なしページへ（動的ページで0件を表示する）
				self.location = sResultPHP;
			}
		});
	}
	else{	// 該当なしページへ（動的ページで0件を表示する）
		self.location = sResultPHP;
	}
}

// こだわり条件確認
function SetParticularCondition(aCnt){
	var sCondition = "";
	if( document.getElementById("check1").checked == true ){
		sCondition += "&co1=on";
		aCnt[0]++;
		aCnt[1] = "co01";
	}
	if( document.getElementById("check2").checked == true ){
		sCondition += "&co2=on";
		aCnt[0]++;
		aCnt[1] = "co02";
	}
	if( document.getElementById("check3").checked == true ){
		sCondition += "&co3=on";
		aCnt[0]++;
		aCnt[1] = "co03";
	}
	if( document.getElementById("check4").checked == true ){
		sCondition += "&co4=on";
		aCnt[0]++;
		aCnt[1] = "co04";
	}
	if( document.getElementById("check5").checked == true ){
		sCondition += "&co5=on";
		aCnt[0]++;
		aCnt[1] = "co05";
	}
	if( document.getElementById("check6").checked == true ){
		sCondition += "&co6=on";
		aCnt[0]++;
		aCnt[1] = "co06";
	}
	if( document.getElementById("check7").checked == true ){
		sCondition += "&co7=on";
		aCnt[0]++;
		aCnt[1] = "co07";
	}
	if( document.getElementById("check8").checked == true ){
		sCondition += "&co8=on";
		aCnt[0]++;
		aCnt[1] = "co08";
	}
	if( document.getElementById("check9").checked == true ){
		sCondition += "&co9=on";
		aCnt[0]++;
		aCnt[1] = "co09";
	}
	if( document.getElementById("check10").checked == true ){
		sCondition += "&co10=on";
		aCnt[0]++;
		aCnt[1] = "co10";
	}
	if( document.getElementById("check11").checked == true ){
		sCondition += "&co11=on";
		aCnt[0]++;
		aCnt[1] = "co11";
	}
	if( document.getElementById("check12").checked == true ){
		sCondition += "&co12=on";
		aCnt[0]++;
		aCnt[1] = "di01";
	}
	if( document.getElementById("check13").checked == true ){
		sCondition += "&co13=on";
		aCnt[0]++;
		aCnt[1] = "di02";
	}
	return sCondition;
}

// オプション設定用ダミー関数
function SetOption( dummy1, dummy2, dummy3 ){
	return true;
}


