		var u = {
			hide: function() {
				return this.setVisibility(arguments, false);
			},
			reveal: function() {
				return this.setVisibility(arguments, true);
			},
			setVisibility: function(aArgs, bVisible) {
				for (i=0; i<aArgs.length; i++) {
					if (bVisible == false)
						$(aArgs[i]).addClass('invisible');
					else
						$(aArgs[i]).removeClass('invisible');
				}
				return ((aArgs.length == 1) ? $(aArgs[0]) : aArgs);
			},
         fixImg: function(oImg) {
		      if (oImg.src.indexOf(".png") >= 0) {
		         oImg.setStyle('filter', 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + oImg.src + '\', sizingMethod=\'scale\')');
		         oImg.src = '/images/t.gif';
		      }
			},


			// Please Wait...
			wait: function() {
				this.reveal($('wait'));
			},
			// Thanks for being patient
			resume: function() {
				this.hide($('wait'));
			},


			// Turning DL's into accordions
			createAccordions: function() {
				$$('dl.accordion').each(
					function(el) {
						new AccorDL(el);
					}, this
				);
			},


			// Form JSONizer
			// Tries to submit the form using JSON request if possible
			jsonForm: function(oForm) {
				if ($defined(editor))
					var elementUrl = location.href.substr(0,location.href.indexOf('?')) + '?id=' + editor.themeId + '&' + ((editor.elementName != '') ? ('element=' + editor.elementName) : ('group=' + editor.groupName));
				var formMethod = ($defined(oForm.getProperty('method'))) ? oForm.getProperty('method').toLowerCase() : 'get';
				var formAction = ((oForm.getProperty('action') != '') ? oForm.getProperty('action') : (($defined(elementUrl)) ? elementUrl : location.href));

				// Building a JSON formatted string for further conversion into object
				var jsonString = '{';

				// Converting form elements into JSON object properties
				for (i=0;i<oForm.elements.length;i++) {
					var value = '';

					if (oForm.elements[i].type == 'checkbox') {
						value = (oForm.elements[i].checked) ? '1' : '0';
					}
					else if (oForm.elements[i].type == 'radio' && oForm.elements[i].checked != true)
						continue;
					else if (oForm.elements[i].type == 'file') {
						// If the form contains 'file' field, it can't be sent as JSON object
						return true;
					}
					else
						value = oForm.elements[i].value;
					jsonString += ((i == 0) ? '' : ',') + '"' + oForm.elements[i].name + '":"' + value + '"';
				}
				jsonString += '}';

				// Well, if there are no problems with this form...
				if ($defined(arguments[1]))
					arguments[1] = new Event(arguments[1]).stop();

				// Peeeeeoooooow!
				return this.json(formAction, formMethod, Json.evaluate(jsonString), this.jsonCallBack);
			},


			// Link JSONizer
			// Sends JSON request instead of following the link
			jsonLink: function(oLink) {
				// Where to send the stuff to
				var linkTarget = oLink.href;

				// Gallery links need special care
				if ($defined(editor) && oLink.hasClass('galleryLink')) {
					if (linkTarget.indexOf('element=') >= 0 || linkTarget.indexOf('group=') >= 0) {
						var urlParts = linkTarget.split('?');
						var qString = urlParts[1].split('&');
						linkTarget = urlParts[0];
						for (i = 0; i < qString.length; i++) {
							if (qString[i].indexOf('element=') < 0 && qString[i].indexOf('group=') < 0)
								linkTarget += ((linkTarget.indexOf('?') >= 0) ? '&' : '?') + qString[i];
						}
					}
					linkTarget += ((linkTarget.indexOf('?') >= 0) ? '&' : '?') + ((editor.elementName == null || editor.elementName == '') ? ((editor.groupName == null || editor.groupName == '') ? '' : ('group=' + editor.groupName)) : ('element=' + editor.elementName));
					editor.gallery.action = linkTarget;
				}

				// Peeeeeoooooow!
				return this.json(linkTarget, 'get', {'gimmeStuff': true}, this.jsonCallBack);
			},


			// Quick method for JSON data interchange
			json: function (sUrl, sMethod, oData, fCallBack) {
				u.wait();
				// Sending the request...
				new Json.Remote(
					sUrl, {
						method: sMethod,
						onComplete: function(jsonObj) {
							// And getting the answer...
							fCallBack(jsonObj);
							u.resume();
							return true;
						}.bind(this),
						onFailure: function() {
							// Or not getting...
							u.resume();
							return false;
						}.bind(this)

					}
				).send(oData);
			},

			// Default callback function for JSONizers
			jsonCallBack: function(jsonObj) {
				// do nothing
			},
/*
			multiSelect: {
				castOn: function(oSelect) {
					oSelect.currentOptions = new Array();
					oSelect.current = new Number();
					oSelect.addEvent('change', u.multiSelect.setSelection);
				},
				setSelection: function(e) {
					this.current = this.selectedIndex;
					for (var i=0; i<this.currentOptions.length; i++) {
						if (this.current == this.currentOptions[i]) {
							this.currentOptions.splice(i, 1);
							break;
						}
					}
					if (i >= this.currentOptions.length) 
						this.currentOptions.push(this.current);

					this.blur();

					for (var i=0; i<this.options.length; i++)
						this.options[i].selected = (this.currentOptions.contains(i)) ? true : false;
				}
			},
*/
			// Flashlighting element and scrolling to it
			flashLight: function(sElement, bFollow) {
				oElement = $(sElement);
				if (bFollow == true) {
					if (window.opera) {
						location.href = "#" + sElement;
						return;
					}
					this.scroll.toElement(oElement);
					iDuration = 300;
				}
				else 
					iDuration = 600;
				var initialValue = oElement.getStyle('background-color'); initialValue = (initialValue.substr(0,1) == '#') ? initialValue : '#fff';
				new Fx.Styles(oElement, {'duration': iDuration})
					.start({'background-color': '#ff8'})
					.chain(function(){
						this.start({'background-color': initialValue});
					});
			},
			// Select the contents of input
			setSelection: function(oInput, iStart, iEnd) {
				if (window.opera) {
					oInput.focus();
				}
				else {
					if (oInput.createTextRange) {
						var range = oInput.createTextRange();
						range.collapse(true);
						range.moveEnd('character', iEnd);
						range.moveStart('character', iStart);
						range.select();
					}
					else if (oInput.setSelectionRange) {
						oInput.focus();
						oInput.setSelectionRange(iStart, iEnd);
					}
				}
			},
			// Smooth window scrolling
			scroll: new Fx.Scroll(window, {
				'duration': 300
			}),
			alert: function(s) {
				if ($('alerts')) {
					new Element('br').inject($('alerts'));
					$('alerts').appendText(s);
				}
				else {
					new Element('div',{'id': 'alerts', 'styles':{'background': '#fea', 'color': '#000', 'padding': 5, 'opacity': .8, 'position': 'absolute', 'top': 0, 'left': 0}}).setHTML(s).inject($E('body'));
				}
			}
		};

		Array.prototype.max = function() {
			var result = new Number();
			for (i = 0; i < this.length; i++) {
				result = Math.max(this[i].toInt(),result);
			}
			return result;
		};
		Array.prototype.min = function() {
			var result = new Number();
			for (i = 0; i < this.length; i++) {
				result = Math.min(this[i].toInt(),result);
			}
			return result;
		};
