// バナー呼び出し共通化(2010.2/12.KANNO)
function banner_put(type, mode, id, val, cntLoad)
{
	tagStr = val["tagStr"];
	/* 【DBG】 */ //alert("banner_put:tagStr=[" + tagStr + "]");
	if (tagStr != null) {
		var obj = document.getElementById(type.toUpperCase() + 'BANNER');
		if (obj != null) {
			obj.innerHTML = tagStr;
		}
	}
	else if (cntLoad < 3) {
		cntLoad++;
		setTimeout("adBannerLoad('" + type + "', '" + mode + "', '" + id + "', 0, " + cntLoad + ")", 100);
	}
}

function adBannerLoad(type, mode, id, cntInit, cntLoad)
{
	/* 【DBG】 */ //alert("adBannerLoad:type=[" + type + "]");
	var obj = document.getElementById(type.toUpperCase() + 'BANNER');
	if (obj != null) {
		var readSessionId = 'read_' + type;
		var api = "http://www.13hw.com/banner/ad_dsp_json.php"
				+ "?kind=" + type
				+ "&mode=" + mode
				+ (('' != id)? ("&id=" + id) : "")
				+ "&cnt=" + cntLoad
				+ "&t=" + (new Date()).getTime();
		var head = document.getElementsByTagName('head').item(0);
		if (null != document.getElementById(readSessionId)) {
			head.removeChild(document.getElementById(readSessionId));
		}
		var s = document.createElement('script');
		s.setAttribute('type', 'text/javascript');
		s.setAttribute('src', api);
		s.setAttribute('id', readSessionId);
		s.setAttribute('charset', 'UTF-8');
		head.appendChild(s);

		if ('head' == type) {
			adBannerLoad('b01', '', '', 0, 0);
			adBannerLoad('foot', '', '', 0, 0);
		}
		else if ('b01' == type) {
			adBannerLoad('b02', '', '', 0, 0);
			adBannerLoad('b03', '', '', 0, 0);
		}
	}
	else if (cntInit < 100) {
		cntInit++;
		setTimeout("adBannerLoad('" + type + "', '" + mode + "', '" + id + "', " + cntInit + ", 0)", 100);
	}
}

