/* Simple AJAX Code-Kit (SACK) v1.6.1 */
/* www.twilightuniverse.com */
/* Software licenced under a modified X11 licence,
see documentation or authors website for more details */
this.resetData = function() {
this.queryStringSeparator = "?";
this.argumentSeparator = "&";
this.encodeURIString = true;
this.vars = new Object();
this.responseStatus = new Array(2);
this.resetFunctions = function() {
this.onLoading = function() { };
this.onLoaded = function() { };
this.onInteractive = function() { };
this.onCompletion = function() { };
this.onError = function() { };
this.onFail = function() { };
this.reset = function() {
this.createAJAX = function() {
this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
if (typeof XMLHttpRequest != "undefined") {
this.xmlhttp = new XMLHttpRequest();
this.setVar = function(name, value){
this.vars[name] = Array(value, false);
this.encVar = function(name, value, returnvars) {
if (true == returnvars) {
return Array(encodeURIComponent(name), encodeURIComponent(value));
this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
this.processURLString = function(string, encode) {
encoded = encodeURIComponent(this.argumentSeparator);
regexp = new RegExp(this.argumentSeparator + "|" + encoded);
varArray = string.split(regexp);
for (i = 0; i < varArray.length; i++){
urlVars = varArray[i].split("=");
this.encVar(urlVars[0], urlVars[1]);
this.setVar(urlVars[0], urlVars[1]);
this.createURLString = function(urlstring) {
if (this.encodeURIString && this.URLString.length) {
this.processURLString(this.URLString, true);
if (this.URLString.length) {
this.URLString += this.argumentSeparator + urlstring;
this.URLString = urlstring;
// prevents caching of URLString
this.setVar("rndval", new Date().getTime());
urlstringtemp = new Array();
if (false == this.vars[key][1] && true == this.encodeURIString) {
encoded = this.encVar(key, this.vars[key][0], true);
this.vars[encoded[0]] = Array(encoded[1], true);
urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
this.URLString += urlstringtemp.join(this.argumentSeparator);
this.runResponse = function() {
this.runAJAX = function(urlstring) {
this.createURLString(urlstring);
this.elementObj = document.getElementById(this.element);
if (this.method == "GET") {
totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
this.xmlhttp.open(this.method, totalurlstring, true);
this.xmlhttp.open(this.method, this.requestFile, true);
this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
this.xmlhttp.onreadystatechange = function() {
switch (self.xmlhttp.readyState) {
self.response = self.xmlhttp.responseText;
self.responseXML = self.xmlhttp.responseXML;
self.responseStatus[0] = self.xmlhttp.status;
self.responseStatus[1] = self.xmlhttp.statusText;
elemNodeName = self.elementObj.nodeName;
elemNodeName.toLowerCase();
if (elemNodeName == "input"
|| elemNodeName == "select"
|| elemNodeName == "option"
|| elemNodeName == "textarea") {
self.elementObj.value = self.response;
self.elementObj.innerHTML = self.response;
if (self.responseStatus[0] == "200") {
this.xmlhttp.send(this.URLString);