//---------------------------------------------
//	（共通）XMLHttpRequest オブジェクトを作成
//---------------------------------------------

function createXMLHttpRequest(callBackFunc){
	var xmlHttpObject = null;
	
	/* Firefox, Safari 用 */
	if (window.XMLHttpRequest) {
		xmlHttpObject = new XMLHttpRequest();
	
	/* IE 用 */
	} else if (window.ActiveXObject) {
		try {
			/* IE6 用 */
			xmlHttpObject = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				/* IE5 用 */
				xmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				return null;
			}
		}
	}
	if (xmlHttpObject) xmlHttpObject.onreadystatechange = callBackFunc;
	return xmlHttpObject;
}

//---------------------------------------------
//	広告アクションカウント用JS
//---------------------------------------------
//リクエスト送信
function countActionSend(AdId,ActionCd){
	wParam = "";
	httpObj = createXMLHttpRequest(countActionReceive);
	if (httpObj) {
		wParam = "ADID=" +  AdId;
		wParam += "&ACTION_CODE=" + ActionCd;

		httpObj.open("GET", "./ajax_banner_action_count.php?" + wParam, true);
		httpObj.send(null);
	}
}

//データ受信
function countActionReceive() {

	if(httpObj.readyState==4 && httpObj.status==200) {
		xmlData = httpObj.responseXML;
		var cnt = xmlData.getElementsByTagName("error").length;

		var msg = '';
		
		//エラーがある場合はアラート表示
		if (cnt!=0) {
			for(i=0; i<cnt; i++) {
				msg += xmlData.getElementsByTagName("error")[i].childNodes[0].nodeValue + "\n";
			}
			alert(msg);
		} else {
		}
	}
}
