function $(e,c){if(typeof e=='string'){e=c?$$("#"+e, $(c))[0] : document.getElementById(e);}return e};
function $a(e,c){if(typeof c=='string')c=document.createElement(c);return $(e).appendChild(c)};
function $d(e){var p=$(e).parentNode; if(p)return p.removeChild($(e))};
function $i(e,t,n){var el=$(e);if(document.all&&!window.opera){var rb = document.createElement("<INPUT type="+t+" name='"+n+"'>");el.appendChild(rb);}else{var rb = $a(el, "INPUT");rb.type = t;rb.name = n;}return rb;}
function collect(a,f){var n=[];for(var i=0;i<a.length;i++){var v=f(a[i]);if(v!=null)n.push(v)}return n};
function isArray(v) { return v && typeof v === 'object' && typeof v.length === 'number' && !(v.propertyIsEnumerable('length')); }
function isFunction(a) { return typeof a == 'function'; }
function isNull(a) { return typeof a == 'object' && !a; } 
function isNumber(a) { return typeof a == 'number' && isFinite(a); } 
function isObject(a) { return (typeof a == 'object' && a) || isFunction(a); }

Function.prototype.inheritsFrom = function( parentClassOrObject, _extend ){
	if (parentClassOrObject) {
		if ( parentClassOrObject.constructor == Function ) {
			//Normal Inheritance
			this.prototype = new parentClassOrObject;
			this.prototype.constructor = this;
			this.prototype.parent = parentClassOrObject.prototype;
		} else {
			//Pure Virtual Inheritance
			this.prototype = parentClassOrObject;
			this.prototype.constructor = this;
			this.prototype.parent = parentClassOrObject;
		}
	}
	
	if(_extend) {
        for(property in _extend) { 
            if(_extend.hasOwnProperty(property)) {
				this.prototype[property] = _extend[property];
			}
		}
	}
	
	return this;
}

Object.extend = function(_constructor, _prototype) {  
    if(!_constructor) var _constructor = function(){}; 
    _constructor.prototype = new this();
    if(_prototype) {
        for(property in _prototype) { 
            if(_prototype.hasOwnProperty(property)) {
				_constructor.prototype[property] = _prototype[property];
			}
		}
	}
    _constructor.prototype.constructor = _constructor;
    _constructor.parent = this;
    _constructor.extend = this.extend;
    return _constructor;
};  

var AjaxToolkit = {
	
	ajax: {

		x: function(){try{return new ActiveXObject('Msxml2.XMLHTTP')}catch(e){try{return new ActiveXObject('Microsoft.XMLHTTP')}catch(e){return new XMLHttpRequest()}}},
		
		serialize: function(f){var g=function(n){return f.getElementsByTagName(n)};var nv=function(e){if(e.name)return encodeURIComponent(e.name)+'='+encodeURIComponent(e.value);else return ''};var i=collect(g('input'),function(i){if((i.type!='radio'&&i.type!='checkbox')||i.checked)return nv(i)});var s=collect(g('select'),nv);var t=collect(g('textarea'),nv);return i.concat(s).concat(t).join('&');},
		
		send: function(u,f,m,a) {
			var x=this.x();
			x.open(m,u,true);
			x.onreadystatechange = function() {
						if(x.readyState==4) {
							if (isArray(f)) {
								f[1].apply(f[0],[x.responseText]);
							} else {
								f(x.responseText);
							}
						}
						}
			if (m=='POST') x.setRequestHeader('Content-type','application/x-www-form-urlencoded');
			x.send(a);
		},
		
		get: function(url,func){setTimeout(function() {_a.ajax.send(url,func,'GET')}, 0)},
		
		gets: function(url){var x=this.x();x.open('GET',url,false);x.send(null);return x.responseText},
		
		post: function(url,func,args){this.send(url,func,'POST',args)},
		
		update: function(url,elm){var e=$(elm);var f=function(r){e.innerHTML=r};this.get(url,f)},
		
		submit: function(url,elm,frm){var e=$(elm);var f=function(r){e.innerHTML=r};this.post(url,f,this.serialize(frm))}
		
	},
	
	packArray: function(data, paramname) {
		var res = "";
		paramname = paramname || "params";
		for (var o in data) {
			res += "&"+paramname+"[" + o + "]=" + encodeURIComponent(data[o]);
		}
		return res;
	},
	
	packObject: function(data, prefix) {
		var res = [];
		for (var o in data) {
			var vname = prefix ? prefix + "["+o+"]" : o;
			if (typeof (data[o]) == "object") {
				res.push(_a.packObject(data[o], vname));
			} else {
				res.push(encodeURIComponent(vname) + "=" + encodeURIComponent(data[o]));
			}
		}
		return res.join('&');
	}, 
	
	GUID: function(prefix) {
		var result, i, j;
		result = prefix || 'GUID-';
		for(j=0; j<21; j++) {
			if( j == 5 || j == 10|| j == 15) {
				result = result + '-';
			} else {
				i = Math.floor(Math.random()*16).toString(16).toUpperCase();
				result = result + i;
			}
		}
		return result;
	},
	
	/*addEvent : function(whichObject,eventType,functionName)
	{ 
	  if(whichObject.attachEvent){ 
		whichObject['e'+eventType+functionName] = functionName; 
		whichObject[eventType+functionName] = function(){whichObject['e'+eventType+functionName]( window.event );} 
		whichObject.attachEvent( 'on'+eventType, whichObject[eventType+functionName] ); 
	  } else 
		whichObject.addEventListener(eventType,functionName,false); 	    
	} 
	,	
			
	removeEvent : function(whichObject,eventType,functionName)
	{ 
	  if(whichObject.detachEvent){ 
		whichObject.detachEvent('on'+eventType, whichObject[eventType+functionName]); 
		whichObject[eventType+functionName] = null; 
	  } else 
		whichObject.removeEventListener(eventType,functionName,false); 
	} */
	
	addEvent: function(o, e, f, s) {
		/** Try to remove event handler if it's already here 
		try {
			this.removeEvent(o, e, f, s);
		} catch(h) {}
		*/
	    var r = o[r = "_" + (e = "on" + e)] = o[r] || (o[e] ? [[o[e], o]] : []), a, c, d;
	    r[r.length] = [f, s || o], o[e] = function(e){
	        try{
	            (e = e || event).preventDefault || (e.preventDefault = function(){e.returnValue = false;});
	            e.stopPropagation || (e.stopPropagation = function(){e.cancelBubble = true;});
	            e.target || (e.target = e.srcElement || null);
	            e.key = (e.which + 1 || e.keyCode + 1) - 1 || 0;
	        }catch(f){}
	        for(d = 1, f = r.length; f; r[--f] && (a = r[f][0], o = r[f][1], a.call ? c = a.call(o, e) : (o._ = a, c = o._(e), o._ = null), d &= c !== false));
	        return e = null, !!d;
	    }
	},

	removeEvent: function(o, e, f, s){
	    for(var i = (e = o["_on" + e] || []).length; i;) {
	        if(e[--i] && e[i][0] == f && (s || o) == e[i][1]) {
	            return delete e[i];
			}
		}
	    return false;
	},
	
	clone: function (myObj) {
		if(typeof(myObj) != 'object') return myObj;
		if(myObj == null) return myObj;

		//var myNewObj = new Object();
		var myNewObj = new myObj.constructor();

		for(var i in myObj)
			myNewObj[i] = this.clone(myObj[i]);

		return myNewObj;
	},
	
	slideTo: function(item, x, y, params) {
		//var pos = Coordinates.northwestOffset($(item), true);
		if ($(item).style.position != "absolute") return;
		
		var difx = Coordinates.northwestOffset($(item), true).x - x;
		var dify = Coordinates.northwestOffset($(item), true).y - y;
		
		difx = Math.ceil(difx/2);
		dify = Math.ceil(dify/2);
		
		if (difx) $(item).style.left = x + difx + "px";
		if (dify) $(item).style.top = y + dify + "px";
		
		if (difx || dify) {
			setTimeout('AjaxToolkit.slideTo("'+$(item).id+'", '+x+', '+y+');', 250);
		}
	},
	
	slideInUse: [],
	
	Slide: function (objId, options) {
		var sObj = {
			
			up: function() {
				this.curHeight = this.height;
				this.newHeight = '1';
				if(AjaxToolkit.slideInUse[objId] != true) {
					var finishTime = this.slide();
					window.setTimeout("AjaxToolkit.Slide('"+objId+"').finishup("+this.height+");",finishTime);
				}
			},
			
			down: function() {
				this.newHeight = this.height;
				this.curHeight = '1';
				if(AjaxToolkit.slideInUse[objId] != true) {
					this.obj.style.height = '1px';
					this.obj.style.display = 'block';
					var finishTime = this.slide();
					window.setTimeout("AjaxToolkit.Slide('"+objId+"').finishdown();",finishTime);
				}
			},
			
			slide: function() {
				AjaxToolkit.slideInUse[objId] = true;
				var frames = 30 * this.duration; // Running at 30 fps

				var tIncrement = (this.duration*1000) / frames;
				tIncrement = Math.round(tIncrement);
				var sIncrement = (this.curHeight-this.newHeight) / frames;

				var frameSizes = new Array();
				for(var i=0; i < frames; i++) {
					if(i < frames/2) {
						frameSizes[i] = (sIncrement * (i/frames))*4;
					} else {
						frameSizes[i] = (sIncrement * (1-(i/frames)))*4;
					}
				}
				
				for(var i=0; i < frames; i++) {
					this.curHeight = this.curHeight - frameSizes[i];
					window.setTimeout("document.getElementById('"+objId+"').style.height='"+Math.round(this.curHeight)+"px';",tIncrement * i);
				}
				
				window.setTimeout("delete(AjaxToolkit.slideInUse['"+objId+"']);",tIncrement * i);
				
				if(this.options.onComplete) {
					window.setTimeout(this.options.onComplete, tIncrement * (i-2));
				}
				
				return tIncrement * i;
			},
			
			finishup: function(height) {
				this.obj.style.display = 'none';
				this.obj.style.height = height + 'px';
				sObj.obj.style.overflow = sObj.obj.old_flow;
			},
			
			finishdown: function() {
				this.obj.style.height = 'auto';
			}
		}
		sObj.obj = $(objId);
		sObj.duration = 1;
		sObj.height = parseInt(sObj.obj.style.height) || parseInt(sObj.obj.offsetHeight);
		
		if (!sObj.height) {
			sObj.obj.style.display='block';
			//sObj.obj.style.height='auto';
			sObj.height = parseInt(sObj.obj.offsetHeight);
			if (sObj.height) sObj.obj.style.display='none';
		}
		
		if(typeof options != 'undefined') { sObj.options = options; } else { sObj.options = {}; }
		if(sObj.options.duration) { sObj.duration = sObj.options.duration; }
		sObj.obj.old_flow = sObj.obj.style.overflow;
		sObj.obj.style.overflow = 'hidden';
		return sObj;
},
	
	each: function( obj, fn, args ) {
		if ( obj.length == undefined )
			for ( var i in obj )
				fn.apply( obj[i], args || [i, obj[i]] );
		else
			for ( var i = 0, ol = obj.length; i < ol; i++ )
				if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break;
		return obj;
	},
	
	isXMLDoc: function(elem) {
		return elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
	},
	
	nodeName: function( elem, name ) {
		return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
	},
	
	inArray: function( b, a ) {
		for ( var i = 0, al = a.length; i < al; i++ )
			if ( a[i] == b )
				return i;
		return -1;
	},
	
	merge: function(first, second) {
		var r = [].slice.call( first, 0 );
		// Now check for duplicates between the two arrays
		// and only add the unique items
		for ( var i = 0, sl = second.length; i < sl; i++ )
			// Check for duplicates
			if ( AjaxToolkit.inArray( second[i], r ) == -1 )
				// The item is unique, add it
				first.push( second[i] );

		return first;
	},
	
	getAll: function( o, r, token, name, re ) {
		for ( var s = o.firstChild; s; s = s.nextSibling )
			if ( s.nodeType == 1 ) {
				var add = true;

				if ( token == "." )
					add = s.className && re.test(s.className);
				else if ( token == "#" )
					add = s.getAttribute("id") == name;
	
				if ( add )
					r.push( s );

				if ( token == "#" && r.length ) break;

				if ( s.firstChild )
					AjaxToolkit.getAll( s, r, token, name, re );
			}
		return r;
	},
	
	grep: function(elems, fn, inv) {
		// If a string is passed in for the function, make a function
		// for it (a handy shortcut)
		if ( typeof fn == "string" )
			fn = new Function("a","i","return " + fn);
		var result = [];
		// Go through the array, only saving the items
		// that pass the validator function
		for ( var i = 0, el = elems.length; i < el; i++ )
			if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
				result.push( elems[i] );
		return result;
	},
	
	tpl: function(el, data) {
		
		if (document.all) {
			if (_a.inArray(el.tagName, ["TR", "TABLE", "THEAD", "TBODY", "TFOOT"]) != -1) {
				var c = el.childNodes;
				for (var i=0; i<c.length; i++) {
					_a.tpl(c[i], data);
				}
				return;
			}
		} 
		
		var r = $(el).innerHTML.toString().replaceVars(data);
		/*var re = new RegExp('\$\$=\((.*?)\);', "g")
		var m = re.exec(r);
		if (m && m.length) {
			alert(m);
		}*/
		
		var re = /\$\$=\((.*?)\);/g;
		r = r.replace(re, function(s){ var r=''; try {if (s.slice(4, -2).trim()) r = eval("("+s.slice(4, -2).trim()+")");}catch(e){}; return r ? r : "";});
		
		$(el).innerHTML = r;
		
	},
	
	updateTableRow: function(table, data, proto) {
		var tbl = $(table);
		if (!tbl) return;
		
		var trs = $$("tbody > tr", tbl);
		var prtr = $(proto) || trs[trs.length-1];
		
		var old = _a.grep($$("tbody > tr", tbl), " a.data ? (a.data.id=='"+data.id+"') : false;");
		if (!old.length) {
			var ntr = _a._insertTableRow(table, data, prtr);
		} else {
			old = old[0];
			var ntr = prtr.cloneNode(true);
			ntr.data = data;
			old.parentNode.insertBefore(ntr, old);
			old.parentNode.removeChild(old);
			_a.tpl(ntr, data);
			ntr.id = "dt-"+data.id;
			ntr.setAttribute("id", ntr.id);
			if (ntr.style.display == "none") {
				ntr.style.display = "";
			}
		}
		tbl.data[data.id] = data;
		return ntr;
	},
	
	parents: function( elem ){
		var matched = [];
		var cur = elem.parentNode;
		while ( cur && cur != document ) {
			matched.push( cur );
			cur = cur.parentNode;
		}
		return matched;
	},
	
	findParent: function(elem, fn) {
		return _a.grep(_a.parents(elem), fn).shift();
	},
	
	findParentNode: function(elem, nodeName) {
		return _a.findParent(elem, function(e) { return _a.nodeName(e, nodeName)});
	},
	
	swap: function(e,o,f) {
		for ( var i in o ) {
			e.style["old"+i] = e.style[i];
			e.style[i] = o[i];
		}
		f.apply( e, [] );
		for ( var i in o )
			e.style[i] = e.style["old"+i];
	},

	css: function(e,p) {
		if ( p == "height" || p == "width" ) {
			var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];

			AjaxToolkit.each( d, function(){
				old["padding" + this] = 0;
				old["border" + this + "Width"] = 0;
			});

			AjaxToolkit.swap( e, old, function() {
				if (AjaxToolkit.css(e,"display") != "none") {
					oHeight = e.offsetHeight;
					oWidth = e.offsetWidth;
				} else {
					e = $a(e.parentNode, e.cloneNode(true));
					e.style.visibility = "hidden";
					e.style.position = "absolute";
					e.style.display = "block";
					e.style.right = "0px";
					e.style.left = "0px";
						
					var parPos = AjaxToolkit.css(e.parentNode,"position");
					if ( parPos == "" || parPos == "static" )
						e.parentNode.style.position = "relative";

					oHeight = e.clientHeight;
					oWidth = e.clientWidth;

					if ( parPos == "" || parPos == "static" )
						e.parentNode.style.position = "static";

					$d(e);
				}
			});

			return p == "height" ? oHeight : oWidth;
		}

		return AjaxToolkit.curCSS( e, p );
	},
	
	isHidden:function(a) {
		return a.type=="hidden" || AjaxToolkit.css(a,"display")=="none" || AjaxToolkit.css(a,"visibility")=="hidden";
	},

	curCSS: function(elem, prop, force) {
		var ret;
		
		if (prop == "opacity" && AjaxToolkit.browser.msie)
			return AjaxToolkit.attr(elem.style, "opacity");
			
		if (prop == "float" || prop == "cssFloat")
		    prop = AjaxToolkit.browser.msie ? "styleFloat" : "cssFloat";

		if (!force && elem.style[prop])
			ret = elem.style[prop];

		else if (document.defaultView && document.defaultView.getComputedStyle) {

			if (prop == "cssFloat" || prop == "styleFloat")
				prop = "float";

			prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
			var cur = document.defaultView.getComputedStyle(elem, null);

			if ( cur )
				ret = cur.getPropertyValue(prop);
			else if ( prop == "display" )
				ret = "none";
			else
				AjaxToolkit.swap(elem, { display: "block" }, function() {
				    var c = document.defaultView.getComputedStyle(this, "");
				    ret = c && c.getPropertyValue(prop) || "";
				});

		} else if (elem.currentStyle) {

			var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
			ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
			
		}

		return ret;
	},
	
	attr: function(elem, name, value){
		var fix = this.isXMLDoc(elem) ? {} : {
			"for": "htmlFor",
			"class": "className",
			"float": this.browser.msie ? "styleFloat" : "cssFloat",
			cssFloat: this.browser.msie ? "styleFloat" : "cssFloat",
			innerHTML: "innerHTML",
			className: "className",
			value: "value",
			disabled: "disabled",
			checked: "checked",
			readonly: "readOnly",
			selected: "selected"
		};
		
		// IE actually uses filters for opacity ... elem is actually elem.style
		if ( name == "opacity" && this.browser.msie && value != undefined ) {
			// IE has trouble with opacity if it does not have layout
			// Force it by setting the zoom level
			elem.zoom = 1; 

			// Set the alpha filter to set the opacity
			return elem.filter = elem.filter.replace(/alpha\([^\)]*\)/gi,"") +
				( value == 1 ? "" : "alpha(opacity=" + value * 100 + ")" );

		} else if ( name == "opacity" && this.browser.msie )
			return elem.filter ? 
				parseFloat( elem.filter.match(/alpha\(opacity=(.*)\)/)[1] ) / 100 : 1;
		
		// Mozilla doesn't play well with opacity 1
		if ( name == "opacity" && this.browser.mozilla && value == 1 )
			value = 0.9999;
			

		// Certain attributes only work when accessed via the old DOM 0 way
		if ( fix[name] ) {
			if ( value != undefined ) elem[fix[name]] = value;
			return elem[fix[name]];

		} else if ( value == undefined && this.browser.msie && this.nodeName(elem, "form") && (name == "action" || name == "method") )
			return elem.getAttributeNode(name).nodeValue;

		// IE elem.getAttribute passes even for style
		else if ( elem.tagName ) {
			if ( value != undefined ) elem.setAttribute( name, value );
			if ( this.browser.msie && /href|src/.test(name) && !this.isXMLDoc(elem) ) 
				return elem.getAttribute( name, 2 );
			return elem.getAttribute( name );

		// elem is actually elem.style ... set the style
		} else {
			name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
			if ( value != undefined ) elem[name] = value;
			return elem[name];
		}
	},
	
	_insertTableRow: function(table, data, proto) {
		var ntr = proto.cloneNode(true);
		ntr.data = data;
		proto.parentNode.insertBefore(ntr, proto);
		_a.tpl(ntr, data);
		ntr.id = "dt-"+data.id;
		ntr.setAttribute("id", ntr.id);
		if (ntr.style.display == "none") {
			ntr.style.display = "";
		}
		return ntr;
	},
	
	_removeTableRow: function(table, data) {
		var tbl = $(table);
		if (!tbl) return;
		var id = (typeof data == "object" ? data.id : data);
		
		if (tbl.data[id]) {
			delete tbl.data[id];
			tbl.data[id] = null;
			var tr = $$("#dt-" + id, tbl)[0];
			if (tr) {
				tr.parentNode.removeChild(tr);
			}
		}
	},
	
	fillTable: function(table, data, protoTr, clean, rowCallBack) {
		
		var tbl = $(table), prtr = $(protoTr), before, after;
		if (!tbl) return;
		
		var trs = $$("> tbody > tr", tbl);
		if (!prtr) {
			prtr = trs[trs.length-1];
		}
		
		if (clean) {
			_a.each(trs, function(i, e) {if (e!=prtr) {
				if (e.data && e.data.id) {
					_a._removeTableRow(tbl, e.data.id);
					try {
						delete e.data;
					} catch(o) {
						e.data = null;
					}
				} else {
					e.parentNode.removeChild(e);
				}
			}});
			if (tbl.data) {
				try {
					delete tbl.data;
				} catch(o) {
					tbl.data = null;
				}
			}
		}
		if (!tbl.data) tbl.data = {};
		
		if (!isArray(data)) {
			return;
		}
		
		if (isArray(rowCallBack) && rowCallBack.length) {
			before = rowCallBack[0];
			after =  rowCallBack[1];
		} else {
			after = rowCallBack || false;
		}
		
		for (var i=0; i<data.length; i++) {
			if (before) data[i] = isArray(before) ? before[1].apply(before[0], [data[i]]) : before(data[i]);
			var ntr = _a.updateTableRow(tbl, data[i], protoTr);
			if (after) {
				isArray(after) ? after[1].apply(after[0], [ntr, data[i]]) : after(ntr, data[i]);
			}
		}
		
	},
	
	parseStr: function(s, p) {
		var rv = p || {}, decode = window.decodeURIComponent || window.unescape;
		s.replace(
			/([^=&]*?)((?:\[\])?)(?:=([^&]*))?(?=&|$)/g,
			function ($,n,arr,v) {
				if (n == '')
					return;
				n = decode(n);
				v = decode(v);
				var rs = n.replaceAll(']','').split('['), rp = rv, m = rs.pop();
				if (!arr && m=="") {
					arr = true;
					m = rs.pop();
				}
				for (var i=0; i<rs.length; i++) {
					if (rp[rs[i]] == undefined) {
						rp[rs[i]] = {};
					}
					rp = rp[rs[i]];
				}
				if (arr) {
					if (typeof rp[m] == 'object') {
						rp[m].push(v);
					} else {
						rp[m] = [v];
					}
				} else {
					rp[m] = v;
				}
			});
		return rv;
	},
	
	getBehind: function(el) {
		if (!el) return;
		if (!document.all || window.opera) return;
		
		iebody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
			
		var allowedOffset = iebody.scrollTop;
		
		//var tags = new Array("applet", "iframe", "select");
		var tags = new Array("applet", "select");
		
		var pos1 = Coordinates.northwestOffset(el, true);
		var pos2 = Coordinates.southeastOffset(el, true);
		
		var EX1 = pos1.x;
		var EX2 = pos2.x;
		var EY1 = pos1.y;
		var EY2 = pos2.y;
		
		var res = [];
		
		function getVisib(obj){
			var value = obj.style.visibility;
			if (!value) {
				if (document.defaultView && typeof (document.defaultView.getComputedStyle) == "function") { // Gecko, W3C
					value = document.defaultView.getComputedStyle(obj, "").getPropertyValue("visibility");
				} else if (obj.currentStyle) { // IE
					value = obj.currentStyle.visibility;
				} else value = '';
			}
			return value;
		};
		
		for (var k = tags.length; k > 0; ) {
			var ar = document.getElementsByTagName(tags[--k]), cc = null, isin;

			for (var i = ar.length; i > 0;) {
				cc = ar[--i];
				
				isin = false;
				var po = cc;
				while (po && po.parentNode) {
					if (po == el) {
						po = null; isin = true;
					} else {
						po = po.parentNode;
					}
				}
				
				if (!isin) {
					var p1 = Coordinates.northwestOffset(cc, true);
					var p2 = Coordinates.southeastOffset(cc, true);
					var CX1 = p1.x;
					var CX2 = p2.x;
					var CY1 = p1.y;
					var CY2 = p2.y;

					// (CX1 > EX2) || (CX2 < EX1) || (CY1 > EY2) || (CY2 < EY1)
					
					if ((p1.inside(pos1, pos2) || p2.inside(pos1, pos2))) {
						if (!cc.__ajtt_save_visibility) {
							cc.__ajtt_save_visibility = getVisib(cc);
						}
						res.push(cc);
					}
				}
			}
		}
		return res;
	},
	
	processBehind: function(e, action) {
		if (!e) return;
		if (!document.all || window.opera) return;
		
		var toDo = action || 'auto';
		
		iebody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
			
		var allowedOffset = iebody.scrollTop;
		
		function getVisib(obj){
			var value = obj.style.visibility;
			if (!value) {
				if (document.defaultView && typeof (document.defaultView.getComputedStyle) == "function") { // Gecko, W3C
					value = document.defaultView.getComputedStyle(obj, "").getPropertyValue("visibility");
				} else if (obj.currentStyle) { // IE
					value = obj.currentStyle.visibility;
				} else value = '';
			}
			return value;
		};

		//var tags = new Array("applet", "iframe", "select");
		var tags = new Array("applet", "select");
		var el = $(e);

		var pos1 = Coordinates.northwestOffset(el, true);
		var pos2 = Coordinates.southeastOffset(el, true);
		
		var EX1 = pos1.x;
		var EX2 = pos2.x;
		var EY1 = pos1.y;
		var EY2 = pos2.y;
		
		for (var k = tags.length; k > 0; ) {
			var ar = document.getElementsByTagName(tags[--k]), cc = null, isin;

			for (var i = ar.length; i > 0;) {
				cc = ar[--i];
				
				isin = false;
				var po = cc;
				while (po && po.parentNode) {
					if (po == el) {
						po = null; isin = true;
					} else {
						po = po.parentNode;
					}
				}
				
				if (!isin) {
					var p1 = Coordinates.northwestOffset(cc, true);
					var p2 = Coordinates.southeastOffset(cc, true);
					var CX1 = p1.x;
					var CX2 = p2.x;
					var CY1 = p1.y;
					var CY2 = p2.y;

					// (CX1 > EX2) || (CX2 < EX1) || (CY1 > EY2) || (CY2 < EY1)
					
					if ((toDo=='show' || toDo=='auto') && (p1.inside(pos1, pos2) || p2.inside(pos1, pos2))) {
						if (!cc.__ajtt_save_visibility) {
							cc.__ajtt_save_visibility = getVisib(cc);
						}
						cc.style.visibility = cc.__ajtt_save_visibility;
					} else if ((toDo=='hide' || toDo=='auto') && (p1.inside(pos1, pos2) || p2.inside(pos1, pos2))) {
						if (!cc.__ajtt_save_visibility) {
							cc.__ajtt_save_visibility = getVisib(cc);
						}
						cc.style.visibility = "hidden";
					}
				}
			}
		}
	},
	
	processBehind2: function(e, action, defEls) {
		if (!e) return;
		if (!document.all || window.opera) return;
		
		var toDo = action || 'hide';
		
		iebody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body;
			
		var allowedOffset = iebody.scrollTop;
		
		function getVisib(obj){
			var value = obj.style.visibility;
			if (!value) {
				if (document.defaultView && typeof (document.defaultView.getComputedStyle) == "function") { // Gecko, W3C
					value = document.defaultView.getComputedStyle(obj, "").getPropertyValue("visibility");
				} else if (obj.currentStyle) { // IE
					value = obj.currentStyle.visibility;
				} else value = '';
			}
			return value;
		};
		
		var els = defEls || AjaxToolkit.getBehind(e);

		for (var i = els.length; i > 0;) {
			cc = els[--i];
			
			if (toDo=='show') {
				if (!cc.__ajtt_save_visibility) {
					cc.__ajtt_save_visibility = getVisib(cc);
				}
				cc.style.visibility = cc.__ajtt_save_visibility;
			} else if (toDo=='hide') {
				if (!cc.__ajtt_save_visibility) {
					cc.__ajtt_save_visibility = getVisib(cc);
				}
				cc.style.visibility = "hidden";
			}
		}
	},
	
	toCenter: function(el) {
		el = $(el);
		if (!el) return;
		
		var sw, sh, scrollLeft, scrollTop;
		
		if (window.innerWidth) {
			sw = window.innerWidth;
			sh = window.innerHeight;
		} else if (document.documentElement && document.documentElement.clientWidth) {
			sh = document.documentElement.clientHeight;
			sw = document.documentElement.clientWidth;
		} else if (document.body) {
			sw = document.body.clientWidth;
			sh = document.body.clientHeigh;
		}
		
		if (_a.isHidden(el)) {
			el.style.position = "absolute";
			el.style.display = "block";
		}
		
		if (self.pageYOffset) {
			// all except Explorer
			scrollLeft = self.pageXOffset;
			scrollTop = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop) {
			// Explorer 6 Strict
			scrollLeft = document.documentElement.scrollLeft;
			scrollTop = document.documentElement.scrollTop;
		} else if (document.body) {
			// all other Explorers
			scrollLeft = document.body.scrollLeft;
			scrollTop = document.body.scrollTop;
		}
		
		var toTop = (sh - _a.css(el, "height")) / 2 + scrollTop;
		if (toTop < 0) toTop = 10;
		
		el.style.left = (sw - _a.css(el, "width")) / 2 + scrollLeft + "px";
		el.style.top = toTop + "px";
		
		
	},
	
	loadHandlers: [],
	
	onLoad: function(f) {
		if (typeof f == 'function') {
			AjaxToolkit.loadHandlers.push(f);
			return;
		}
		
		if (arguments.callee.done) return;

		// flag this function so we don't do the same thing twice
		arguments.callee.done = true;
		
		for (var i=0; i<AjaxToolkit.loadHandlers.length; i++) {
			var func = AjaxToolkit.loadHandlers[i];
			func();
		}
	}, 
	
	/*pause: function (ms) {
	    var date = new Date;
	    curDate = null;
	    do {
	        var curDate = new Date;
	    } while (curDate - date < ms);
	},*/
	
	
	doWaitCallback: function (f, ms, c) {
		if (f) {
			if (typeof f == "string") {
				eval(f);
			} else {
				f();
			}
		}
		setTimeout(c, ms);
	},
	
	_movers: [],
	
	cutAndPaste: function (what, where, callback, opt) {
			var mto = $(where);
			var coord = ToolMan.coordinates();
			var cfrom = coord.topLeftOffset(what.parentNode);
			what = $a(document.body, $d(what));
			what.style.position = "absolute";
			what.style.left = cfrom.x;
			what.style.top = cfrom.y;
			
			var cto = coord.bottomRightOffset(mto);
			var cto2 = coord.topLeftOffset(mto);
			
			cto.x = cto2.x;
			
			var f = function() {
				
				this.style.position='';
				this.style.top=0;
				this.style.left=0;
				$a(mto, $d(this));
				if (callback) callback.apply(this);
			}
			this.moveThing(what, cto, f, opt);
	},
	
	moveThing: function(what, where, callback, opt) {
			
		var f = function() {
			if (callback) callback.apply(this);
		}
		AjaxToolkit.effect(what).move(where, f, opt);
	},
	
	doMove: function(i, x, y) {
		AjaxToolkit._movers[i].style.left = x;
		AjaxToolkit._movers[i].style.top = y;
	},
	
	isFunction: function( fn ) {
		return !!fn && typeof fn != "string" && !fn.nodeName && 
			typeof fn[0] == "undefined" && /function/i.test( fn + "" );
	}
}

var _a = AjaxToolkit;
var _l = function(f) {if (typeof f == 'function') _a.onLoad(f);}

function $$(t, c) {
	t = t || document;
	if (typeof t != 'string') {
		return [t];
	}
	
	if ( c && !c.nodeType ) c = null;
	c = c || document;
	
	var ret = [c], done = [], last = null;

	while ( t && last != t ) {
		var r = [];
		last = t;

		t = t.replace(/^\s+|\s+$/g, "");

		var foundToken = false;

		// An attempt at speeding up child selectors that
		// point to a specific element tag
		var re = /^[\/>]\s*([a-z0-9*-]+)/i;
		var m = re.exec(t);

		if ( m ) {
			// Perform our own iteration and filter
			_a.each( ret, function(){
				for ( var c = this.firstChild; c; c = c.nextSibling )
					if ( c.nodeType == 1 && ( _a.nodeName(c, m[1]) || m[1] == "*" ) )
						r.push( c );
			});
			ret = r;
			t = t.replace( re, "" );
			if ( t.indexOf(" ") == 0 ) continue;
			foundToken = true;
		}

		// See if there's still an expression, and that we haven't already
		// matched a token
		if ( t && !foundToken ) {
			// Handle multiple expressions
			if ( !t.indexOf(",") ) {
				// Clean the result set
				if ( ret[0] == c ) ret.shift();

				// Merge the result sets
				_a.merge( done, ret );

				// Reset the context
				r = ret = [c];

				// Touch up the selector string
				t = " " + t.substr(1,t.length);

			} else {
				// Optomize for the case nodeName#idName
				var re2 = /^([a-z0-9_-]+)(#)([a-z0-9\\*_-]*)/i;
				var m = re2.exec(t);
				
				// Re-organize the results, so that they're consistent
				if ( m ) {
				   m = [ 0, m[2], m[3], m[1] ];

				} else {
					// Otherwise, do a traditional filter check for
					// ID, class, and element selectors
					re2 = /^([#.]?)([a-z0-9\\*_-]*)/i;
					m = re2.exec(t);
				}

				// Try to do a global search by ID, where we can
				if ( m[1] == "#" && ret[ret.length-1].getElementById ) {
					// Optimization for HTML document case
					var oid = ret[ret.length-1].getElementById(m[2]);
					
					ret = r = oid && (!m[3] || _a.nodeName(oid, m[3])) ? [oid] : [];

				} else {
					// Pre-compile a regular expression to handle class searches
					if ( m[1] == "." )
						var rec = new RegExp("(^|\\s)" + m[2] + "(\\s|$)");

					// We need to find all descendant elements, it is more
					// efficient to use getAll() when we are already further down
					// the tree - we try to recognize that here
					_a.each( ret, function(){
						// Grab the tag name being searched for
						var tag = m[1] != "" || m[0] == "" ? "*" : m[2];

						// Handle IE7 being really dumb about <object>s
						if ( _a.nodeName(this, "object") && tag == "*" )
							tag = "param";

						_a.merge( r,
							m[1] != "" && ret.length != 1 ?
								_a.getAll( this, [], m[1], m[2], rec ) :
								this.getElementsByTagName( tag )
						);
					});

					// It's faster to filter by class and be done with it
					
					if ( m[1] == "." && ret.length == 1 )
						r = _a.grep( r, function(e) {
							return rec.test(e.className);
						});

					// Same with ID filtering
					if ( m[1] == "#" && ret.length == 1 ) {
						// Remember, then wipe out, the result set
						var tmp = r;
						r = [];

						// Then try to find the element with the ID
						_a.each( tmp, function(){
							if ( this.getAttribute("id") == m[2] ) {
								r = [ this ];
								return false;
							}
						});
					}

					ret = r;
				}

				t = t.replace( re2, "" );
			}

		}
/*
		// If a selector string still exists
		if ( t ) {
			// Attempt to filter it
			var val = jQuery.filter(t,r);
			ret = r = val.r;
			t = jQuery.trim(val.t);
		}*/
	}

	// Remove the root context
	if ( ret && ret[0] == c ) ret.shift();

	// And combine the results
	_a.merge( done, ret );

	return done;	
}

String.prototype.replaceAll = function(find, replace) {
	var str = this;
	if (typeof str != "string") str = str.toString();
	while (str.indexOf(find) > -1) {
		str = str.replace(find, replace);
	}
	return str;
}

AjaxToolkit.ksort = function(source, compare) {
	compare = compare || null;
	if (!isFunction(compare)) {
		compare = function(a,b) {return a < b ? -1 : 1};
	}
	var keys = [];
	for (var i in source) {
		if (source.hasOwnProperty(i))
			keys.push(i);
	}
	keys.sort(compare);
	var res = {};
	for (var i=0; i<keys.length; i++) {
		res[keys[i]] = source[keys[i]];
	}
	return res;
}

String.prototype.replaceVars = function(vars) {
	var str = this;
	if (typeof str != "string") str = str.toString();
	vars = _a.ksort(vars, function(a,b) {return a > b ? -1 : 1});
	for (var i in vars) {
		//str = str.replaceAll('{'+i+'}', vars[i]);
		var val = vars[i];
		if (val == undefined || val === false) val = "";
		if (typeof val == "object") {
			if (val.toSource) {
				val = val.toSource();
			} else {
				if (val.length != undefined)
					val = "[" + val.toString() + "]";
			}
		}
		str = str.replaceAll('$$'+i, val);
		//str = str.replaceAll('$$$'+i, eval("("+vars[i]+")"));
	}
	return str;
}

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };

// Load handlers init
if(document.addEventListener  && !window.opera &&
  !(!document.all && document.childNodes && !navigator.taintEnabled)){
	document.addEventListener('DOMContentLoaded', AjaxToolkit.onLoad, null);
}
else{
	window.attachEvent('onload', AjaxToolkit.onLoad);
}

new function() {
	var b = navigator.userAgent.toLowerCase();
	// Figure out what browser is being used
	AjaxToolkit.browser = {
		safari: /webkit/.test(b),
		opera: /opera/.test(b),
		msie: /msie/.test(b) && !/opera/.test(b),
		mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
	};

	// Check to see if the W3C box model is being used
	AjaxToolkit.boxModel = !AjaxToolkit.browser.msie || document.compatMode == "CSS1Compat";
};