function xmlhttp(){
	var obj;
	try {
		obj = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			obj = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {
			obj = false;
		}
	}
	if (!obj && typeof XMLHttpRequest!='undefined') {
		obj = new XMLHttpRequest();
	}
	return obj;
}


function ajax(url,data,callback,method,cl,async){
	if(method == null) method = 'POST';
	if(async == null) async = true;
	if(callback == null) callback = function(){};

	//XMLHttpRequestオブジェクト生成
	var oj = (cl) ? GXmlHttp.create() : xmlhttp();
	if( oj == null ) return null;
	
	if(method.toUpperCase() == 'GET')url += "?";
	
	oj.onreadystatechange = function(){
		if(oj.readyState == 4){
			callback(oj);
		}
	}
	data = uriEncode(data)
	if(method.toUpperCase() == 'GET') {
		url += data
	}
	
	oj.open(method,url,async);

	setEncHeader(oj)

	oj.send(data);

	function setEncHeader(oj){
		var contentTypeUrlenc = 'application/x-www-form-urlencoded;';
		if(!window.opera){
			oj.setRequestHeader('Content-Type',contentTypeUrlenc);
		} else {
			if((typeof oj.setRequestHeader) == 'function')
				oj.setRequestHeader('Content-Type',contentTypeUrlenc);
		}	
		return oj
	}

	function uriEncode(data){
		if(data!=""){
			var encdata = new Array();
			var datas = data.split('&');
			for(i=0;i<datas.length;i++)
			{
				var dataq = datas[i].split('=');
				encdata.push(encodeURIComponent(dataq[0])+'='+encodeURIComponent(dataq[1]));
			}
		} else {
			var encdata = new Array();
		}
		return encdata.join('&');
	}
	return oj;
}

function ajaxRaw(url,data,callback,method,cl,async){
	if(method == null) method = 'POST';
	if(async == null) async = true;
	if(callback == null) callback = function(){};

	//XMLHttpRequestオブジェクト生成
	var oj = (cl) ? GXmlHttp.create() : xmlhttp();
	if( oj == null ) return null;
	
	if(method.toUpperCase() == 'GET')url += "?";
	
	oj.onreadystatechange = function(){
		if(oj.readyState == 4){
			callback(oj);
		}
	}
	if(method.toUpperCase() == 'GET') {
		url += data
	}
	
	oj.open(method,url,async);

	setEncHeader(oj)

	oj.send(data);

	function setEncHeader(oj){
		var contentTypeUrlenc = 'application/x-www-form-urlencoded;';
		if(!window.opera){
			oj.setRequestHeader('Content-Type',contentTypeUrlenc);
		} else {
			if((typeof oj.setRequestHeader) == 'function')
				oj.setRequestHeader('Content-Type',contentTypeUrlenc);
		}	
		return oj
	}

	return oj;
}

function e(obj){ return document.getElementById(obj)};
