function quickCheck()
{
	var url = document.quickForm.action;
	var select_value = document.quickForm.aral.selectedIndex;

	if(select_value == 0){
		return false;
	}else if(document.quickForm.sc){
		url += 'z-' + document.quickForm.zn.value + '/md-QUICK' + '/sc-' + document.quickForm.sc.value + '/al-' + document.quickForm.aral.value + '/';
	}else{
		url += 'z-' + document.quickForm.zn.value + '/md-QUICK' + '/al-' + document.quickForm.aral.value + '/';
	}

	if(document.quickForm.bizl.selectedIndex != 0){
		url += 'cl-' + document.quickForm.bizl.value +'/';
	}

	url += 'p-1/s-new/';

	location.href = url;
	return false;
}

function secondCheck()
{
	var url = document.secondForm.action;
	var select_value = document.secondForm.aral.selectedIndex;
	var select_value2 = document.secondForm.stid.selectedIndex;

	if(select_value == 0 || select_value2 == 0){
		return false;
	}else if(document.quickForm.sc){
		url += 'z-' + document.secondForm.zn.value + '/';
		url += 'md-SECOND/';
		url += 'sc-' + document.secondForm.sc.value + '/';
		url += 'ts-' + document.secondForm.stid.value + '/';
		url += 'al-' + document.secondForm.aral.value + '/';
	}else{
		url += 'z-' + document.secondForm.zn.value + '/';
		url += 'md-SECOND/';
		url += 'ts-' + document.secondForm.stid.value + '/';
		url += 'al-' + document.secondForm.aral.value + '/';
	}

	url += 'p-1/';

	location.href = url;
	return false;
}

function cityQuickCheck()
{	
	return true;
}

function citySecondCheck()
{	
	var value = document.citySecondForm.stid.selectedIndex;
	if(value == 0) {
		return false;
	}
	return true;
}

function wholeQuickCheck()
{
	var url = document.quickForm.action;

	if(document.quickForm.zn.selectedIndex == 0){
		return false;
	}else{
		url += 'z-' + document.quickForm.zn.value +'/md-QUICK/';
	}

	if(document.quickForm.bizl.selectedIndex != 0){
		url += 'cl-' + document.quickForm.bizl.value +'/';
	}

	url += 'p-1/s-new/';

	location.href = url;
	return false;
}

function wholeSecondCheck()
{
	var url = document.secondForm.action;
	var select_value = document.secondForm.zn.selectedIndex;
	var select_value2 = document.secondForm.aral.selectedIndex;
	var select_value3 = document.secondForm.stid.selectedIndex;

	if(select_value == 0 || select_value2 == 0 || select_value3 == 0){
		return false;
	}else{
		url += 'z-' + document.secondForm.zn.value + '/';
		url += 'md-SECOND/';
		url += 'ts-' + document.secondForm.stid.value + '/';
		url += 'al-' + document.secondForm.aral.value + '/';
	}

	url += 'p-1/';

	location.href = url;
	return false;
}

function secondChoice(action)
{	
	document.wholeSecondForm.method="post";
	document.wholeSecondForm.action=action;
	document.wholeSecondForm.submit();
}

function go_enkai_top(area) {
	if(navigator.cookieEnabled){
		document.cookie = 'sp_enkai_top='+ area +'; path=/;';
	}
}

function setOption(zn){
	var select_name_aral = document.secondForm.aral.options[0].text;
	var select_name_stid = document.secondForm.stid.options[0].text;

	area_len = document.secondForm.aral.options.length;
	for (i=area_len-1; i>=1; i--){
		document.secondForm.aral.options[i] = null;
	}
	theme_len = document.secondForm.stid.options.length;
	for (i=theme_len-1; i>=1; i--){
		document.secondForm.stid.options[i] = null;
	}
	
	url = "../API/getSecData.php";
	var myAjax = new Ajax.Request(
		url,
		{ 
			method: 'post',
			parameters: {zn:zn.value, type:"enkai"},
			onComplete: function(xmlhttp){
							callBack1(select_name_aral,select_name_stid,xmlhttp);
						}
		});

	document.secondForm.aral.selectedIndex = 0;
	document.secondForm.stid.selectedIndex = 0;
}
 
function callBack1(select_name_aral,select_name_stid,xmlhttp){
	var result = xmlhttp.responseText;
	document.secondForm.aral.options[0] = new Option(select_name_aral,'');
	document.secondForm.stid.options[0] = new Option(select_name_stid,'');
	
	var resArray = result.split("/");
	var areal_data = resArray[0].split(",");
	var theme = resArray[1].split(",");
	
	for (i=0; i<areal_data.length; i++) {
		var kenArray = areal_data[i].split(":");
		document.secondForm.aral.options[i+1] = new Option(kenArray[1], kenArray[0]);
	}
	
	for (i=0; i<theme.length; i++) {
		var themeArray = theme[i].split(":");
		document.secondForm.stid.options[i+1] = new Option(themeArray[1], themeArray[0]);
	}

}
//検索結果から戻った場合の再読み込み

function secondReload(){
	if(document.quickForm){
		if(document.quickForm.zn){
			document.quickForm.zn.selectedIndex = 0;
		}
		if(document.quickForm.bizl){
			document.quickForm.bizl.selectedIndex = 0;
		}
	}
	zn = document.secondForm.zn.options[document.secondForm.zn.selectedIndex].value;
	if(zn == ""){
		return false;
	}

	area_len = document.secondForm.aral.options.length;
	for (i=area_len-1; i>=1; i--){
		document.secondForm.aral.options[i] = null;
	}
	theme_len = document.secondForm.stid.options.length;
	for (i=theme_len-1; i>=1; i--){
		document.secondForm.stid.options[i] = null;
	}

	document.secondForm.aral.selectedIndex = 0;
	document.secondForm.stid.selectedIndex = 0;

	url = "../API/getSecData.php";
	var myAjax = new Ajax.Request(
		url,
		{ 
			method: 'post',
			parameters: {zn:zn, type:"enkai"},
			onComplete: callBack1
		});
}

function setSecondAreaOption(aral){
	url = "http://sp.gnavi.co.jp/API/getPullDownData.php";
	var zn_val = document.secondForm.zn.value;
	var aral_val = aral.value;
	var select_name = document.secondForm.stid.options[0].text;

	var myAjax = new Ajax.Request(
		url,
		{ 
			method: 'post',
			parameters: {region:zn_val, aral:aral_val, type:"enkai", s_type:"second"},
			onComplete: function(xmlhttp){
							callBackSecond("theme",select_name,xmlhttp);
						}
		});
}

function setSecondStidOption(stid){
	url = "http://sp.gnavi.co.jp/API/getPullDownData.php";
	var zn_val = document.secondForm.zn.value;
	var stid_val = stid.value;
	var select_name = document.secondForm.aral.options[0].text;

	var myAjax = new Ajax.Request(
		url,
		{ 
			method: 'post',
			parameters: {region:zn_val, stid:stid_val, type:"enkai", s_type:"second"},
			onComplete: function(xmlhttp){
							callBackSecond("area",select_name,xmlhttp);
						}
		});
}

function setScSecondAreaOption(aral){
	url = "http://sp.gnavi.co.jp/API/getPullDownData.php";
	var zn_val = document.secondForm.zn.value;
	var sc_val = document.secondForm.sc.value;
	var aral_val = aral.value;
	var select_name = document.secondForm.stid.options[0].text;

	var myAjax = new Ajax.Request(
		url,
		{ 
			method: 'post',
			parameters: {region:zn_val, aral:aral_val, sc:sc_val, type:"enkai", s_type:"second"},
			onComplete: function(xmlhttp){
							callBackSecond("theme",select_name,xmlhttp);
						}
		});
}

function setScSecondStidOption(stid){
	url = "http://sp.gnavi.co.jp/API/getPullDownData.php";
	var zn_val = document.secondForm.zn.value;
	var sc_val = document.secondForm.sc.value;
	var stid_val = stid.value;
	var select_name = document.secondForm.aral.options[0].text;

	var myAjax = new Ajax.Request(
		url,
		{ 
			method: 'post',
			parameters: {region:zn_val, stid:stid_val, sc:sc_val, type:"enkai", s_type:"second"},
			onComplete: function(xmlhttp){
							callBackSecond("area",select_name,xmlhttp);
						}
		});
}
function callBackSecond(list_type,select_name,xmlhttp){
	var result = xmlhttp.responseText;
	var data = result.split(",");

	if(list_type == "theme"){
		var index = document.secondForm.stid.selectedIndex;
		var stid_value = document.secondForm.stid.options[index].value;

		theme_len = document.secondForm.stid.options.length;
		for (i=theme_len-1; i>=0; i--){
			document.secondForm.stid.options[i] = null;
		}

		document.secondForm.stid.options[0] = new Option(select_name,'');
		for (i=0; i<data.length; i++) {
			var themeArray = data[i].split(":");
			document.secondForm.stid.options[i+1] = new Option(themeArray[1], themeArray[0]);
			if(themeArray[0] == stid_value){
				document.secondForm.stid.selectedIndex = i+1;
			}
		}
	}else if(list_type == "area"){
		var index = document.secondForm.aral.selectedIndex;
		var aral_value = document.secondForm.aral.options[index].value;

		area_len = document.secondForm.aral.options.length;
		for (i=area_len-1; i>=0; i--){
			document.secondForm.aral.options[i] = null;
		}

		document.secondForm.aral.options[0] = new Option(select_name,'');
		for (i=0; i<data.length; i++) {
			var kenArray = data[i].split(":");
			document.secondForm.aral.options[i+1] = new Option(kenArray[1], kenArray[0]);
			if(kenArray[0] == aral_value){
				document.secondForm.aral.selectedIndex = i+1;
			}
		}
	}
}

function setQuickZnOption(zn){
	url = "http://sp.gnavi.co.jp/API/getPullDownData.php";
	var zn_val = zn.value;
	var select_name = document.quickForm.bizl.options[0].text;

	var myAjax = new Ajax.Request(
		url,
		{ 
			method: 'post',
			parameters: {region:zn_val, type:"enkai", s_type:"quick", area_type:"zenkoku"},
			onComplete: function(xmlhttp){
							callBackQuick("bizl",select_name,xmlhttp);
						}
		});
}

function setQuickZnBizlOption(bizl){
	url = "http://sp.gnavi.co.jp/API/getPullDownData.php";
	var bizl_val = bizl.value;
	var select_name = document.quickForm.zn.options[0].text;

	var myAjax = new Ajax.Request(
		url,
		{ 
			method: 'post',
			parameters: {bizl:bizl_val, type:"enkai", s_type:"quick", area_type:"zenkoku"},
			onComplete: function(xmlhttp){
							callBackQuick("zn",select_name,xmlhttp);
						}
		});
}

function setQuickAreaOption(aral){
	url = "http://sp.gnavi.co.jp/API/getPullDownData.php";
	var zn_val = document.quickForm.zn.value;
	var aral_val = aral.value;
	var select_name = document.quickForm.bizl.options[0].text;
	
	var myAjax = new Ajax.Request(
		url,
		{ 
			method: 'post',
			parameters: {region:zn_val, aral:aral_val, type:"enkai", s_type:"quick"},
			onComplete: function(xmlhttp){
							callBackQuick("bizl",select_name,xmlhttp);
						}
		});
}

function setQuickBizlOption(bizl){
	url = "http://sp.gnavi.co.jp/API/getPullDownData.php";
	var zn_val = document.quickForm.zn.value;
	var bizl_val = bizl.value;
	var select_name = document.quickForm.aral.options[0].text;

	var myAjax = new Ajax.Request(
		url,
		{ 
			method: 'post',
			parameters: {region:zn_val, bizl:bizl_val, type:"enkai", s_type:"quick"},
			onComplete: function(xmlhttp){
							callBackQuick("area",select_name,xmlhttp);
						}
		});
}

function setScQuickAreaOption(aral){
	url = "http://sp.gnavi.co.jp/API/getPullDownData.php";
	var zn_val = document.quickForm.zn.value;
	var sc_val = document.quickForm.sc.value;
	var aral_val = aral.value;
	var select_name = document.quickForm.bizl.options[0].text;
	
	var myAjax = new Ajax.Request(
		url,
		{ 
			method: 'post',
			parameters: {region:zn_val, aral:aral_val, sc:sc_val, type:"enkai", s_type:"quick"},
			onComplete: function(xmlhttp){
							callBackQuick("bizl",select_name,xmlhttp);
						}
		});
}

function setScQuickBizlOption(bizl){
	url = "http://sp.gnavi.co.jp/API/getPullDownData.php";
	var zn_val = document.quickForm.zn.value;
	var sc_val = document.quickForm.sc.value;
	var bizl_val = bizl.value;
	var select_name = document.quickForm.aral.options[0].text;
	
	var myAjax = new Ajax.Request(
		url,
		{ 
			method: 'post',
			parameters: {region:zn_val, bizl:bizl_val, sc:sc_val, type:"enkai", s_type:"quick"},
			onComplete: function(xmlhttp){
							callBackQuick("area",select_name,xmlhttp);
						}
		});
}

function callBackQuick(list_type,select_name,xmlhttp){
	var result = xmlhttp.responseText;
	var data = result.split(",");
	if(list_type == "bizl"){
		var index = document.quickForm.bizl.selectedIndex;
		var bizl_value = document.quickForm.bizl.options[index].value;
		//テーマプルダウン初期化
		bizl_len = document.quickForm.bizl.options.length;
		for (i=bizl_len-1; i>=0; i--){
			document.quickForm.bizl.options[i] = null;
		}

		document.quickForm.bizl.options[0] = new Option(select_name,'');
		for (i=0; i<data.length; i++) {
			var bizlArray = data[i].split(":");
			document.quickForm.bizl.options[i+1] = new Option(bizlArray[1], bizlArray[0]);
			if(bizlArray[0] == bizl_value){
				document.quickForm.bizl.selectedIndex = i+1;
			}
		}
	}else if(list_type == "area"){
		var index = document.quickForm.aral.selectedIndex;
		var aral_value = document.quickForm.aral.options[index].value;

		area_len = document.quickForm.aral.options.length;
		for (i=area_len-1; i>=0; i--){
			document.quickForm.aral.options[i] = null;
		}

		document.quickForm.aral.options[0] = new Option(select_name,'');
		for (i=0; i<data.length; i++) {
			var kenArray = data[i].split(":");
			document.quickForm.aral.options[i+1] = new Option(kenArray[1], kenArray[0]);
			if(kenArray[0] == aral_value){
				document.quickForm.aral.selectedIndex = i+1;
			}
		}
	}else if(list_type == "zn"){
		var index = document.quickForm.zn.selectedIndex;
		var zn_value = document.quickForm.zn.options[index].value;
		
		zn_len = document.quickForm.zn.options.length;
		for (i=zn_len-1; i>=0; i--){
			document.quickForm.zn.options[i] = null;
		}

		document.quickForm.zn.options[0] = new Option(select_name,'');
		for (i=0; i<data.length; i++) {
			var tiikiArray = data[i].split(":");
			document.quickForm.zn.options[i+1] = new Option(tiikiArray[1], tiikiArray[0]);
			if(tiikiArray[0] == zn_value){
				document.quickForm.zn.selectedIndex = i+1;
			}
		}
	}
}

window.onload = function(){
	if(document.quickForm){
		if(document.quickForm.zn){
			if(document.quickForm.zn.type != 'hidden'){
				document.quickForm.zn.selectedIndex = 0;
			}
		}
		if(document.quickForm.aral){
			if(document.quickForm.aral.type != 'hidden'){
				document.quickForm.aral.selectedIndex = 0;
			}
		}
		if(document.quickForm.bizl){
			document.quickForm.bizl.selectedIndex = 0;
		}
	}
	if(document.secondForm){
		if(document.secondForm.zn){
			if(document.secondForm.zn.type != 'hidden'){
				document.secondForm.zn.selectedIndex = 0;
			}
		}
		if(document.secondForm.aral){
			if(document.secondForm.aral.type != 'hidden'){
				document.secondForm.aral.selectedIndex = 0;
			}
		}
		if(document.secondForm.stid){
			document.secondForm.stid.selectedIndex = 0;
		}
	}
}

