// JavaScript Document

var xmlhttp;
function createxmlhttprequest() {
    try
    {
        xmlhttp=new XMLHttpRequest();
    }catch (trymicrosoft)
    {
        try
        {
            xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
        }catch (othermicrosoft)
        {
            try
            {
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }catch (failed)
            {
                alert("Error initializing XMLHttpRequest!");
            }
        }
    }
}


function useajax(urlstr,data) {
   createxmlhttprequest();
   var url = urlstr;
   
   xmlhttp.open("POST", url, true);
   xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
   xmlhttp.setRequestHeader("Content-Length",data.length);
   xmlhttp.setRequestHeader("Connection", "close");
   xmlhttp.onreadystatechange = handlestatechange;
   xmlhttp.send(data);
}


function handlestatechange() {
    if(xmlhttp.readyState==4) {
        if(xmlhttp.status==200) {
            WhatNeedDo();
        }
    }
}

function $(id) {
	return document.getElementById(id);
}
function Trim(str) {
	return str.replace(/(^\s*　*)|(\s*　*$)/g, "");
}
function KeyCode(evt) {
	return window.event ? window.event.keyCode : evt.which;
}
function AjaxCls() {
	this.url = "";
	this.data = "";
	this.result = "";
	this.Complete = function() {};
	
	if(typeof AjaxCls._initialized == "undefined") {
		AjaxCls.prototype.CreateReq = function() {
			var req;
			try {
				req = new XMLHttpRequest();
			} catch (trymicrosoft) {
				try {
					req = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (othermicrosoft) {
					try {
						req = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (failed) {
						alert("Error initializing XMLHttpRequest!");
					}
				}
			}
			return req;
		};
		AjaxCls.prototype.SendReq = function() {
			var thiss = this;
			(this.reqobj).open("POST", this.url, true);
			(this.reqobj).setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			(this.reqobj).setRequestHeader("Content-Length", (this.data).length);
			(this.reqobj).setRequestHeader("Connection", "close");
			(this.reqobj).onreadystatechange = function() {
				if((thiss.reqobj).readyState==4 && (thiss.reqobj).status==200) {
					thiss.result = (thiss.reqobj).responseText;
					thiss.Complete();
				}
			};
			(this.reqobj).send(this.data);
		};
    }
	AjaxCls._initialized = true;
	
	this.reqobj = this.CreateReq();
}
