function display_m3point(m3point,status,msgType) {
	var jpStatus = '<a href="http://mrkun.m3.com/pcl/membership_status.htm">レギュラー</a>';
	if( status == 'premium' ){
	  jpStatus = '<a href="http://mrkun.m3.com/pcl/membership_status.htm">プレミアム</a>';
	}
    var notification = '';
    var msg_prefix = '<span class="m3_c-red">';
	var msg_suffix = '</span><a href="http://mrkun.m3.com/pcl/membership_status.htm">レギュラー</a>会員にダウン';
	switch(msgType){
	  case '0':
	    notification = msg_prefix + '【本日まで】' + msg_suffix;
	    break;
	  case '1':
	    notification = msg_prefix + '【あと1日】' + msg_suffix;
	    break;
	  case '2':
	    notification = msg_prefix + '【あと2日】' + msg_suffix;
	    break;
	  case '3':
	    notification = msg_prefix + '【あと3日】' + msg_suffix;
	    break;
	}   
	jQuery("#header_points_info").html(m3point).format({format:'#,###', locale:'jp'});
	jQuery("#header_status_info").html(jpStatus);
	jQuery("#header_alert_info").html(notification);

	//backward compatibility
	var amazon = Math.floor(m3point * (500 / 105));
	jQuery("#header_amazon_info").html(amazon).format({format:'#,###', locale:'jp'});
}

function write_header_m3point(scd, cache) {
	var m3point = jQuery.cookie("m3point");
	var status = jQuery.cookie("status");
	var msgType = jQuery.cookie("msgType");
	if (m3point != null) {
		display_m3point(m3point, status, msgType);
		return;
	}
	jQuery.ajax({
		url : location.protocol + "//mrkun.m3.com/api/point/getM3Point.do",
		dataType : "jsonp",
		data : {
			scd : scd,
			cache: cache
		},
		success : function(json){
			display_m3point(json.m3point, json.status, json.msgType);
		}
	});
}
