/*
 * Timetable
 *
 * Copyright: (c) 2009 九州旅客鉄道株式会社
 *
 * Depends Script:
 *	none
 */

var search = {
/* action~ */
	spot: function(path) {
		var keyword = document['search-spot-form']['main-search-form'].value,
			hostname = location.protocol == 'http:' ? '' : 'http://' + location.hostname;
		if (keyword) location.href = hostname + path + '?' + 'search[keyword]' + '=' + encodeURI(keyword);
	},

	timetable: function() {
		var def_charset = document.charset;
		document.charset = 'shift_jis';
		var form = document.createElement('form'),
			input = new Object(),
			start_value = document['search-timetable-form']['start-station'].value,
			arrival_value = document['search-timetable-form']['arrival-station'].value;
		form.action = 'http://www.yoyaku.jrkyushu.co.jp/jrk/reserve/route/pc/Home/searchStation.do';
		form.method = 'post';
		form.target = '_blank';
		form.setAttribute('accept-charset', 'shift_jis');
		input.start = document.createElement('input');
		input.start.setAttribute('type', 'text');
		input.start.setAttribute('name', 'dsName');
		input.start.setAttribute('value', start_value);
		input.arrival = document.createElement('input');
		input.arrival.setAttribute('type', 'text');
		input.arrival.setAttribute('name', 'asName');
		input.arrival.setAttribute('value', arrival_value);
		for (var i in input) form.appendChild(input[i]);
		document.body.appendChild(form);
		form.submit();
		document.body.removeChild(form);
		document.charset = def_charset;
	}
/* ~action */
};
