﻿var _General;
var _Private;
var xmllinks='../amf/8b3c45f8-9c79-484c-bfdc-e8570f49add3.aspx'
function ajax() {
    this.xmlHttp = null;
    this.xmllinks = new String('../amf/8b3c45f8-9c79-484c-bfdc-e8570f49add3.aspx');
    this.FunLoad = new Object();
    this.FunCall = new Object();

}

ajax.prototype.Execute = function(url, post, parameters) {
    this.xmlHttp = this.GetXmlHttpObject();
    _General = this;
    if (this.xmlHttp == null) {
        sitemessage("عذراً المتصفح الذي تستخدمه غير مدعم من خلال الموقع يرجى استخدام احدى المتصفحات التالية:\n");
        return;
    }

    url = this.nocache_url(url)

    this.xmlHttp.onreadystatechange = this.CallBackGeneral;

    if (!post) {

        this.xmlHttp.open("GET", url, true);
        this.xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
        this.xmlHttp.send(null);

    }

    else {

        this.xmlHttp.open('POST', url, true);
        this.xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        this.xmlHttp.setRequestHeader("Content-length", parameters.length);
        this.xmlHttp.setRequestHeader("Connection", "close");
        this.xmlHttp.send(parameters);


    }


}

ajax.prototype.ExecuteMore = function(url, post, parameters) {
    this.xmlHttp = this.GetXmlHttpObject();
    _Private = this;
    if (this.xmlHttp == null) {
        sitemessage("عذراً المتصفح الذي تستخدمه غير مدعم من خلال الموقع يرجى استخدام احدى المتصفحات التالية:\n");
        return;
    }

    url = this.nocache_url(url)

    this.xmlHttp.onreadystatechange = this.CallBackPrivate;

    if (!post) {

        this.xmlHttp.open("GET", url, true);
        this.xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
        this.xmlHttp.send(null);

    }

    else {

        this.xmlHttp.open('POST', url, true);
        this.xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        this.xmlHttp.setRequestHeader("Content-length", parameters.length);
        this.xmlHttp.setRequestHeader("Connection", "close");
        this.xmlHttp.send(parameters);


    }


}

ajax.prototype.GetXmlHttpObject = function() {

this.objXMLHttp = null
if (window.XMLHttpRequest) {
    this.objXMLHttp = new XMLHttpRequest()
}
else if (window.ActiveXObject) {
    this.objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP")
}
return this.objXMLHttp
}




ajax.prototype.CallBackGeneral = function() {


if (_General.readystate() == 1 || _General.readystate() == 3 || _General.readystate() == 2) {
    if (_General.FunLoad !=null)
    _General.FunLoad();
    }

    else {


        if (_General.readystate() == 4 || _General.readystate() == "complete") {

            if (_General.Status() == 200)
                {_General.FunLoad =null;
                if (_General.FunCall !=null)
                _General.FunCall();
                }
            else
                alert(_General.Text())
        }



    }
}


ajax.prototype.CallBackPrivate = function() {


if (_Private.readystate() == 1 || _Private.readystate() == 3 || _Private.readystate() == 2) {
    if (_Private.FunLoad !=null)
    _Private.FunLoad();
    }

    else {


        if (_Private.readystate() == 4 || _Private.readystate() == "complete") {

            if (_Private.Status() == 200)
                {
                if (_Private.FunCall !=null)
                _Private.FunCall();
                }
            else
                alert(_Private.Text())
        }



    }
}


ajax.prototype.readystate=function () {
return this.xmlHttp.readyState;
}

ajax.prototype.Status=function () {
    return this.xmlHttp.status;
}



ajax.prototype.XML=function () {

    return this.xmlHttp.responseXML;

}


ajax.prototype.Text=function () {

    return this.xmlHttp.responseText;

}


ajax.prototype.nocache_url=function (url) {
    this.sep = (-1 < url.indexOf("?")) ? "&" : "?";
    this.mydate = new Date();
    this.newurl = url + this.sep + "__=" + this.mydate.getTime();
    return this.newurl;
}
	
