//*****************************************************************
//Please save this file with a character code "UTF-8".
//*****************************************************************

// [init]
var adt_number = "";
var chd_number = "";
var infants_number = "";
var member_no = "";
if (JLJS02.site.lang.isEN) {
	adt_number = "Adults (age 12 and older on the day of international departure)";
	chd_number = "Children (ages 2 - 11 on the day of international departure and infant occupying a seat)";
	infants_number =
			"Infants (younger than age 2 on the day of international departure and not occupying a seat)";
	member_no = '<img src="/common/img/icon_balloon_001.gif" width="52" height="30" alt="">Membership Number<br>(7 or 9 digits)';
}else{
	adt_number = "\u5927\u4eba(12\u624d\u4ee5\u4e0a)&nbsp;&nbsp;&nbsp;&nbsp;(\u6d77\u5916\u65c5\u884c\u958b\u59cb\u65e5\u306e\u5e74\u9f62)";
	chd_number ="\u5c0f\u5150(2\u624d~11\u624d)&nbsp;&nbsp;&nbsp;&nbsp;(\u6d77\u5916\u65c5\u884c\u958b\u59cb\u65e5\u306e\u5e74\u9f62)&nbsp;&nbsp;&nbsp;&nbsp;(\u304a\u3088\u3073\u5ea7\u5e2d\u3092\u3054\u5229\u7528\u306e\u5e7c\u5150)";
	infants_number =			"\u5e7c\u5150(0\u624d~1\u624d)&nbsp;&nbsp;&nbsp;&nbsp;(\u6d77\u5916\u65c5\u884c\u958b\u59cb\u65e5\u306e\u5e74\u9f62)&nbsp;&nbsp;&nbsp;&nbsp;(\u4f46\u3057\u3001\u5ea7\u5e2d\u3054\u5229\u7528\u306e\u5e7c\u5150\u3092\u9664\u304f)";
	member_no = '<img src="/common/img/icon_balloon_001.gif" width="52" height="30" alt="">\u304a\u5f97\u610f\u69d8\u756a\u53f7<br>(7\u6841\u304b9\u6841)'
}

var JLJS_InfoBalloonData = {
	'member_no' : member_no,
	'FIELD_ADT_NUMBER1' : adt_number,
	'FIELD_CHD_NUMBER1' : chd_number,
	'FIELD_INFANTS_NUMBER1' : infants_number
};

//---------- [/topModule] ----------
function JLJS_topModuleSetup() {

	var defaultAreaSlctSet1 = "";
	var defaultAreaSlctSet2 = "whole_exJPN_05";
	var defaultArea1 = "CHN_05";
	var defaultArea2 = "JPN_08";
	var defaultCity1 = null;
	var defaultCity2 = "TYO";
	var onLineOnly1 = 0;
	var onLineOnly2 = 0;
	var onLineSeparatingView_Off1 = 0;
	var onLineSeparatingView_Off2 = 0;
	var noAreaSelection1 = 1;
	var noAreaSelection2 = 1;
	var noGroup1 = 1;
	var noGroup2 = 1;
	var noDevide1 = 1;
	var noDevide2 = 0;
	var defaultDay_Outbound = 3;
	var defaultDay_Inbound = defaultDay_Outbound + 5;
		
	JLJS_TicketModuleSetup_Fp( [
		{ "areaSlctSet" : defaultAreaSlctSet1, "default" : [ defaultArea1, defaultCity1 ], "AMD" : 1, "onLineOnly" : onLineOnly1, "noAreaSelection" : noAreaSelection1, "onLineSeparatingView_Off" : onLineSeparatingView_Off1, "noGroup" : noGroup1, "noDevide" : noDevide1, "EN" : ( JLJS02.site.lang.isEN ) ? 1 : 0 },
		{ "areaSlctSet" : defaultAreaSlctSet2, "default" : [ defaultArea2, defaultCity2 ], "AMD" : 1, "onLineOnly" : onLineOnly2, "noAreaSelection" : noAreaSelection2, "onLineSeparatingView_Off" : onLineSeparatingView_Off2, "noGroup" : noGroup2, "noDevide" : noDevide2, "EN" : ( JLJS02.site.lang.isEN ) ? 1 : 0 },
		{ "default" : [ "today+" + defaultDay_Outbound, "today+" + defaultDay_Inbound ] },
		{ "EN" : ( JLJS02.site.lang.isEN ) ? 1 : 0, "isJumpingToOJPage" : 1, "OJ_URL" : "/en/flight_planning/reservation/oj/", "method" : "get" }
	] );
		
	JLJS.addEvent( JLJS_AMDs[0].formNode["E_AREA"], "change", function( e ) {
				e.target.form._TM_instance_.changeEArea(0);
	} );	
	JLJS.addEvent( JLJS_AMDs[0].formNode["E_AREA"], "change", function( e ) {
				e.target.form._TM_instance_.changeTopClass();
		} );
	JLJS.addEvent( JLJS_AMDs[0].formNode["E_LOCATION_1"], "change", function( e ) {
			e.target.form._TM_instance_.changeTopClass();
	} );
	JLJS_AMDs[0].createTopClass();
	
	if(JLJS_AMDs[0].isZHCN){//Chinese_Calendar_Set
		JLJS_AMDs[0].topCalendarSetup();
	}else{
		if (JLJS02.site.lang.isEN){
			JLJS_AMDCAL.lang = "en";
		}else{
			JLJS_AMDCAL.lang = "ja";
		}		
		JLJS_AMDCAL.url = "/world/fp/common/html/ticketModuleCalendar.html";
	}
};

// [topCalendarSetup(Chinese_site Used)]
JLJS_ticketModule_Fp.prototype.topCalendarSetup = function(){

	var floatCalIcons = JLJS.getElementsByClassName("floatCalIcon", "a",this.formNode);
	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 = {};
					if (JLJS.classAttr["check"](e.currentTarget, "meet")) {
						prm["board"] = {month: form["B_MONTH"], day: form["B_DAY"]};
						prm["arrival"] = {month: form["E_MONTH"], day: form["E_DAY"]};
					}else{
						prm["board"] = {month: form["E_MONTH"], day: form["E_DAY"]};		
					}
					JLJS_CalNav.calDisplay(
						{target: e.currentTarget,
						option: JLJS_CalNav.OPT_AMD_TM,
						frm : prm
						}
					)
				}
			);

		} else {
			JLJS.classAttr.add(floatCalIcon, "hidden");
		}
	}
};
// [//topCalendarSetup(Chinese_site Used)]

// [changeEArea]
JLJS_ticketModule_Fp.prototype.changeEArea = function( num ){
	
	var b_area = "B_AREA";
	var e_area = "E_AREA";
	var b_locate ="B_LOCATION_2";
	var e_locate = "E_LOCATION_1";
	if (num != 0){
		b_area = b_area + "_" + num;
		e_area = e_area + "_" + num;
	}

	var jpn = "JPN_08";
	var hwaii = "HWI_GUM02";
	var usa = "USA_11";
	var canMex = "CAN_MEX_SouthAmerica_02";
	var eur = "Europe_03";
	var rus = "RUS_MDE_02";
	var asiaOcean = "ASA_PACIFIC";	
	var separateFlg = 0;
	var noGroupFlg = 1;
	var node;
	
	if(num != 2){
		node = this.formNode[e_area];
	}else{
		node = this.formNode[b_area];
	}

	if (node.value != asiaOcean && node.value != jpn && node.value != hwaii && node.value != usa && node.value != canMex && node.value != eur && node.value != rus){
		return;
	}
	
	var defaultSet = "whole_exJPN_05";
	var defaultArea;
	
	if (node.value == asiaOcean){
		defaultArea = asiaOcean;
		separateFlg = 1;
		noGroupFlg = 0;
	}else if(node.value == jpn){
		defaultArea = jpn;
	}else if(node.value == hwaii){
		defaultArea = hwaii;
	}else if(node.value == usa){
		defaultArea = usa;
	}else if(node.value == canMex){
		defaultArea = canMex;
	}else if(node.value == eur){
		defaultArea = eur;
	}else if(node.value == rus){
		defaultArea = rus;
	}
	
	var narrowDownArgs;
	if(num == 1){
		narrowDownArgs = ['a', 'E_AREA_' + num, 'E_LOCATION_' + num];
	}else if(num == 2){
		narrowDownArgs = ['d', 'B_AREA_' + num, 'B_LOCATION_' + num];
	}
	
	JLJS_TicketModuleModify_Fp( [
		{  },
		{ "areaSlctSet" : defaultSet, "default" : [ defaultArea, "" ], "AMD" : 1, "noGroup" : noGroupFlg, "EN" : ( JLJS02.site.lang.isEN ) ? 1 : 0, "onLineSeparatingView_Off" : separateFlg },
		{ "narrowDownArgs" : narrowDownArgs, "EN" : ( JLJS02.site.lang.isEN ) ? 1 : 0 }
	] );
	
}
// [/changeEArea]

// [---TravelClassSet---]
// [getTopClassList]
JLJS_ticketModule_Fp.prototype.topClassList = null;

JLJS_ticketModule_Fp.prototype.getTopClassList = function( prm ){
	if(prm == 1){
		if(this.isZHCN){//Language is Chinese.
			this.topClassList = [["3CNECORES", "经济舱(最低运价)"], ["3CNECO", "经济舱"], ["3CNFIRBIZ", "头等舱/商务舱"]];
		}else{
			if(!JLJS02.site.lang.isEN){//Language is Japanese.
				this.topClassList = [["3CNECORES", "\u30a8\u30b3\u30ce\u30df\u30fc\uff08\u6700\u4f4e\u904b\u8cc3\uff09"], ["3CNECO", "\u30a8\u30b3\u30ce\u30df\u30fc\u30af\u30e9\u30b9"], ["3CNFIRBIZ", "\u30d5\u30a1\u30fc\u30b9\u30c8/\u30a8\u30b0\u30bc\u30af\u30c6\u30a3\u30d6\u30af\u30e9\u30b9"]];
			}
		}		
	}else{
		if(this.isZHCN){//Language is Chinese.
			this.topClassList = [["3CNECO", "经济舱"], ["3CNFIRBIZ", "头等舱/商务舱"]];
		}else{
			if(!JLJS02.site.lang.isEN){//Language is Japanese.
				this.topClassList = [["3CNECO", "\u30a8\u30b3\u30ce\u30df\u30fc\u30af\u30e9\u30b9"], ["3CNFIRBIZ", "\u30d5\u30a1\u30fc\u30b9\u30c8/\u30a8\u30b0\u30bc\u30af\u30c6\u30a3\u30d6\u30af\u30e9\u30b9"]];
			}
		}
	}
}
// [/getTopClassList]

// [createTopClass]
JLJS_ticketModule_Fp.prototype.createTopClass = function(){
	var classFlag = 1;
	var classNode = JLJS_AMDs[0].formNode["COMMERCIAL_FARE_FAMILY_1"];

	this.getTopClassList(classFlag);	

	if( JLJS.env.isIE ) {
		while( classNode.options[ 0 ] ) {
			classNode.options.remove( 0 );
		}
		while( classNode.firstChild ) {
			classNode.removeChild( classNode.firstChild );
		}
	} else {
		while( classNode.firstChild ) {
			classNode.removeChild( classNode.firstChild );
		}
	}

	this.setOption(this.topClassList, classNode);

}
// [/createTopClass]

// [setOption]
JLJS_ticketModule_Fp.prototype.setOption = function(list, node){
	for (var i=0;i<list.length;i++) {
		var newOpt = document.createElement( 'option' );
		newOpt.value = list[i][0];
		newOpt.innerHTML = list[i][1];
		node.appendChild( newOpt );
	}
}
// [/setOption]

// [changeTopClass]
JLJS_ticketModule_Fp.prototype.changeTopClass = function(){
	var eAreaNode =  this.formNode["E_AREA"];
	var eLocationNode =  this.formNode["E_LOCATION_1"];
	var classNode = this.formNode["COMMERCIAL_FARE_FAMILY_1"];
	var cityList = [ "TYO", "OSA", "NGO", "FUK", "SPK", "OKA", "MMB", "AKJ", "KUH", "OBO", "HKD", "AOJ", "MSJ", "AXT", "HNA", "GAJ", "SDJ", "KIJ", "KMQ", "FSZ", "SHM", "OKJ", "IZO", "HIJ", "UBJ", "TKS", "TAK", "KCZ", "MYJ", "KKJ", "OIT", "NGS", "KMJ", "KMI", "KOJ", "ASJ", "MMY", "ISG" ];
	var classFlag = 0;
	
	if(eAreaNode.value == "JPN_08"){
		classFlag = 1;
	}else if(eAreaNode.value == ""){
		if(eLocationNode.value){
			for(i=0; i<cityList.length; i++){
				if(eLocationNode.value == cityList[i]){
					classFlag = 1;
					break;
				}
			}	
		}		
	}
	this.getTopClassList(classFlag);
	
	classNode.options.length = 0;
	this.setOption(this.topClassList, classNode);
}
// [/changeTopClass]
// [/---TravelClassSet---]

// [setTopPrm]
JLJS_ticketModule_Fp.prototype.setTopPrm = function(){
	this.formNode.action = this.formAction;
	this.formNode["amadeusAction"].value = this.amadeusAction;
	this.formNode["EMBEDDED_TRANSACTION"].value = "FlexPricerAvailability";
	this.formNode["SITE"].value = "CBCPCBCP";
	this.formNode["TRIP_FLOW"].value = "YES";
	this.formNode["DIRECT_LOGIN"].value = "NO";
	this.formNode["ARRANGE_BY"].value = "N";
	this.formNode["REFRESH"].value = "0";
	this.formNode["EXTERNAL_ID"].value = "JAL_SR_CN";
	this.formNode["DATE_RANGE_VALUE_1"].value = "3";
	this.formNode["DATE_RANGE_VALUE_2"].value = "3";
	this.formNode["DATE_RANGE_QUALIFIER_1"].value = "C";
	this.formNode["DATE_RANGE_QUALIFIER_2"].value = "C";
	this.formNode["SO_SITE_OFFICE_ID"].value = "SHAJL18AA";
	this.formNode["SO_GL"].value = '';	//"SO_GL" is made in a "imprtant notice" page.
	this.formNode["SO_SITE_MAIL_FROM"].value = 'Japan Airlines Reservation <org.shatt.jal@jal.com>';
	this.formNode["SO_SITE_PNR_ADD_EMAIL1"].value = 'Japan Airlines Reservation <shatt.web@jal.com>';
	this.formNode["SO_SITE_POINT_OF_SALE"].value = 'SHA';
	this.formNode["SO_SITE_POINT_OF_TICKETING"].value = 'SHA';
	this.formNode["SO_FAILURE_QUEUE_OFFICE_ID"].value = 'SHAJL1200';
	this.formNode["SO_QUEUE_OFFICE_ID"].value = 'SHAJL1200';
	this.formNode["SO_SITE_MIN_AVAIL_DATE_SPAN"].value = 'H72';
	this.formNode["SO_SITE_MINIMAL_TIME"].value = 'H72';
	this.formNode["SO_SITE_MINIMAL_TIME_MODIF"].value = 'H72';
	this.formNode["SO_SITE_EXT_PSPTYPE"].value = "HTML";
	this.formNode["SO_SITE_PSP_FORM_METHOD"].value = "POST";
	this.formNode["SO_SITE_EXT_PSPURL"].value = this.pspUrlParam;
	this.formNode["SO_SITE_EXT_MerchantID"].value = this.merchantIDParam;
	
	if(this.isZHCN){
		this.formNode["LANGUAGE"].value = "CN";
	}else{
		if(!JLJS02.site.lang.isEN){
			this.formNode["LANGUAGE"].value = "JP";
		}
	}

	this.formNode["B_ANY_TIME_1"].value = "TRUE";
	
	if (this.tripType == "R") {
		this.formNode["B_ANY_TIME_2"].value = "TRUE";
	}
	if (this.formNode["IS_FLEXIBLE"].checked) {
		this.formNode["DISPLAY_TYPE"].value = "1";
	}else{
		this.formNode["DISPLAY_TYPE"].value = "2";
	}
	
	this.formNode["PRICING_TYPE"].value = "I";
	
	this.createAdditionalPrm();
}
// [/setTopPrm]

//---------- [/topModule] ----------

// [setHiddenPrm]
JLJS_ticketModule_Fp.prototype.setHiddenPrm = function(){
	if (this.pageType == "T") {
		this.setTopPrm();
	}else if(this.pageType == "M"){
		this.setMultiPrm();
	}
}
// [/setHiddenPrm]

// [createAdditionalPrm]
JLJS_ticketModule_Fp.prototype.createAdditionalPrm = function(){
	
	while( this.additionalParameterBlock.firstChild ){
		this.additionalParameterBlock.removeChild( this.additionalParameterBlock.firstChild );
	}
	
	for( var i = 0; i < this.ADT; i ++ ) {
		var newINPUT = document.createElement( 'input' );
		newINPUT.type = "hidden";
		newINPUT.name = "TRAVELLER_TYPE_" + ( i + 1 );
		newINPUT.value = "ADT";
		this.additionalParameterBlock.appendChild( newINPUT );
	}
	
	for( var i = this.ADT; i < this.ADT + this.CHD; i ++ ) {
		var newINPUT = document.createElement( 'input' );
		newINPUT.type = "hidden";
		newINPUT.name = "TRAVELLER_TYPE_" + ( i + 1 );
		newINPUT.value = "CHD";
		this.additionalParameterBlock.appendChild( newINPUT );
	}

	for( var i = 0; i < this.INF; i ++ ) {
		var newINPUT = document.createElement( 'input' );
		newINPUT.type = "hidden";
		newINPUT.name = "HAS_INFANT_" + ( i + 1 );
		newINPUT.value = "TRUE";
		this.additionalParameterBlock.appendChild( newINPUT );
	}
}
// [/createAdditionalPrm]

//---------- [multiModule] ----------
function JLJS_multiModuleSetup() {

	var defaultAreaSlctSet1 = "";
	var defaultAreaSlctSet2 = "whole_exJPN_05";
	var defaultArea1 = "CHN_05";
	var defaultArea2 = "JPN_08";
	var defaultCity1 = "";
	var defaultCity2 = "TYO";
	var onLineOnly1 = 0;
	var onLineOnly2 = 0;
	var onLineSeparatingView_Off1 = 0;
	var onLineSeparatingView_Off2 = 0;
	var noAreaSelection1 = 1;
	var noAreaSelection2 = 1;
	var noGroup1 = 1;
	var noGroup2 = 1;
	var noDevide1 = 1;
	var noDevide2 = 0;
	var defaultDay_Outbound = 3;
	var defaultDay_Inbound = defaultDay_Outbound + 5;
	
	JLJS_MultiModuleSetup_Fp( [
		{ "areaSlctSet" : defaultAreaSlctSet1, "default" : [ defaultArea1, defaultCity1 ], "AMD" : 1, "onLineOnly" : onLineOnly1, "noAreaSelection" : noAreaSelection1, "onLineSeparatingView_Off" : onLineSeparatingView_Off1, "noGroup" : noGroup1, "noDevide" : noDevide1, "EN" : ( JLJS02.site.lang.isEN ) ? 1 : 0 },
		{ "areaSlctSet" : defaultAreaSlctSet2, "default" : [ defaultArea2, defaultCity2 ], "AMD" : 1, "onLineOnly" : onLineOnly2, "noAreaSelection" : noAreaSelection2, "onLineSeparatingView_Off" : onLineSeparatingView_Off2, "noGroup" : noGroup2, "noDevide" : noDevide2, "EN" : ( JLJS02.site.lang.isEN ) ? 1 : 0 },
		{ "areaSlctSet" : defaultAreaSlctSet2, "default" : [ defaultArea2, defaultCity2 ], "AMD" : 1, "onLineOnly" : onLineOnly2, "noAreaSelection" : noAreaSelection2, "onLineSeparatingView_Off" : onLineSeparatingView_Off2, "noGroup" : noGroup2, "noDevide" : noDevide2, "EN" : ( JLJS02.site.lang.isEN ) ? 1 : 0 },
		{ "areaSlctSet" : defaultAreaSlctSet1, "default" : [ defaultArea1, defaultCity1 ], "AMD" : 1, "onLineOnly" : onLineOnly1, "noAreaSelection" : noAreaSelection1, "onLineSeparatingView_Off" : onLineSeparatingView_Off1, "noGroup" : noGroup1, "noDevide" : noDevide1, "EN" : ( JLJS02.site.lang.isEN ) ? 1 : 0 },
		{ "defaultDate" : [ "today+" + defaultDay_Outbound, "today+" + defaultDay_Inbound ] },
		{ "EN" : ( JLJS02.site.lang.isEN ) ? 1 : 0, "method" : "get", "areaDisp" : 0 }
	] );

	for (var i=0;i<JLJS_AMDs.length;i++) {
		
		JLJS_AMDs[i].formNode["TRIP_TYPE"].value = "M";
		JLJS_AMDs[i].formNode[ "stopoverCheck_1" ].value = "0";
		JLJS_AMDs[i].formNode[ "stopoverCheck_2" ].value = "0";

		JLJS_AMDs[i].add_setDefaultValue( 1, 1 );
		JLJS_AMDs[i].add_setDefaultValue( 2, 1 );
		
		JLJS.addEvent( JLJS_AMDs[i].formNode["B_MONTH"], "change", function( e ) {
			e.target.form._TM_instance_.add_adjustDates( 1 );
		} );
		JLJS.addEvent( JLJS_AMDs[i].formNode["B_DAY"], "change", function( e ) {
			e.target.form._TM_instance_.add_adjustDates( 1 );
		} );

		JLJS.addEvent( JLJS_AMDs[i].formNode["B_MONTH_SO_1"], "change", function( e ) {
			e.target.form._TM_instance_.add_adjustDates( 2 );
		} );
		JLJS.addEvent( JLJS_AMDs[i].formNode["B_DAY_SO_1"], "change", function( e ) {
			e.target.form._TM_instance_.add_adjustDates( 2 );
		} );

		JLJS.addEvent( JLJS_AMDs[i].formNode["E_MONTH"], "change", function( e ) {
			e.target.form._TM_instance_.add_adjustDates( 3 );
		} );
		JLJS.addEvent( JLJS_AMDs[i].formNode["E_DAY"], "change", function( e ) {
			e.target.form._TM_instance_.add_adjustDates( 3 );
		} );

		JLJS.addEvent( JLJS_AMDs[i].formNode["B_MONTH_SO_2"], "change", function( e ) {
			e.target.form._TM_instance_.add_adjustDates( 4 );
		} );
		JLJS.addEvent( JLJS_AMDs[i].formNode["B_DAY_SO_2"], "change", function( e ) {
			e.target.form._TM_instance_.add_adjustDates( 4 );
		} );
		
		JLJS.addEvent( JLJS_AMDs[0].formNode["E_AREA_1"], "change", function( e ) {
				e.target.form._TM_instance_.changeEArea(1);
		} );
		
		JLJS.addEvent( JLJS_AMDs[0].formNode["B_AREA_2"], "change", function( e ) {
				e.target.form._TM_instance_.changeEArea(2);
		} );

	}
	
	if(JLJS_AMDs[0].isZHCN){//Chinese_MultiCalendar_Set
		JLJS_AMDs[0].multiCalendarSetup();
	}else{
		JLJS_CALGP = new JLJS_Calendar_GeneralPurpose();

		JLJS.addEvent( document.getElementById( "TM_Calendar_1" ), "click", function() {
			JLJS_CALGP.click( "B_MONTH", "B_DAY", 1 );
		} );
	
		JLJS.addEvent( document.getElementById( "TM_Calendar_2" ), "click", function() {
			JLJS_CALGP.click( "B_MONTH_SO_1", "B_DAY_SO_1", 2 );
		} );
	
		JLJS.addEvent( document.getElementById( "TM_Calendar_3" ), "click", function() {
			JLJS_CALGP.click( "E_MONTH", "E_DAY", 3 );
		} );
	
		JLJS.addEvent( document.getElementById( "TM_Calendar_4" ), "click", function() {
			JLJS_CALGP.click( "B_MONTH_SO_2", "B_DAY_SO_2", 4 );
		} );
	}
}

// [MultiCalendarSetup(Chinese_site Used)]
JLJS_ticketModule_Fp.prototype.multiCalendarSetup = function(){
	var dateNodeList = [
		["B_MONTH", "B_DAY"],
		["B_MONTH_SO_1", "B_DAY_SO_1"],
		["E_MONTH", "E_DAY"],
		["B_MONTH_SO_2", "B_DAY_SO_2"]
	];
	
	var floatCalIcons = JLJS.getElementsByClassName("floatCalIcon", "a", this.formNode);
	for (var i=0;i<floatCalIcons.length;i++) {
		var floatCalIcon = floatCalIcons[i];
		floatCalIcon._TM_instance_ = this;
		floatCalIcon.num = i;
		
		if(JLJS_CalNav.used) {
			JLJS.addEvent(floatCalIcon, "click", function(e){
				var tm = e.currentTarget._TM_instance_;
				var num = e.currentTarget.num;
				var form = tm.formNode;
				var prm = {};
				prm["multi"] = {month: form[dateNodeList[num][0]], day: form[dateNodeList[num][1]]};
				JLJS_CalNav.OPT_AMD_TM.callBack = function(){tm.multiAdjustDatesSet(num)};
				JLJS_CalNav.calDisplay({target:e.currentTarget, option:JLJS_CalNav.OPT_AMD_TM, frm:prm});
			});
		}else{
			JLJS.classAttr.add(floatCalIcon, "hidden");
		}
	}
};

JLJS_ticketModule_Fp.prototype.multiAdjustDatesSet = function(num){
	if(num==0){
		this.add_adjustDates(1);
	}else if(num==1){
		this.add_adjustDates(2);
	}else if(num==2){
		this.add_adjustDates(3);
	}else if(num==3){
		this.add_adjustDates(4);
	}
};
// [/MultiCalendarSetup(Chinese_site Used)]

// [displaySo]
var openImg = new Image();
var closeImg = new Image();
openImg.src = "/world/common/img/icon_open_001.gif";
closeImg.src = "/world/common/img/icon_close_001.gif";
function JLJS_displaySo(num) {

	var imgElem = document.getElementById("soArea" + num + "_img");
	var imgText = document.getElementById("soArea" + num + "_text");

	var areaElem = document.getElementById("soArea" + num);
	var display = areaElem.style.display;
	var text = "";

	if(display == "none") {
		JLJS_AMDs[ 0 ].formNode[ "B_LOCATION_SO_" + num ].disabled = false;
		JLJS_AMDs[ 0 ].formNode[ "B_MONTH_SO_" + num ].disabled = false;
		JLJS_AMDs[ 0 ].formNode[ "B_DAY_SO_" + num ].disabled = false;
		areaElem.style.display = "";
		imgElem.src = closeImg.src;
		
		if(JLJS_AMDs[0].isZHCN){
			text = "\u53d6\u6d88\u4e2d\u9014\u505c\u7559";
		}else{
			if (JLJS02.site.lang.isEN){
				text = "Cancel";
			}else{
				text = "\u3092\u89e3\u9664\u3059\u308b";
			}
		}
		imgText.innerHTML = text;
		JLJS_AMDs[ 0 ].formNode[ "stopoverCheck_" + num ].value = 1;
	} else {
		areaElem.style.display = "none";
		imgElem.src = openImg.src;
		
		if(JLJS_AMDs[0].isZHCN){
			text = "\u9009\u62e9\u4e2d\u9014\u505c\u7559";
		}else{
			if (JLJS02.site.lang.isEN){
				text = "Make";
			}else{
				text = "\u3059\u308b";
			}
		}
		imgText.innerHTML = text;
		JLJS_AMDs[ 0 ].formNode[ "B_LOCATION_SO_" + num ].disabled = true;
		JLJS_AMDs[ 0 ].formNode[ "B_MONTH_SO_" + num ].disabled = true;
		JLJS_AMDs[ 0 ].formNode[ "B_DAY_SO_" + num ].disabled = true;
		JLJS_AMDs[ 0 ].formNode[ "stopoverCheck_" + num ].value = 0;
	}
}
// [/displaySo]

JLJS_ticketModule_Fp.prototype.add_adjustDates = function( calendarNumber, onload ) {
	var oi_interval = 5;
	var d = new Date();
	var f = JLJS_AMDs[ 0 ].formNode;
	var M_node =
		calendarNumber == 1 ? f.elements[ "B_MONTH" ] :

		calendarNumber == 2 ? f.elements[ "B_MONTH_SO_1" ] :
		calendarNumber == 4 ? f.elements[ "B_MONTH_SO_2" ] :

		calendarNumber == 3 ? f.elements[ "E_MONTH" ] : null;
	var D_node =
		calendarNumber == 1 ? f.elements[ "B_DAY" ] :

		calendarNumber == 2 ? f.elements[ "B_DAY_SO_1" ] :
		calendarNumber == 4 ? f.elements[ "B_DAY_SO_2" ] :

		calendarNumber == 3 ? f.elements[ "E_DAY" ] : null;

	var M = M_node.selectedIndex;
	var D = D_node.selectedIndex + 1;
	var Y = M < d.getMonth() ? d.getFullYear() + 1 : d.getFullYear();

	var d0 = new Date( Y, M, D );
	var T0 = d0.getTime();

	var M_origin =
		calendarNumber == 2 ? f.elements[ "B_MONTH" ].selectedIndex :
		calendarNumber == 4 ? f.elements[ "E_MONTH" ].selectedIndex : null;
	var D_origin =
		calendarNumber == 2 ? f.elements[ "B_DAY" ].selectedIndex + 1 :
		calendarNumber == 4 ? f.elements[ "E_DAY" ].selectedIndex + 1 : null;
	var Y_origin = M_origin < d.getMonth() ? d.getFullYear() + 1 : d.getFullYear();
	var d_origin = new Date( Y_origin, M_origin, D_origin );
	var T_origin = d_origin.getTime();

	var interval = ( T0 - T_origin ) / ( 24 * 60 * 60 * 1000 );
	if( calendarNumber == 1 ) {
		var d = new Date( Y, M, D + 2 );

		f.elements[ "B_MONTH_SO_1" ].selectedIndex = d.getMonth();
		f.elements[ "B_DAY_SO_1" ].selectedIndex = d.getDate() - 1;

	}
	if( calendarNumber <= 2 ) {
		var node = JLJS_AMDs[ 0 ].formNode[ "stopoverCheck_1" ];
		var n = node && calendarNumber == 1 && node.checked ? 2 : 0;
		var d1 = new Date( Y, M, D + n + oi_interval );
		f.elements[ "E_MONTH" ].selectedIndex = d1.getMonth();
		f.elements[ "E_DAY" ].selectedIndex = d1.getDate() - 1;

		var d2 = new Date( Y, M, D + n + oi_interval + 2 );
		f.elements[ "B_MONTH_SO_2" ].selectedIndex = d2.getMonth();
		f.elements[ "B_DAY_SO_2" ].selectedIndex = d2.getDate() - 1;

	}
	if( calendarNumber == 3 ) {

		var d = new Date( Y, M, D + 2 );
		f.elements[ "B_MONTH_SO_2" ].selectedIndex = d.getMonth();
		f.elements[ "B_DAY_SO_2" ].selectedIndex = d.getDate() - 1;

	}
};

JLJS_ticketModule_Fp.prototype.add_setDefaultValue = function( n, onload ) {
	var defaultDay_Outbound = 3;
	var defaultDay_Inbound = defaultDay_Outbound + 5;

	if( n == 1 ) {

		var sel1 = JLJS_AMDs[ 0 ].formNode[ "B_MONTH_SO_1" ];
		var sel2 = JLJS_AMDs[ 0 ].formNode[ "B_DAY_SO_1" ];
		var S = new JLJS_DateSelector( sel1, sel2 );
		S.adjustToToday();
		S.applyOffset( '+' + ( defaultDay_Outbound + 2 ) + 'd' );

		var sel1 = JLJS_AMDs[ 0 ].formNode[ "B_MONTH_SO_2" ];
		var sel2 = JLJS_AMDs[ 0 ].formNode[ "B_DAY_SO_2" ];
		var S = new JLJS_DateSelector( sel1, sel2 );
		S.adjustToToday();
		S.applyOffset( '+' + ( defaultDay_Inbound + 2 ) + 'd' );

		var elmNames = [
			"B_LOCATION_1", "B_MONTH", "B_DAY",
			"E_LOCATION_1", "E_MONTH", "E_DAY",
			"FIELD_ADT_NUMBER", "FIELD_CHD_NUMBER", "FIELD_INFANTS_NUMBER"
		];

		for( var i = 0; i < elmNames.length; i ++ ) {
			var cookieVal = JLJS02.getValueFromCookie( elmNames[ i ] + "0" );
			if( ! cookieVal ) continue;
			if( elmNames[ i ].match( /^(B|E)_MONTH$/ )) cookieVal = Number( cookieVal.substring( 4, 6 ));

			var node = JLJS_AMDs[ 0 ].formNode[ elmNames[ i ]];
			for( var j = 0; j < node.options.length; j ++ ) {
				if( node.options[ j ].value == cookieVal ) {
					node.selectedIndex = j;
					if( elmNames[ i ] == "B_DAY" ) JLJS_AMDs[ 0 ].add_adjustDates( 1, onload );
					if( elmNames[ i ] == "E_DAY" ) JLJS_AMDs[ 0 ].add_adjustDates( 3, onload );
					break;
				}
			}
		}
	}
	else if( n == 2 ) {

		var elmNames = [[ "B_LOCATION_1", "E_LOCATION_2" ], [ "E_LOCATION_1", "B_LOCATION_2" ]];

		for( var i = 0; i < elmNames.length; i ++ ) {
			var cookieVal = JLJS02.getValueFromCookie( elmNames[ i ][ 0 ] + "0" );
			if( ! cookieVal ) continue;

			var node = JLJS_AMDs[ 0 ].formNode[ elmNames[ i ][ 1 ]];
			for( var j = 0; j < node.options.length; j ++ ) {
				if( node.options[ j ].value == cookieVal ) {
					node.selectedIndex = j;
					break;
				}
			}
		}
	}
};

JLJS_ticketModule_Fp.prototype.setMultiPrm = function(){
	this.formNode.action = this.formAction;
	this.formNode["amadeusAction"].value = this.amadeusAction;
	this.formNode["EMBEDDED_TRANSACTION"].value = "AirComplexAvailability";
	this.formNode["SITE"].value = "CBCPCBCP";
	this.formNode["TRIP_FLOW"].value = "YES";
	this.formNode["DIRECT_LOGIN"].value = "NO";
	this.formNode["B_ANY_TIME_1"].value = "TRUE";
	this.formNode["B_ANY_TIME_2"].value = "TRUE";
	this.formNode["ARRANGE_BY"].value = "N";
	this.formNode["EXTERNAL_ID"].value = "JAL_SR_CN";
	this.formNode["SO_SITE_OFFICE_ID"].value = "SHAJL18AA";
	this.formNode["SO_GL"].value = '';	//"SO_GL" is made in a "imprtant notice" page.
	this.formNode["SO_SITE_MAIL_FROM"].value = "Japan Airlines Reservation <org.shatt.jal@jal.com>";
	this.formNode["SO_SITE_PNR_ADD_EMAIL1"].value = "Japan Airlines Reservation <shatt.web@jal.com>";
	this.formNode["SO_SITE_POINT_OF_SALE"].value = "SHA";
	this.formNode["SO_SITE_POINT_OF_TICKETING"].value = "SHA";
	this.formNode["SO_FAILURE_QUEUE_OFFICE_ID"].value = "SHAJL1200";
	this.formNode["SO_QUEUE_OFFICE_ID"].value = "SHAJL1200";
	this.formNode["SO_SITE_MIN_AVAIL_DATE_SPAN"].value = "H72";
	this.formNode["SO_SITE_MINIMAL_TIME"].value = "H72";
	this.formNode["SO_SITE_MINIMAL_TIME_MODIF"].value = "H72";
	this.formNode["SO_SITE_EXT_PSPTYPE"].value = "HTML";
	this.formNode["SO_SITE_PSP_FORM_METHOD"].value = "POST";
	this.formNode["SO_SITE_EXT_PSPURL"].value = this.pspUrlParam;
	this.formNode["SO_SITE_EXT_MerchantID"].value = this.merchantIDParam;

	if(this.isZHCN){
		this.formNode["LANGUAGE"].value = "CN";
	}else{
		if(!JLJS02.site.lang.isEN){
			this.formNode["LANGUAGE"].value = "JP";
		}
	}
		
	this.createAdditionalPrm();
}

//---------- [/multiModule] ----------

// [errorCheck]
// [private_submitCheck]
JLJS_ticketModule_Fp.prototype.private_submitCheck = function() {
	if (this.pageType == "T"){
		return this.topSubmitCheck();
	}else{
		return this.soSubmitCheck();
	}
};
// [/private_submitCheck]

// [topSubmitCheck]
JLJS_ticketModule_Fp.prototype.topSubmitCheck = function() {
	
	var msg = "";
	return msg;

};
// [/topSubmitCheck]

JLJS_ticketModule_Fp.prototype.submitCheck = function() {

	this.convertMonValue();
	this.getTripType();

	var errorMsg = "";

	if( this.formNode[ "E_LOCATION_1" ].options[ this.formNode[ "E_LOCATION_1" ].selectedIndex ].value == "" ){
		if(this.isZHCN){
			errorMsg += "- 请选择目的地\n";
		}else{
			if(!JLJS02.site.lang.isEN){
				errorMsg += "- \u76EE\u7684\u5730\u3092\u304A\u9078\u3073\u304F\u3060\u3055\u3044\u3002\n";
			}
		}		
	}else if( this.tripType == "M" && this.formNode[ "B_LOCATION_2" ].value == "" ){
		if(this.isZHCN){
			errorMsg += "- 请选择出发城市\n";
		}else{
			if(!JLJS02.site.lang.isEN){
				errorMsg += "- \u51FA\u767A\u5730\u3092\u304A\u9078\u3073\u304F\u3060\u3055\u3044\u3002\n";
			}
		}
	}	

	this.depYearMon = this.formNode[ "B_MONTH" ].options[ this.formNode[ "B_MONTH" ].selectedIndex ].value;
	this.depDay = this.formNode[ "B_DAY" ].options[ this.formNode[ "B_DAY" ].selectedIndex ].value;
	this.depDay = ( this.depDay.length < 2 ) ? ( "0" + this.depDay ) : this.depDay;
	this.depTime = "0000";
	this.formNode[ "B_DATE_1" ].value = this.depYearMon + this.depDay + this.depTime;

	this.depYear = this.depYearMon.substr( 0, 4 );
	this.depMon = this.depYearMon.substr( 4, 2 );

	var errorMsg_tmp = this.checkDate( this.depMon, this.depDay, this.depYear, 0 );
	if( errorMsg_tmp ) errorMsg += errorMsg_tmp;

	var today = new Date();
	var depDate = new Date();

	depDate.setFullYear( this.depYear, eval( this.depMon ) - 1, this.depDay );

//	if( this.tripType == "R" ) {
		this.rtnYearMon = this.formNode[ "E_MONTH" ].options[ this.formNode[ "E_MONTH" ].selectedIndex ].value;
		this.rtnDay = this.formNode[ "E_DAY" ].options[ this.formNode[ "E_DAY" ].selectedIndex ].value;
		this.rtnDay = ( this.rtnDay.length < 2 ) ? ( "0" + this.rtnDay ) : this.rtnDay;
		this.rtnTime = "0000";
		this.formNode[ "B_DATE_2" ].value = this.rtnYearMon + this.rtnDay + this.rtnTime;

		this.rtnYear = this.rtnYearMon.substr( 0, 4 );
		this.rtnMon = this.rtnYearMon.substr( 4, 2 );

		var errorMsg_tmp = this.checkDate( this.rtnMon, this.rtnDay, this.rtnYear, 1 );
		if( errorMsg_tmp ) errorMsg += errorMsg_tmp;
		var errorMsg_tmp = "";

		var rtnDate = new Date();
		rtnDate.setFullYear( this.rtnYear, eval( this.rtnMon ) - 1, this.rtnDay );
		
		if( depDate.getTime() > rtnDate.getTime()){
			if(this.isZHCN){
				errorMsg += "- 回程日期应于出发日期以后\n";
			}else{
				if(!JLJS02.site.lang.isEN){
					errorMsg += "- \u5E30\u56FD\u642D\u4E57\u65E5\u304C\u51FA\u767A\u65E5\u3088\u308A\u3082\u524D\u306B\u306A\u3063\u3066\u304A\u308A\u307E\u3059\u3002\n";
				}
			}
		}
	//}

	var days_beforeDep = Math.floor(( depDate.getTime() - today.getTime()) / ( 1000 * 60 * 60 * 24 ));
	var n = null;
	if (days_beforeDep < 0){
		n = 0;
	}		

	if( errorMsg_tmp ){ errorMsg += errorMsg_tmp; }
	
	var errorMsg_tmp = "";
	if( n == 0 ) {
		if(this.isZHCN){
			errorMsg_tmp = "- 出发日期应于今天以后\n";
		}else{
			if(!JLJS02.site.lang.isEN){
				errorMsg_tmp = "- \u51FA\u767A\u65E5\u304C\u672C\u65E5\u3088\u308A\u3082\u524D\u306B\u306A\u3063\u3066\u304A\u308A\u307E\u3059\u3002\n";
			}
		}
	}
	
	if( errorMsg_tmp ) errorMsg += errorMsg_tmp;

	this.ADT = eval( this.formNode[ "FIELD_ADT_NUMBER" ].value );
	this.CHD = eval( this.formNode[ "FIELD_CHD_NUMBER" ].value );
	this.INF = eval( this.formNode[ "FIELD_INFANTS_NUMBER" ].value );

	if ( this.ADT < this.INF ){
		if(this.isZHCN){
			errorMsg += "- " + this.ADT + " 名婴儿仅允许与 " + this.ADT + " 名成人同行\n";
		}else{
			if(!JLJS02.site.lang.isEN){
				errorMsg += "- 1\u4E73\u5150\u306B\u3064\u304D\u5927\u4EBA\u4E00\u540D\u69D8\u306E\u540C\u4F34\u304C\u5FC5\u8981\u3067\u3059\u3002\n";
			}
		}		
	}
	if( this.ADT + this.CHD > 9 ){
		if(this.isZHCN){
			errorMsg += "- 最多只允许9名乘客(包括婴儿及儿童)同时预订\n";
		}else{
			if(!JLJS02.site.lang.isEN){
				errorMsg += "- \u5927\u4EBA\uFF0B\u5B50\u4F9B\u306E\u5408\u8A08\u304C10\u540D\u69D8\u4EE5\u4E0A\u306E\u3054\u4E88\u7D04\u306F\u51FA\u6765\u307E\u305B\u3093\u3002\n";
			}
		}
	}

	errorMsg += this.private_submitCheck();

	if( ! errorMsg ) {
		this.setHiddenPrm();
		this.writeCookie();
		if( this.tripType == "M" && this.isJumpingToOJPage ) {
			document.location = this.OJ_URL;
			return false;
		}
		else {
			var wnd = window.open( "", "IBE_window", "resizable=yes,location=no,menubar=no,scrollbars=yes,status=yes,titlebar=yes,toolbar=no" );
			this.formNode.submit(); 
			this.reConvertMonValue();
			return true;
		}
	}
	else {
		alert( errorMsg );
		this.reConvertMonValue();
		return false;
	}
};

JLJS_ticketModule_Fp.prototype.checkDate = function( month, day, year, returning ) {

	var comp1 = ( month == "02" || month == "04" || month == "06" || month == "09" || month == "11" );
	var comp2 = ( day == "31" );
	var Y = eval( year );
	var leap_year = ( Y % 4 == 0 && Y % 100 != 0 ) || ( Y % 400 == 0 );

	if(
		( comp1 && comp2 ) ||
		( month == "02" && day == "30" ) ||
		( ! leap_year && month == "02" && day == "29" )
	) {
		if( ! returning ){
			if(this.isZHCN){
				return "- 出发日期出错\n";
			}else{
				if(!JLJS02.site.lang.isEN){
					return "- \u51FA\u767A\u65E5\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093\u3002\n";
				}
			}
		}else{
			if(this.isZHCN){
				return "- 回程日期出错\n";
			}else{
				if(!JLJS02.site.lang.isEN){
					return "- \u5E30\u56FD\u642D\u4E57\u65E5\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093\u3002\n";
				}
			}
		}
	}
	else return "";
};

// [soSubmitCheck]
JLJS_ticketModule_Fp.prototype.soSubmitCheck = function() {
	var node = this.formNode[ "stopoverCheck_1" ];
	var is_so1 = node.value == "1" ? true : false;
	node = this.formNode[ "B_LOCATION_1" ];
	var val_b1 = node ? node[ node.selectedIndex ].value : "";
	node = this.formNode[ "B_LOCATION_SO_1" ];
	var val_so1 = node ? node[ node.selectedIndex ].value : "";
	node = this.formNode[ "E_LOCATION_1" ];
	var val_e1 = node ? node[ node.selectedIndex ].value : "";

	node = this.formNode[ "stopoverCheck_2" ];
	var is_so2 = node.value == "1" ? true : false;
	node = this.formNode[ "B_LOCATION_2" ];
	var val_b2 = node ? node[ node.selectedIndex ].value : "";
	node = this.formNode[ "B_LOCATION_SO_2" ];
	var val_so2 = node ? node[ node.selectedIndex ].value : "";
	node = this.formNode[ "E_LOCATION_2" ];
	var val_e2 = node ? node[ node.selectedIndex ].value : "";
	
	var msg = "";
	
	var soDate;
	if ( is_so1 ) {
		msg += this.checkSoDate("1");
	}
	
	if ( is_so2 ) {
		msg += this.checkSoDate("2");
	}

	if ( ( is_so1 && ( val_b1 == val_so1 || val_so1 == val_e1 )) || ( is_so2 && ( val_b2 == val_so2 || val_so2 == val_e2 )) ) {
		if(this.isZHCN){
			msg += "- 请再度确认中途停留城市\n";
		}else{
			if(!JLJS02.site.lang.isEN){
				msg += "- \u518d\u5ea6\u30b9\u30c8\u30c3\u30d7\u30aa\u30fc\u30d0\u30fc\u3059\u308b\u90fd\u5e02\u3092\u3054\u78ba\u8a8d\u304f\u3060\u3055\u3044\u3002\n";
			}
		}
	}
	return msg;

};

JLJS_ticketModule_Fp.prototype.checkSoDate = function(num) {
	
	var yearMon = this.formNode[ "B_MONTH" ].options[ this.formNode[ "B_MONTH_SO_" + num].selectedIndex ].value;
	var depDay = this.formNode[ "B_DAY_SO_" + num ].value;
	if (depDay.length < 2) {
		depDay = "0" + depDay;
	}
	
	var isReturn;
	if (num == "1" ) {
		isReturn = false;
	}else{
		isReturn = true;
	}
	var msg = this.checkDate(yearMon.substr(4, 2), depDay, yearMon.substr(0, 4), isReturn);

	var soDate = new Date(yearMon.substr(0, 4), parseInt(yearMon.substr(4, 2), 10) - 1, depDay);
	
	var targetDate;
	if (num == "1" ) {
		targetDate = new Date(this.depYear, this.depMon - 1, this.depDay);
		if ( soDate < targetDate ){
			if(this.isZHCN){
				msg += "- 出发日期出错\n";
			}else{
				if(!JLJS02.site.lang.isEN){
					msg += "- \u51FA\u767A\u65E5\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093\u3002\n";
				}
			}
		}
	}else{
		targetDate = new Date(this.rtnYear, this.rtnMon - 1, this.rtnDay);
		if ( soDate < targetDate ){
			if(this.isZHCN){
				msg += "- 回程日期出错\n";
			}else{
				if(!JLJS02.site.lang.isEN){
					msg += "- \u5E30\u56FD\u642D\u4E57\u65E5\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093\u3002\n";
				}
			}
		}
	}
	
	return msg;
}
// [/soSubmitCheck]
// [/errorCheck]