/**
 * A modified version of Stefan Hayden's onJSReady Prototype plugin. 
 * http://www.stefanhayden.com/blog/2008/07/29/javascript-event-onjsready-fires-when-all-js-files-have-loaded/
 *
 * @author John-David Dalton <john.david.dalton[at]gmail[dot]com>
 * @usage
 *   Prototype.include(['test1.js','test2.js','test3.js']); // array OR
 *   Prototype.include('test1.js', 'test2.js', 'test3.js'); // separate arguments OR
 *   Prototype.include('test1.js,test2.js,test3.js');       // comma separated string OR 
 *
 *   document.observe('scripts:loaded', function(){ dependent_on_external_js() });
 * @edit Clinton LaForest <clinton_laforest[at]wgte[dot]org>
 * @edit_notes
 *	 Altered include -> includeJS and added includeCSS for the seperate file types.
 *   Will revert to include when I find a good method to discover the Content Type without loading the file twice.
 */
Array.prototype.exists = function(search){
  for (var i=0; i<this.length; i++)
    if (this[i] == search) return true;
	  return false;
}

Prototype.includeJS = Object.extend(
  function() {
    var callee = arguments.callee,
     head = document.getElementsByTagName('HEAD')[0],
     args = Array.prototype.slice.call(arguments, 0);

    args._each(function(files) {
      if (Object.isString(files))
        files = files.split(',');
		
      callee.total += files.length;
      files._each(function(file) {
        head.appendChild(
          new Element('script', { type: 'text/javascript', src: file.strip() })
        )
        .observe('readystatechange', function () {
          if (!this.loaded && /^(loaded|complete)$/.test(this.readyState)) {
            this.loaded = true;
            callee.downloaded++;
          }
        })
        .observe('load', function () {
          if (this.loaded) return;
          this.loaded = true;
          callee.downloaded++;
        }); // end observers
      }); // end files _each 
    }); // end args _each
  }, 
  {
    total: 0,
    downloaded: 0
  }
);

(function() {
  var JStimer;
  function JSready() {
    if (arguments.callee.done) return;
    clearInterval(JStimer);
    arguments.callee.done = true;
    document.fire('scripts:loaded');
  }
  
  JStimer = setInterval(function() {
    var i = Prototype.includeJS;
    if (i.total && i.downloaded === i.total) JSready();
  }, 10);
})();


Prototype.includeCSS = Object.extend(
  function() {
    var callcss = arguments.callee,
     head = document.getElementsByTagName('HEAD')[0],
     args = Array.prototype.slice.call(arguments, 0);
	 
    args._each(function(files) {
      if (Object.isString(files))
        files = files.split(',');
      callcss.total += files.length;
      files._each(function(file) {
        head.appendChild(
          new Element('link', { type: 'text/css', rel: 'stylesheet', href: file.strip() })
        )
        .observe('readystatechange', function () {
          if (!this.loaded && /^(loaded|complete)$/.test(this.readyState)) {
            this.loaded = true;
            callcss.downloaded++;
          }
        })
        .observe('load', function () {
          if (this.loaded) return;
          this.loaded = true;
          callcss.downloaded++;
        }); // end observers
      }); // end files _each 
    }); // end args _each
  }, 
  {
    total: 0,
    downloaded: 0
  }
);

(function() {
  var CSStimer;
  function CSSready() {
    if (arguments.callee.done) return null;
    clearInterval(CSStimer);
    arguments.callee.done = true;
    document.fire('styles:loaded');
  }
  
  CSStimer = setInterval(function() {
    var j = Prototype.includeCSS;
    if (j.total && j.downloaded === j.total) CSSready();
  }, 10);
})();

/**
 * browser_detect
 */
 
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

/**
 * create_guid - genuinely unique identification number
 */
var create_guid = function(){

	var temp_name = '';
	var random_switch = 0;
	
	for( var x=1; x<=4; x++ )
	{
		
		for( var y=1; y<=4; y++ )
		{
			do
			{		
				random_switch = Math.round(Math.random()*10);
			}
			while (random_switch >= 10 || random_switch <= 0)
			temp_name = temp_name + random_switch;
		}
		temp_name = temp_name+'_';
		
	}
	temp_name = temp_name.substr(0, temp_name.length-1);
	
	return(temp_name);
	
}

// EXTENSIONS
/*
 * A culmination of functions commonly used
 */
var Extensions = {
	init: function(){
		this.open = '';
	},
	log: function(e){
		if (window.console)
			console.log(e);
	},
	error: function(e){
		Extensions.log(e);
        if (!window.errorCt) {
            window.errorCt = 0;
        }
        window.errorCt++;
		if (arguments[1]) {
			custom_message = arguments[1];
		} else {
			custom_message = '';
		}
		new Ajax.Request('/modules/includes/reportError.php', {
			method: 'post',
			parameters: {
				'userid': (window.LeafBase)?(LeafBase.user.UserId)?LeafBase.user.userid:(LeafBase.userid)?LeafBase.userid:(window.UserId)?window.UserId:'No User Reported':(window.UserId)?window.UserId:'No User Reported',
				'msg': e.name + ': ' + e.message+'\n'+custom_message,
				'url': (e.fileName)?e.fileName:'Errored in IE: No file name given. (' + location.href + ')',
				'l': (e.lineNumber)?e.lineNumber:(e.stack)?e.stack.split(':')[1]:'No Line Number Available'
			}
		});
        return true;
	},
	silenterror: function(e){
		Extensions.log(e);
        if (!window.errorCt) {
            window.errorCt = 0;
        }
        window.errorCt++;
        return true;
	},
	jsonSort: function(origArray,SortValue){
		var tempArray = origArray;
		valueList = [];
		valueKeys = [];
		lastList = [];
		newArray = [];
		for (var z in tempArray){
			if (String(parseInt(z)) != "NaN"){
				var tmpValue = eval("tempArray[z]."+SortValue+";");
				valueKeys[valueKeys.length] = tmpValue;
				valueList[valueList.length] = {'key':tmpValue,'value':z};
			}
		}
		if (String(parseInt(valueKeys[0])) != "NaN"){
			valueKeys.sort(function(a,b){return a - b});
		}else{
			valueKeys.sort(function(a,b){
				var a = String(a).toUpperCase(); 
				var b = String(b).toUpperCase(); 
				if (a > b) 
					return 1 
				if (a < b) 
					return -1 
				return 0;
			});
		}
		if (SortValue == window.currentSort && window.sortDir == 'reverse'){
			valueKeys.reverse();
		}
		for(var i in valueKeys){
			if (String(parseInt(i)) != "NaN"){
				for (var j in valueList){
					if (String(parseInt(j)) != "NaN"){
						if (valueList[j].key == valueKeys[i]){
							if (!lastList.exists(valueList[j].value)){
								lastList[lastList.length] = valueList[j].value;
								break;
							}
						}
					}
				}
			}
		}
		for(var i in lastList){
			if (String(parseInt(i)) != "NaN"){
				newArray[newArray.length] = tempArray[lastList[i]];
			}
		}
		if (SortValue == window.currentSort){
			if (window.sortDir == "forward"){
				window.sortDir = "reverse";
			}else{
				window.sortDir = "forward";
			}
		}else{
			window.sortDir = "reverse";
		}
		window.currentSort = SortValue;
		return newArray;
	},
	round_by_degree: function(num, degree){
		try {
			var val = num / degree;
			return Math.round(val) * degree;
		} catch (e) {
			Extensions.error(e);
		}
	},
	color_value: function(hex){
		try {
			if(typeof hex != 'undefined'){
				hex = hex.replace('#','');
				if (hex.length > 3) {
					R = parseInt(hex.substring(0, 2), 16);
					G = parseInt(hex.substring(2, 4), 16);
					B = parseInt(hex.substring(4, 6), 16);
				}else{
					R = parseInt(hex.substring(0, 1)+hex.substring(0, 1), 16);
					G = parseInt(hex.substring(1, 2)+hex.substring(1, 2), 16);
					B = parseInt(hex.substring(2, 3)+hex.substring(2, 3), 16);
				}
				return R+G+B;	
			}else{
				Extensions.log('function: Extensions.color_value(hex) where hex = '+hex+';')
			}
		} catch (e) {
			Extensions.error(e);
		}
	},
	color_percent: function(hex){
		try {
		var value = this.color_value(hex);
		var total = 255+255+255;
		return value/total;
		} catch (e) {
			Extensions.error(e);
		}
	},
	isEmpty: function( inputStr ) {
		try {
		// ISEMPTY
		// Written by freebookzone.com on snipplr.com
		if ( null == inputStr || "" == inputStr ) { return true; } return false;
		} catch (e) {
			Extensions.error(e);
		}
	},
	strrpos: function( haystack, needle, offset){
		try {
	    // http://kevin.vanzonneveld.net
	    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // *     example 1: strrpos('Kevin van Zonneveld', 'e');
	    // *     returns 1: 16
	 
	    var i = haystack.lastIndexOf( needle, offset );
		//alert(haystack+' : '+needle+' : '+offset+' : '+i+' : '+haystack.length+' : '+(haystack.length-i));
	    return i >= 0 ? i : false;
		} catch (e) {
			Extensions.error(e);
		}
	},
	substr: function( f_string, f_start, f_length ) {
		try {
	    // http://kevin.vanzonneveld.net
	    // +     original by: Martijn Wieringa
	    // +     bugfixed by: T.Wild
	    // *       example 1: substr('abcdef', 0, -1);
	    // *       returns 1: 'abcde'
	    // *       example 2: substr(2, 0, -6);
	    // *       returns 2: ''
	 
	    f_string = f_string+'';
	    
	    if(f_start < 0) {
	        f_start += f_string.length;
	    }
	 
	    if(f_length == undefined) {
	        f_length = f_string.length;
	    } else if(f_length < 0){
	        f_length += f_string.length;
	    } else {
	        f_length += f_start;
	    }
	 
	    if(f_length < f_start) {
	        f_length = f_start;
	    }
	 
	 	//alert(f_string+' : '+f_start+' : '+f_length);
	 
	    return f_string.substring(f_start, f_length);
		} catch (e) {
			Extensions.error(e);
		}
	},
	str_replace: function(search, replace, subject) {
		try {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // -    depends on: is_array
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'    
    
    var f = search, r = replace, s = subject;
	//alert(f+':'+r+':'+s);
    var ra = Extensions.is_array(r), sa = Extensions.is_array(s), f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length;

    while (j = 0, i--) {
        while (s[i] = s[i].split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
    };
     
    return sa ? s : s[0];
	} catch (e) {
			Extensions.error(e);
		}
	},
	is_array: function( mixed_var ) {
		try {
	    // http://kevin.vanzonneveld.net
	    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // +   improved by: Legaev Andrey
	    // +   bugfixed by: Cord
	    // *     example 1: is_array(['Kevin', 'van', 'Zonneveld']);
	    // *     returns 1: true
	    // *     example 2: is_array('Kevin van Zonneveld');
	    // *     returns 2: false
	 
	    return ( mixed_var instanceof Array );
		} catch (e) {
			Extensions.error(e);
		}
	},
	in_array: function(needle, haystack, strict) {  
	try {
	    // Checks if the given value exists in the array    
	    //   
	    // version: 810.114  
	    // discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_in_array  
	  
	    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)  
	    // *     example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']);  
	    // *     returns 1: true  
	    var found = false, key, strict = !!strict;  
	  
	    for (key in haystack) {  
	        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {  
	            found = true;  
	            break;  
	        }  
		}
		
		return found;  
		} catch (e) {
			Extensions.error(e);
		}
	},
	str_pad: function( input, pad_length, pad_string, pad_type ) {
		try {
	    // http://kevin.vanzonneveld.net
	    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // + namespaced by: Michael White (http://getsprink.com)
	    // *     example 1: str_pad('Kevin van Zonneveld', 30, '-=', 'STR_PAD_LEFT');
	    // *     returns 1: '-=-=-=-=-=-Kevin van Zonneveld'
	    // *     example 2: str_pad('Kevin van Zonneveld', 30, '-', 'STR_PAD_BOTH');
	    // *     returns 2: '------Kevin van Zonneveld-----'
	 
	    var half = '', pad_to_go;
	 
	    var str_pad_repeater = function(s, len) {
	        var collect = '', i;
	 
	        while(collect.length < len) collect += s;
	        collect = collect.substr(0,len);
	 
	        return collect;
	    };
	 
	    input += '';
	 
	    if (pad_type != 'STR_PAD_LEFT' && pad_type != 'STR_PAD_RIGHT' && pad_type != 'STR_PAD_BOTH') { pad_type = 'STR_PAD_RIGHT'; }
	    if ((pad_to_go = pad_length - input.length) > 0) {
	        if (pad_type == 'STR_PAD_LEFT') { input = str_pad_repeater(pad_string, pad_to_go) + input; }
	        else if (pad_type == 'STR_PAD_RIGHT') { input = input + str_pad_repeater(pad_string, pad_to_go); }
	        else if (pad_type == 'STR_PAD_BOTH') {
	            half = str_pad_repeater(pad_string, Math.ceil(pad_to_go/2));
	            input = half + input + half;
	            input = input.substr(0, pad_length);
	        }
	    }
	 
	    return input;
		} catch (e) {
			Extensions.error(e);
		}
	},
	decbin: function(number) {
		try {
	    // http://kevin.vanzonneveld.net
	    // +   original by: Enrique Gonzalez
	    // *     example 1: decbin(12);
	    // *     returns 1: '1100'
	    // *     example 2: decbin(26);
	    // *     returns 2: '11010'
	    
	    return number.toString(2);
		} catch (e) {
			Extensions.error(e);
		}
	},
	isset: function() {
		try {
	    // http://kevin.vanzonneveld.net
	    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // +   improved by: FremyCompany
	    // +   improved by: Onno Marsman
	    // *     example 1: isset( undefined, true);
	    // *     returns 1: false
	    // *     example 2: isset( 'Kevin van Zonneveld' );
	    // *     returns 2: true
	    
	    var a=arguments; var l=a.length; var i=0;
	    
	    if (l==0) { 
	        throw new Error('Empty isset'); 
	    }
	    
	    while (i!=l) {
	        if (typeof(a[i])=='undefined' || a[i]===null) { 
	            return false; 
	        } else { 
	            i++; 
	        }
	    }
	    return true;
		} catch (e) {
			Extensions.error(e);
		}
	},
	create_guid: function(xm,ym){
		try {
		xm = (!Extensions.isEmpty(xm))?xm:1;
		ym = (!Extensions.isEmpty(ym))?ym:1;
		
		var temp_name = '';
		var random_switch = 0;
		
		for( var x=1; x<=4; x++ )
		{
			
			for( var y=1; y<=4; y++ )
			{
				do
				{		
					random_switch = Math.round(Math.random()*10);
				}
				while (random_switch >= 10 || random_switch <= 0)
				temp_name = temp_name + random_switch;
			}
			temp_name = temp_name+'_';
			
		}
		temp_name = temp_name.substr(0, temp_name.length-1);
		
		return(temp_name);
		} catch (e) {
			Extensions.error(e);
		}
	},
	typeOf: function(value) {
		try {
	    var s = typeof value;
	    if (s === 'object') {
	        if (value) {
	            if (typeof value.length === 'number' &&
	                    !(value.propertyIsEnumerable('length')) &&
	                    typeof value.splice === 'function') {
	                s = 'array';
	            }
	        } else {
	            s = 'null';
	        }
	    }
	    return s;
		} catch (e) {
			Extensions.error(e);
		}
	},
	
	getProperties: function(obj) {
		try {
		var i, v;
		var count = 0;
		var props = [];
			if (typeof(obj) === 'object') {
				for (i in obj) {
					v = obj[i];
					if (v !== undefined && typeof(v) !== 'function') {
						props[count] = i;
						count++;
					}
				}
			}
		return props;
		} catch (e) {
			Extensions.error(e);
		}
	},
	getPageSize: function(){
	try {
		var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight){ // Explorer 6 strict mode
			xScroll = document.documentElement.scrollWidth;
			yScroll = document.documentElement.scrollHeight;
		} else { // Explorer Mac...would also work in Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		if (self.innerHeight) { // all except Explorer
			windowWidth = window.innerWidth;
			windowHeight = window.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else {
			pageHeight = yScroll;
		}
		
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){
			pageWidth = windowWidth;
		} else {
			pageWidth = xScroll;
		}
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
		return arrayPageSize;
		} catch (e) {
			Extensions.error(e);
		}
	}
}
Extensions.init();

// PHP.JS : PHP to Javascript Project
// URLEncode

var urlencode = function( str ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Philip Peterson
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: AJ
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // %          note: info on what encoding functions to use from: http://xkr.us/articles/javascript/encode-compare/
    // *     example 1: urlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin+van+Zonneveld%21'
    // *     example 2: urlencode('http://kevin.vanzonneveld.net/');
    // *     returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
    // *     example 3: urlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
    // *     returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
                                     
    var histogram = {}, histogram_r = {}, code = 0, tmp_arr = [];
    var ret = str.toString();
    
    // The histogram is identical to the one in urldecode.
    histogram['!']   = '%21';
    histogram['%20'] = '+';
    
    // Begin with encodeURIComponent, which most resembles PHP's encoding functions
    ret = encodeURIComponent(ret);
    
    for (search in histogram) {
        replace = histogram[search];
        tmp_arr = ret.split(search); // Custom replace
        ret = tmp_arr.join(replace); 
    }
    
    // Uppercase for full PHP compatibility
    return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
        return "%"+m2.toUpperCase();
    });
    
    return ret;
}

// AJAX QUEUE
// Can't believe I'm programming this.

Ajax.AddToQueue = function(objects){
	if(objects){
		if(Extensions.is_array(objects)){
			var length = objects.length;
		}else{
			return null;	
		}
	}else{
		return null;
	}
	
	if(!Ajax.Queue) Ajax.Queue = [];
	
	for(var n = 0; n < length; n++){
		if(typeof objects[n] === 'object'){
			var type = objects[n].type;
			var url = objects[n].url;
			var container = objects[n].container;
			var submitObj = {};
			
			// OVERALL OPTIONS
			if(objects[n].method) submitObj.method = objects[n].method;
			if(objects[n].asynchronous) submitObj.asynchronous = objects[n].asynchronous;
			if(objects[n].contentType) submitObj.contentType = objects[n].contentType;
			if(objects[n].encoding) submitObj.encoding = objects[n].encoding;
			if(objects[n].parameters) submitObj.parameters = objects[n].parameters;
			if(objects[n].postBody) submitObj.postBody = objects[n].postBody;
			if(objects[n].requestHeaders) submitObj.requestHeaders = objects[n].requestHeaders;
			if(objects[n].evalJS) submitObj.evalJS = objects[n].evalJS;
			if(objects[n].evalJSON) submitObj.evalJSON = objects[n].evalJSON;
			if(objects[n].sanitizeJSON) submitObj.sanitizeJSON = objects[n].sanitizeJSON;
			if(objects[n].onCreate) submitObj.onCreate = objects[n].onCreate;
			if (objects[n].onComplete) {
				eval('submitObj.onComplete = function(transport){var extra = '+objects[n].onComplete+';extra(transport);Ajax.ProcessQueue();}');
			}
			if(objects[n].onException) submitObj.onException = objects[n].onException;
			if(objects[n].onFailure) submitObj.onFailure = objects[n].onFailure;
			if(objects[n].onInteractive) submitObj.onInteractive = objects[n].onInteractive;
			if(objects[n].onLoading) submitObj.onLoading = objects[n].onLoading;
			if(objects[n].onLoaded) submitObj.onLoaded = objects[n].onLoaded;
			if(objects[n].onSuccess) submitObj.onSuccess = objects[n].onSuccess;
			if(objects[n].onUninitialized) submitObj.onUninitialized = objects[n].onUninitialized;
			
			// REQUEST OPTIONS
			// : none at this time
			
			// UPDATER OPTIONS
			if(objects[n].evalScripts) submitObj.evalScripts = objects[n].evalScripts;
			if(objects[n].insertion) submitObj.insertion = objects[n].insertion;
			
			Ajax.Queue[Ajax.Queue.length] = {
				'type': type,
				'url': url,
				'container': container,
				'options': submitObj
			};
		}
	}
	
	if(!Ajax.ProcessQueue) {
		Ajax.ProcessQueue = function(){
			if(Ajax.Queue){
				if(Ajax.Queue.length > 0){
					var object = Ajax.Queue[0];
					if(object)
						if(typeof object === 'object')
							if(object.type)
								if(object.url)
									if(typeof object.type === 'string' && typeof object.url === 'string'){
										if(object.options)
											if(typeof object.options != 'object')
												object.options = {};
										switch(object.type){
											case 'update':
											case 'updater':
												if(object.container)
													if(typeof object.container === 'string')
														new Ajax.Updater(object.container, object.url, object.options);
												break;
											default:
												new Ajax.Request(object.url, object.options);
												break;										}
									}
					Ajax.Queue.splice(0,1);
				}
			}
		};
	}
	
	Ajax.ProcessQueue();
};



