var IE = 0,NN = 0,N6 = 0;
if(document.all) IE = true;
else if(document.layers) NN = true;
else if(document.getElementById) N6 = true;

function OnLink(Msg,mX,mY,nX,nY){
	var pX = 0,pY = 0;
	var sX = -10,sY = 30;
	if(IE){
		MyMsg = document.all(Msg).style;
		MyMsg.visibility = "visible";
	}
	if(NN){
		MyMsg = document.layers[Msg];
		MyMsg.visibility = "show";
	}
	if(N6){
		MyMsg = document.getElementById(Msg).style;
		MyMsg.visibility = "visible";
	}
	if(IE){
		pX = document.body.scrollLeft;
		pY = document.body.scrollTop;
		MyMsg.left = mX + pX + sX;
		MyMsg.top = mY + pY + sY;
	}
	if(NN || N6){
		MyMsg.left = nX+ sX;
		MyMsg.top = nY + sY;
	}
}

function OffLink(Msg){
	if(IE) document.all(Msg).style.visibility = "hidden";
	if(NN) document.layers[Msg].visibility = "hide";
	if(N6) document.getElementById(Msg).style.visibility = "hidden";
}

var openWin;
function PlaceObject( a, co, ci, f, document ) {
	this.areaName = a;
	this.countryName = co;
	this.cityName = ci;
	this.formName = f;

	this.document = document;
	//　関数登録
	this.initialArea = initialArea;
	this.initialCountry = initialCountry;
	this.initialCity = initialCity;
	this.setArea = setArea;
	this.changeArea = changeArea;
	this.changeCountry = changeCountry;
}

function setArea() {
	var		i;
	var		f = this.document.forms[this.formName];

	f[this.areaName].options[0] = new Option( "↓ 地域を選択してください", "",false,false );
	for( i=0 ; i<area.length ; i++ ) {
	f[this.areaName].options[i+1] = new Option( area[i].name, area[i].code );
	}
}

function initialCity() {

	var		str;
	var		f = this.document.forms[this.formName];

	str = (f[this.areaName].options[f[this.areaName].options.selectedIndex].value == "") ?
			"地域を選択してください" : "国を選択してください";
	for( i=0 ; i<f[this.cityName].options.length ; i++ ) {
		f[this.cityName].options[i] = new Option( ("← " + str), "", false, false);

	}

}

function initialCountry() {
	var		f = this.document.forms[this.formName];
	for( i=0 ; i<f[this.countryName].options.length ; i++ ) {
		f[this.countryName].options[i] = new Option( "← 地域を選択してください", "",false,false );
	}
}


function initialArea() {
	this.setArea();
	this.initialCountry();
	this.initialCity();
}

function changeArea( idx ) {
	var		i,j;
	var		f = this.document.forms[this.formName];

	f[this.countryName].options[0].selected = true;
	f[this.countryName].options.length = 6;

	if( f[this.areaName].options[idx].value == "" ) {
		this.initialCountry();
	}else{
		for( i=1 ; i<f[this.countryName].options.length ; i++ ) {
			f[this.countryName].options[i].value = "";
			f[this.countryName].options[i].text = "";
		}
		f[this.countryName].options[0].selected = true;
		f[this.countryName].options[0] = new Option( "↓ 国を選択してください", "", false, false );
		for( i=0,j=1 ; i<contry.length ; i++ ) {
			if( contry[i].area == f[this.areaName].options[idx].value ) {
				f[this.countryName].options[j] = new Option( contry[i].name, contry[i].code );
				j++;
			}
		}
		//f[this.contryName].options[j] = new Option('その他の国', -2);
	}
	this.initialCity();
}

function changeCountry( idx ) {
	var		i,j;
	var		f = this.document.forms[this.formName];

	f[this.cityName].options.length = 6;
	f[this.cityName].options[0].selected = true;
	if( f[this.countryName].options[idx].value == "" ) {
		this.initialCity();
	}else if( f[this.countryName].options[idx].value == "-2" ) {
		for( i=0 ; i<6 ; i++ ) {
			f[this.cityName].options[i] = new Option( "------------------", "-3" );
		}
		f[this.cityName].options[0].selected = true;
	}else {
		f[this.cityName].options[0] = new Option( "↓ 都市を選択してください", "",true,true );
		for( i=1 ; i<6 ; i++ ) {
			f[this.cityName].options[i] = new Option( "", "" );
		}
		j = 1;
		for( i=0 ; i<city.length ; i++ ) {
			if( city[i].contry == f[this.countryName].options[idx].value ) {
				f[this.cityName].options[j] = new Option( city[i].name, city[i].code );
				j++;
			}
		}
	}

}
var		place1= new PlaceObject("A","C","DIST",0,document);

function initialize() {
	place1.initialArea();
}

function call_changeArea( obj, idx ) {
	obj.changeArea(idx);
}

function call_changeCountry( obj, idx ) {
	obj.changeCountry(idx)
}

function submitConfirm(){
	if ((document.form1.DEP[0].checked == false) && (document.form1.DEP[1].checked == false) && (document.form1.DEP[2].checked == false) && (document.form1.DEP[3].checked == false) && (document.form1.DEP[4].checked == false) && (document.form1.DEP[5].checked == false)){
		alert("出発地が指定されていません");
		return false;
	}
	if (fiUtlCheckDate((document.form1.YYYY.options[document.form1.YYYY.selectedIndex].value),(document.form1.MM.options[document.form1.MM.selectedIndex].value),(document.form1.DD.options[document.form1.DD.selectedIndex].value),"出発日の指定が不適切です") == false) {
		return false;
	}
	if (document.form1.A.options[document.form1.A.selectedIndex].value == "" && document.form1.WORD.value == ""){
		alert("目的地かキーワードを指定してください");
		return false;
	}
	if (eval(document.form1.PRICE1.options[document.form1.PRICE1.selectedIndex].value) > eval(document.form1.PRICE2.options[document.form1.PRICE2.selectedIndex].value)){
		alert("予算の指定が不適切です");
		return false;
	}
	if(fiUtlCheckDate((document.form1.YYYY.options[document.form1.YYYY.selectedIndex].value),(document.form1.MM.options[document.form1.MM.selectedIndex].value),'01',"出発日の指定が不適切です") == false) {
		return false;
	}
	return true;
}

function form_reset(){
	document.form1.reset();
	document.form1.DEP[0].checked = false;
	document.form1.DEP[1].checked = false;
	document.form1.DEP[2].checked = false;
	document.form1.DEP[3].checked = false;
	document.form1.DEP[4].checked = false;
	document.form1.DEP[5].checked = false;
	document.form1.WORD.value = "";
	document.form1.PRICE1.value = "";
	document.form1.PRICE2.value = "";
}
