//*****************************************************************
//Please save this file with a character code "iso-8859-1".
//*****************************************************************

// [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 = "JPN_USA_06";
	var defaultArea1 = "SGP";
	var defaultArea2 = "JPN_12";
	var defaultCity1 = "";
	var defaultCity2 = "TYO";
	var onLineOnly1 = 0;
	var onLineOnly2 = 0;
	var onLineSeparatingView_Off1 = 0;
	var onLineSeparatingView_Off2 = 1;
	var noAreaSelection1 = 1;
	var noAreaSelection2 = 1;
	var noGroup1 = 1;
	var noGroup2 = 1;
	var noDevide1 = 1;
	var noDevide2 = 0;
	var defaultDay_Outbound = 1;
	var defaultDay_Inbound = defaultDay_Outbound + 7;
	
	
	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" }
	] );
	
	for (var i=0;i<JLJS_AMDs.length;i++) {
		JLJS.addEvent( JLJS_AMDs[i].formNode["E_AREA"], "change", function( e ) {
				e.target.form._TM_instance_.changeTopEArea();
				e.target.form._TM_instance_.changeTopClass();
		} );
		JLJS.addEvent( JLJS_AMDs[i].formNode["E_LOCATION_1"], "change", function( e ) {
				e.target.form._TM_instance_.changeTopClass();
		} );
	}

	if (JLJS02.site.lang.isEN){
		JLJS_AMDCAL.lang = "en";
	}else{
		JLJS_AMDCAL.lang = "ja";
	}

	JLJS_AMDCAL.url = "/world/fp/common/html/ticketModuleCalendar.html";
	
	JLJS_AMDs[0].createTopClass();
}
//---------- [/topModule] ----------

// [changeTopEArea]
JLJS_ticketModule_Fp.prototype.changeTopEArea = function(){
	var areaNode= this.formNode["E_AREA"];
	var cityNode= this.formNode["E_LOCATION_1"];
	if (!areaNode.value){
		cityNode.disabled = true;
	}else{
		cityNode.disabled = false;
	}
}
// [/changeTopEArea]

// [setHiddenPrm]
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_SG";
	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 = "SINJL18AA";
	this.formNode["SO_GL"].value = '';	//"SO_GL" is made in a "imprtant notice" page.
	this.formNode["SO_SITE_DEFAULT_BILLING_COUN"].value = "SG";
	this.formNode["SO_SITE_MAIL_FROM"].value = "Japan Airlines Reservation <jalsin.webticket@jal.com>";
	this.formNode["SO_SITE_PNR_ADD_EMAIL1"].value = "Japan Airlines Reservation <jalsin.webticket@jal.com>";
	this.formNode["SO_SITE_POINT_OF_SALE"].value = "SIN";
	this.formNode["SO_SITE_POINT_OF_TICKETING"].value = "SIN";
	this.formNode["SO_FAILURE_QUEUE_OFFICE_ID"].value = "SINJL1200";
	this.formNode["SO_QUEUE_OFFICE_ID"].value = "SINJL1200";
	this.formNode["SO_SITE_MIN_AVAIL_DATE_SPAN"].value = "H24";
	this.formNode["SO_SITE_MINIMAL_TIME"].value = "H24";
	this.formNode["SO_SITE_MINIMAL_TIME_MODIF"].value = "H24";
	this.formNode["SO_SITE_EXT_PSPURL"].value = this.pspUrlParam;
	this.formNode["SO_SITE_EXT_MerchantID"].value = "JALSGPAYMENT";
	
	if (this.EN){
		this.formNode["LANGUAGE"].value = "GB";
	}else{
		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();
}
// [/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]

JLJS_ticketModule_Fp.prototype.topClassList = null;
// [getTopClassList]
JLJS_ticketModule_Fp.prototype.getTopClassList = function( prm ){
	if (prm == 1){
		if ( this.EN ) {
			this.topClassList = [["3SGECOF", "Economy Flex"], ["3SGBIZN", "Business"]];
		}else{
			this.topClassList = [["3SGECOF", "\u30a8\u30b3\u30ce\u30df\u30fc\u30d5\u30ec\u30c3\u30af\u30b9"], ["3SGBIZN", "\u30d3\u30b8\u30cd\u30b9"]];
		}
	}else{
		if (this.EN) {
			this.topClassList = [["3SGECOS", "Economy Lowest"], ["3SGECOF", "Economy Flex"], ["3SGBIZN", "Business"]];
		}else{
			this.topClassList = [["3SGECOS", "\u30a8\u30b3\u30ce\u30df\u30fc\uff08\u6700\u4f4e\u904b\u8cc3\uff09"], ["3SGECOF", "\u30a8\u30b3\u30ce\u30df\u30fc\u30d5\u30ec\u30c3\u30af\u30b9"], ["3SGBIZN", "\u30d3\u30b8\u30cd\u30b9"]];
		}
	}
}
// [/getTopClassList]

// [createTopClass]
JLJS_ticketModule_Fp.prototype.createTopClass = function(){
	var classNode = JLJS_AMDs[0].formNode["COMMERCIAL_FARE_FAMILY_1"];
	var classFlag = 0;
	this.getTopClassList(classFlag);	
	
	classNode.options.length = 0;
	this.setOption(this.topClassList, classNode);
}
// [/createTopClass]

// [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 = [ "LAX", "SFO", "CHI", "NYC", "HNL", "KOA", "YVR", "KUL" ];
	var classFlag = 0;
	
	if(eAreaNode.value == "USA_07" || eAreaNode.value == "CAN_03" || eAreaNode.value == "MYS_04"){
		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]

// [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]

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

	var defaultAreaSlctSet1 = "";
	var defaultAreaSlctSet2 = "JPN_USA_06";
	var defaultArea1 = "SGP";
	var defaultArea2 = "JPN_12";
	var defaultCity1 = "";
	var defaultCity2 = "TYO";
	var onLineOnly1 = 0;
	var onLineOnly2 = 0;
	var onLineSeparatingView_Off1 = 0;
	var onLineSeparatingView_Off2 = 1;
	var noAreaSelection1 = 1;
	var noAreaSelection2 = 0;
	var noGroup1 = 1;
	var noGroup2 = 1;
	var noDevide1 = 1;
	var noDevide2 = 0;
	var defaultDay_Outbound = 1;
	var defaultDay_Inbound = defaultDay_Outbound + 7;
	
	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.addEvent( JLJS_AMDs[0].formNode["E_AREA_1"], "change", function( e ) {
				e.target.form._TM_instance_.changeMultiArea("E");
		} );
		
		JLJS.addEvent( JLJS_AMDs[0].formNode["B_AREA_2"], "change", function( e ) {
				e.target.form._TM_instance_.changeMultiArea("B");
		} );

		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_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 );
	} );
}

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

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

// [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 (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 (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 = 1;
	var defaultDay_Inbound = defaultDay_Outbound + 7;

	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;
				}
			}
		}
	}
};

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

};
// [/topSubmitCheck]

// [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.EN) {
			msg += "- Please confirm the city of stopover again.\n";	
		}else{
			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;

};
// [/soSubmitCheck]

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.EN){
				msg += "- Departure date is not valid.\n"
			}else{
				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.EN){
				msg += "- Return date is not valid.\n"
			}else{
				msg += "- \u5E30\u56FD\u642D\u4E57\u65E5\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093\u3002\n"
			}
		}
	}
	
	return msg;
}

// [changeMultiArea]
JLJS_ticketModule_Fp.prototype.changeMultiArea = function(div){
	if (div == "E"){
		var areaNode= this.formNode["E_AREA_1"];
		var cityNode= this.formNode["E_LOCATION_1"];		
	}else if (div == "B") {
		var areaNode= this.formNode["B_AREA_2"];
		var cityNode= this.formNode["B_LOCATION_2"];			
	}

	if (!areaNode.value){
		cityNode.disabled = true;
	}else{
		cityNode.disabled = false;
	}
}
// [/changeMultiArea]

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["SEVEN_DAY_SEARCH"].value = "TRUE";
	this.formNode["EXTERNAL_ID"].value = "JAL_SR_SG";
	this.formNode["SO_SITE_OFFICE_ID"].value = "SINJL18AA";
	this.formNode["SO_GL"].value = '';	//"SO_GL" is made in a "imprtant notice" page.
	this.formNode["SO_SITE_DEFAULT_BILLING_COUN"].value = "SG";
	this.formNode["SO_SITE_MAIL_FROM"].value = "Japan Airlines Reservation <jalsin.webticket@jal.com>";
	this.formNode["SO_SITE_PNR_ADD_EMAIL1"].value = "Japan Airlines Reservation <jalsin.webticket@jal.com>";
	this.formNode["SO_SITE_POINT_OF_SALE"].value = "SIN";
	this.formNode["SO_SITE_POINT_OF_TICKETING"].value = "SIN";
	this.formNode["SO_FAILURE_QUEUE_OFFICE_ID"].value = "SINJL1200";
	this.formNode["SO_QUEUE_OFFICE_ID"].value = "SINJL1200";
	this.formNode["SO_SITE_MIN_AVAIL_DATE_SPAN"].value = "H24";
	this.formNode["SO_SITE_MINIMAL_TIME"].value = "H24";
	this.formNode["SO_SITE_MINIMAL_TIME_MODIF"].value = "H24";
	this.formNode["SO_SITE_EXT_PSPURL"].value = this.pspUrlParam;
	this.formNode["SO_SITE_EXT_MerchantID"].value = "JALSGPAYMENT";
	
	if (this.EN){
		this.formNode["LANGUAGE"].value = "GB";
	}else{
		this.formNode["LANGUAGE"].value = "JP";	
	}
	
	this.createAdditionalPrm();
	
	
	//OJ/SO parameters are made in a "imprtant notice" page.
}

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