/*AutoCacheCompiler: /media/javascript/basic_functions.js */ //add event functionality function fw_addEvent( obj, type, fn ) { if (obj.addEventListener) { obj.addEventListener( type, fn, false ); EventCache.add(obj, type, fn); } else if (obj.attachEvent) { obj["e"+type+fn] = fn; obj[type+fn] = function() { obj["e"+type+fn]( window.event ); } obj.attachEvent( "on"+type, obj[type+fn] ); EventCache.add(obj, type, fn); } else { obj["on"+type] = obj["e"+type+fn]; } } //event cache functionality var EventCache = function(){ var listEvents = []; return { listEvents : listEvents, add : function(node, sEventName, fHandler){ listEvents.push(arguments); }, flush : function(){ var i, item; for(i = listEvents.length - 1; i >= 0; i = i - 1){ item = listEvents[i]; if(item[0].removeEventListener){ item[0].removeEventListener(item[1], item[2], item[3]); }; if(item[1].substring(0, 2) != "on"){ item[1] = "on" + item[1]; }; if(item[0].detachEvent){ item[0].detachEvent(item[1], item[2]); }; item[0][item[1]] = null; }; } }; }(); fw_addEvent(window,'unload',EventCache.flush); //selector functionality function $() { var elements = new Array(); for (var i = 0; i < arguments.length; i++) { var element = arguments[i]; if (typeof element == 'string') element = document.getElementById(element); if (arguments.length == 1) return element; elements.push(element); } return elements; } /** // Sample Usage: var obj1 = document.getElementById('element1'); var obj2 = document.getElementById('element2'); function alertElements() { var i; var elements = $('a','b','c',obj1,obj2,'d','e'); for ( i=0;i 0){ ajax_queue_state = 1; ajax_current_record = ajax_queue[ajax_queue.length-1]; ajax_queue.pop(); ajax_http = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); ; //xmlhttprequest obj if (log){ log("calling url " + ajax_current_record[0]); } ajax_http.onreadystatechange = ajax_callbackFromQueue; ajax_http.open("GET", ajax_current_record[0], true); ajax_http.send(true); if (log){ log("call made, awaiting callback"); } }else{ //log("no items in the poll queue"); } }else{ if (log){ log('Poll Queue says something else is already processing'); } } } function ajax_callbackFromQueue(){ //check and call if (typeof(ajax_http) == 'object'){ if (log){ log("got callback from queue, readystate = " + ajax_http.readyState); } if (ajax_http.readyState == 4){ ajax_queue_state = 0; ajax_response = ajax_http.responseText; log("calling " +ajax_current_record[1]); eval("" + ajax_current_record[1]); } } } setTimeout("ajax_pollQueue();",500); setTimeout("ajax_callbackFromQueue()",1000);