﻿
var initPrice = 0;
// var initPrice = 150000;
var AmountPrice ;

var i=0;
var j=0;
var m=0;
var n=0;
var x=0;


function chgPriceFunc(strObjName, strTdID, strHotelCd, intAirGoodsAmount, intHotelIndex, intHotelAmount, strDispId){
	i=0;
	j=0;
	m=0;
	n=0;
	x=1;
	var airSelect;
	var hotelSelect;
	var AirGoodsAmount = 0;
	var HotelAmount = 0;
	
	var strAirId = "";
	var strImgTdId = "";
	
	objAirLines = document.getElementsByName(strObjName);
	
	for( i = 0; i < objAirLines.length; i++ ){
		strAirId = 'air_price_' + strHotelCd + '_' + i;
		strCbxTdId = 'cbx_td_' + strHotelCd + '_' + i;
		strImgTdId = 'img_td_' + strHotelCd + '_' + i;
		
		if( document.getElementById(strAirId).checked == true ){
			if( document.getElementById(strCbxTdId).className != 'disabled' ){
				document.getElementById(strCbxTdId).className = 'act';
				document.getElementById(strImgTdId).className = 'act';
			}
			AirGoodsAmount = intAirGoodsAmount - 0;
			j = i;
		} else {
			if( document.getElementById(strCbxTdId).className != 'disabled' ){
				document.getElementById(strCbxTdId).className = '';
				document.getElementById(strImgTdId).className = '';
			}
		}
	}
	chgPrice = parseInt(initPrice) + parseInt(AirGoodsAmount) + parseInt(intHotelAmount);
	AmountPrice = comma(chgPrice);
	parentPriceDisp(strDispId);
}

	
function comma( n ) {
	var l, m = '';
	n = '' + n;
	while ( (l = n.length) > 3 ) {
		m = "," + n.substr( l - 3, 3 ) + m;
		n = n.substr( 0, l - 3 );
	}
	n = '' + n + m;
	return n;
}

function parentPriceDisp(strDispId){
	//document.getElementById(strDispId).innerText = '&yen;' + AmountPrice;
	//alert(strDispId);
	document.getElementById(strDispId).innerHTML = '<strong id="'+strDispId+'">&yen;'+AmountPrice+'～</strong>';
}

function setHidden(strHiddenName, HiddenValue, strPageHiddenName, PageHiddenValue) {
	document.getElementById(strHiddenName).value = HiddenValue;
	document.getElementById(strPageHiddenName).value = PageHiddenValue;
}

function check_hotel_detail(strFormName, strObjName){

	if(document.forms[strFormName].elements[strObjName].checked){
		document.forms[strFormName].elements[strObjName].checked = false;
	}
	else{
		document.forms[strFormName].elements[strObjName].checked = true;
	}
}

function sendPost(FormName,hdnName,PageNo){	
	var formN = document.forms[FormName];
	var hdnN  = hdnName
	formN[hdnN].value = PageNo;
	formN.action = "./dynamic_list.jsp";
	formN.submit();
}

//****************************************
// 指定箇所からN件表示する
// intaddValue 開始位置の移動範囲
// strColName  COLエレメントIDのヘッダー名
// intViewCount 画面に表示する件数
// intintMaxView   表示対象の最大件数
//****************************************

function slideAirLine(intaddValue, strColHeadName, intViewCount, intMaxView) {
	// 現在指定箇所のエレメント取得
	oElement = document.getElementById(strColHeadName);
	// COLエレメントの取得
	FElement = document.getElementById(strColHeadName + "F");
	MElement = document.getElementById(strColHeadName + "M");
	LElement = document.getElementById(strColHeadName + "L");
	// 現在指定箇所の取得
	var intViewFirst = 0;
	intViewFirst = parseInt(intaddValue) + parseInt(oElement.value);
	// 表示の初期化
	FElement.style.display = "none";
	MElement.style.display = "none";
	LElement.style.display = "none";

	if (intMaxView < 7) {
		intMaxView = 7;
	}

	if (intViewFirst <= 0) { // 先頭箇所の場合
		intViewFirst = 0;
		// 先頭から表示件数分を表示する
		FElement.span = intViewCount;
		FElement.style.display = "block";
		if ((intMaxView - intViewCount) <= 0 ) {
			MElement.span = 1;
		} else {
			MElement.span = intMaxView - intViewCount;
		}
		MElement.style.display = "none";
		LElement.span = 1;
		LElement.style.display = "none";
	} else { // 先頭箇所以外の場合
		// 最終表示が最大件数を超えた場合
		if (parseInt(intMaxView) - parseInt(intViewFirst) <= parseInt(intViewCount) + 1) {
			// 表示開始位置を修正する(表示件数分表示出来るようにする)
			intViewFirst = parseInt(intMaxView) - parseInt(intViewCount) - 1;
		}
		// 最終非表示位置を取得
		var LastValue = parseInt(intMaxView) - (parseInt(intViewFirst) + parseInt(intViewCount));
		// 最終非表示位置が０だった場合１を設定
		if (LastValue <= 0) {
			LastValue = 1;
		}

		if (intViewFirst < 0) {
			intViewFirst = 0;
			FElement.span = intViewCount;
			FElement.style.display = "block";
			if ((intMaxView - intViewCount) <= 0 ) {
				MElement.span = 1;
			} else {
				MElement.span = intMaxView - intViewCount;
			}
			MElement.style.display = "none";
			LElement.span = 1;
			LElement.style.display = "none";
		} else {
			if (intViewFirst == 0) {
				intViewFirst = 1;
			}
			FElement.span = intViewFirst;
			FElement.style.display = "none";
			MElement.span = intViewCount;
			MElement.style.display = "block";
			LElement.span = LastValue;
			LElement.style.display = "none";
		}

	}
	// 開始位置を保持する
	oElement.value = intViewFirst;
}
