﻿////////////////////////////////////////////////////////////////////////////////
//
//   Java Script Function
//
//
//
////////////////////////////////////////////////////////////////////////////////

// Ajax用基礎スクリプト
function getXMLHttpRequest(){
	var xmlhttp;
	try{
		// msxml3.dll がインストールされている場合（InternetExplorer6.0以降）
		xmlhttp = new ActiveXObject( "Msxml2.XMLHTTP" );
	}
	catch( e ){
		try{
			// msxml.dll がインストールされている場合（InternetExplorer5.5以前）
			xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP" );
		}
		catch( e ){
			xmlhttp = undefined;
		}
	}
	if( !xmlhttp ){
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

// アクティベート処理
function activate( url, id ){
	var request = getXMLHttpRequest();
	request.onreadystatechange = function(){
		if( request.readyState == 4 ){
			if( request.status != 200 ){
				window.status = "Ajax error status = " + request.status;
			}
		}
	};
	request.open( "POST", url, true );
	request.send( "" );
	setTimeout( "activate( '" + url + "', '" + id + "' )", 20 * 1000 );
}

// ページロード時の共通処理
window.onload = function accessLog(){
	// アクセスログ
	var request = getXMLHttpRequest();
	request.open( "POST", '/activate.cgi?referer=' + document.referrer, true );
	request.send( "" );

	// 10秒間隔でアクティベート
	setTimeout( "activate( '/activate.cgi', 'activate' )", 20 * 1000 );
}


// [ァ-ン] → [ぁ-ん], [ヽヾ] → [ゝゞ]
function katakanaToHiragana( str ){
	var newStr = new String;
	for( var i = 0; i < str.length; i++ ){
		var c = str.charCodeAt( i );
		if( ( c >= 12449 && c <= 12531 ) || c == 12541 || c == 12542 ){
			newStr += String.fromCharCode( c - 96 );
		}
		else{
			newStr += str.charAt( i );
		}
	}
	return newStr;
}

// 入力された文字を適切に補正する
function inputRevision( str ){
	str = specialCharacter( str );
	str = hankakuToZenkaku( str );
	return str;
}

// 入力された文字を適切に補正する
function inputRevisionEscape( str ){
	str = specialCharacter( str );
	str = urlEscape( str );
	return str;
}

// 一部文字を全角に置き換える
function urlEscape( str ){
	var newStr = "";
	var hankaku = "_@/!?&<>()";
	var zenkaku = "＿＠／！？＆＜＞（）";
	for( i = 0; i < str.length; i++ ){
		var chr = str.charAt( i );
		var pos = hankaku.indexOf( chr );
		if( pos == -1 ){
			newStr += chr;
		}
		else{
			newStr += zenkaku.charAt( pos );
		}
	}
	return newStr;
}

// 半角文字を全角文字に置き換える
function hankakuToZenkaku( str ){
	var newStr = "";
	var hankaku = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.@:/!?&<>() ";
	var zenkaku = "０１２３４５６７８９ａｂｃｄｅｆｇｈｉｊｋｌｍｎｏｐｑｒｓｔｕｖｗｘｙｚＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ－＿．＠：／！？＆＜＞（）　";
	for( i = 0; i < str.length; i++ ){
		var chr = str.charAt( i );
		var pos = hankaku.indexOf( chr );
		if( pos == -1 ){
			newStr += chr;
		}
		else{
			newStr += zenkaku.charAt( pos );
		}
	}
	return newStr;
}

// 全角文字を半角文字に置き換える
function zenkakuToHankaku( str ){
	var newStr = "";
	var zenkaku = "０１２３４５６７８９ａｂｃｄｅｆｇｈｉｊｋｌｍｎｏｐｑｒｓｔｕｖｗｘｙｚＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ－＿．＠　";
	var hankaku = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_.@ ";
	for( i = 0; i < str.length; i++ ){
		var chr = str.charAt( i );
		var pos = zenkaku.indexOf( chr );
		if( pos == -1 ){
			newStr += chr;
		}
		else{
			newStr += hankaku.charAt( pos );
		}
	}
	return newStr;
}

// 特殊文字を通常文字に置き換える
function specialCharacter( str ){
	str = str.replace( /-/g, "‐" );
	str = str.replace( /－/g, "‐" );
	str = str.replace( /㈱/g, "(株)" );
	str = str.replace( /㈲/g, "(有)" );
	str = str.replace( /㈹/g, "(代)" );
	str = str.replace( /℡/g, "TEL" );
	str = str.replace( /Ⅰ/g, "I" );
	str = str.replace( /Ⅱ/g, "II" );
	str = str.replace( /Ⅲ/g, "III" );
	str = str.replace( /Ⅳ/g, "IV" );
	str = str.replace( /Ⅴ/g, "V" );
	str = str.replace( /Ⅵ/g, "VI" );
	str = str.replace( /Ⅶ/g, "VII" );
	str = str.replace( /Ⅷ/g, "VIII" );
	str = str.replace( /Ⅸ/g, "IX" );
	str = str.replace( /Ⅹ/g, "X" );
	str = str.replace( /①/g, "(1)" );
	str = str.replace( /②/g, "(2)" );
	str = str.replace( /③/g, "(3)" );
	str = str.replace( /④/g, "(4)" );
	str = str.replace( /⑤/g, "(5)" );
	str = str.replace( /⑥/g, "(6)" );
	str = str.replace( /⑦/g, "(7)" );
	str = str.replace( /⑧/g, "(8)" );
	str = str.replace( /⑨/g, "(9)" );
	str = str.replace( /⑩/g, "(10)" );
	str = str.replace( /⑪/g, "(11)" );
	str = str.replace( /⑫/g, "(12)" );
	str = str.replace( /⑬/g, "(13)" );
	str = str.replace( /⑭/g, "(14)" );
	str = str.replace( /⑮/g, "(15)" );
	str = str.replace( /⑯/g, "(16)" );
	str = str.replace( /⑰/g, "(17)" );
	str = str.replace( /⑱/g, "(18)" );
	str = str.replace( /⑲/g, "(19)" );
	str = str.replace( /⑳/g, "(20)" );
	return str;
}

// 旧漢字を現代漢字に変換する
function oldCharacter( str ){
	str = str.replace( /﨑/g, "崎" );
	str = str.replace( /髙/g, "高" );
	str = str.replace( /賴/g, "頼" );
	str = str.replace( /瀨/g, "瀬" );
	str = str.replace( /黑/g, "黒" );
	str = str.replace( /鄕/g, "郷" );
	str = str.replace( /濵/g, "浜" );
	str = str.replace( /德/g, "徳" );
	str = str.replace( /羽/g, "羽" );
	str = str.replace( /桒/g, "桑" );
	str = str.replace( /栁/g, "柳" );
	str = str.replace( /增/g, "増" );
	str = str.replace( /隆/g, "隆" );
	str = str.replace( /綠/g, "緑" );
	str = str.replace( /釋/g, "釈" );
	return str;
}

// 数字以外の文字を排除する
function numberFilter( str ){
	str = zenkakuToHankaku( str );
	str = str.replace( /[^0-9]/g, "" );
	return str;
}

// 数値を桁区切り(***,***,***)に補正する関数
function numberSeparate( val ){
	var ret = "", i, pos;
	val = val.toString();
	for( i = 0; i < val.length; i++ ){
		ret = ret + val.charAt( i );
		pos = val.length - i;
		if( ( pos == 4 || pos == 7 ) && val.charAt( i ) != "-" ){
			ret = ret + ",";
		}
	}
	return ret;
}

// order03-customerData.html
function deliverySelect(){
	var totalProductPriceBuffer, shipmentFeeBuffer, receiptFeeBuffer, receiptFeeValue, feeFreeLimit;

	totalProductPriceBuffer = document.getElementById( 'totalProductPrice' ).innerHTML;
	totalProductPriceBuffer = totalProductPriceBuffer.replace( /[^0-9]/g, "" );
	shipmentFeeBuffer       = document.getElementById( 'shipmentFee' ).innerHTML;
	shipmentFeeBuffer       = shipmentFeeBuffer.replace( /[^0-9]/g, "" );
	shipmentFeeBuffer       = ( shipmentFeeBuffer != "" ? shipmentFeeBuffer : 0 );
	receiptFeeBuffer        = 0;
	receiptFeeValue         = document.getElementById( 'receiptFeeValue' ).innerHTML;
	receiptFeeValue         = receiptFeeValue.replace( /[^0-9]/g, "" );
	feeFreeLimit            = document.getElementById( 'feeFreeLimit' ).innerHTML;
	feeFreeLimit            = feeFreeLimit.replace( /[^0-9]/g, "" );

	if( document.customerData.customerData_radio_delivelyAddress[ 0 ].checked ){
		document.getElementById( 'secondAddress' ).style.visibility='hidden';
		document.getElementById( 'receiptData' ).style.visibility='visible';
		document.getElementById( 'customerDelivery' ).innerHTML = "お買い上げ商品<br>" + "お買い上げ明細書<br>" + "領収書<br>";
		document.getElementById( 'deliveryDelivery' ).innerHTML = "<br><br><br>";
		document.getElementById( 'receiptFee' ).style.display = "none";
		document.getElementById( 'receiptFeeCount' ).innerHTML = "0";
	}
	else if( document.customerData.customerData_radio_delivelyAddress[ 1 ].checked ){
		document.getElementById( 'secondAddress' ).style.visibility='visible';
		document.getElementById( 'receiptData' ).style.visibility='visible';
		document.getElementById( 'customerDelivery' ).innerHTML = "<br><br><br>";
		document.getElementById( 'deliveryDelivery' ).innerHTML = "お買い上げ商品<br>" + "お買い上げ明細書<br>" + "領収書<br>";
		document.getElementById( 'receiptFee' ).style.display = "none";
		document.getElementById( 'receiptFeeCount' ).innerHTML = "0";
	}
	else if( document.customerData.customerData_radio_delivelyAddress[ 2 ].checked ){
		document.getElementById( 'secondAddress' ).style.visibility='visible';
		document.getElementById( 'receiptData' ).style.visibility='hidden';
		document.getElementById( 'customerDelivery' ).innerHTML = "<br><br><br>";
		document.getElementById( 'deliveryDelivery' ).innerHTML = "お買い上げ商品<br><br><br>";
		document.getElementById( 'receiptFee' ).style.display = "none";
		document.getElementById( 'receiptFeeCount' ).innerHTML = "0";
	}
	else if( document.customerData.customerData_radio_delivelyAddress[ 3 ].checked ){
		document.getElementById( 'secondAddress' ).style.visibility='visible';
		document.getElementById( 'receiptData' ).style.visibility='visible';
		document.getElementById( 'customerDelivery' ).innerHTML = "お買い上げ明細書<br>" + "領収書<br><br>";
		document.getElementById( 'deliveryDelivery' ).innerHTML = "お買い上げ商品<br><br><br>";
		document.getElementById( 'receiptFee' ).style.display = "";
		if( totalProductPriceBuffer < feeFreeLimit ){
			receiptFeeBuffer = receiptFeeValue;
			document.getElementById( 'receiptFeeMessage' ).innerHTML = "<span style=\"width:100px\">領収書別送料</span><span style=\"color:#ff0000\">&yen;" + numberSeparate( feeFreeLimit ) + "以上お買い上げいただくと別送料が無料になります。</span>";
			document.getElementById( 'receiptFeeCount' ).innerHTML = "1";
			document.getElementById( 'receiptFeeSum' ).innerHTML   = "&yen;" + receiptFeeValue;
		}
		else{
			receiptFeeBuffer = 0;
			document.getElementById( 'receiptFeeMessage' ).innerHTML = "<span style=\"width:100px\">領収書別送料</span><span style=\"color:#009900\">&yen;" + numberSeparate( feeFreeLimit ) + "以上お買い上げいただきましたので別送料が無料になります。</span>";
			document.getElementById( 'receiptFeeCount' ).innerHTML = "0";
			document.getElementById( 'receiptFeeSum' ).innerHTML   = "無料";
		}
	}
	document.getElementById( 'totalPrice' ).innerHTML = "&yen;" + numberSeparate( parseInt( totalProductPriceBuffer ) + parseInt( shipmentFeeBuffer ) + parseInt( receiptFeeBuffer ) );
	document.getElementById( 'totalCount' ).innerHTML = parseInt( document.getElementById( 'totalProductCount' ).innerHTML ) + parseInt( document.getElementById( 'shipmentFeeCount' ).innerHTML ) + parseInt( document.getElementById( 'receiptFeeCount' ).innerHTML );
}

function inputCheckCustomerData(){
	var mailAddressArray = document.customerData.customerData_text_customerEmailAddress.value.split( "@" );
	if( document.customerData.customerData_text_customerName.value == "" ){
		alert( "お名前が入力されていません。" );
		document.customerData.customerData_text_customerName.focus();
	}
	else if( document.customerData.customerData_text_customerNameRead.value == "" ){
		alert( "お名前（ふりがな）が入力されていません。" );
		document.customerData.customerData_text_customerNameRead.focus();
	}
	else if( document.customerData.customerData_text_customerTelephoneNumber.value == "" ){
		alert( "電話番号が入力されていません。" );
		document.customerData.customerData_text_customerTelephoneNumber.focus();
	}
	else if( document.customerData.customerData_text_customerPostalCode.value == "" ){
		alert( "郵便番号が入力されていません。" );
		document.customerData.customerData_text_customerPostalCode.focus();
	}
	else if( document.customerData.customerData_select_customerAddress1.value == "" ){
		alert( "都道府県が選択されていません。" );
		document.customerData.customerData_select_customerAddress1.focus();
	}
	else if( document.customerData.customerData_text_customerAddress2.value == "" ){
		alert( "ご住所が入力されていません。" );
		document.customerData.customerData_text_customerAddress2.focus();
	}
	else if( document.customerData.customerData_text_customerEmailAddress.value == "" ){
		alert( "メールアドレスが入力されていません。" );
		document.customerData.customerData_text_customerEmailAddress.focus();
	}
	else if( mailAddressArray.length < 2 ){
		alert( "メールアドレスに「＠」がありません。" );
		document.customerData.customerData_text_customerEmailAddress.focus();
	}
	else if( mailAddressArray.length > 2 ){
		alert( "メールアドレスに「＠」が複数あります。" );
		document.customerData.customerData_text_customerEmailAddress.focus();
	}
	else if( mailAddressArray[ 0 ].length < 1 ){
		alert( "メールアドレスのアカウント(＠の前)が指定されていません。" );
		document.customerData.customerData_text_customerEmailAddress.focus();
	}
	else if( mailAddressArray[ 1 ].length < 1 ){
		alert( "メールアドレスのドメイン名(＠の後)が指定されていません。" );
		document.customerData.customerData_text_customerEmailAddress.focus();
	}
	else if( !document.customerData.customerData_text_customerEmailAddress.value.match( /[\w\-\~\.]+@[\w\-\~]+\.[\w\-\~\.]+/ ) ){
		alert( "メールアドレスをご確認下さい。" );
		document.customerData.customerData_text_customerEmailAddress.focus();
	}
	else if( document.customerData.customerData_text_customerEmailAddress.value != document.customerData.customerData_text_customerEmailAddress1.value + "@" + document.customerData.customerData_text_customerEmailAddress2.value ){
		alert( "メールアドレスが確認用メールアドレスと一致しません。" );
		document.customerData.customerData_text_customerEmailAddress.focus();
	}
	else if( !document.customerData.customerData_radio_delivelyAddress[ 0 ].checked && document.customerData.customerData_text_deliveryName.value == "" ){
		alert( "お名前が入力されていません。" );
		document.customerData.customerData_text_deliveryName.focus();
	}
	else if( !document.customerData.customerData_radio_delivelyAddress[ 0 ].checked && document.customerData.customerData_text_deliveryNameRead.value == "" ){
		alert( "お名前（ふりがな）が入力されていません。" );
		document.customerData.customerData_text_deliveryNameRead.focus();
	}
	else if( !document.customerData.customerData_radio_delivelyAddress[ 0 ].checked && document.customerData.customerData_text_deliveryTelephoneNumber.value == "" ){
		alert( "電話番号が入力されていません。" );
		document.customerData.customerData_text_deliveryTelephoneNumber.focus();
	}
	else if( !document.customerData.customerData_radio_delivelyAddress[ 0 ].checked && document.customerData.customerData_text_deliveryPostalCode.value == "" ){
		alert( "郵便番号が入力されていません。" );
		document.customerData.customerData_text_deliveryPostalCode.focus();
	}
	else if( !document.customerData.customerData_radio_delivelyAddress[ 0 ].checked && document.customerData.customerData_select_deliveryAddress1.value == "" ){
		alert( "都道府県が選択されていません。" );
		document.customerData.customerData_select_deliveryAddress1.focus();
	}
	else if( !document.customerData.customerData_radio_delivelyAddress[ 0 ].checked && document.customerData.customerData_text_deliveryAddress2.value == "" ){
		alert( "ご住所が入力されていません。" );
		document.customerData.customerData_text_deliveryAddress2.focus();
	}
	else{
		document.customerData.submit();
	}
}

function postalCodeSearch( postalCode, address1, address2, label ){
	if( postalCode.value == "" ){
		alert( "郵便番号が指定されていません。" );
		postalCode.focus();
	}
	else if( postalCode.value.length != 7 ){
		alert( "郵便番号は7桁で指定してください。" );
		postalCode.focus();
	}
	else{
		label.innerHTML = "検索中．．．";
		var request = getXMLHttpRequest();
		request.onreadystatechange = function(){
			if( request.readyState == 4 ){
				if( request.status == 200 ){
					if( request.responseText != "" ){
						var results = request.responseText.split( "&" );
						for( i = 0; i < results.length; i++ ){
							recode = results[ i ].split( "=" );
							if( recode[ 0 ] == "prefecture" ){
								address1.value = recode[ 1 ];
							}
							else if( recode[ 0 ] == "city" ){
								address2.value = recode[ 1 ];
							}
						}
						label.innerHTML = "郵便番号から住所を検索";
					}
					else{
						label.innerHTML = "郵便番号不明";
					}
				}
				else{
					window.status = "AJAX Error：status = " + request.status;
				}
			}
		};
		request.open( "POST", "./shoppingCart.cgi?command=postalCodeSearch&postalCode=" + postalCode.value, true );
		request.send( "" );
	}
}

function addressSearch( postalCode, address1, address2, label ){
	if( address1.value == "" ){
		alert( "都道府県が指定されていません。" );
		address1.focus();
	}
	else if( address2.value.length == "" ){
		alert( "住所が指定されていません。" );
		address2.focus();
	}
	else{
		label.innerHTML = "検索中．．．";
		var request = getXMLHttpRequest();
		request.onreadystatechange = function(){
			if( request.readyState == 4 ){
				if( request.status == 200 ){
					if( request.responseText != "" ){
						var results = request.responseText.split( "&" );
						for( i = 0; i < results.length; i++ ){
							recode = results[ i ].split( "=" );
							if( recode[ 0 ] == "postalCode" ){
								postalCode.value = recode[ 1 ];
							}
						}
						label.innerHTML = "住所から郵便番号を検索";
					}
					else{
						label.innerHTML = "郵便番号不明";
					}
				}
				else{
					window.status = "AJAX Error：status = " + request.status;
				}
			}
		};
		request.open( "POST", "./shoppingCart.cgi?command=addressSearch&address=" + address1.value + address2.value, true );
		request.send( "" );
	}
}

// order05-paymentDetail.html
function paymentSelect(){
	var totalProductPriceBuffer, shipmentFeeBuffer, receiptFeeBuffer, collectFeeBuffer, collectFeeValue, feeFreeLimit;

	totalProductPriceBuffer = document.getElementById( 'totalProductPrice' ).innerHTML;
	totalProductPriceBuffer = totalProductPriceBuffer.replace( /[^0-9]/g, "" );
	shipmentFeeBuffer       = document.getElementById( 'shipmentFee' ).innerHTML;
	shipmentFeeBuffer       = shipmentFeeBuffer.replace( /[^0-9]/g, "" );
	shipmentFeeBuffer       = ( shipmentFeeBuffer != "" ? shipmentFeeBuffer : 0 );
	receiptFeeBuffer        = document.getElementById( 'receiptFeeSum' ).innerHTML;
	receiptFeeBuffer        = receiptFeeBuffer.replace( /[^0-9]/g, "" );
	receiptFeeBuffer        = ( receiptFeeBuffer != "" ? receiptFeeBuffer : 0 );
	collectFeeBuffer        = 0;
	collectFeeValue         = document.getElementById( 'collectFeeValue' ).innerHTML;
	collectFeeValue         = collectFeeValue.replace( /[^0-9]/g, "" );
	feeFreeLimit            = document.getElementById( 'feeFreeLimit' ).innerHTML;
	feeFreeLimit            = feeFreeLimit.replace( /[^0-9]/g, "" );

	if( document.paymentDetail.paymentDetail_radio_paymentMethod[ 0 ].checked ){
		document.getElementById( 'collectFee' ).style.display = "";
		if( totalProductPriceBuffer < feeFreeLimit ){
			collectFeeBuffer = collectFeeValue;
			document.getElementById( 'collectFeeMessage' ).innerHTML = "<span style=\"width:100px\">代金引換手数料</span><span style=\"color:#ff0000\">&yen;" + numberSeparate( feeFreeLimit ) + "以上お買い上げいただくと手数料が無料になります。</span>";
			document.getElementById( 'collectFeeCount' ).innerHTML = "1";
			document.getElementById( 'collectFeeSum' ).innerHTML   = "&yen;" + collectFeeValue;
		}
		else{
			document.getElementById( 'collectFeeMessage' ).innerHTML = "<span style=\"width:100px\">代金引換手数料</span><span style=\"color:#009900\">&yen;" + numberSeparate( feeFreeLimit ) + "以上お買い上げいただきましたので手数料が無料になります。</span>";
			document.getElementById( 'collectFeeCount' ).innerHTML = "0";
			document.getElementById( 'collectFeeSum' ).innerHTML   = "無料";
		}
	}
	else{
		document.getElementById( 'collectFee' ).style.display = "none";
		document.getElementById( 'collectFeeCount' ).innerHTML = "0";
		document.getElementById( 'collectFeeSum' ).innerHTML   = "無料";
	}

	document.getElementById( 'totalPrice' ).innerHTML = "&yen;" + numberSeparate( parseInt( totalProductPriceBuffer ) + parseInt( shipmentFeeBuffer ) + parseInt( receiptFeeBuffer ) + parseInt( collectFeeBuffer ) );
	document.getElementById( 'totalCount' ).innerHTML = parseInt( document.getElementById( 'totalProductCount' ).innerHTML ) + parseInt( document.getElementById( 'shipmentFeeCount' ).innerHTML ) + parseInt( document.getElementById( 'receiptFeeCount' ).innerHTML ) + parseInt( document.getElementById( 'collectFeeCount' ).innerHTML );

	document.getElementById( 'id_paymentDetailComment1' ).style.backgroundColor = ( document.paymentDetail.paymentDetail_radio_paymentMethod[ 0 ].checked ? "#FFCC66" : "#ffffff" );
	document.getElementById( 'id_paymentDetailComment2' ).style.backgroundColor = ( document.paymentDetail.paymentDetail_radio_paymentMethod[ 1 ].checked ? "#FFCC66" : "#ffffff" );
	document.getElementById( 'id_paymentDetailComment3' ).style.backgroundColor = ( document.paymentDetail.paymentDetail_radio_paymentMethod[ 2 ].checked ? "#FFCC66" : "#ffffff" );
	document.getElementById( 'id_paymentDetailComment4' ).style.backgroundColor = ( document.paymentDetail.paymentDetail_radio_paymentMethod[ 3 ].checked ? "#FFCC66" : "#ffffff" );
	document.getElementById( 'id_paymentDetailComment5' ).style.backgroundColor = ( document.paymentDetail.paymentDetail_radio_paymentMethod[ 4 ].checked ? "#FFCC66" : "#ffffff" );
	document.getElementById( 'id_paymentDetailComment6' ).style.backgroundColor = ( document.paymentDetail.paymentDetail_radio_paymentMethod[ 5 ].checked ? "#FFCC66" : "#ffffff" );
}

function inputCheckPaymentDetail(){
	var flag = 0;
	for( i = 0; i < document.paymentDetail.paymentDetail_radio_paymentMethod.length; i++ ){
		if( document.paymentDetail.paymentDetail_radio_paymentMethod[ i ].checked ){
			flag = 1;
			break;
		}
	}
	if( flag == 0 ){
		alert( "お支払い方法をご選択下さい。" );
	}
	else{
		document.paymentDetail.submit();
	}
}

// 指定月カレンダー表示
function calendar( year, month, day, cellspacing, monthMove ){
	var targetDate, uruu, mon, max, monthMax, backgroundColor, workingDay, currentDay;

	mon = Array( 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec' );
	targetDate = new Date( mon[ month - 1 ] + ' 01, ' + year + ' 00:00:00' );

	uruu = ( ( year % 4 == 0 && year % 100 != 0 ) || year % 400 == 0 ) ? 1 : 0;
	monthMax = Array( 31, 28 + uruu, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
	max = monthMax[ month - 1 ] + targetDate.getDay() - 1;

	html  = "<table class=\"takumiCalendarTable\" cellspacing=\"" + cellspacing + "\">";
	html += "<tr class=\"takumiCalendarHeader1\"><td colspan=\"7\">";
	html += "<table style=\"width:90%;margin:0px auto\"><tr>";
	html += "<td style=\"width:20%\">" + ( monthMove == -1 ? "<a href=\"javascript:void( 0 )\" onclick=\"document.getElementById( 'toMonthCalendar' ).style.display = 'block';document.getElementById( 'nextMonthCalendar' ).style.display = 'none'\" class=\"monthMoveArrow\">&lt;</a>" : "" ) + "</td>";
	html += "<td style=\"width:60%\">" + year + "年" + month + "月</td>";
	html += "<td style=\"width:20%\">" + ( monthMove == 1 ? "<a href=\"javascript:void( 0 )\" onclick=\"document.getElementById( 'toMonthCalendar' ).style.display = 'none';document.getElementById( 'nextMonthCalendar' ).style.display = 'block'\" class=\"monthMoveArrow\">&gt;</a>" : "" ) + "</td>";
	html += "</tr></table>";
	html += "</td></tr>";
	html += "<tr class=\"takumiCalendarHeader2\">";
	html += "<td class=\"takumiCalendarHeaderCell\" id=\"takumiCalendarSunday\">日</td>";
	html += "<td class=\"takumiCalendarHeaderCell\" id=\"takumiCalendarMonday\">月</td>";
	html += "<td class=\"takumiCalendarHeaderCell\" id=\"takumiCalendarTuesday\">火</td>";
	html += "<td class=\"takumiCalendarHeaderCell\" id=\"takumiCalendarWednesday\">水</td>";
	html += "<td class=\"takumiCalendarHeaderCell\" id=\"takumiCalendarThursday\">木</td>";
	html += "<td class=\"takumiCalendarHeaderCell\" id=\"takumiCalendarFriday\">金</td>";
	html += "<td class=\"takumiCalendarHeaderCell\" id=\"takumiCalendarSaturday\">土</td>";
	html += "</tr>";

	for( i = 0; i < max + ( 7 - ( max % 7 ) ); i++ ){
		currentDay = ( i > targetDate.getDay() - 1 && i <= max ) ? ( i - ( targetDate.getDay() - 1 ) ) : "";
		var className;
		// 枠色の指定
		if( currentDay == "" ){
			className = "takumiCalendarNotDateCell"	// 日にち以外
		}
		else if( currentDay == day ){
			className = "takumiCalendarTodayCell"	// 当日
		}
		else{
			className = "takumiCalendarDateCell"	// 当日以外
		}

		if( i % 7 == 0 ){ html += "<tr class=\"takumiCalendarCell\">"; }
		html += "<td class=\"" + className + "\" id=\"" + ( currentDay != "" ? year + ( month < 10 ? "0" : "" ) + month + ( currentDay < 10 ? "0" : "" ) + currentDay : "" ) + "\">" + currentDay + "<br></td>";
		if( i % 7 == 6 ){ html += "</tr>"; }
	}
	html += "</table>";

	return( html );
}

// 単月表示カレンダー
function singleMonthCalendar( year, month, day ){
	var nextMonth, nextMonthYear, workingDay, toDay;

	toDay = year + ( month < 10 ? "0" : "" ) + month + ( day < 10 ? "0" : "" ) + day;

	nextMonth     = ( month == 12 ? 1 : parseInt( month ) + 1 );
	nextMonthYear = ( month == 12 ? parseInt( year ) + 1 : year );

	document.write( "<div id=\"toMonthCalendar\" style=\"display:block\">" + calendar( year, month, day, 1, 1 ) + "</div>" );
	document.write( "<div id=\"nextMonthCalendar\" style=\"display:none\">" + calendar( nextMonthYear, nextMonth, 0, 1, -1 ) + "</div>" );

	var request = getXMLHttpRequest();

	request.onreadystatechange = function(){
		if( request.readyState == 4 ){
			workingDay = ( request.status == 200 ? request.responseText : "Error status = " + request.status ).split( "," );
			for( i = 0; i < workingDay.length; i++ ){
				if( workingDay[ i ] == toDay ){
					document.getElementById( workingDay[ i ] ).className = "takumiCalendarTodayWorkDayCell";
				}
				else{
					document.getElementById( workingDay[ i ] ).className = "takumiCalendarDateWorkDayCell";
				}
			}
		}
	};
	request.open( "POST", "/getWorkingDay.cgi?targetMonth=" + year + ( month < 10 ? "0" : "" ) + month + "-" + nextMonthYear + ( nextMonth < 10 ? "0" : "" ) + nextMonth, true );
	request.send( "" );
}

// 当月・翌月カレンダー表示
function toMonthNextMonthCalendar( mode, topMargin ){
	var now, year, month, day, nextMonth, nextMonthYear, html, workingDay, toDay, i;
	now = new Date();

	year  = now.getFullYear();
	month = now.getMonth() + 1;
	day   = now.getDate();

	toDay = year + ( month < 10 ? "0" : "" ) + month + ( day < 10 ? "0" : "" ) + day;

	nextMonth     = ( month == 12 ? 1 : parseInt( month ) + 1 );
	nextMonthYear = ( month == 12 ? parseInt( year ) + 1 : year );

	html  = "<table style=\"margin-top:" + topMargin + "px\"><tr style=\"vertical-align:top\"><td>";
	html += calendar( year, month, day, 1, 0 );
	html += ( mode == 0 ? "</td><td>" : "<br>" );
	html += calendar( nextMonthYear, nextMonth, 0, 1, 0 );
	html += "</td></tr></table>";

	document.write( html );

	var request = getXMLHttpRequest();

	request.onreadystatechange = function(){
		if( request.readyState == 4 ){
			workingDay = ( request.status == 200 ? request.responseText : "Error status = " + request.status ).split( "," );
			for( i = 0; i < workingDay.length; i++ ){
				if( workingDay[ i ] == toDay ){
					document.getElementById( workingDay[ i ] ).className = "takumiCalendarTodayWorkDayCell";
				}
				else{
					document.getElementById( workingDay[ i ] ).className = "takumiCalendarDateWorkDayCell";
				}
			}
		}
	};
	request.open( "POST", "/getWorkingDay.cgi?targetMonth=" + year + ( month < 10 ? "0" : "" ) + month + "-" + nextMonthYear + ( nextMonth < 10 ? "0" : "" ) + nextMonth, true );
	request.send( "" );
}

/*
 * ヘルプ検索
 * 例) あたり[<a href="javascript:void(0)" onclick="search_word('あたり')">?</a>]
 */
function search_word(word) {
  word = encodeURI(word);
  var w = window.open('http://www.inkan-takumi.com/help/search.php?w=' + word, '', 'width=720,height=600,scrollbars=yes');
}


