/**
 * HitTours site
 * Search javascript
 *
 * Noriko Shimazaki
 * 2007/08/24(Fri.)
 */
	var	document_root;
	var	pageURL;
	var	selectURL;

	/**
	 * load時の処理
	 */
	function initialize() {
		// ドキュメントルートを取得（開発処置）
		document_root = getDocumentRoot();
		pageURL = document_root + '/package/overseas/tour/';
		selectURL = document_root + '/package/overseas/select/';

		/**
		 * Eventハンドラ追加
		 */
		// Clickイベント
		Event.observe( $( 'btn_search' ), 'click', function(){ sendForm();  }, false );

		// Changeイベント
		Event.observe( $( 'm_area_id' ), 'change', function(){ changeCountryList(); }, false );
		Event.observe( $( 'm_country_id' ), 'change', function(){ changeCityList(); }, false );

		// 画像の入れ替え
		new Image().src = document_root + '/images/button/toursearch1r.gif';
		pageEffect = new PageEffect();
		pageEffect.imageRollOver( $( 'btn_search' ), document_root + '/images/button/toursearch1r.gif', document_root + '/images/button/toursearch1.gif' );
	}

	/**
	 * SendForm
	 */
	 function sendForm()	{
		var m_area_id = $( 'm_area_id' ).value;
		var m_country_id = $( 'm_country_id' ).value;

		if( m_area_id < 1 )	{
			alert( '地域，国を選択してください' );
			return false;
		}

		if( m_country_id < 1 )	{
			alert( '国を選択してください' );
			return false;
		}

		 $( 'frm_condition' ).submit();
	 }

	/**
	 * データを送信して結果を挿入
	 */
	// 目的地(国)
	 function changeCountryList()	{
		var id = $( 'm_area_id' ).value;

		// データ取得
		url = selectURL + 'country/id/' + id + '/';

		sendGet( url, 'html' );
		return;
	 }

	// 目的地(都市)
	 function changeCityList()	{
		var id = $( 'm_country_id' ).value;

		// データ取得
		url = selectURL + 'city/id/' + id + '/';

		sendGet( url, 'html' );
		return;
	 }

	/**
	 * load時のイベントハンドラをセットする
	 */
	Event.observe( window, 'load', initialize, false );

