// JavaScript Document
window.my_onready = null;

function get_xmlhttp()
{
	return GetXMLHttp();
}
function GetXMLHttp()
{
	var xmlhttp = false;

	if (window.XMLHttpRequest)
	{
		xmlhttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}

	return xmlhttp;
}

function set_ouput(xmlhttp, status1, status2, text) {
	if(status2 != false){
		var obj = document.getElementById(status2);
		if(obj!='undefined'&&obj!=null) obj.innerHTML=text;
	}
	if(status1 != false){
		var obj = document.getElementById(status1);
		if(obj!='undefined'&&obj!=null) obj.innerHTML=xmlhttp.responseText;
	}
}

function __dopost(xmlhttp, url, params, status1, status2, text, asyn)
{
	var as = asyn;
	if(as=='undefined'||as==null) as = true;
	Env(xmlhttp, 'POST', url, params, status1, status2, text, as);
}
function __doget(xmlhttp, url, params, status1, status2, text, asyn)
{
	var as = asyn;
	if(as=='undefined'||as==null) as = true;
	Env(xmlhttp, 'GET', url, params, status1, status2, text, as);
}
function Env(xmlhttp, method, url, params, status1, status2, text, asyn)
{
	$.ajax({
	  type: method,
	  url: url,
	  data: params,
	  async: asyn,
	  success: function(data, textStatus, xmlhttp){
		  set_ouput(xmlhttp, status1, status2, text);
		  if(window.my_onready) window.my_onready(data);
	  }
	});
}

