
function setCountry(dc){	
	var dest = dc;
	var cnt =0;
	var p_countrySet;
	for(i=0;i<document.sForm.elements.length;i++){
		if(document.sForm.elements[i].type == 'select-one' && document.sForm.elements[i].name == 'p_prefecture'){
				var p_countrySet = document.sForm.elements[i];
		}
	}
	p_countrySet.options.length = 1;
	if(dest != ""){
		for( i=0; i < countryList.length; i++){
			if (countryList[i].dest == dest){
				cnt = cnt +1;
				p_countrySet.options[cnt] = new Option(countryList[i].name,countryList[i].group);
			}
		}
		if(dest == 13){
			dest = 14;
			for( i=0; i < countryList.length; i++){
				if (countryList[i].dest == dest){
					cnt = cnt +1;
					p_countrySet.options[cnt] = new Option(countryList[i].name,countryList[i].group);
				}
			}
		}
		if(dest == 14){
			dest = 15;
			for( i=0; i < countryList.length; i++){
				if (countryList[i].dest == dest){
					cnt = cnt +1;
					p_countrySet.options[cnt] = new Option(countryList[i].name,countryList[i].group);
				}
			}
		}
   	}
	   	
	p_countrySet.options.length = cnt+1;
	p_countrySet.selectedIndex = 0;

}

function setCity(cc ){
	var country = cc;
	var cnt =0;
	
	this.document.sForm.p_city.options.length = 1;
	if(country != ""){
		for(i=0; i< cityList.length; i++){
			if (cityList[i].country == country ){
				cnt = cnt +1;
				this.document.sForm.p_city.options[cnt]=new Option(cityList[i].name, cityList[i].code);
			}
		}
	}
	this.document.sForm.p_city.options.length = cnt+1;
	this.document.sForm.p_city.selectedIndex = 0;
}

function setCityV(){
	var num = document.sForm.p_city.selectedIndex;
	var city = document.sForm.p_city.options[num].value;
}

function setGroup(gc){	
	var group = gc;
	var cnt =0;
	
	this.document.sForm.p_prefecture.options.length = 1;
	if(group != ""){
		for( i=0; i < countryList.length; i++){
			if (countryList[i].group == group){
				cnt = cnt +1;
				this.document.sForm.p_prefecture.options[cnt] = new Option(countryList[i].name, countryList[i].code);
			}
		}
   	}
	   	
	this.document.sForm.p_prefecture.options.length = cnt+1;
	this.document.sForm.p_prefecture.selectedIndex = 0;
	this.document.sForm.p_city.options.length = 1;
	this.document.sForm.p_city.selectedIndex = 0;

}


//list
function destRec(naigai, code, name){
	this.naigai = naigai;
	this.code = code;
	this.name = name;
	return
}

function makeArray(n){
	this.length=n;
	for(var i=1; i<=n; i++)
	this[i]=null;
	return this;
}

function countryRec(dest, code, name, group){
	this.dest = dest;
	this.code = code;
	this.name = name;
	this.group = group;
}

function cityRec(country, code, name){
	this.country = country;
	this.code = code;
	this.name = name;
}

function hatsuRec(dest, code, name, group){
	this.dest = dest;
	this.code = code;
	this.name = name;
	this.group = group;
}

function setRes(){
	document.sForm.reset();
}

var i ;

var hatsuList=new makeArray();
i = 0;
hatsuList[i++] =new hatsuRec('J','104','関東','01');
hatsuList[i++] =new hatsuRec('J','106','関西','02');
hatsuList[i++] =new hatsuRec('J','105','中部・北陸','03');
hatsuList[i++] =new hatsuRec('J','103','中部・北陸','03');
hatsuList[i++] =new hatsuRec('J','111','中部・北陸','03');
hatsuList[i++] =new hatsuRec('J','109','九州','04');
hatsuList[i++] =new hatsuRec('J','101','北海道','05');
hatsuList[i++] =new hatsuRec('J','102','東北','06');
hatsuList[i++] =new hatsuRec('J','107','中国・四国','07');
hatsuList[i++] =new hatsuRec('J','108','中国・四国','07');
hatsuList.length =10;

var destList=new makeArray();
i = 0;
destList[i++] =new destRec('W','HWI','ハワイ');
destList[i++] =new destRec('W','MNA','ミクロネシア');
destList[i++] =new destRec('W','AAS','アジア');
destList[i++] =new destRec('W','BEU','ヨーロッパ');
destList[i++] =new destRec('W','DNU','北アメリカ');
destList[i++] =new destRec('W','ESU','南アメリカ');
destList[i++] =new destRec('W','FOC','オセアニア');
destList[i++] =new destRec('W','CAF','アフリカ');
destList[i++] =new destRec('W','CHT','中近東');
destList.length =9;

var countryList=new makeArray();
i = 0;
countryList[i++] =new countryRec('10','J','北海道','01');
countryList[i++] =new countryRec('11','J','青森県','02');
countryList[i++] =new countryRec('11','J','岩手県','03');
countryList[i++] =new countryRec('11','J','宮城県','04');
countryList[i++] =new countryRec('11','J','秋田県','05');
countryList[i++] =new countryRec('11','J','山形県','06');
countryList[i++] =new countryRec('11','J','福島県','07');
countryList[i++] =new countryRec('12','J','茨城県','08');
countryList[i++] =new countryRec('12','J','栃木県','09');
countryList[i++] =new countryRec('12','J','群馬県','10');
countryList[i++] =new countryRec('21','J','東京都','13');
countryList[i++] =new countryRec('12','J','埼玉県','11');
countryList[i++] =new countryRec('12','J','千葉県','12');
countryList[i++] =new countryRec('12','J','神奈川県','14');
countryList[i++] =new countryRec('12','J','静岡県','22');
countryList[i++] =new countryRec('13','J','山梨県','19');
countryList[i++] =new countryRec('13','J','新潟県','15');
countryList[i++] =new countryRec('13','J','富山県','16');
countryList[i++] =new countryRec('13','J','石川県','17');
countryList[i++] =new countryRec('13','J','福井県','18');
countryList[i++] =new countryRec('13','J','長野県','20');
countryList[i++] =new countryRec('13','J','岐阜県','21');
countryList[i++] =new countryRec('13','J','静岡県','22');
countryList[i++] =new countryRec('13','J','愛知県','23');
countryList[i++] =new countryRec('13','J','三重県','24');
countryList[i++] =new countryRec('16','J','滋賀県','25');
countryList[i++] =new countryRec('16','J','京都府','26');
countryList[i++] =new countryRec('16','J','大阪府','27');
countryList[i++] =new countryRec('16','J','奈良県','29');
countryList[i++] =new countryRec('16','J','兵庫県','28');
countryList[i++] =new countryRec('16','J','和歌山県','30');
countryList[i++] =new countryRec('17','J','鳥取県','31');
countryList[i++] =new countryRec('17','J','島根県','32');
countryList[i++] =new countryRec('17','J','岡山県','33');
countryList[i++] =new countryRec('17','J','広島県','34');
countryList[i++] =new countryRec('17','J','山口県','35');
countryList[i++] =new countryRec('18','J','徳島県','36');
countryList[i++] =new countryRec('18','J','香川県','37');
countryList[i++] =new countryRec('18','J','愛媛県','38');
countryList[i++] =new countryRec('18','J','高知県','39');
countryList[i++] =new countryRec('19','J','福岡県','40');
countryList[i++] =new countryRec('19','J','佐賀県','41');
countryList[i++] =new countryRec('19','J','長崎県','42');
countryList[i++] =new countryRec('19','J','熊本県','43');
countryList[i++] =new countryRec('19','J','大分県','44');
countryList[i++] =new countryRec('19','J','宮崎県','45');
countryList[i++] =new countryRec('19','J','鹿児島県','46');
countryList[i++] =new countryRec('20','J','沖縄県','47');


countryList.length = 48

var setArray = new Array();
var setHatsuArray = new Array();

function setHatsu(dc){
	var z = 0;
	for(i=0;i<document.sForm.elements.length;i++){
		if(document.sForm.elements[i].type == 'hidden' && document.sForm.elements[i].name == 'p_hatsu'){
				document.sForm.elements[i].value = "";
				setHatsuArray[z] = document.sForm.elements[i];
				z++;
		}
	}
	z = 0;
	for(i=0;i<hatsuList.length;i++){
		if(hatsuList[i].group == dc){
			setHatsuArray[z].value = hatsuList[i].code;
			z++;
		}
	}
}

function formSubmit(){
	
	var dfhatsu;
	
	for(i=0;i<document.sForm.elements.length;i++){
		if(document.sForm.elements[i].type == 'select-one' && document.sForm.elements[i].name == 'p_hatsu'){
				dfhatsu = document.sForm.elements[i];
		}
	}

	var dfdest = document.sForm.p_dest.options;
	
	var dfcount = document.sForm.p_prefecture.options;
	
	var dfmonth = document.sForm.p_month.options;

	var dfdd = document.sForm.p_dd.options;


//	var checkfg = '';
	var checkfg = '0';

/*	if (dfhatsu.selectedIndex == 0 ) {
		checkfg = checkfg + '1';
		}
	else{
		checkfg = checkfg + '0';
		}
*/
	if ( dfdest.selectedIndex == 0 ) {
		checkfg = checkfg + '1';
		}
	else{
		checkfg = checkfg + '0';
		}

	switch(checkfg){
		case '11':
		alert("【ご出発地】【エリア】を選択 してください");
		return;
		break;

		case '10':
		alert("【出発地】を選択 してください");
		return;
		break;
		
		case '01':
		alert("【エリア】を選択 してください");
		return;
		break;
		}

	if ( dfmonth.selectedIndex > 0 && dfdd.selectedIndex == 0 ) {
		alert("日付を指定してください");
		return;
		}
	thisDest = document.sForm.p_dest.options[document.sForm.p_dest.selectedIndex].value;
	var z = 0;
	var p_countrySet;
	for(i=0;i<document.sForm.elements.length;i++){
		if(document.sForm.elements[i].type == 'select-one' && document.sForm.elements[i].name == 'p_prefecture'){
				var p_countrySet = document.sForm.elements[i];
		}
	}

	if(p_countrySet.options.selectedIndex == 0){
		for(i=0;i<countryList.length;i++){
			if(countryList[i].dest == thisDest){
				setArray[z] = countryList[i].group;
				z++;
			}
		}
	}
	z = 0;
	for(i=0;i<document.sForm.elements.length;i++){
		if(document.sForm.elements[i].name == 'p_prefecture' && document.sForm.elements[i].type == 'hidden'){
			document.sForm.elements[i].value = setArray[z];
			z++;
		}
	}
/*	dfhatsu.options[dfhatsu.selectedIndex].value = "";
*/	document.sForm.p_dest.options[document.sForm.p_dest.selectedIndex].value = "";
	document.sForm.submit();
}

function hatsusaubch(p) {
	switch (p.options[p.selectedIndex].text) {
		case "福岡" : document.sForm.p_hatsu_sub.value="091";break;
		case "鹿児島" : document.sForm.p_hatsu_sub.value="097";break;
		default : document.sForm.p_hatsu_sub.value="";break;
	}
}


