function oAjax( url,callback)
{
try{
this.HttpRequest = null;
this.Debug= false;
this.Url = url;
this.ContentType = "text/xml";
this.HttpRequest = this.createXMLHttpRequest();

if ( this.HttpRequest == null )
{
this._debug("XMLHttpRequest create failure!");
return;
}

var xhReq = this.HttpRequest;
xhReq.onreadystatechange = function (){
oAjax._OnReadyStateChange( xhReq,callback );
}

} catch(e){
this._debug( "unknow err: " + e.message );
}
}

/*
 * Get URL resource
 */
oAjax.prototype.Get = function() {

this.SetContentType( "text/html" );
this._get();
}

/*
 * Post data to the server
 */
oAjax.prototype.Post = function( arrKey, arrValue ) {

var data = '';
this.SetContentType( "application/x-www-form-urlencoded" );
for( i = 0; i < arrKey.length; i ++)
{
data += "&" + escape(arrKey[i]) + "=" + escape(arrValue[i]);
//data += "&" + arrKey[i] + "=" + arrValue[i];
}
//document.write(data);
data = data.replace(/^&/g, "");
this._post(data);
}

/*
 * Initialization for oAjax class
 */
oAjax.prototype.Init = function() {
// initialization
}

/*
 * Change URL for request
 */
oAjax.prototype.SetUrl = function( url ) {
this.Url = url;
}

/*
 * Set content type for HTTP header before sending request
 */
oAjax.prototype.SetContentType = function( type ) {
this.ContentType = type;
}

oAjax.prototype.createXMLHttpRequest = function() {

try { return new ActiveXObject("Msxml2.XMLHTTP");} catch(e) {}
try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
try { return new XMLHttpRequest(); } catch(e) {}
return null;
}

/*
 * Debug information for testing
 */
oAjax.prototype._debug = function(message) {

if ( this.Debug )
{
alert(message);
}
}

/*
 * Process message and data from server
 */
oAjax._OnReadyStateChange = function( xreq, callback ){

if ( xreq == null )
{
return;}

/*Status is completed, then process result */
if ( xreq.readyState == 4)
{
// OK
if ( xreq.status == 200 )
{
//alert(xreq.responseText);
callback (xreq.responseText); 
}else{
//alert('服务器端错误！');
document.write (xreq.responseText);
}
} else {
// Others
}
}

oAjax.prototype._SendRequest = function(HttpMethod, data){

this._debug( 'Send Request ' + HttpMethod + data );

if ( this.HttpRequest != null )
{
this.HttpRequest.open(HttpMethod, this.Url, true);

if ( this.ContentType != null )
{
//<FORM> MIME type: application/x-www-form-urlencoded
this.HttpRequest.setRequestHeader("Content-Type", this.ContentType);
}
this.HttpRequest.send(data);
return true;
}
return false;
}

/* Send GET request to server */
oAjax.prototype._get = function () {

this._debug( 'GET' );
return this._SendRequest("GET", null);
}

/* Send POST request and data to server */
oAjax.prototype._post = function (data) {

this._debug( 'POST' );
return this._SendRequest("POST", data);
}

oAjax.ArrayValue = function ( xmlobj ) {
var array = new Array();
var i = 0;
var response = xmlobj.getElementsByTagName('Response')[0];
var element = response.firstChild;
array[i] = element.firstChild.nodeValue;
while ( element = element.nextSibling )
{
i ++;
array[i] = element.firstChild.nodeValue;
}
return array;
}

function GE(a)
{
return document.getElementById(a);
} 

function ls(str) {
var totallength=0;for (var i=0;i<str.length;i++)
{
var intCode=str.charCodeAt(i); if (intCode>=0&&intCode<=128) {
totallength=totallength+1; //非中文单个字符长度加 1
}
else {
totallength=totallength+2; //中文字符长度则加 2
}
} //end for
return totallength;
}

function acts()
{
var act=GE("actions");
var fom=GE("form1");
//alert(val)
if(fom.actions[0].checked)
{
if(confirm("您确定要删除？此操作无法恢复"))
{
fom.submit();
}
}
else
{
fom.submit();
}
}

function outlen(obj,obj1,str_ok,str_err,zd,zc)
{
var chk=true;
if (ls(obj1.value)<zd || ls(obj1.value)>zc){chk=false;}
if (chk){
obj.className="d_ok";
obj.innerHTML=ok+str_ok;
}
else
{
obj.className="d_err";
obj.innerHTML=err+str_err;
}
return chk;
}

function outnum(obj,obj1,str_ok,str_err)
{
var chk=true;
if (isNaN(obj1.value)){chk=false;}
if (chk){
obj.className="d_ok";
obj.innerHTML=ok+str_ok
}
else
{
obj.className="d_err";
obj.innerHTML=err+str_err;
}
return chk;
}
function outnum1(obj,obj1,str_ok,str_err)
{
var chk=true;
if (isNaN(obj1.value)||obj1.value==""){chk=false;}
if (chk){
obj.className="d_ok";
obj.innerHTML=ok+str_ok
}
else
{
obj.className="d_err";
obj.innerHTML=err+str_err;
}
return chk;
}
function outb(obj,obj1,str_ok,str_err)
{
var chk=true;
if (obj1.value==""){chk=false;}
if (chk){
obj.className="d_ok";
obj.innerHTML=ok+str_ok;
}
else
{
obj.className="d_err";
obj.innerHTML=err+str_err;
}
return chk;
}

function outc(obj,obj1,str_ok,str_err)
{
var chk=true;
if (obj1==""){chk=false;}
if (chk){
obj.className="d_ok";
obj.innerHTML=ok+str_ok;
}
else
{
obj.className="d_err";
obj.innerHTML=err+str_err;
}
return chk;
}


var ok="<img src=\"/images/admin/li_ok.gif\">";
var err="<img src=\"/images/admin/li_err.gif\">";
var lion="";
var loading="<img src=\"/images/admin/ajax-loader.gif\">Loading......";
