/* 10000 true security checkuser slideshow remove_item */ var counter = 0; var Queuecount = 1; var ajax_processing = false; var theTimeout = new Array; var AjaxQueue = new Array; var FuncQueue = new Array; // Perform the AJAX call function ajax_performXML(thefunc, type, args){ var args1 = new Array(); for (var i = 0; i < args.length; i++){ args1[i] = args[i]; } func = args[args.length - 1]; if (self.func && func.substring(func.length - 5) == '_init'){ args1.pop() new ajax(thefunc, args1, type, func); } else { new ajax(thefunc, args1, type); } } get_security = function(){ ajax_performXML('security', 'get', arguments); } post_security = function(){ ajax_performXML('security', 'post', arguments); } get_checkuser = function(){ ajax_performXML('checkuser', 'get', arguments); } post_checkuser = function(){ ajax_performXML('checkuser', 'post', arguments); } get_slideshow = function(){ ajax_performXML('slideshow', 'get', arguments); } post_slideshow = function(){ ajax_performXML('slideshow', 'post', arguments); } get_remove_item = function(){ ajax_performXML('remove_item', 'get', arguments); } post_remove_item = function(){ ajax_performXML('remove_item', 'post', arguments); } function ajax(func, params, method, return_func){ ajax_processing = true; // Increment the counter counter++; ajax.counter = counter; ajax.obj = new Object(); ajax.createXMLobj = function(){ // Try every ActiveX object we can var xmlhttpobjects = new Array(); xmlhttpobjects[0] = 'Microsoft.XMLHTTP'; xmlhttpobjects[1] = 'Msxml2.XMLHTTP.5.0'; xmlhttpobjects[2] = 'Msxml2.XMLHTTP.4.0'; xmlhttpobjects[3] = 'Msxml2.XMLHTTP.3.0'; xmlhttpobjects[4] = 'Msxml2.XMLHTTP'; // Loop through and try them for (var i = 0; i < xmlhttpobjects.length; i++){ try { // Create object ajax.xmlobj = new ActiveXObject(xmlhttpobjects[i]); } catch (e){ // Nope :( ajax.xmlobj = false } if (ajax.xmlobj != false){ break; } } // Didn't work? if (!ajax.xmlobj && typeof(XMLHttpRequest) != "undefined"){ try { // Create object ajax.xmlobj = new XMLHttpRequest(); } catch (e){ // Can't be done :( ajax.xmlobj = false; } } // Last resort... iFrames else if (!ajax.xmlobj){ // Create a new object ajax.xmlobj = new Object(); // Replicate the open function ajax.xmlobj.open = function(){ // Create the iframe document.body.appendChild(document.createElement("")); } // Replicate the send function ajax.xmlobj.send = function(){ // Tell the iframe to go get the data ajax_GetByID("ajax_call_no_" + ajax.counter).src = ajax.url; // Set a timeout for the readystate thing setTimeout("SetState(" + ajax.counter + ")", 5); } ajax.xmlobj.proccessXMLchange = function(){ return false; } SetState = function(counter){ var element = document.getElementById("ajax_call_no_" + counter); if (element.readyState == 'complete'){ ajax.xmlobj.readyState = 4; ajax.xmlobj.status = 200; ajax.xmlobj.responseText = document.frames["ajax_call_no_" + counter].document.body.innerText; ajax.xmlobj.onreadystatechange(); element.parentNode.removeChild(element); } else { setTimeout("SetState(" + counter + ")", 5); } } } } ajax.performXML = function(){ ajax.callTimeout = setTimeout('ajax_timedout(\''+ counter +'\');', 10000); document.body.style.cursor = 'wait'; if (typeof(return_func) != "undefined" && return_func != ""){ ajax.xfunction = return_func; } var theparams = new Array(); var start = '?'; // Check params is set if (typeof(params) != "undefined"){ theparams['ajax_param'] = params; theparams = ajax_serialize(theparams); } // Check if $_GET is already in use if (location.href.indexOf('?') != -1){ var start = '&'; } ajax.url = location.href.replace(/#.*/, '') + start + theparams + '&ajax_function=' + escape(func); var obj = ajax.xmlobj; // Perform Ajax if (typeof(method) == "undefined" || method == 'GET'){ obj.open("GET", ajax.url, true); } else { obj.open("POST", location.href.replace(/#.*/, '')); } // Handle the results obj.onreadystatechange = function(){ // Everything alright? if (obj.readyState == 4){ // I don't know why, but JS sometimes moans that there's no body when loading if (typeof(document.body.style.cursor) != 'undefined'){ document.body.style.cursor = 'auto'; } if (typeof(obj) != 'undefined' && typeof(obj.status) != 'undefined' && obj.status == 200 && typeof(obj.responseText) != 'undefined'){ if (typeof(ajax.callTimeout) != 'undefined'){ clearTimeout(ajax.callTimeout); } var data = obj.responseText; if (data.substring(0, 5) == ' 1){ args[j] = arguments[i]; args_no[j] = 'args[' + j + ']'; j++; } } } else { args = FuncQueue[theCount]['args'] args_no = FuncQueue[theCount]['args_no'] } // Is it busy? if (ajax_processing){ // Store the details? if (typeof(theCount) == 'undefined' || theCount == false){ FuncQueue[Queuecount] = new Array(); // Store the arguments; FuncQueue[Queuecount]['args'] = args; FuncQueue[Queuecount]['args_no'] = args_no; // Store the arguments; FuncQueue[Queuecount]['func'] = func; setTimeout('ajax_queue(FuncQueue[' + Queuecount + '][\'func\'], ' + Queuecount + ')', 300); Queuecount++; } // Set a timeout (again?) else { setTimeout('ajax_queue(FuncQueue[' + theCount + '][\'func\'], ' + theCount + ')', 300); } } else { return eval(func + '(' + args_no.join(', ') + ');'); } } // To make up for Javascripts poor standardisation function ajax_isObject(param) { return (param && typeof(param) == "object") || ajax_isFunction(param); } function ajax_serialize(formdata, numeric_prefix, key){ var numeric_prefix = (typeof(numeric_prefix) == 'undefined') ? '' : numeric_prefix; var key = (typeof(key) == 'undefined') ? '' : key; var result = new Array(); // Loop through the form data for (var k in formdata){ // URLencode the key and add a numeric prefix var temp_key = ajax_utf8_string(!isNaN(parseFloat(k)) ? numeric_prefix + k : k); // Add the previous key if (key){ temp_key = key + '[' + temp_key + ']'; } // If it's an array, do it all again if (ajax_isArray(formdata[k])){ result.push(ajax_serialize(formdata[k], '', temp_key)); } else { result.push(temp_key + '=' + ajax_utf8_string(formdata[k])); } } return result.join('&'); } function ajax_isArray(param){ return ajax_isObject(param) && param.constructor == Array; } function ajax_isFunction(param){ return typeof(param) == "function"; } // Make life easy and browser compatible function ajax_GetByID(id){ if (document.getElementById){ return document.getElementById(id); } else if (document.all){ return document.all[id]; } else if (document.layers) { return document.layers[id]; } }