//confirmBox.js

//商品購入時、確認ボックスを表示する
function dispConfirmBox(articleId,episodeId,memberId){
	var end = location.href.indexOf(":",0);
	var p   = location.href.substring(0,end);
	var domain = location.hostname;
	domain = p+"://"+domain;
	$.ajax({
		type : "POST",
		url : domain+"/getConfirmHtml_ajax.php?cache=" + (new Date()).getTime(),
		data: {
				"ARTICLE_ID": articleId,
				"EPISODE_ID":episodeId,
				"MEMBER_ID":memberId
			},
		dataType : "json",
		success : function(value){

			//PHPで生成した確認画面（HTML）を画面に追加
			var div = $("<DIV>");
			div.html(value);
			$('body').append(div);

			//確認画面オブジェクトのID
			var id = "#dialog";

			//ブラックアウトする領域の指定
			$('#mask').css({'width':'100%','height':'100%'});
			$('#mask').css('position',  'fixed');

			//ブラックアウト効果の設定
			$('#mask').fadeIn(500);//表示スピード
			$('#mask').fadeTo(1,0.5);//透過率、透過スピード

			//確認画面のCSS定義
			$(id).css('position',  'fixed');
			$(id).css('top',  '50%');
			$(id).css('left', '50%');
			var h = $(id).height()/2*(-1) + 120
			var w = $(id).width()/2*(-1) + 250
			$(id).css('margin-left',  w+'px');
			$(id).css('margin-top', h+'px');

			//確認画面の表示&表示スピードの設定
			$(id).fadeIn(1000);
		},
		error:function(data){
			alert('通信に失敗しました');
			return false;
		}
	});
}
//確認ボックスを閉じる
function boxClose() {
	$('#mask').remove();
	$('#boxes').remove();
}

//SBPS連携時仮売上を立てて、ポストパラメータを生成する
function postSbps(mode,url){
	var end = location.href.indexOf(":",0);
	var p   = location.href.substring(0,end);
	var domain = location.hostname;
	var point_course_id = $("input:radio[@name='POINT_COURSE_ID']:checked").val();
	domain = p+"://"+domain;
	$.ajax({
		type : "POST",
		url : domain+"/SBPSconnect.php?cache=" + (new Date()).getTime(),
		data: {
				"POINT_COURSE_ID": point_course_id,
				"MODE":mode
			},
		dataType : "json",
		success : function(value){

			//フォームのIDを生成
			var id = "#buyForm";

			//PHPで生成したポストパラメータをフォームに追加
			$(id).append(value[1]);

			//文字コード変換してサブミット
			buff=document.charset;
			document.charset='shift_jis';
			submitBtn('buyForm',url);
			document.charset=buff;
		},
		error:function(data){
			alert('通信に失敗しました');
			return false;
		}
	});
}