function JLJS_IntTicketModuleContoller_en() {
	this.INT_TM_BLOCK = "JS_intTicketModuleBlock";
	this.INT_AIR_BLOCK = "JS_intAirTicketModuleBlock";

	this.ROUND_TRIP = "roundtrip";
	this.STOP_OVER = "stopover";
	this.XML_FILE = "/en/common_rn/xml/intTicketModule_en.xml";
	this.IS_GOT_PARAMS_FROM_ARGS = "isGotParamsFromArgs";
	this.SETUP_MODULE_IN_CASE_NO_TAB = "setupModuleInCaseNoTab";
	
	this.isAllowedToSetupOnLoad = true;
	this.isGotParamsFromArgs = false;
	this.isGotElementById = false;
	this.setupModuleInCaseNoTab = "";
	this.isXMLLoaded = false;
	
	this.JLJS_IntTMs = [];
	this.xmlValue = [];
	
	this.moduleArgs = {};
}

JLJS_IntTicketModuleContoller_en.prototype = {
	setup : function() {
		
		var intTmBlocks = this.getElements(this.INT_TM_BLOCK, "div");	
		if (!intTmBlocks) return;

		if (!this.moduleArgs[0]) {
			this.moduleArgs[0] = {};
			for (var i in this.moduleArgs) {
				if (i != "0") {
					this.moduleArgs[0][i] = this.moduleArgs[i];
				}
			}
		}

		for (var i=0;i<intTmBlocks.length;i++) {
			intTmBlocks[i].number = i;
			intTmBlocks[i].isGotParamsFromArgs = this.isGotParamsFromArgs;
			this.ticketModuleSetup(intTmBlocks[i]);
		}
	},
	
	ticketModuleSetup : function(intTmBlock) {
		
		var intAirTmBlocks = this.getElements(this.INT_AIR_BLOCK, "div", intTmBlock);
		if (!intAirTmBlocks) return;
		var intAirTmBlock = intAirTmBlocks[0];
		
		intAirTmBlock.number = intTmBlock.number;
		intAirTmBlock.isGotParamsFromArgs = intTmBlock.isGotParamsFromArgs;
		
		var setupModule = "";
		var intTm = new JLJS_IntTicketModule(intAirTmBlock);
		this.JLJS_IntTMs[intAirTmBlock.number] = intTm;
		if (!this.isGotParamsFromArgs) {
			this.readXML();
		}
		
		var args = null;
		if(!intTm.isLoaded){
			if (this.moduleArgs[intAirTmBlock.number][this.ROUND_TRIP]) {
				args = this.moduleArgs[intAirTmBlock.number][this.ROUND_TRIP];
			}
			intTm.setup(args);
		}
	},
	
	readXML : function() {

		if(typeof JKL == "function" && !this.isXMLLoaded) {
			var param = "?t=" + new Date().getTime();
			var tmXML = new JKL.ParseXML(this.XML_FILE + param);
			tmXML.setOutputArrayElements(["pattern"]);  
			var tmParseXML = tmXML.parse();
			var tmPatternXML = this.parseXMLPattern(tmParseXML);
			if(tmPatternXML) {
				var setupFilePath = tmPatternXML.setupFile;
				if(setupFilePath) {
					var setupXMl = new JKL.ParseXML(setupFilePath + param);
					setupXMl.setOutputArrayElements(["pattern", "setup"]);
					var setupParseXML = setupXMl.parse();
					var setupPatternXML = this.parseXMLPattern(setupParseXML);
					if(setupPatternXML) {
						var setup = setupPatternXML.setup;
						if(setup) {
							for(var i=0; i<setup.length; i++) {
								if(setup[i].form) {
									var frmName = setup[i].form;
									delete setup[i].form;
									var index = -1;
									for(var j=0; j<this.xmlValue.length; j++) {
										if(!this.xmlValue[j][frmName]) {
											break;
										}
										index++;
									}
									if(!this.xmlValue[index+1]) {
										this.xmlValue[index+1] = {};
									}
									this.xmlValue[index+1][frmName] = setup[i];
									
								}
							}
							this.isXMLLoaded = true;
						}
					}
				}
			}
		}
	},

	parseXMLPattern : function (parseXML) {
		var pattern;
		if(parseXML && parseXML.ticketModule && parseXML.ticketModule.pattern) {
			
			var patterns = parseXML.ticketModule.pattern;
			for(var i=0; i<patterns.length; i++) {
				var url = patterns[i].url;
				if(url && (url == "*" || window.location.href.indexOf(url) != -1)) {
					pattern = patterns[i];
					break;
				}
			}
			
		}
		return pattern;
	},
	
	getElements : function(value, targetTag, parent) {
		var elements = "";
		if (this.isGotElementById){
			elements = [];
			if (!value) {return null};
			var elm = document.getElementById(value);
			if (!elm) {return null};
			elements[0] = elm;
		}else{
			if (!value || !targetTag) {return null}; 
			elements = JLJS.getElementsByClassName(value, targetTag, parent);
			if (!elements[0]) elements = "";
		}
		return elements;
	}
}

var JLJS_IntTMCtrl_en = new  JLJS_IntTicketModuleContoller_en();

JLJS.addOnload( function(){
	if (JLJS_IntTMCtrl_en.isAllowedToSetupOnLoad) JLJS_IntTMCtrl_en.setup();
});
JLJS.addEvent(window, "unload", function(){});

function JLJS_IntTicketModule(block) {

	this.INT_ROUND_TRIP_BLOCK = "JS_intRoundTripBlock";
	this.INT_ROUND_TRIP_FORM = "intRoundTripForm";

	this.FORM = "formNode";
	this.ACTION = "action";
	this.METHOD = "method";
	this.TARGET = "target";
	this.ADD_FORM_SAFARI = "addFormSafari";
	this.MEMBER_BACK_URL = "memberBackUrl";
	this.MEMBER_PATTERN = "memberPattern";
	this.GUEST_BACK_URL = "guestBackUrl";
	this.GUEST_PATTERN = "guestPattern";
	this.PRM_EXT_LINK_ID = "PRM_EXT_LINK_ID";
	
	this.PRM_MEETINGMONTH = "PRM_MEETINGMONTH";
	this.PRM_MEETINGDATE = "PRM_MEETINGDATE";
	this.PRM_SENDINGMONTH = "PRM_SENDINGMONTH";
	this.PRM_SENDINGDATE = "PRM_SENDINGDATE";
	this.DATE = "dateNode";
	this.OFFSET = "offset";
	this.INTERVAL = "interval";
	this.DAY_OF_WEEK_FLG = "dayOfWeekFlag";
	
	this.FLOAT_CAL_ICON = "floatCalIcon";
	
	this.NARROW_DOWN = "narrowDownNode";
	this.PRM_DEPAREA = "PRM_DEPAREA";
	this.PRM_DEPARTURE = "PRM_DEPARTURE";
	this.PRM_ARRAREA = "PRM_ARRAREA";
	this.PRM_ARRIVAL = "PRM_ARRIVAL";
	this.PRM_OPEN_DEPARTURE = "PRM_OPEN_DEPARTURE";
	this.PRM_OPEN_ARRIVAL = "PRM_OPEN_ARRIVAL";
	
	this.TYPE_D = "d";
	this.TYPE_A = "a";
	this.DEP_NO_AREA_SELECTION = "depNoAreaSelection";
	this.DEP_AREA_SLCT_SET = "depAreaSlctSet";
	this.DEP_DEFAULT_AREA = "depDefaultArea";
	this.DEP_DEFAULT_CITY = "depDefaultCity";
	this.DEP_DEFAULT_CITY_OJ = "depDefaultCityOJ"; 
	this.DEP_NO_GROUP = "depNoGroup";
	this.DEP_NO_LABEL = "depNoLabel";
	this.DEP_NO_DEVIDE = "depNoDevide";
	this.DEP_ONLINE_ONLY = "depOnlineOnly";
	this.DEP_ONLINE_SEPARATING_VIEW_OFF = "depOnlineSeparatingViewOff";
	this.DEP_LABEL_OPT = "depLabelOpt";
	this.ARR_NO_AREA_SELECTION = "arrNoAreaSelection";
	this.ARR_AREA_SLCT_SET = "arrAreaSlctSet";
	this.ARR_DEFAULT_AREA = "arrDefaultArea";
	this.ARR_DEFAULT_CITY = "arrDefaultCity";
	this.ARR_DEFAULT_CITY_OJ = "arrDefaultCityOJ";
	this.ARR_NO_GROUP = "arrNoGroup";
	this.ARR_NO_LABEL = "arrNoLabel";
	this.ARR_NO_DEVIDE = "arrNoDevide";
	this.ARR_ONLINE_ONLY = "arrOnlineOnly";
	this.ARR_ONLINE_SEPARATING_VIEW_OFF = "arrOnlineSeparatingViewOff";
	this.ARR_LABEL_OPT = "arrLabelOpt";
	this.EN = "en";
	this.NO_DOM = "noDOM";
	
	this.FARE = "fareNode";
	this.DEFAULT_FARE = "defaultFare";
	
	this.PRM_SEARCH_KIND2 = "PRM_SEARCH_KIND2";
	this.PRM_SEARCH_CALENDAR = "PRM_SEARCH_CALENDAR";
	this.SEARCH_CALENDAR_LABEL = "searchCalendarLabel";

	this.tmAirBlock = block;
	this.roundTripBlock = {};
	this.formNode = {};
	this.vacantAction = "https://ag.5931.jal.co.jp/jalint/toVacant.do";
	
	this.isLoaded = false;
	
	this.env = {};
	this.env.isIE50 = ( JLJS.env.isIE && navigator.appVersion.toLowerCase().match( /msie 5\.0/ )) ? true : false;
	this.env.isIE55 = ( JLJS.env.isIE && navigator.appVersion.toLowerCase().match( /msie 5\.5/ )) ? true : false;
	this.lang = {};
	this.lang.isEN = location.pathname.match( /^\/en\/.?/ ) ? true : false;
	
	this.setupParams = {};
	this.setupParams[this.FORM] = {};
	this.setupParams[this.FORM][this.ACTION] = this.vacantAction;
	this.setupParams[this.FORM][this.METHOD] = "post";
	this.setupParams[this.FORM][this.TARGET] = "_blank";
	this.setupParams[this.FORM][this.PRM_EXT_LINK_ID] = "";
	this.setupParams[this.DATE] = {};
	this.setupParams[this.DATE][this.OFFSET] = 30;
	this.setupParams[this.DATE][this.INTERVAL] = 4;
	this.setupParams[this.DATE][this.DAY_OF_WEEK_FLG] = true;
	this.setupParams[this.NARROW_DOWN] = {};
	this.setupParams[this.NARROW_DOWN][this.DEP_NO_AREA_SELECTION] = true;
	this.setupParams[this.NARROW_DOWN][this.DEP_AREA_SLCT_SET] = "";
	this.setupParams[this.NARROW_DOWN][this.DEP_DEFAULT_AREA] = "JPN";
	this.setupParams[this.NARROW_DOWN][this.DEP_DEFAULT_CITY] = "";
	this.setupParams[this.NARROW_DOWN][this.DEP_DEFAULT_CITY_OJ] = "";
	this.setupParams[this.NARROW_DOWN][this.DEP_NO_GROUP] = true;
	this.setupParams[this.NARROW_DOWN][this.DEP_NO_LABEL] = true;
	this.setupParams[this.NARROW_DOWN][this.DEP_NO_DEVIDE] = false;
	this.setupParams[this.NARROW_DOWN][this.DEP_ONLINE_ONLY] = false;
	this.setupParams[this.NARROW_DOWN][this.DEP_ONLINE_SEPARATING_VIEW_OFF] = false;
	this.setupParams[this.NARROW_DOWN][this.DEP_LABEL_OPT] = false;
	this.setupParams[this.NARROW_DOWN][this.ARR_NO_AREA_SELECTION] = false;
	this.setupParams[this.NARROW_DOWN][this.ARR_AREA_SLCT_SET] = "whole_exJPN_01";
	this.setupParams[this.NARROW_DOWN][this.ARR_DEFAULT_AREA] = "";
	this.setupParams[this.NARROW_DOWN][this.ARR_DEFAULT_CITY] = "";
	this.setupParams[this.NARROW_DOWN][this.ARR_DEFAULT_CITY_OJ] = ""; 
	this.setupParams[this.NARROW_DOWN][this.ARR_NO_GROUP] = false;
	this.setupParams[this.NARROW_DOWN][this.ARR_NO_LABEL] = false;
	this.setupParams[this.NARROW_DOWN][this.ARR_NO_DEVIDE] = false;
	this.setupParams[this.NARROW_DOWN][this.ARR_ONLINE_ONLY] = false;
	this.setupParams[this.NARROW_DOWN][this.ARR_ONLINE_SEPARATING_VIEW_OFF] = false;
	this.setupParams[this.NARROW_DOWN][this.ARR_LABEL_OPT] = false;
	this.setupParams[this.FARE] = {};
	this.setupParams[this.FARE][this.DEFAULT_FARE] = "";

	this.isGotParamsFromArgs = block.isGotParamsFromArgs;
}

JLJS_IntTicketModule.prototype = {

	setup : function() {

		var roundTripBlocks = JLJS_IntTMCtrl_en.getElements(this.INT_ROUND_TRIP_BLOCK, "div", this.tmAirBlock);
		if (!roundTripBlocks) return;
		this.roundTripBlock = roundTripBlocks[0];
		
		this.formNode = JLJS.getElementsByTagName("form", this.roundTripBlock)[0];
		if (!this.formNode) return;
		
		this.initSetupParams(arguments[0]);	
		this.setupFormNode();
		this.setupDateNodes();
		this.setupCalendarNodes();
		this.setupNarrowDownNodes();
		this.setupFareNodes();
		this.afterSetUp();
		this.isLoaded = true;
	},
	
	initSetupParams : function(args) {
		var setupParams = {};
		if (this.isGotParamsFromArgs){
			setupParams = args;
		}else{
			setupParams = JLJS_IntTMCtrl_en.xmlValue[this.tmAirBlock.number][this.INT_ROUND_TRIP_FORM];
		}
		
		for (var key1 in setupParams) {
			for (var key2 in setupParams[key1]) {
				this.setupParams[key1][key2] = setupParams[key1][key2];
			}
		}
	},
	
	setupFormNode : function() {
		this.formNode._TM_instance_ = this;
		var formParams = this.setupParams[this.FORM];
		this.formNode.action = formParams[this.ACTION];
		this.formNode.method = formParams[this.METHOD];
		this.formNode.target = formParams[this.TARGET];

		JLJS.addEvent(this.formNode, "submit", function(e) {
			if( !e.currentTarget._TM_instance_.submitForm()) e.preventDefault();
		});
		
		if (this.formNode[this.PRM_EXT_LINK_ID]) {
			this.formNode[this.PRM_EXT_LINK_ID].value = formParams[this.PRM_EXT_LINK_ID];
		}
		
	},
	
	setupDateNodes : function() {
		var dateNodes = {"board" : {month : this.PRM_MEETINGMONTH, day : this.PRM_MEETINGDATE},
						"return" : {month : this.PRM_SENDINGMONTH, day : this.PRM_SENDINGDATE}};
		var dateParams = this.setupParams[this.DATE];
		var options = {offset : eval(dateParams[this.OFFSET])
						, interval : eval(dateParams[this.INTERVAL])
						, dayOfWeekFlag : eval(dateParams[this.DAY_OF_WEEK_FLG])
		}
		var JLJS_TMDS = new JLJS_intTM_DateSelector(this, dateNodes, options);
		
		JLJS_TMDS.dateSpecify();
	},
	
	setupCalendarNodes : function() {
		var dateParams = this.setupParams[this.DATE];
		var floatCalIcons = JLJS.getElementsByClassName( this.FLOAT_CAL_ICON, "a", this.formNode);
		JLJS_CalNav.isEN = this.lang.isEN;
		JLJS_CalNav.OPT_INT_TM.dayOfWeekFlag = eval(dateParams[this.DAY_OF_WEEK_FLG]);
		for (var i=0;i<floatCalIcons.length;i++) {
			var floatCalIcon = floatCalIcons[i];
			floatCalIcon._TM_instance_ = this;
			if(JLJS_CalNav.used) {

				JLJS.addEvent(floatCalIcon,
					"click",
					function(e) {
						var tm = e.currentTarget._TM_instance_;
						var form = tm.formNode;
						var prm = {};
						var opt = {};
						opt = JLJS_CalNav.OPT_INT_TM;
						opt["isEN"] = tm.lang.isEN; 
						if (JLJS.classAttr["check"](e.currentTarget, "meet")) {
							prm["board"] = {month: form[tm.PRM_MEETINGMONTH], day: form[tm.PRM_MEETINGDATE]};
							prm["arrival"] = {month: form[tm.PRM_SENDINGMONTH], day: form[tm.PRM_SENDINGDATE]};
						}else{
							prm["board"] = {month: form[tm.PRM_SENDINGMONTH], day: form[tm.PRM_SENDINGDATE]};
						}
						JLJS_CalNav.calDisplay(
							{target: e.currentTarget,
							option: opt,
							frm : prm
							}
						)
					}
				);

			} else {
				JLJS.classAttr.add(floatCalIcon, "hidden");
			}			
		}		
	},

	setupNarrowDownNodes : function() {
		var narrowDownParams = this.setupParams[this.NARROW_DOWN];
		var narrowDownArgs = {
			dep : {
				nodes : {
					areaNode : this.PRM_DEPAREA
					,cityNode : this.PRM_DEPARTURE
					,ojCityNode : this.PRM_OPEN_ARRIVAL
				}
				,options : {
					type : this.TYPE_D
					,noAreaSelection : narrowDownParams[this.DEP_NO_AREA_SELECTION]
					,areaSlctSet : narrowDownParams[this.DEP_AREA_SLCT_SET]
					,defaultArea : narrowDownParams[this.DEP_DEFAULT_AREA]
					,defaultCity :  narrowDownParams[this.DEP_DEFAULT_CITY]
					,defaultCityOJ : narrowDownParams[this.ARR_DEFAULT_CITY_OJ]
					,noGroup : eval(narrowDownParams[this.DEP_NO_GROUP])
					,noLabel : eval(narrowDownParams[this.DEP_NO_LABEL])
					,noDevide : eval(narrowDownParams[this.DEP_NO_DEVIDE])
					,onLineOnly : eval(narrowDownParams[this.DEP_ONLINE_ONLY])
					,onLineSeparatingView_Off : eval(narrowDownParams[this.DEP_ONLINE_SEPARATING_VIEW_OFF])
					,labelOpt : eval((narrowDownParams[this.DEP_LABEL_OPT] || ( this.env.isIE50 || this.env.isIE55 || ( JLJS.env.isMac && JLJS.env.isIE ) || JLJS.env.isOpera )))
				}
			}
			,arr : {
				nodes : {
					areaNode : this.PRM_ARRAREA
					,cityNode : this.PRM_ARRIVAL
					,ojCityNode : this.PRM_OPEN_DEPARTURE
				}
				,options : {
					type : this.TYPE_A
					,noAreaSelection : narrowDownParams[this.ARR_NO_AREA_SELECTION]
					,areaSlctSet : narrowDownParams[this.ARR_AREA_SLCT_SET]
					,defaultArea : narrowDownParams[this.ARR_DEFAULT_AREA]
					,defaultCity :  narrowDownParams[this.ARR_DEFAULT_CITY]
					,defaultCityOJ : narrowDownParams[this.DEP_DEFAULT_CITY_OJ]
					,noGroup : eval(narrowDownParams[this.ARR_NO_GROUP])
					,noLabel : eval(narrowDownParams[this.ARR_NO_LABEL])
					,noDevide : eval(narrowDownParams[this.ARR_NO_DEVIDE])
					,onLineOnly : eval(narrowDownParams[this.ARR_ONLINE_ONLY])
					,onLineSeparatingView_Off : eval(narrowDownParams[this.ARR_ONLINE_SEPARATING_VIEW_OFF])
					,labelOpt : eval((narrowDownParams[this.ARR_LABEL_OPT] || ( this.env.isIE50 || this.env.isIE55 || ( JLJS.env.isMac && JLJS.env.isIE ) || JLJS.env.isOpera )))
				}
			}
		}

		for( var key in narrowDownArgs ) {
			
			var args = narrowDownArgs[key];
			
			args["options"][this.EN] = this.lang.isEN;
			args["options"][this.NO_DOM] = this.env.isIE50;

			var JLJS_TMAND = new JLJS_intTM_AirportNarrowDown(this, args["nodes"], args["options"]);
			
			JLJS_TMAND.setDefault();
			JLJS_TMAND.setAreaSelector();
			JLJS_TMAND.narrowDown(JLJS_TMAND.defaultArea);
			
			JLJS_TMAND.defaultCity = "";

			if( JLJS_TMAND.areaNode ) {
				JLJS.addEvent( JLJS_TMAND.areaNode, 'change', function( e ) {
					if(!e.currentTarget._TMAND_instance_.narrowDown( e.currentTarget.value )) e.preventDefault();
				} );
			}
		}
	},
	
	setupFareNodes : function() {
		var fareParams = this.setupParams[this.FARE];
		var JLJS_TMFL = new JLJS_intTM_FareList(this);
		JLJS_TMFL.createFareList(fareParams[this.DEFAULT_FARE]);
		JLJS.addEvent(JLJS_TMFL.areaNode, "change", function(e) {
			if(!e.currentTarget._TMFL_instance_.createFareList()) e.preventDefault();
		});
	},
	
	afterSetUp : function() {
	},
	
	private_submitCheck : function() {
		return true;
	},

	submitFormSafari : function(frm) {
		var frmId = this.ADD_FORM_SAFARI;
		var addFrmElm = document.getElementById(frmId);
		
		if(addFrmElm) {

			document.body.removeChild(addFrmElm);
		}
		
		var createFrm = document.createElement("form");
		createFrm.id = frmId;
		createFrm.action = frm.action;
		createFrm.method = frm.method;
		createFrm.target = frm.target;
		
		var frmElms = frm.elements;
		for(var i=0; i<frmElms.length; i++) {
		
			frmElm = frmElms[i];
			if(!frmElm.disabled) {
			
				var name = "";
				var value = "";
				if(frmElm.type == "text" || 
					frmElm.type == "password" || 
					frmElm.type == "hidden" || 
					(frmElm.type == "radio" && frmElm.checked) || 
					(frmElm.type == "checkbox" && frmElm.checked) || 
					frmElm.type == "textarea") {
					
					name = frmElm.name;
					value = frmElm.value;
					
				} else if(frmElm.type == "select-one") {
				
					name = frmElm.name;
					value = frmElm.options[frmElm.selectedIndex].value;
					
				}
				
				if(name) {
				
					var createInput = document.createElement("input");
					createInput.type = "hidden";
					createInput.name = name;
					createInput.value = value;
					createFrm.appendChild(createInput);
					
				}
				
			}
		
		}
		
		document.body.appendChild(createFrm);
		addFrmElm = document.getElementById(frmId)
		addFrmElm.submit();
	},
	
	submitForm : function() {

		if( ! this.private_submitCheck()) return false;
		
		var da = this.formNode[ this.PRM_DEPAREA ];
		var aa = this.formNode[ this.PRM_ARRAREA ];

		if( da ) da.disabled = true;
		if( aa ) aa.disabled = true;
		if(JLJS.env.isSafari) {
			this.submitFormSafari(this.formNode);
		} else {
			this.formNode.submit();
		}
		if( da ) da.disabled = false;
		if( aa ) aa.disabled = false;

		return false;

	}
}

function JLJS_intTM_DateSelector( _TM_instance_, dateNodes, options ) {
	
	this.TODAY = "today";
	this.BOARD = "board";
	this.RETURN = "return";
	this.MONTH = "month";
	this.DAY = "day";
	this.OFFSET = "offset";
	this.INTERVAL = "interval";
	this.DAY_OF_WEEK_FLG = "dayOfWeekFlag";
	this.DEP_DATE = "departureDate";
	this.RTN_DATE = "returnDate";
	this.INIT = "init";
	
	this.offset = 30;
	this.interval = 4;
	this.dayOfWeekFlag = true;
	
	if (options){
		this.offset = (options[this.OFFSET] || options[this.OFFSET]==0)  ? options[this.OFFSET] : this.offset;
		this.interval = (options[this.INTERVAL] || options[this.INTERVAL]==0) ? options[this.INTERVAL] : this.interval;
		this.dayOfWeekFlag = options[this.DAY_OF_WEEK_FLG] ? true : false;
	}
	
	this.depMonNode = _TM_instance_.formNode[ dateNodes[this.BOARD][this.MONTH] ];
	this.depDayNode = _TM_instance_.formNode[ dateNodes[this.BOARD][this.DAY] ];
	this.depMonNode._TMDS_instance_ = this;
	this.depDayNode._TMDS_instance_ = this;
	this.rtnMonNode = null;
	this.rtnDayNode = null;
	
	this.depDS = new JLJS_DateSelector( this.depMonNode, this.depDayNode );
	this.depDS.dayOfWeekFlag = this.dayOfWeekFlag;	

	if (dateNodes[this.RETURN]) {
		this.rtnMonNode = _TM_instance_.formNode[ dateNodes[this.RETURN][this.MONTH] ];
		this.rtnDayNode = _TM_instance_.formNode[ dateNodes[this.RETURN][this.DAY] ];
		this.rtnMonNode._TMDS_instance_ = this;
		this.rtnDS = new JLJS_DateSelector( this.rtnMonNode, this.rtnDayNode );
		this.rtnDS.dayOfWeekFlag = this.dayOfWeekFlag;
	}

	JLJS.addEvent( this.depMonNode, "change", function( e ) {
		e.currentTarget._TMDS_instance_.depMonthChange();
	} );
	JLJS.addEvent( this.depDayNode, "change", function( e ) {
		e.currentTarget._TMDS_instance_.depDayChange();
	} );
	JLJS.addEvent( this.rtnMonNode, "change", function( e ) {
		e.currentTarget._TMDS_instance_.rtnMonthChange();
	} );
}

JLJS_intTM_DateSelector.prototype = {
	dateSpecify : function() {
		var depArg = {init : true};
		var rtnArg = {init : true};
		this.depDateSpecify(depArg);
		this.rtnDateSpecify(rtnArg);
	},
	
	depDateSpecify : function(arg) {
		if (!arg) {arg = {};};
		if( this.depMonNode && this.depDayNode ) {
			if (arg[this.INIT]) {
				this.depDS.adjustToToday();
				this.depDS.applyOffset( '+' + this.offset + 'd' );
			}
			if (this.dayOfWeekFlag) this.depDS.setDay();
		}
	},
	
	rtnDateSpecify : function(arg) {
		if (!arg) {arg = {};};
		if(this.rtnMonNode && this.rtnDayNode) {
			if (arg[this.INIT]) {
				var depYear = this.depDS.Date.getFullYear();
				var depMonth = this.depDS.Date.getMonth() + 1;
				var depDate = this.depDS.Date.getDate();
				
				this.rtnDS.adjustToDate(depYear + "-" + depMonth + "-" + depDate);
				this.rtnDS.applyOffset( '+' + this.interval + 'd' );
			}
			if (this.dayOfWeekFlag) this.rtnDS.setDay();
		}
	},

	depMonthChange : function() {
		this.depDS.setDateBySelecter();
		this.depDateSpecify();
		var rtnArg = {init : true};
		this.rtnDateSpecify(rtnArg);
	},
	depDayChange : function() {
		this.depDS.setDateBySelecter();
		var rtnArg = {init : true};
		this.rtnDateSpecify(rtnArg);
	},
	rtnMonthChange : function() {
		this.rtnDS.setDateBySelecter();
		this.rtnDateSpecify();
	}
};

function JLJS_intTM_FareList (TM_instance_) {
	
	this.PRM_SEARCH_KIND2 = "PRM_SEARCH_KIND2";
	this.PRM_ARRAREA = "PRM_ARRAREA";
	
	this.GROUP_ECONOMY = "Economy Class";
	this.GROUP_BUSINESS = "Business Class";
	this.GROUP_FIRST = "First Class";
	this.ECONOMY_LOWEST = "Economy Lowest";
	this.ECONOMY = "Normal Economy";
	this.BUSINESS = "Normal Business";
	this.BUSINESS_LOWEST = "Business Lowest";
	this.FIRST = "First";
	this.PRM_SEARCH_BUSINESS = "PRM_SEARCH_BUSINESS";
	
	this.formNode = TM_instance_.formNode;
	this.fareNode = this.formNode[this.PRM_SEARCH_KIND2];
	this.searchBusinessNode = this.formNode[this.PRM_SEARCH_BUSINESS];
	
	this.SEARCH_BUSINESS_TYPE = {
		"0" : this.BUSINESS_LOWEST,
		"2" : this.BUSINESS
	}
	
	if( this.fareNode )
		this.fareNode._TMFL_instance_ = this;
	this.areaNode = this.formNode[this.PRM_ARRAREA];
	
	if( this.areaNode )
		this.areaNode._TMFL_instance_ = this;
	this.selectedValue = null;
	
	this.env = {};
	this.env.isIE50 = ( JLJS.env.isIE && navigator.appVersion.toLowerCase().match( /msie 5\.0/ )) ? true : false;
	this.env.isIE55 = ( JLJS.env.isIE && navigator.appVersion.toLowerCase().match( /msie 5\.5/ )) ? true : false;
	this.path = document.location.pathname;
	
	this.addChangeFareEvent();
}

JLJS_intTM_FareList.prototype = {
	createFareList : function () {
		
		if (!arguments[0]){
			this.selectedValue = this.fareNode.value;
		}else{
			this.selectedValue = arguments[0];
		} 
		
		var businessFareType = "";
		if(this.selectedValue == "3") {
			if(arguments[1]) {
				businessFareType = arguments[1];
			} else {
				if(!this.searchBusinessNode.value) {
					businessFareType = "0";
				} else {
					businessFareType = this.searchBusinessNode.value;
				}
			}
		}
		
		var group;
		var labels;
		var optValues;
		
		group = [this.GROUP_ECONOMY, this.GROUP_BUSINESS, this.GROUP_FIRST];
			labels = [
				   [this.ECONOMY_LOWEST, this.ECONOMY],
				   [this.BUSINESS_LOWEST, this.BUSINESS],
				   [this.FIRST]
				  ];
			optValues = [ [1,2], [3,3], [4] ];
		
		if( JLJS.env.isIE ) {
			while( this.fareNode.options[ 0 ] ) {
				this.fareNode.options.remove( 0 );
			}
			
			while( this.fareNode.firstChild ) {
				this.fareNode.removeChild( this.fareNode.firstChild );
			}
		} else {
			while( this.fareNode.firstChild ) {
				this.fareNode.removeChild( this.fareNode.firstChild );
			}
		}
		
		var optionCnt = 0;
		
		var isIE6Under = this.env.isIE50 || this.env.isIE55;
		
		for(var i = 0; i < group.length; i++) {
	
			var newOpGrp = "";
			
			if(isIE6Under) {
				var newOpt = document.createElement( 'option' );
				newOpt.innerHTML = "<" + group[i] + ">";
				this.fareNode.appendChild( newOpt );
			} else {
				newOpGrp = document.createElement( 'optgroup' );
				newOpGrp.label = group[i];
			}
			
			for(var j = 0; j < labels[i].length; j++) {
				var newOpt = document.createElement( 'option' );
				newOpt.value = optValues[i][j];
				newOpt.innerHTML = labels[i][j];
				if(isIE6Under && i == 0 && j == 0) {
					newOpt.selected = "selected";
				}
				
				if(this.selectedValue) {
					if(this.selectedValue == optValues[i][j]) {
						if(this.selectedValue == 3) {
							if(this.SEARCH_BUSINESS_TYPE[businessFareType] == labels[i][j]) {
								newOpt.selected = "selected";
							}
						} else {
							newOpt.selected = "selected";
						}
					}
				}
				
				if(isIE6Under) {
					this.fareNode.appendChild( newOpt );
				} else {
					newOpGrp.appendChild( newOpt );
				}
				
			}
			
			if(!isIE6Under) {
				this.fareNode.appendChild( newOpGrp );
			}
		
		}
		
	},
	
	addChangeFareEvent : function() {
		var self = this;
		JLJS.addEvent(
			this.fareNode,
			"change",
			function() {
				self.changeSearchBusiness();
			}
		);
		
	},
	
	changeSearchBusiness : function() {
		var fareText = this.fareNode.options[this.fareNode.selectedIndex].text;
		var searchBusiness = "";
		
		if(fareText == this.BUSINESS) {
			searchBusiness = "2";
		} else if(fareText == this.BUSINESS_LOWEST) {
			searchBusiness = "0";
		} else {
			searchBusiness = "";
		}
		
		this.searchBusinessNode.value = searchBusiness;
	}
}

function JLJS_intTM_AirportNarrowDown(TM_instance_, nodes, options) {

	this.AREA_NODE = "areaNode";
	this.CITY_NODE = "cityNode";
	this.OJ_CITY_NODE = "ojCityNode";
	this.AREA_SLCT_SET = "areaSlctSet";
	this.DEFAULT_AREA = "defaultArea";
	this.DEFAULT_CITY = "defaultCity";
	this.DEFAULT_CITY_OJ = "defaultCityOJ";
	this.DEFAULT_COUNTRY = "defaultCity";
	this.TYPE = "type";

	this.NO_GROUP = "noGroup";
	this.NO_LABEL = "noLabel";
	this.NO_DIVIDE = "noDevide";
	this.LABEL_OPT = "labelOpt";
	this.ONLINE_ONLY = "onLineOnly";
	this.ONLINE_SEPARATING_VIEW_OFF = "onLineSeparatingView_Off";
	this.NO_AREA_SELECTION = "noAreaSelection";
	this.NO_DOM = "noDOM";
	this.EN = "en";
	
	this.airportTable = {};
	this.airportTable.selectionSets = JLJS_TMAL.selectionSets;
	this.airportTable.globalAreas = JLJS_TMAL.globalAreas;
	this.airportTable.countries = JLJS_TMAL.countries;
	this.airportTable.cities = JLJS_TMAL.cities;

	this.areaNode = TM_instance_.formNode[nodes[this.AREA_NODE]];
	if( this.areaNode ) this.areaNode._TMAND_instance_ = this;
	this.cityNode = TM_instance_.formNode[nodes[this.CITY_NODE]];
	this.cityNode_OJ = TM_instance_.formNode[nodes[this.OJ_CITY_NODE]];
	
	this.type = options[this.TYPE];
	this.noAreaSelection = options[this.NO_AREA_SELECTION] ? true : false;
	this.selection = options[this.AREA_SLCT_SET] ? options[this.AREA_SLCT_SET] : options[this.DEFAULT_AREA];
	this.selectionSet = [];
	if( this.airportTable.selectionSets[ this.selection ] ) {
		this.selectionSet = this.airportTable.selectionSets[ this.selection ];
	}
	this.defaultArea = options[this.DEFAULT_AREA];
	this.defaultCity = options[this.DEFAULT_CITY];
	this.defaultCity_OJ = options[this.DEFAULT_CITY_OJ];
	this.defaultCountry = options[this.DEFAULT_COUNTRY];
	
	this.noGroup = options[this.NO_GROUP] ? true : false;
	this.noLabel = options[this.NO_LABEL] ? true : false;
	this.noDevide = options[this.NO_DIVIDE] ? true : false;
	this.labelOpt = options[this.LABEL_OPT] ? true : false;
	this.onLineOnly = options[this.ONLINE_ONLY] ? true : false;
	this.onLineSeparatingView_Off = options[this.ONLINE_SEPARATING_VIEW_OFF] ? true : false;
	this.noDOM = options[this.NO_DOM] ? true : false;
	this.isEn = options[this.EN];


	this.globalArea = null;
	this.countries = null;
	this.cities = null;
	this.selectedIndex = 0;
	this.buff = 0;
	this.devided = null;
	this.onLine_displayed = null;
}

JLJS_intTM_AirportNarrowDown.prototype = {

	setDefault : function() {

		if( ! this.noAreaSelection && this.defaultCity && this.selectionSet.length ) {
			LABEL_01 :
			for( var i = 0; i < this.selectionSet.length; i ++ ) {
				var countries = cities = null;
				var tmp = null;

				if( this.selectionSet[ i ] == "" ) continue;

				if( tmp = this.airportTable.globalAreas[ this.selectionSet[ i ]] )
					countries = tmp[ "list" ];

				if( countries ) {
					for( var j = 0; j < countries.length; j ++ ) {
						if( this.airportTable.countries[ countries[ j ]] )
							cities = this.airportTable.countries[ countries[ j ]][ "list" ];
						else continue;
						for( var k = 0; k < cities.length; k ++ )
							if( this.airportTable.cities[ cities[ k ]][ "CD" ] == this.defaultCity ) {
								this.defaultArea = tmp[ "CD" ];
								break LABEL_01;
							}
					}
				}
				else {
					tmp = this.airportTable.countries[ this.selectionSet[ i ]];
					cities = this.airportTable.countries[ tmp[ "CD" ]][ "list" ];
					for( var j = 0; j < cities.length; j ++ )
						if( this.airportTable.cities[ cities[ j ]][ "CD" ] == this.defaultCity ) {
							this.defaultArea = tmp[ "CD" ];
							break LABEL_01;
						}
				}
			}
		}
	},

	setAreaSelector : function() {
		this.selectedIndex = 0;
		this.buff = 0;

		var ptn = /^select$/i;
		if(
			this.areaNode && this.areaNode.nodeName.match( ptn ) &&
			this.cityNode && this.cityNode.nodeName.match( ptn )
		) {}
		else return;
		if( JLJS.env.isIE )
			while( this.areaNode.options[ 0 ] ) this.areaNode.options.remove( 0 );
		else
			while( this.areaNode.firstChild ) this.areaNode.removeChild( this.areaNode.firstChild );

		if( this.selectionSet.length ) {
			var newOPT = document.createElement( 'option' );
			newOPT.value = "";
			newOPT.text = this.type == 'd' ?
				! this.isEn ? '\u51FA\u767A\u30A8\u30EA\u30A2' : 'Departure Area' :
				! this.isEn ? '\u5230\u7740\u30A8\u30EA\u30A2' : 'Arrival Area';
			if( JLJS.env.isIE ) this.areaNode.add( newOPT, 0 );
			else this.areaNode.appendChild( newOPT );
			this.buff ++;

			for( var i = 0; i < this.selectionSet.length; i ++ ) {
				this.globalArea = null;

				if( this.selectionSet[ i ] == "" ) {
					var newOPT = document.createElement( 'option' );
					newOPT.text = "-------------";
					newOPT.value = "";
					if( JLJS.env.isIE ) this.areaNode.add( newOPT, this.buff  + 1 );
					else this.areaNode.appendChild( newOPT );
					this.buff ++;
					continue;
				}

				if( this.airportTable.globalAreas[ this.selectionSet[ i ]] )
					this.globalArea = this.airportTable.globalAreas[ this.selectionSet[ i ]];

				if( ! this.globalArea )
					this.globalArea = this.airportTable.countries[ this.selectionSet[ i ]];

				if( this.globalArea ) {
					var newOPT = document.createElement( 'option' );
					newOPT.value = this.globalArea[ "CD" ];
					newOPT.text = ! this.isEn ? this.globalArea[ "title_J" ] : this.globalArea[ "title_E" ];
					if( this.defaultArea && this.globalArea[ "CD" ] == this.defaultArea ) {
						newOPT.selected = true;
						this.selectedIndex = this.buff;
					}
					if( JLJS.env.isIE ) this.areaNode.add( newOPT, this.buff  + 1 );
					else this.areaNode.appendChild( newOPT );
					this.buff ++;
				}
			}
			this.areaNode.options.selectedIndex = this.selectedIndex;
		}
		
		else {
			this.globalArea = null;
			var find = 0;
			if( this.airportTable.globalAreas[ this.selection ] )
				this.globalArea = this.airportTable.globalAreas[ this.selection ];

			if( ! this.globalArea )
				this.globalArea = this.airportTable.countries[ this.selection ];

			if( this.globalArea ) {
				var newOPT = document.createElement( 'option' );
				newOPT.value = this.globalArea[ "CD" ];
				newOPT.text = ! this.isEn ? this.globalArea[ "title_J" ] : this.globalArea[ "title_E" ];
				if( JLJS.env.isIE ) this.areaNode.add( newOPT, this.buff  + 1 );
				else this.areaNode.appendChild( newOPT );
				this.buff ++;
			}
		}
	},

	narrowDown : function( area ) {
		if( ! this.noDOM ) {
			if( JLJS.env.isMac && JLJS.env.isIE ) {
				if( ! this.modifyOJOnly ) while( this.cityNode.options[ 0 ] ) this.cityNode.options.remove( 0 );
				if( this.cityNode_OJ ) while ( this.cityNode_OJ.options[ 0 ] ) this.cityNode_OJ.options.remove( 0 );
			}
			else {
				if( ! this.modifyOJOnly ) while( this.cityNode.childNodes[ 0 ] ) this.cityNode.removeChild( this.cityNode.childNodes[ 0 ] );
				if( this.cityNode_OJ ) while ( this.cityNode_OJ.childNodes[ 0 ] ) this.cityNode_OJ.removeChild( this.cityNode_OJ.childNodes[ 0 ] );
			}
		}

		this.selectedIndex = this.selectedIndex_OJ = 0;
		this.buff = 0;
		if( ! area || this.OJ_noAreaSelection ) {
			var text = this.type == 'd' ?
				! this.isEn ? '\u51FA\u767A\u90FD\u5E02' : 'Departure City' :
				! this.isEn ? '\u5230\u7740\u90FD\u5E02' : 'Arrival City';
			var text2 = this.type == 'd' ?
				! this.isEn ? '\u5230\u7740\u90FD\u5E02' : 'Arrival City' :
				! this.isEn ? '\u51FA\u767A\u90FD\u5E02' : 'Departure City';

			if( this.noDOM ) {
				if( ! this.modifyOJOnly ) {
					this.cityNode.options.length = 1;
					this.cityNode.options[ this.buff ].text = text;
				}

				if( this.cityNode_OJ ) {
					this.cityNode_OJ.options.length = this.buff + 1;
					this.cityNode_OJ.options[ this.buff ].text = text2;
				}
				this.buff ++;
			}

			else {
				var newOPT = document.createElement( 'option' );
				var newOPT2 = document.createElement( 'option' );
				newOPT.value = newOPT2.value = "";
				newOPT.text = text;
				newOPT2.text = text2;
				if( ! this.modifyOJOnly ) {
					if( JLJS.env.isIE ) this.cityNode.add( newOPT, 0 );
					else this.cityNode.appendChild( newOPT );
				}
				if( this.cityNode_OJ ) {
					if( JLJS.env.isIE ) this.cityNode_OJ.add( newOPT2, 0 );
					else this.cityNode_OJ.appendChild( newOPT2 );
						return;
				}
				this.buff ++;
			}
		}

		if( this.selectionSet.length ) {


			this.onLine_displayed = false;

			if( ! area && ! this.onLineSeparatingView_Off ) {
				this.setOptions_OL_start();

				var buff = this.buff;

				for( var i = 0; i < this.selectionSet.length; i ++ ) {
					this.countries = null;
					var tmp;
					if( tmp = this.airportTable.globalAreas[ this.selectionSet[ i ]] )
						this.countries = this.getListFromTable( tmp, true );

					this.cities = null;
					var tmp;
					if( this.countries ) {
						for( var j = 0; j < this.countries.length; j ++ ) {
							if( tmp = this.airportTable.countries[ this.countries[ j ]] )
								this.cities = this.getListFromTable( tmp, true ); 

							if( this.cities )
								for( var k = 0; k < this.cities.length; k ++ ) this.setOptions_OL( k, buff, area ? 1 : 0 );
						}
					}
					else {
						if( tmp = this.airportTable.countries[ this.selectionSet[ i ]] )
							this.cities = this.getListFromTable( tmp, true );

						if( this.cities )
							for( var j = 0; j < this.cities.length; j ++ ) this.setOptions_OL( j, buff, area ? 1 : 0 );
					}
				}

				if( this.cities ) {
					this.setOptions_OL_end();
					this.onLine_displayed = true;
				}
			}




			this.devided = false;
			LABEL_03:
			for( var i = 0; i < this.selectionSet.length; i ++ ) {
				if( area )
					if( this.selectionSet[ i ] != area ) continue;

				this.countries = null;
				var tmp;
				if( tmp = this.airportTable.globalAreas[ this.selectionSet[ i ]] )
					this.countries = this.getListFromTable( tmp, true );

				if( area && ! this.onLineSeparatingView_Off ) {
					this.setOptions_OL_start();

					var buff = this.buff;
					this.cities = null;
					var tmp;
					if( this.countries ) {
						for( var j = 0; j < this.countries.length; j ++ ) {
							if( tmp = this.airportTable.countries[ this.countries[ j ]] )
								this.cities = this.getListFromTable( tmp, true ); 

							if( this.cities )
								for( var k = 0; k < this.cities.length; k ++ ) this.setOptions_OL( k, buff, area ? 1 : 0 );
						}
					}
					else {
						if( tmp = this.airportTable.countries[ area ] )
							this.cities = this.getListFromTable( tmp, true );

						if( this.cities )
							for( var j = 0; j < this.cities.length; j ++ ) this.setOptions_OL( j, buff, area ? 1 : 0 );
					}

					if( this.cities ) {
						this.setOptions_OL_end();
						this.onLine_displayed = true;
					}
				}

				var tmp;
				if( tmp = this.airportTable.globalAreas[ this.selectionSet[ i ]] )
					this.countries = this.getListFromTable( tmp );

				this.cities = null;
				if( this.countries ) {
					for( var j = 0; j < this.countries.length; j ++ ) {
						var tmp;
						if( tmp = this.airportTable.countries[ this.countries[ j ]] )
							this.cities = this.getListFromTable( tmp );

						if( this.cities ) this.setOptions( tmp );
					}
					if( area ) break LABEL_03;
				}
				else {
					if( ! area ) {
						var tmp;
						if( tmp = this.airportTable.countries[ this.selectionSet[ i ]] )
							this.cities = this.getListFromTable( tmp );

						if( this.cities ) this.setOptions( tmp );
					}
					else if( area ) {
						var tmp;
						if( tmp = this.airportTable.countries[ area ] )
							this.cities = this.getListFromTable( tmp );

						if( this.cities ) {
							this.setOptions( tmp );
							break LABEL_03;
						}
					}
				}
			}
		}

		else {
			this.countries = null;
			var tmp;
			if( tmp = this.airportTable.globalAreas[ area ] )
				this.countries = this.getListFromTable( tmp, true );

			this.onLine_displayed = false;

			if( ! this.onLineSeparatingView_Off ) {
				this.setOptions_OL_start();

				var buff = this.buff;
				this.cities = null;
				var tmp;

				if( this.countries ) {
					for( var i = 0; i < this.countries.length; i ++ ) {
						if( tmp = this.airportTable.countries[ this.countries[ i ]] )
							this.cities = this.getListFromTable( tmp, true );

						if( this.cities )
							for( var j = 0; j < this.cities.length; j ++ ) this.setOptions_OL( j, buff, area ? 1 : 0 );
					}
				}
				else {
					if( tmp = this.airportTable.countries[ area ] )
						this.cities = this.getListFromTable( tmp, true );

					if( this.cities )
						for( var i = 0; i < this.cities.length; i ++ ) this.setOptions_OL( i, buff, area ? 1 : 0 );
				}

				if( this.cities ) {
					this.setOptions_OL_end();
					this.onLine_displayed = true;
				}
			}



			var tmp;
			if( tmp = this.airportTable.globalAreas[ area ] )
				this.countries = this.getListFromTable( tmp );

			this.cities = null;
			this.devided = false;
			if( this.countries ) {
				for( var i = 0; i < this.countries.length; i ++ ) {
					var tmp;
					if( tmp = this.airportTable.countries[ this.countries[ i ]] )
						this.cities = this.getListFromTable( tmp );

					if( this.cities ) this.setOptions( tmp );
				}
			}
			else {
				var tmp;
				if( tmp = this.airportTable.countries[ area ] )
					this.cities = this.getListFromTable( tmp );

				if( this.cities ) this.setOptions( tmp );
			}
		}
		if( this.OJ_noAreaSelection ) {
			this.selectedIndex = this.selectedIndex_OJ = 0;
			this.cityNode.options[ 0 ].selected =
			this.cityNode_OJ.options[ 0 ].selected = true;
		}
	},



	getListFromTable : function( tmp, srchOL ) {
		var list = null;
		if( srchOL ) {
			if( this.AMD )
				list = ! this.isEn ? tmp[ "list_AMD_MJ" ] : tmp[ "list_AMD_MJ_E" ] ? tmp[ "list_AMD_MJ_E" ] : tmp[ "list_AMD_MJ" ];
			else
				list = ! this.isEn ? tmp[ "list_OL" ] : tmp[ "list_OL_E" ] ? tmp[ "list_OL_E" ] : tmp[ "list_OL" ];
		}
		if( ! list )
			list = ! this.isEn ? tmp[ "list" ] : tmp[ "list_E" ] ? tmp[ "list_E" ] : tmp[ "list" ];

		return list;
	},


	setOptions_OL_start : function() {
		var label = ! this.isEn ? '\u4E3B\u8981\u90FD\u5E02' : 'Major Cities';
		this.newOPG = document.createElement( 'optgroup' );
		this.newOPG2 = document.createElement( 'optgroup' );
		this.newOPG.label = this.newOPG2.label = label;

		if( ! this.noGroup && ! this.onLineOnly && this.noDOM ) {
			if( ! this.modifyOJOnly ) {
				this.cityNode.options.length = this.buff + 1;
				this.cityNode.options[ this.buff ].text = '< ' + label + '>';
			}

			if( this.cityNode_OJ )
				if( ! this.OJ_noAreaSelection ) {
					this.cityNode_OJ.options.length = this.buff + 1;
					this.cityNode_OJ.options[ this.buff ].text = '< ' + label + '>';
				}
			this.buff ++;
		}
		else if( ! this.noGroup && ! this.onLineOnly && this.labelOpt ) {
			var newOPT = document.createElement( 'option' );
			var newOPT2 = document.createElement( 'option' );
			newOPT.text = newOPT2.text = '< ' + label + ' >';

			if( ! this.modifyOJOnly ) {
				if( JLJS.env.isIE ) this.cityNode.add( newOPT, this.buff + 1 );
				else this.cityNode.appendChild( newOPT );
			}
			if( this.cityNode_OJ )
				if( ! this.OJ_noAreaSelection ) {
					if( JLJS.env.isIE ) this.cityNode_OJ.add( newOPT2, this.buff + 1 );
					else this.cityNode_OJ.appendChild( newOPT2 );
				}
			this.buff ++;
		}
	},

	setOptions_OL : function( n, buff, area ) {
		var city = this.airportTable.cities[ this.cities[ n ]];
		if( this.AMD ) {
			if( ! city[ "AMD_MJ" ] ) return;
		}
		else
			if( ! city[ "OL" ] ) return;

		if( this.noDOM ) {
			var cityName = ! this.isEn ? city[ "title_J" ] : city[ "title_E" ];
			if( ! this.modifyOJOnly ) {
				this.cityNode.options.length = this.buff + 1;
				this.cityNode.options[ this.buff ].text = cityName;
				this.cityNode.options[ this.buff ].value = city[ "CD" ];
				if( this.defaultCity && city[ "CD" ] == this.defaultCity ) {
					this.selectedIndex = this.buff;
					this.cityNode.options[ this.buff ].selected = true;
				}
			}

			if( this.cityNode_OJ )
				if( ! this.OJ_noAreaSelection ) {
					this.cityNode_OJ.options.length = this.buff + 1;
					this.cityNode_OJ.options[ this.buff ].text = cityName;
					this.cityNode_OJ.options[ this.buff ].value = city[ "CD" ];
					if( this.defaultCity_OJ && city[ "CD" ] == this.defaultCity_OJ ) {
						this.selectedIndex_OJ = this.buff;
						this.cityNode_OJ.options[ this.buff ].selected = true;
					}
				}

			if( buff == this.buff && area ) {
				if( ! this.modifyOJOnly ) {
					this.cityNode.options[ this.buff ].selected = true;
					this.selectedIndex = this.buff;
				}
				if( this.citiNody_OJ )
					if( ! this.OJ_noAreaSelection ) {
						this.cityNode_OJ.options[ this.buff ].selected = true;
						this.selectedIndex_OJ = this.buff;
					}
			}

			this.buff ++;
		}
		else {
			var cityName = ! this.isEn ? city[ "title_J" ] : city[ "title_E" ];
			var newOPT = document.createElement( 'option' );
			var newOPT2 = document.createElement( 'option' );
			newOPT.value = newOPT2.value = city[ "CD" ];

			if( this.defaultCity && city[ "CD" ] == this.defaultCity )
				if( ! this.modifyOJOnly ) {
					newOPT.selected = true;
					this.selectedIndex = this.buff;
				}
			if( this.defaultCity_OJ && city[ "CD" ] == this.defaultCity_OJ )
				if( ! this.OJ_noAreaSelection ) {
					newOPT2.selected = true;
					this.selectedIndex_OJ = this.buff;
				}

			if( ! this.noGroup && ! this.labelOpt && ! this.onLineOnly ) {
				newOPT.innerHTML = newOPT2.innerHTML = cityName;
				if( ! this.modifyOJOnly )
					this.newOPG.appendChild( newOPT );
				if( this.cityNode_OJ )
					if( ! this.OJ_noAreaSelection )
						this.newOPG2.appendChild( newOPT2 );
				this.buff ++;
			}

			else {
				newOPT.text = newOPT2.text = cityName;
				if( ! this.modifyOJOnly ) {
					if( JLJS.env.isIE ) this.cityNode.add( newOPT, this.buff + 1 );
					else this.cityNode.appendChild( newOPT );
				}
				if( this.cityNode_OJ )
					if( ! this.OJ_noAreaSelection ) {
						if( JLJS.env.isIE ) this.cityNode_OJ.add( newOPT2, this.buff + 1 );
						else this.cityNode_OJ.appendChild( newOPT2 );
					}
				if( buff == this.buff && area ) {
					if( ! this.modifyOJOnly ) {
						this.cityNode.options[ this.buff ].selected = true;
						this.selectedIndex = this.buff ;
					}
					if( this.cityNode_OJ )
						if( ! this.OJ_noAreaSelection ) {
							this.cityNode_OJ.options[ this.buff ].selected = true;
							this.selectedIndex_OJ = this.buff ;
						}
				}

				this.buff ++;

			}
		}
	},

	setOptions_OL_end : function() {
		if( ! this.noGroup && ! this.labelOpt && ! this.onLineOnly ) {
			if( ! this.modifyOJOnly ) {
				if(this.newOPG.childNodes.length > 0) {
					this.cityNode.appendChild( this.newOPG );
					this.noDevide = false;
				} else {
					this.noDevide = true;
				}
			}
			if( this.cityNode_OJ ) {
				if( ! this.OJ_noAreaSelection ) {
					if(this.newOPG2.childNodes.length > 0) {
						this.cityNode_OJ.appendChild( this.newOPG2 );
						this.noDevide = false;
					} else {
						this.noDevide = true;
					}
				}
			}
		} 
	},

	setOptions_Devide : function() {
		if( this.noDevide ) return;
		if( this.cityNode.options.length == 0) {
			this.devided = true;
			return;
		}
		if( this.noDOM ) {
			if( ! this.modifyOJOnly ) {
				this.cityNode.options.length = this.buff + 1;
				this.cityNode.options[ this.buff ].text = "-------------";
				this.cityNode.options[ this.buff ].value = "";
			}

			if( this.cityNode_OJ )
				if( ! this.OJ_noAreaSelection ) {
					this.cityNode_OJ.options.length = this.buff + 1;
					this.cityNode_OJ.options[ this.buff ].text = "-------------";
					this.cityNode_OJ.options[ this.buff ].value = "";
				}
			this.buff ++;
			this.devided = true;
		}
		else {
			var newOPT = document.createElement( 'option' );
			var newOPT2 = document.createElement( 'option' );
			newOPT.text = newOPT2.text = "-------------";
			newOPT.value = newOPT2.value = "";
			if( ! this.modifyOJOnly ) {
				if( JLJS.env.isIE ) this.cityNode.add( newOPT, this.buff + 1 );
				else this.cityNode.appendChild( newOPT );
			}
			if( this.cityNode_OJ )
				if( ! this.OJ_noAreaSelection ) {
					if( JLJS.env.isIE ) this.cityNode_OJ.add( newOPT2, this.buff + 1 );
					else this.cityNode_OJ.appendChild( newOPT2 );
				}
			this.buff ++;
			this.devided = true;

		}
	},

	setOptions : function( country, area ) {
		if( this.onLineOnly && ! this.onLineSeparatingView_Off ) return;
		if( this.noDOM ) {
			var countryName = ! this.isEn ? country[ "title_J" ] : country[ "title_E" ];

			var buff = this.buff;
			for( var i = 0; i < this.cities.length; i ++ ) {
				var devide = ! this.cities[ i ] ? true : false;
				var city = this.airportTable.cities[ this.cities[ i ]];
				if( ! this.onLineSeparatingView_Off ) {
					if( this.AMD ) {
						if( ! devide && city[ "AMD_MJ" ] ) continue;
					}
					else
						if( ! devide && city[ "OL" ] ) continue;
				}
				else if( this.onLineOnly ) {
					if( this.AMD ) {
						if( ! devide && ! city[ "AMD_MJ" ] ) continue;
					}
					else
						if( ! devide && ! city[ "OL" ] ) continue;
				}

				if( buff == this.buff ) {
					if( ! this.devided && this.onLine_displayed ) this.setOptions_Devide();

					if( ! this.noGroup && ! this.noLabel && this.labelOpt ) {
						if( ! this.modifyOJOnly ) {
							this.cityNode.options.length = this.buff + 1;
							this.cityNode.options[ this.buff ].text = "";
						}
						if( this.cityNode_OJ )
							if( ! this.OJ_noAreaSelection ) {
								this.cityNode_OJ.options.length = this.buff + 1;
								this.cityNode_OJ.options[ this.buff ].text = "";
							}
						this.buff ++;

						if( ! this.modifyOJOnly ) {
							this.cityNode.options.length = this.buff + 1;
							this.cityNode.options[ this.buff ].text = "< " + countryName + " >";
						}
						if( this.cityNode_OJ )
							if( ! this.OJ_noAreaSelection ) {
								this.cityNode_OJ.options.length = this.buff + 1;
								this.cityNode_OJ.options[ this.buff ].text = "< " + countryName + " >";
							}
						this.buff ++;
					}

					if( ! this.onLine_displayed && area ) {
						if( ! this.modifyOJOnly ) {
							this.cityNode.options[ this.buff ].selected = true;
							this.selectedIndex = this.buff;
						}
						if( this.citiNody_OJ )
							if( ! this.OJ_noAreaSelection ) {
								this.cityNode_OJ.options[ this.buff ].selected = true;
								this.selectedIndex_OJ = this.buff;
							}
					}
				}

				var cityName = devide ? "-------------" : ! this.isEn ? city[ "title_J" ] : city[ "title_E" ];
				var value = devide ? "" : city[ "CD" ];

				if( ! this.modifyOJOnly ) {
					this.cityNode.options.length = this.buff + 1;
					this.cityNode.options[ this.buff ].text = cityName;
					this.cityNode.options[ this.buff ].value = value;
					if( this.defaultCity && value == this.defaultCity ) {
						this.cityNode.options[ this.buff ].selected = true;
						this.selectedIndex = this.buff;
					}
				}

				if( this.cityNode_OJ )
					if( ! this.OJ_noAreaSelection ) {
						this.cityNode_OJ.options.length = this.buff + 1;
						this.cityNode_OJ.options[ this.buff ].text = cityName;
						this.cityNode_OJ.options[ this.buff ].value = value;
						if( this.defaultCity_OJ && value == this.defaultCity_OJ ) {
							this.cityNode_OJ.options[ this.buff ].selected = true;
							this.selectedIndex_OJ = this.buff;
						}
					}

				this.buff ++;
			}

		}
		else {
			var countryName = ! this.isEn ? country[ "title_J" ] : country[ "title_E" ];

			var newOPG = document.createElement( 'optgroup' );
			var newOPG2 = document.createElement( 'optgroup' );
			if( ! this.noLabel )
				newOPG.label = newOPG2.label = countryName;

			var buff = this.buff;
			for( var i = 0; i < this.cities.length; i ++ ) {
				var devide = ! this.cities[ i ] ? true : false;
				var city = this.airportTable.cities[ this.cities[ i ]];
				if( ! this.onLineSeparatingView_Off ) {
					if( this.AMD ) {
						if( ! devide && city[ "AMD_MJ" ] ) continue;
					}
					else
						if( ! devide && city[ "OL" ] ) continue;
				}
				else if( this.onLineOnly ) {
					if( this.AMD ) {
						if( ! devide && ! city[ "AMD_MJ" ] ) continue;
					}
					else
						if( ! devide && ! city[ "OL" ] ) continue;
				}

				if( buff == this.buff ) {
					if( ! this.devided && this.onLine_displayed ) this.setOptions_Devide();

					if( ! this.noGroup && ! this.noLabel && this.labelOpt ) {
						var newOPT = document.createElement( 'option' );
						var newOPT2 = document.createElement( 'option' );
						newOPT.text = newOPT2.text = "";

						if( ! this.modifyOJOnly ) {
							if( JLJS.env.isIE ) this.cityNode.add( newOPT, this.buff + 1 );
							else this.cityNode.appendChild( newOPT );
						}
						if( this.cityNode_OJ )
							if( ! this.OJ_noAreaSelection ) {
								if( JLJS.env.isIE ) this.cityNode_OJ.add( newOPT2, this.buff + 1 );
								else this.cityNode_OJ.appendChild( newOPT2 );
							}
						this.buff ++;

						var newOPT = document.createElement( 'option' );
						var newOPT2 = document.createElement( 'option' );
						newOPT.text = newOPT2.text = "< " + countryName + " >";

						if( ! this.modifyOJOnly ) {
							if( JLJS.env.isIE ) this.cityNode.add( newOPT, this.buff + 1 );
							else this.cityNode.appendChild( newOPT );
						}
						if( this.cityNode_OJ )
							if( ! this.OJ_noAreaSelection ) {
								if( JLJS.env.isIE ) this.cityNode_OJ.add( newOPT2, this.buff + 1 );
								else this.cityNode_OJ.appendChild( newOPT2 );
							}
						this.buff ++;
					}

					if( ! this.onLine_displayed && area ) {
						if( ! this.modifyOJOnly ) {
							this.cityNode.options[ this.buff ].selected = true;
							this.selectedIndex = this.buff;
						}
						if( this.citiNody_OJ )
							if( ! this.OJ_noAreaSelection ) {
								this.cityNode_OJ.options[ this.buff ].selected = true;
								this.selectedIndex_OJ = this.buff;
							}
					}
				}

				var cityName = devide ? "-------------" : ! this.isEn ? city[ "title_J" ] : city[ "title_E" ];
				var value = devide ? "" : city[ "CD" ];
				var newOPT = document.createElement( 'option' );
				var newOPT2 = document.createElement( 'option' );

				if( this.defaultCity && value == this.defaultCity )
					if( ! this.modifyOJOnly ) {
						newOPT.selected = true;
						this.selectedIndex = this.buff;
					}
				if( this.defaultCity_OJ && value == this.defaultCity_OJ )
					if( ! this.OJ_noAreaSelection ) {
						newOPT2.selected = true;
						this.selectedIndex_OJ = this.buff;
					}

				newOPT.value = newOPT2.value = value;

				if( ! this.noGroup && ! this.labelOpt ) {
					newOPT.innerHTML = newOPT2.innerHTML = cityName;
					if( ! this.modifyOJOnly )
						newOPG.appendChild( newOPT );
					if( this.cityNode_OJ )
						if( ! this.OJ_noAreaSelection )
							newOPG2.appendChild( newOPT2 );
				}

				else {
					newOPT.text = newOPT2.text = cityName;
					if( ! this.modifyOJOnly ) {
						if( JLJS.env.isIE ) this.cityNode.add( newOPT, this.buff + 1 );
						else this.cityNode.appendChild( newOPT );
					}
					if( this.cityNode_OJ )
						if( ! this.OJ_noAreaSelection ) {
							if( JLJS.env.isIE ) this.cityNode_OJ.add( newOPT2, this.buff + 1 );
							else this.cityNode_OJ.appendChild( newOPT2 );
						}
				}

				this.buff ++;
			}

			if( ! this.noGroup && ! this.labelOpt ) {
				if( buff != this.buff ) {
					if( ! this.modifyOJOnly )
						this.cityNode.appendChild( newOPG );
					if( this.cityNode_OJ )
						if( ! this.OJ_noAreaSelection )
							this.cityNode_OJ.appendChild( newOPG2 );
				}
			}
		}

		if( ! this.modifyOJOnly )
			this.cityNode.options.selectedIndex = this.selectedIndex;
		if( this.cityNode_OJ )
			if( ! this.OJ_noAreaSelection )
				this.cityNode_OJ.options.selectedIndex = this.selectedIndex_OJ;
	}

}
