if (typeof document.getElementById('breadcrumbs').textContent != 'undefined') {
	breadcrumb = document.getElementById('breadcrumbs').textContent;
} else {
	breadcrumb = document.getElementById('breadcrumbs').innerText;
}
var name = breadcrumb.substr(breadcrumb.lastIndexOf('>') + 1).replace(/^[ \n]+|[ \n]+$/g, '');
paths = location.pathname.split('/');
var id = paths[2] + '/' + paths[3].replace('.jsp', '').replace('.html', '');;

histories = new Array;
cards = new Array;
cookies = document.cookie.split('; ');
for (var i = 0; i < cookies.length; i ++) {
	if(cookies[i].substr(0,13) == 'card_history='){
		cards = cookies[i].substr(13,cookies[i].length).split('>');
		break;
	}
}
cards.unshift(escape(id) + ',' + escape(location.pathname) + ',' + escape(name));
exists = new Array;
cookie_str = '';
for (var i = 0; i < cards.length; i ++) {
	card = cards[i].split(',');
	if(exists[card[0]] != 1){
		histories.push({
			'id'  : unescape(card[0]),
			'url' : unescape(card[1]),
			'name': unescape(card[2])
		});
		exists[card[0]] = 1;
		cookie_str += '>' + card;
		if(histories.length > 5){ //履歴の数
			break;
		}
	}
}
exp = new Date();
exp.setTime(exp.getTime() + (14 * 1000 * 60 * 60 * 24)); // 有効期限
document.cookie = 'card_history=' + cookie_str.substr(1) + '; path=/; expires=' + exp.toGMTString();

document.write('<h2><img src="/nyukai/common/title_check.gif" width="185" height="31" alt="最近チェックしたクレジットカード" /></h2><div class="checkCardBox01"><div class="bgB">');
if(histories.length - 1){
	for (var i = 1; i < histories.length; i ++) {
		document.write('<dl class="' + (i != 1 ? 'mgt8 ' : '') + 'clearfix"><dt><img src="/nyukai/common/ico/' + histories[i].id + '.gif" width="47" height="30" alt="" /></dt><dd class="fm01"><p class="iArrGrn01"><a href="' + histories[i].url + '">' + histories[i].name + '</a></p></dd></dl>');
	}
}
else{
	document.write('<p class="fm01">最近チェックしたカードはありません。</p>');
}
document.write('</div></div>');
