﻿/*************************************************************************************
KV AJAX Styles Class
This class is used for a client-side formating of AJAX elements
				
Written Tuesday, April 14, 2008
Questions? Contact Cornelius(cornz24@yahoo.com)
***********************************************************************************************/

function KVAJAX() { }

function eObjects() {
    this.superclass();
    this.processor;
    this.isWorking = false;
    this.isAsync = true;

    eObjects.prototype.createXmlHttpObject = function() {
        var o;
        if (window.xmlhttpRequest && !(window.ActiveXObject)) {
            try {
                o = new oRequest();
            } catch (e) { o = false; }
        } else if (window.ActiveXObject) {
            try {
                o = new ActiveXObject("Msxml2.xmlhttp");
            } catch (e) {
                try {
                    o = new ActiveXObject("Microsoft.xmlhttp");
                } catch (e) { o = false; }
            }
        }
        return o;
    };

    eObjects.prototype.SendXmlHttpRequest = function(obj, qstr, fnc) {
        eObjects.processor = fnc;
        if (!this.isWorking && obj) {
            obj.open("POST", qstr, this.isAsync);
            obj.onreadystatechange = function() {
                if (obj.readyState == 4) {
                    if (obj.responseText.indexOf('invalid') == -1) {
                        r = obj.responseText;
                        var p = fnc(obj.responseText);
                    }
                }
            }
            obj.send('');
        }
    };

    eObjects.prototype.SendXmlHttpRequestPost = function(obj, url, qstr, fnc) {
        eObjects.processor = fnc;
        if (!this.isWorking && obj) {
            obj.open("POST", url, this.isAsync);
            //obj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            //obj.setRequestHeader("Content-length", qstr.length);
            //obj.setRequestHeader("Connection", "close");
            obj.send(qstr);

            obj.onreadystatechange = function() {
                if (obj.readyState == 4) {
                    if (obj.responseText.indexOf('invalid') == -1) {
                        r = obj.responseText;
                        var p = fnc(obj.responseText);
                    }
                }
            }
            obj.send(qstr);
        }
    };

    eObjects.prototype.DestroyXmlHttpObject = function(obj) {
        if (obj != null)
            delete obj;
    };
}

eObjects.prototype = new KVAJAX();
eObjects.prototype.contructor = eObjects;
eObjects.prototype.superclass = KVAJAX;
eObjects = new eObjects();

KVAJAX = new KVAJAX();
