var httpObj;					//HTTP通信用オブジェクト
var timerId;					//タイマーID
var timeout_sec = 10;		//タイムアウトの秒数

//HTTPリクエスト開始
function httpRequest(target_url, funcRef){
	try{
		if(window.XMLHttpRequest){
			httpObj = new XMLHttpRequest();
		}else if(window.ActiveXObject){
			httpObj = new ActiveXObject("Microsoft.XMLHTTP")
		}else{
			httpObj = false;
		}
	}catch(e){
		httpObj = false;
	}
	if(! httpObj){
		httpObjGenerateFail();
	}

	//タイムアウト用タイマーオブジェクト等の初期化
	clearInterval(timerId);
	timeout_sec = 10;
	timerId = setInterval('timeoutCheck()', 1000);

	with(httpObj){
		open("GET", target_url, true);
		setRequestHeader("Content-Type" , "application/x-www-form-urlencoded");
		onreadystatechange = function(){
			if(readyState == 4){
				clearInterval(timerId);
				timeout_sec = 10;
				if(status == 200){
					funcRef(responseText);
				}else{
					alert(status + ':' + statusText);
					return false;
				}
			}
		}
		send('');
	}
}

function timeoutCheck(){
	timeout_sec--;
	if(timeout_sec <= 0){
		clearInterval(timerId);
		httpObj.abort();
		timeout_sec = 10;
//		alert('タイムアウトです。');
		return false;
	}
}

function httpObjGenerateFail(){
	alert('ご利用のブラウザーでは、当サイトをご利用頂けません。');
	return false;
}

