diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/components/common/CallbackManager.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/components/common/CallbackManager.js
new file mode 100644
index 0000000000000000000000000000000000000000..d96c5ae8f629429a44bbe1d5483cd2249ae2da6c
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/components/common/CallbackManager.js
@@ -0,0 +1,40 @@
+define([ "jquery" ], function($) {
+
+	//
+	// CALLBACK MANAGER
+	//
+
+	function CallbackManager(callback) {
+		this.init(callback);
+	}
+
+	$.extend(CallbackManager.prototype, {
+
+		init : function(callback) {
+			this.callback = callback;
+			this.callbacks = {};
+		},
+
+		registerCallback : function(callback) {
+			var manager = this;
+
+			var wrapper = function() {
+				callback.apply(this, arguments);
+
+				delete manager.callbacks[callback]
+
+				for (c in manager.callbacks) {
+					return;
+				}
+
+				manager.callback();
+			}
+
+			this.callbacks[callback] = callback;
+			return wrapper;
+		}
+	});
+
+	return CallbackManager;
+
+});
\ No newline at end of file
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/components/common/ListenerManager.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/components/common/ListenerManager.js
new file mode 100644
index 0000000000000000000000000000000000000000..f1c2cb5631f49ecf5ad907d807491883e199e4f4
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/components/common/ListenerManager.js
@@ -0,0 +1,35 @@
+define([ "jquery" ], function($) {
+
+	//
+	// LISTENER MANAGER
+	//
+
+	function ListenerManager() {
+		this.init();
+	}
+
+	$.extend(ListenerManager.prototype, {
+
+		init : function() {
+			this.listeners = {};
+		},
+
+		addListener : function(eventType, listener) {
+			if (!this.listeners[eventType]) {
+				this.listeners[eventType] = []
+			}
+			this.listeners[eventType].push(listener);
+		},
+
+		notifyListeners : function(eventType) {
+			if (this.listeners[eventType]) {
+				this.listeners[eventType].forEach(function(listener) {
+					listener();
+				});
+			}
+		}
+	});
+
+	return ListenerManager;
+
+});
\ No newline at end of file
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/config.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/config.js
new file mode 100644
index 0000000000000000000000000000000000000000..e779526e9e7da97c59957778a89e0c60af08152f
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/config.js
@@ -0,0 +1,20 @@
+var require = {
+	baseUrl : "/openbis-test-screening/resources",
+	paths : {
+		"jquery" : "js/jquery",
+		"openbis" : "js/openbis",
+		"openbis-screening" : "js/openbis-screening",
+		"bootstrap" : "lib/bootstrap/js/bootstrap.min",
+		"bootstrap-slider" : "lib/bootstrap-slider/js/bootstrap-slider.min"
+	},
+	shim : {
+		"openbis" : {
+			deps : [ "jquery" ],
+			exports : "openbis"
+		},
+		"openbis-screening" : {
+			deps : [ "openbis" ],
+			exports : "openbis"
+		}
+	}
+}
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap-slider/css/bootstrap-slider.css b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap-slider/css/bootstrap-slider.css
similarity index 100%
rename from screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap-slider/css/bootstrap-slider.css
rename to openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap-slider/css/bootstrap-slider.css
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap-slider/css/bootstrap-slider.min.css b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap-slider/css/bootstrap-slider.min.css
similarity index 100%
rename from screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap-slider/css/bootstrap-slider.min.css
rename to openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap-slider/css/bootstrap-slider.min.css
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap-slider/js/bootstrap-slider.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap-slider/js/bootstrap-slider.js
new file mode 100644
index 0000000000000000000000000000000000000000..06cc433791cc7c41e4543db8967b10831a32016e
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap-slider/js/bootstrap-slider.js
@@ -0,0 +1,729 @@
+/* =========================================================
+ * bootstrap-slider.js v3.0.0
+ * http://www.eyecon.ro/bootstrap-slider
+ * =========================================================
+ * Copyright 2012 Stefan Petre
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================= */
+ 
+(function( $ ) {
+
+	var ErrorMsgs = {
+		formatInvalidInputErrorMsg : function(input) {
+			return "Invalid input value '" + input + "' passed in";
+		},
+		callingContextNotSliderInstance : "Calling context element does not have instance of Slider bound to it. Check your code to make sure the JQuery object returned from the call to the slider() initializer is calling the method"
+	};
+
+	var Slider = function(element, options) {
+		var el = this.element = $(element).hide();
+		var origWidth =  $(element)[0].style.width;
+
+		var updateSlider = false;
+		var parent = this.element.parent();
+
+
+		if (parent.hasClass('slider') === true) {
+			updateSlider = true;
+			this.picker = parent;
+		} else {
+			this.picker = $('<div class="slider">'+
+								'<div class="slider-track">'+
+									'<div class="slider-selection"></div>'+
+									'<div class="slider-handle"></div>'+
+									'<div class="slider-handle"></div>'+
+								'</div>'+
+								'<div id="tooltip" class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'+
+								'<div id="tooltip_min" class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'+
+								'<div id="tooltip_max" class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'+
+							'</div>')
+								.insertBefore(this.element)
+								.append(this.element);
+		}
+
+		this.id = this.element.data('slider-id')||options.id;
+		if (this.id) {
+			this.picker[0].id = this.id;
+		}
+
+		if (typeof Modernizr !== 'undefined' && Modernizr.touch) {
+			this.touchCapable = true;
+		}
+
+		var tooltip = this.element.data('slider-tooltip')||options.tooltip;
+
+		this.tooltip = this.picker.find('#tooltip');
+		this.tooltipInner = this.tooltip.find('div.tooltip-inner');
+
+		this.tooltip_min = this.picker.find('#tooltip_min');
+		this.tooltipInner_min = this.tooltip_min.find('div.tooltip-inner');
+
+		this.tooltip_max = this.picker.find('#tooltip_max');
+		this.tooltipInner_max= this.tooltip_max.find('div.tooltip-inner');
+
+		if (updateSlider === true) {
+			// Reset classes
+			this.picker.removeClass('slider-horizontal');
+			this.picker.removeClass('slider-vertical');
+			this.tooltip.removeClass('hide');
+			this.tooltip_min.removeClass('hide');
+			this.tooltip_max.removeClass('hide');
+
+		}
+
+		this.orientation = this.element.data('slider-orientation')||options.orientation;
+		switch(this.orientation) {
+			case 'vertical':
+				this.picker.addClass('slider-vertical');
+				this.stylePos = 'top';
+				this.mousePos = 'pageY';
+				this.sizePos = 'offsetHeight';
+				this.tooltip.addClass('right')[0].style.left = '100%';
+				this.tooltip_min.addClass('right')[0].style.left = '100%';
+				this.tooltip_max.addClass('right')[0].style.left = '100%';
+				break;
+			default:
+				this.picker
+					.addClass('slider-horizontal')
+					.css('width', origWidth);
+				this.orientation = 'horizontal';
+				this.stylePos = 'left';
+				this.mousePos = 'pageX';
+				this.sizePos = 'offsetWidth';
+				this.tooltip.addClass('top')[0].style.top = -this.tooltip.outerHeight() - 14 + 'px';
+				this.tooltip_min.addClass('top')[0].style.top = -this.tooltip_min.outerHeight() - 14 + 'px';
+				this.tooltip_max.addClass('top')[0].style.top = -this.tooltip_max.outerHeight() - 14 + 'px';
+				break;
+		}
+
+		var self = this;
+		$.each(['min', 'max', 'step', 'value'], function(i, attr) {
+			if (typeof el.data('slider-' + attr) !== 'undefined') {
+				self[attr] = el.data('slider-' + attr);
+			} else if (typeof options[attr] !== 'undefined') {
+				self[attr] = options[attr];
+			} else if (typeof el.prop(attr) !== 'undefined') {
+				self[attr] = el.prop(attr);
+			} else {
+				self[attr] = 0; // to prevent empty string issues in calculations in IE
+			}
+		});
+
+		if (this.value instanceof Array) {
+			if (updateSlider && !this.range) {
+				this.value = this.value[0];
+			} else {
+				this.range = true;
+			}
+		} else if (this.range) {
+			// User wants a range, but value is not an array
+			this.value = [this.value, this.max];
+		}
+
+		this.selection = this.element.data('slider-selection')||options.selection;
+		this.selectionEl = this.picker.find('.slider-selection');
+		if (this.selection === 'none') {
+			this.selectionEl.addClass('hide');
+		}
+
+		this.selectionElStyle = this.selectionEl[0].style;
+
+		this.handle1 = this.picker.find('.slider-handle:first');
+		this.handle1Stype = this.handle1[0].style;
+
+		this.handle2 = this.picker.find('.slider-handle:last');
+		this.handle2Stype = this.handle2[0].style;
+
+		if (updateSlider === true) {
+			// Reset classes
+			this.handle1.removeClass('round triangle');
+			this.handle2.removeClass('round triangle hide');
+		}
+
+		var handle = this.element.data('slider-handle')||options.handle;
+		switch(handle) {
+			case 'round':
+				this.handle1.addClass('round');
+				this.handle2.addClass('round');
+				break;
+			case 'triangle':
+				this.handle1.addClass('triangle');
+				this.handle2.addClass('triangle');
+				break;
+		}
+
+		if (this.range) {
+			this.value[0] = Math.max(this.min, Math.min(this.max, this.value[0]));
+			this.value[1] = Math.max(this.min, Math.min(this.max, this.value[1]));
+		} else {
+			this.value = [ Math.max(this.min, Math.min(this.max, this.value))];
+			this.handle2.addClass('hide');
+			if (this.selection === 'after') {
+				this.value[1] = this.max;
+			} else {
+				this.value[1] = this.min;
+			}
+		}
+		this.diff = this.max - this.min;
+		this.percentage = [
+			(this.value[0]-this.min)*100/this.diff,
+			(this.value[1]-this.min)*100/this.diff,
+			this.step*100/this.diff
+		];
+
+		this.offset = this.picker.offset();
+		this.size = this.picker[0][this.sizePos];
+
+		this.formater = options.formater;
+		this.tooltip_separator = options.tooltip_separator;
+		this.tooltip_split = options.tooltip_split;
+
+		this.reversed = this.element.data('slider-reversed')||options.reversed;
+
+		this.layout();
+        this.layout();
+
+		this.handle1.on({
+			keydown: $.proxy(this.keydown, this, 0)
+		});
+
+		this.handle2.on({
+			keydown: $.proxy(this.keydown, this, 1)
+		});
+
+		if (this.touchCapable) {
+			// Touch: Bind touch events:
+			this.picker.on({
+				touchstart: $.proxy(this.mousedown, this)
+			});
+		} else {
+			this.picker.on({
+				mousedown: $.proxy(this.mousedown, this)
+			});
+		}
+
+		if(tooltip === 'hide') {
+			this.tooltip.addClass('hide');
+			this.tooltip_min.addClass('hide');
+			this.tooltip_max.addClass('hide');
+		} else if(tooltip === 'always') {
+			this.showTooltip();
+			this.alwaysShowTooltip = true;
+		} else {
+			this.picker.on({
+				mouseenter: $.proxy(this.showTooltip, this),
+				mouseleave: $.proxy(this.hideTooltip, this)
+			});
+			this.handle1.on({
+				focus: $.proxy(this.showTooltip, this),
+				blur: $.proxy(this.hideTooltip, this)
+			});
+			this.handle2.on({
+				focus: $.proxy(this.showTooltip, this),
+				blur: $.proxy(this.hideTooltip, this)
+			});
+		}
+
+		this.enabled = options.enabled && 
+						(this.element.data('slider-enabled') === undefined || this.element.data('slider-enabled') === true);
+		if(this.enabled) {
+			this.enable();
+		} else {
+			this.disable();
+		}
+	};
+
+	Slider.prototype = {
+		constructor: Slider,
+
+		over: false,
+		inDrag: false,
+		
+		showTooltip: function(){
+            if (this.tooltip_split === false ){
+                this.tooltip.addClass('in');
+            } else {
+                this.tooltip_min.addClass('in');
+                this.tooltip_max.addClass('in');
+            }
+
+			this.over = true;
+		},
+		
+		hideTooltip: function(){
+			if (this.inDrag === false && this.alwaysShowTooltip !== true) {
+				this.tooltip.removeClass('in');
+				this.tooltip_min.removeClass('in');
+				this.tooltip_max.removeClass('in');
+			}
+			this.over = false;
+		},
+
+		layout: function(){
+			var positionPercentages;
+
+			if(this.reversed) {
+				positionPercentages = [ 100 - this.percentage[0], this.percentage[1] ];
+			} else {
+				positionPercentages = [ this.percentage[0], this.percentage[1] ];
+			}
+
+			this.handle1Stype[this.stylePos] = positionPercentages[0]+'%';
+			this.handle2Stype[this.stylePos] = positionPercentages[1]+'%';
+
+			if (this.orientation === 'vertical') {
+				this.selectionElStyle.top = Math.min(positionPercentages[0], positionPercentages[1]) +'%';
+				this.selectionElStyle.height = Math.abs(positionPercentages[0] - positionPercentages[1]) +'%';
+			} else {
+				this.selectionElStyle.left = Math.min(positionPercentages[0], positionPercentages[1]) +'%';
+				this.selectionElStyle.width = Math.abs(positionPercentages[0] - positionPercentages[1]) +'%';
+
+                var offset_min = this.tooltip_min[0].getBoundingClientRect();
+                var offset_max = this.tooltip_max[0].getBoundingClientRect();
+
+                if (offset_min.right > offset_max.left) {
+                    this.tooltip_max.removeClass('top');
+                    this.tooltip_max.addClass('bottom')[0].style.top = 18 + 'px';
+                } else {
+                    this.tooltip_max.removeClass('bottom');
+                    this.tooltip_max.addClass('top')[0].style.top = -30 + 'px';
+                }
+			}
+
+			if (this.range) {
+				this.tooltipInner.text(
+					this.formater(this.value[0]) + this.tooltip_separator + this.formater(this.value[1])
+				);
+				this.tooltip[0].style[this.stylePos] = this.size * (positionPercentages[0] + (positionPercentages[1] - positionPercentages[0])/2)/100 - (this.orientation === 'vertical' ? this.tooltip.outerHeight()/2 : this.tooltip.outerWidth()/2) +'px';
+
+                this.tooltipInner_min.text(
+					this.formater(this.value[0])
+				);
+                this.tooltipInner_max.text(
+					this.formater(this.value[1])
+				);
+
+				this.tooltip_min[0].style[this.stylePos] = this.size * ( (positionPercentages[0])/100) - (this.orientation === 'vertical' ? this.tooltip_min.outerHeight()/2 : this.tooltip_min.outerWidth()/2) +'px';
+				this.tooltip_max[0].style[this.stylePos] = this.size * ( (positionPercentages[1])/100) - (this.orientation === 'vertical' ? this.tooltip_max.outerHeight()/2 : this.tooltip_max.outerWidth()/2) +'px';
+
+			} else {
+				this.tooltipInner.text(
+					this.formater(this.value[0])
+				);
+				this.tooltip[0].style[this.stylePos] = this.size * positionPercentages[0]/100 - (this.orientation === 'vertical' ? this.tooltip.outerHeight()/2 : this.tooltip.outerWidth()/2) +'px';
+			}
+		},
+
+		mousedown: function(ev) {
+			if(!this.isEnabled()) {
+				return false;
+			}
+			// Touch: Get the original event:
+			if (this.touchCapable && ev.type === 'touchstart') {
+				ev = ev.originalEvent;
+			}
+
+			this.triggerFocusOnHandle();
+
+			this.offset = this.picker.offset();
+			this.size = this.picker[0][this.sizePos];
+
+			var percentage = this.getPercentage(ev);
+
+			if (this.range) {
+				var diff1 = Math.abs(this.percentage[0] - percentage);
+				var diff2 = Math.abs(this.percentage[1] - percentage);
+				this.dragged = (diff1 < diff2) ? 0 : 1;
+			} else {
+				this.dragged = 0;
+			}
+
+			this.percentage[this.dragged] = this.reversed ? 100 - percentage : percentage;
+			this.layout();
+
+			if (this.touchCapable) {
+				// Touch: Bind touch events:
+				$(document).on({
+					touchmove: $.proxy(this.mousemove, this),
+					touchend: $.proxy(this.mouseup, this)
+				});
+			} else {
+				$(document).on({
+					mousemove: $.proxy(this.mousemove, this),
+					mouseup: $.proxy(this.mouseup, this)
+				});
+			}
+
+			this.inDrag = true;
+			var val = this.calculateValue();
+			this.setValue(val);
+			this.element.trigger({
+					type: 'slideStart',
+					value: val
+				}).trigger({
+					type: 'slide',
+					value: val
+				});
+			return true;
+		},
+
+		triggerFocusOnHandle: function(handleIdx) {
+			if(handleIdx === 0) {
+				this.handle1.focus();
+			} 
+			if(handleIdx === 1) {
+				this.handle2.focus();
+			}
+		},
+
+		keydown: function(handleIdx, ev) {
+			if(!this.isEnabled()) {
+				return false;
+			}
+
+			var dir;
+			switch (ev.which) {
+				case 37: // left
+				case 40: // down
+					dir = -1;
+					break;
+				case 39: // right
+				case 38: // up
+					dir = 1;
+					break;
+			}
+			if (!dir) {
+				return;
+			}
+
+			var oneStepValuePercentageChange = dir * this.percentage[2];
+			var percentage = this.percentage[handleIdx] + oneStepValuePercentageChange;
+
+			if (percentage > 100) {
+				percentage = 100;
+			} else if (percentage < 0) {
+				percentage = 0;
+			}
+
+			this.dragged = handleIdx;
+			this.adjustPercentageForRangeSliders(percentage);
+			this.percentage[this.dragged] = percentage;
+			this.layout();
+
+			var val = this.calculateValue();
+			this.setValue(val);
+			this.element
+				.trigger({
+					type: 'slide',
+					value: val
+				})
+				.trigger({
+					type: 'slideStop',
+					value: val
+				})
+				.data('value', val)
+				.prop('value', val);
+			return false;
+		},
+
+		mousemove: function(ev) {
+			if(!this.isEnabled()) {
+				return false;
+			}
+			// Touch: Get the original event:
+			if (this.touchCapable && ev.type === 'touchmove') {
+				ev = ev.originalEvent;
+			}
+			
+			var percentage = this.getPercentage(ev);
+			this.adjustPercentageForRangeSliders(percentage);
+			this.percentage[this.dragged] = this.reversed ? 100 - percentage : percentage;
+			this.layout();
+
+			var val = this.calculateValue();
+			this.setValue(val);
+			this.element
+				.trigger({
+					type: 'slide',
+					value: val
+				})
+				.data('value', val)
+				.prop('value', val);
+			return false;
+		},
+
+		adjustPercentageForRangeSliders: function(percentage) {
+			if (this.range) {
+				if (this.dragged === 0 && this.percentage[1] < percentage) {
+					this.percentage[0] = this.percentage[1];
+					this.dragged = 1;
+				} else if (this.dragged === 1 && this.percentage[0] > percentage) {
+					this.percentage[1] = this.percentage[0];
+					this.dragged = 0;
+				}
+			}
+		},
+
+		mouseup: function() {
+			if(!this.isEnabled()) {
+				return false;
+			}
+			if (this.touchCapable) {
+				// Touch: Bind touch events:
+				$(document).off({
+					touchmove: this.mousemove,
+					touchend: this.mouseup
+				});
+			} else {
+				$(document).off({
+					mousemove: this.mousemove,
+					mouseup: this.mouseup
+				});
+			}
+
+			this.inDrag = false;
+			if (this.over === false) {
+				this.hideTooltip();
+			}
+			var val = this.calculateValue();
+			this.layout();
+			this.element
+				.data('value', val)
+				.prop('value', val)
+				.trigger({
+					type: 'slideStop',
+					value: val
+				});
+			return false;
+		},
+
+		calculateValue: function() {
+			var val;
+			if (this.range) {
+				val = [this.min,this.max];
+                if (this.percentage[0] !== 0){
+                    val[0] = (Math.max(this.min, this.min + Math.round((this.diff * this.percentage[0]/100)/this.step)*this.step));
+                }
+                if (this.percentage[1] !== 100){
+                    val[1] = (Math.min(this.max, this.min + Math.round((this.diff * this.percentage[1]/100)/this.step)*this.step));
+                }
+				this.value = val;
+			} else {
+				val = (this.min + Math.round((this.diff * this.percentage[0]/100)/this.step)*this.step);
+				if (val < this.min) {
+					val = this.min;
+				}
+				else if (val > this.max) {
+					val = this.max;
+				}
+				val = parseFloat(val);
+				this.value = [val, this.value[1]];
+			}
+			return val;
+		},
+
+		getPercentage: function(ev) {
+			if (this.touchCapable) {
+				ev = ev.touches[0];
+			}
+			var percentage = (ev[this.mousePos] - this.offset[this.stylePos])*100/this.size;
+			percentage = Math.round(percentage/this.percentage[2])*this.percentage[2];
+			return Math.max(0, Math.min(100, percentage));
+		},
+
+		getValue: function() {
+			if (this.range) {
+				return this.value;
+			}
+			return this.value[0];
+		},
+
+		setValue: function(val) {
+			this.value = this.validateInputValue(val);
+
+			if (this.range) {
+				this.value[0] = Math.max(this.min, Math.min(this.max, this.value[0]));
+				this.value[1] = Math.max(this.min, Math.min(this.max, this.value[1]));
+			} else {
+				this.value = [ Math.max(this.min, Math.min(this.max, this.value))];
+				this.handle2.addClass('hide');
+				if (this.selection === 'after') {
+					this.value[1] = this.max;
+				} else {
+					this.value[1] = this.min;
+				}
+			}
+			this.diff = this.max - this.min;
+			this.percentage = [
+				(this.value[0]-this.min)*100/this.diff,
+				(this.value[1]-this.min)*100/this.diff,
+				this.step*100/this.diff
+			];
+			this.layout();
+
+			this.element
+				.trigger({
+					'type': 'slide',
+					'value': this.value
+				})
+				.data('value', this.value)
+				.prop('value', this.value);
+		},
+
+		validateInputValue : function(val) {
+			if(typeof val === 'number') {
+				return val;
+			} else if(val instanceof Array) {
+				$.each(val, function(i, input) { if (typeof input !== 'number') { throw new Error( ErrorMsgs.formatInvalidInputErrorMsg(input) ); }});
+				return val;
+			} else {
+				throw new Error( ErrorMsgs.formatInvalidInputErrorMsg(val) );
+			}
+		},
+
+		destroy: function(){
+			this.handle1.off();
+			this.handle2.off();
+			this.element.off().show().insertBefore(this.picker);
+			this.picker.off().remove();
+			$(this.element).removeData('slider');
+		},
+
+		disable: function() {
+			this.enabled = false;
+			this.handle1.removeAttr("tabindex");
+			this.handle2.removeAttr("tabindex");
+			this.picker.addClass('slider-disabled');
+			this.element.trigger('slideDisabled');
+		},
+
+		enable: function() {
+			this.enabled = true;
+			this.handle1.attr("tabindex", 0);
+			this.handle2.attr("tabindex", 0);
+			this.picker.removeClass('slider-disabled');
+			this.element.trigger('slideEnabled');
+		},
+
+		toggle: function() {
+			if(this.enabled) {
+				this.disable();
+			} else {
+				this.enable();
+			}
+		},
+
+		isEnabled: function() {
+			return this.enabled;
+		},
+
+		setAttribute: function(attribute, value) {
+			this[attribute] = value;
+		},
+
+		getAttribute: function(attribute) {
+			return this[attribute];
+		}
+
+	};
+
+	var publicMethods = {
+		getValue : Slider.prototype.getValue,
+		setValue : Slider.prototype.setValue,
+		setAttribute : Slider.prototype.setAttribute,
+		getAttribute : Slider.prototype.getAttribute,
+		destroy : Slider.prototype.destroy,
+		disable : Slider.prototype.disable,
+		enable : Slider.prototype.enable,
+		toggle : Slider.prototype.toggle,
+		isEnabled: Slider.prototype.isEnabled
+	};
+
+	$.fn.slider = function (option) {
+		if (typeof option === 'string' && option !== 'refresh') {
+			var args = Array.prototype.slice.call(arguments, 1);
+			return invokePublicMethod.call(this, option, args);
+		} else {
+			return createNewSliderInstance.call(this, option);
+		}
+	};
+
+	function invokePublicMethod(methodName, args) {
+		if(publicMethods[methodName]) {
+			var sliderObject = retrieveSliderObjectFromElement(this);
+			var result = publicMethods[methodName].apply(sliderObject, args);
+
+			if (typeof result === "undefined") {
+				return $(this);
+			} else {
+				return result;
+			}
+		} else {
+			throw new Error("method '" + methodName + "()' does not exist for slider.");
+		}
+	}
+
+	function retrieveSliderObjectFromElement(element) {
+		var sliderObject = $(element).data('slider');
+		if(sliderObject && sliderObject instanceof Slider) {
+			return sliderObject;
+		} else {
+			throw new Error(ErrorMsgs.callingContextNotSliderInstance);
+		}
+	}
+
+	function createNewSliderInstance(opts) {
+		var $this = $(this);
+		$this.each(function() {
+			var $this = $(this),
+				slider = $this.data('slider'),
+				options = typeof opts === 'object' && opts;
+
+			// If slider already exists, use its attributes
+			// as options so slider refreshes properly
+			if (slider && !options) {
+				options = {};
+
+				$.each($.fn.slider.defaults, function(key) {
+					options[key] = slider[key];
+				});
+			}
+
+			$this.data('slider', (new Slider(this, $.extend({}, $.fn.slider.defaults, options))));
+		});
+		return $this;
+	}
+
+	$.fn.slider.defaults = {
+		min: 0,
+		max: 10,
+		step: 1,
+		orientation: 'horizontal',
+		value: 5,
+		range: false,
+		selection: 'before',
+		tooltip: 'show',
+        tooltip_separator: ':',
+        tooltip_split: false,
+		handle: 'round',
+		reversed : false,
+		enabled: true,
+		formater: function(value) {
+			return value;
+		}
+	};
+
+	$.fn.slider.Constructor = Slider;
+
+})( window.jQuery );
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap-slider/js/bootstrap-slider.min.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap-slider/js/bootstrap-slider.min.js
similarity index 100%
rename from screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap-slider/js/bootstrap-slider.min.js
rename to openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap-slider/js/bootstrap-slider.min.js
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/css/bootstrap-theme.css b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/css/bootstrap-theme.css
similarity index 100%
rename from screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/css/bootstrap-theme.css
rename to openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/css/bootstrap-theme.css
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/css/bootstrap-theme.css.map b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/css/bootstrap-theme.css.map
similarity index 100%
rename from screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/css/bootstrap-theme.css.map
rename to openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/css/bootstrap-theme.css.map
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/css/bootstrap-theme.min.css b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/css/bootstrap-theme.min.css
similarity index 100%
rename from screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/css/bootstrap-theme.min.css
rename to openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/css/bootstrap-theme.min.css
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/css/bootstrap.css b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/css/bootstrap.css
similarity index 100%
rename from screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/css/bootstrap.css
rename to openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/css/bootstrap.css
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/css/bootstrap.css.map b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/css/bootstrap.css.map
similarity index 100%
rename from screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/css/bootstrap.css.map
rename to openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/css/bootstrap.css.map
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/css/bootstrap.min.css b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/css/bootstrap.min.css
similarity index 100%
rename from screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/css/bootstrap.min.css
rename to openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/css/bootstrap.min.css
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/fonts/glyphicons-halflings-regular.eot b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/fonts/glyphicons-halflings-regular.eot
similarity index 100%
rename from screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/fonts/glyphicons-halflings-regular.eot
rename to openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/fonts/glyphicons-halflings-regular.eot
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/fonts/glyphicons-halflings-regular.svg b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/fonts/glyphicons-halflings-regular.svg
similarity index 100%
rename from screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/fonts/glyphicons-halflings-regular.svg
rename to openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/fonts/glyphicons-halflings-regular.svg
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/fonts/glyphicons-halflings-regular.ttf b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/fonts/glyphicons-halflings-regular.ttf
similarity index 100%
rename from screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/fonts/glyphicons-halflings-regular.ttf
rename to openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/fonts/glyphicons-halflings-regular.ttf
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/fonts/glyphicons-halflings-regular.woff b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/fonts/glyphicons-halflings-regular.woff
similarity index 100%
rename from screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/fonts/glyphicons-halflings-regular.woff
rename to openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/fonts/glyphicons-halflings-regular.woff
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/js/bootstrap.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/js/bootstrap.js
similarity index 100%
rename from screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/js/bootstrap.js
rename to openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/js/bootstrap.js
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/js/bootstrap.min.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/js/bootstrap.min.js
similarity index 100%
rename from screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/lib/bootstrap/js/bootstrap.min.js
rename to openbis/source/java/ch/systemsx/cisd/openbis/public/resources/lib/bootstrap/js/bootstrap.min.js
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/require.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/require.js
new file mode 100644
index 0000000000000000000000000000000000000000..24b061e620367919e822b8f2b8edfc2a6b03d0bc
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/require.js
@@ -0,0 +1,2068 @@
+/** vim: et:ts=4:sw=4:sts=4
+ * @license RequireJS 2.1.11 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
+ * Available via the MIT or new BSD license.
+ * see: http://github.com/jrburke/requirejs for details
+ */
+//Not using strict: uneven strict support in browsers, #392, and causes
+//problems with requirejs.exec()/transpiler plugins that may not be strict.
+/*jslint regexp: true, nomen: true, sloppy: true */
+/*global window, navigator, document, importScripts, setTimeout, opera */
+
+var requirejs, require, define;
+(function (global) {
+    var req, s, head, baseElement, dataMain, src,
+        interactiveScript, currentlyAddingScript, mainScript, subPath,
+        version = '2.1.11',
+        commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
+        cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
+        jsSuffixRegExp = /\.js$/,
+        currDirRegExp = /^\.\//,
+        op = Object.prototype,
+        ostring = op.toString,
+        hasOwn = op.hasOwnProperty,
+        ap = Array.prototype,
+        apsp = ap.splice,
+        isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document),
+        isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
+        //PS3 indicates loaded and complete, but need to wait for complete
+        //specifically. Sequence is 'loading', 'loaded', execution,
+        // then 'complete'. The UA check is unfortunate, but not sure how
+        //to feature test w/o causing perf issues.
+        readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?
+                      /^complete$/ : /^(complete|loaded)$/,
+        defContextName = '_',
+        //Oh the tragedy, detecting opera. See the usage of isOpera for reason.
+        isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]',
+        contexts = {},
+        cfg = {},
+        globalDefQueue = [],
+        useInteractive = false;
+
+    function isFunction(it) {
+        return ostring.call(it) === '[object Function]';
+    }
+
+    function isArray(it) {
+        return ostring.call(it) === '[object Array]';
+    }
+
+    /**
+     * Helper function for iterating over an array. If the func returns
+     * a true value, it will break out of the loop.
+     */
+    function each(ary, func) {
+        if (ary) {
+            var i;
+            for (i = 0; i < ary.length; i += 1) {
+                if (ary[i] && func(ary[i], i, ary)) {
+                    break;
+                }
+            }
+        }
+    }
+
+    /**
+     * Helper function for iterating over an array backwards. If the func
+     * returns a true value, it will break out of the loop.
+     */
+    function eachReverse(ary, func) {
+        if (ary) {
+            var i;
+            for (i = ary.length - 1; i > -1; i -= 1) {
+                if (ary[i] && func(ary[i], i, ary)) {
+                    break;
+                }
+            }
+        }
+    }
+
+    function hasProp(obj, prop) {
+        return hasOwn.call(obj, prop);
+    }
+
+    function getOwn(obj, prop) {
+        return hasProp(obj, prop) && obj[prop];
+    }
+
+    /**
+     * Cycles over properties in an object and calls a function for each
+     * property value. If the function returns a truthy value, then the
+     * iteration is stopped.
+     */
+    function eachProp(obj, func) {
+        var prop;
+        for (prop in obj) {
+            if (hasProp(obj, prop)) {
+                if (func(obj[prop], prop)) {
+                    break;
+                }
+            }
+        }
+    }
+
+    /**
+     * Simple function to mix in properties from source into target,
+     * but only if target does not already have a property of the same name.
+     */
+    function mixin(target, source, force, deepStringMixin) {
+        if (source) {
+            eachProp(source, function (value, prop) {
+                if (force || !hasProp(target, prop)) {
+                    if (deepStringMixin && typeof value === 'object' && value &&
+                        !isArray(value) && !isFunction(value) &&
+                        !(value instanceof RegExp)) {
+
+                        if (!target[prop]) {
+                            target[prop] = {};
+                        }
+                        mixin(target[prop], value, force, deepStringMixin);
+                    } else {
+                        target[prop] = value;
+                    }
+                }
+            });
+        }
+        return target;
+    }
+
+    //Similar to Function.prototype.bind, but the 'this' object is specified
+    //first, since it is easier to read/figure out what 'this' will be.
+    function bind(obj, fn) {
+        return function () {
+            return fn.apply(obj, arguments);
+        };
+    }
+
+    function scripts() {
+        return document.getElementsByTagName('script');
+    }
+
+    function defaultOnError(err) {
+        throw err;
+    }
+
+    //Allow getting a global that is expressed in
+    //dot notation, like 'a.b.c'.
+    function getGlobal(value) {
+        if (!value) {
+            return value;
+        }
+        var g = global;
+        each(value.split('.'), function (part) {
+            g = g[part];
+        });
+        return g;
+    }
+
+    /**
+     * Constructs an error with a pointer to an URL with more information.
+     * @param {String} id the error ID that maps to an ID on a web page.
+     * @param {String} message human readable error.
+     * @param {Error} [err] the original error, if there is one.
+     *
+     * @returns {Error}
+     */
+    function makeError(id, msg, err, requireModules) {
+        var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id);
+        e.requireType = id;
+        e.requireModules = requireModules;
+        if (err) {
+            e.originalError = err;
+        }
+        return e;
+    }
+
+    if (typeof define !== 'undefined') {
+        //If a define is already in play via another AMD loader,
+        //do not overwrite.
+        return;
+    }
+
+    if (typeof requirejs !== 'undefined') {
+        if (isFunction(requirejs)) {
+            //Do not overwrite and existing requirejs instance.
+            return;
+        }
+        cfg = requirejs;
+        requirejs = undefined;
+    }
+
+    //Allow for a require config object
+    if (typeof require !== 'undefined' && !isFunction(require)) {
+        //assume it is a config object.
+        cfg = require;
+        require = undefined;
+    }
+
+    function newContext(contextName) {
+        var inCheckLoaded, Module, context, handlers,
+            checkLoadedTimeoutId,
+            config = {
+                //Defaults. Do not set a default for map
+                //config to speed up normalize(), which
+                //will run faster if there is no default.
+                waitSeconds: 7,
+                baseUrl: './',
+                paths: {},
+                bundles: {},
+                pkgs: {},
+                shim: {},
+                config: {}
+            },
+            registry = {},
+            //registry of just enabled modules, to speed
+            //cycle breaking code when lots of modules
+            //are registered, but not activated.
+            enabledRegistry = {},
+            undefEvents = {},
+            defQueue = [],
+            defined = {},
+            urlFetched = {},
+            bundlesMap = {},
+            requireCounter = 1,
+            unnormalizedCounter = 1;
+
+        /**
+         * Trims the . and .. from an array of path segments.
+         * It will keep a leading path segment if a .. will become
+         * the first path segment, to help with module name lookups,
+         * which act like paths, but can be remapped. But the end result,
+         * all paths that use this function should look normalized.
+         * NOTE: this method MODIFIES the input array.
+         * @param {Array} ary the array of path segments.
+         */
+        function trimDots(ary) {
+            var i, part, length = ary.length;
+            for (i = 0; i < length; i++) {
+                part = ary[i];
+                if (part === '.') {
+                    ary.splice(i, 1);
+                    i -= 1;
+                } else if (part === '..') {
+                    if (i === 1 && (ary[2] === '..' || ary[0] === '..')) {
+                        //End of the line. Keep at least one non-dot
+                        //path segment at the front so it can be mapped
+                        //correctly to disk. Otherwise, there is likely
+                        //no path mapping for a path starting with '..'.
+                        //This can still fail, but catches the most reasonable
+                        //uses of ..
+                        break;
+                    } else if (i > 0) {
+                        ary.splice(i - 1, 2);
+                        i -= 2;
+                    }
+                }
+            }
+        }
+
+        /**
+         * Given a relative module name, like ./something, normalize it to
+         * a real name that can be mapped to a path.
+         * @param {String} name the relative name
+         * @param {String} baseName a real name that the name arg is relative
+         * to.
+         * @param {Boolean} applyMap apply the map config to the value. Should
+         * only be done if this normalization is for a dependency ID.
+         * @returns {String} normalized name
+         */
+        function normalize(name, baseName, applyMap) {
+            var pkgMain, mapValue, nameParts, i, j, nameSegment, lastIndex,
+                foundMap, foundI, foundStarMap, starI,
+                baseParts = baseName && baseName.split('/'),
+                normalizedBaseParts = baseParts,
+                map = config.map,
+                starMap = map && map['*'];
+
+            //Adjust any relative paths.
+            if (name && name.charAt(0) === '.') {
+                //If have a base name, try to normalize against it,
+                //otherwise, assume it is a top-level require that will
+                //be relative to baseUrl in the end.
+                if (baseName) {
+                    //Convert baseName to array, and lop off the last part,
+                    //so that . matches that 'directory' and not name of the baseName's
+                    //module. For instance, baseName of 'one/two/three', maps to
+                    //'one/two/three.js', but we want the directory, 'one/two' for
+                    //this normalization.
+                    normalizedBaseParts = baseParts.slice(0, baseParts.length - 1);
+                    name = name.split('/');
+                    lastIndex = name.length - 1;
+
+                    // If wanting node ID compatibility, strip .js from end
+                    // of IDs. Have to do this here, and not in nameToUrl
+                    // because node allows either .js or non .js to map
+                    // to same file.
+                    if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) {
+                        name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, '');
+                    }
+
+                    name = normalizedBaseParts.concat(name);
+                    trimDots(name);
+                    name = name.join('/');
+                } else if (name.indexOf('./') === 0) {
+                    // No baseName, so this is ID is resolved relative
+                    // to baseUrl, pull off the leading dot.
+                    name = name.substring(2);
+                }
+            }
+
+            //Apply map config if available.
+            if (applyMap && map && (baseParts || starMap)) {
+                nameParts = name.split('/');
+
+                outerLoop: for (i = nameParts.length; i > 0; i -= 1) {
+                    nameSegment = nameParts.slice(0, i).join('/');
+
+                    if (baseParts) {
+                        //Find the longest baseName segment match in the config.
+                        //So, do joins on the biggest to smallest lengths of baseParts.
+                        for (j = baseParts.length; j > 0; j -= 1) {
+                            mapValue = getOwn(map, baseParts.slice(0, j).join('/'));
+
+                            //baseName segment has config, find if it has one for
+                            //this name.
+                            if (mapValue) {
+                                mapValue = getOwn(mapValue, nameSegment);
+                                if (mapValue) {
+                                    //Match, update name to the new value.
+                                    foundMap = mapValue;
+                                    foundI = i;
+                                    break outerLoop;
+                                }
+                            }
+                        }
+                    }
+
+                    //Check for a star map match, but just hold on to it,
+                    //if there is a shorter segment match later in a matching
+                    //config, then favor over this star map.
+                    if (!foundStarMap && starMap && getOwn(starMap, nameSegment)) {
+                        foundStarMap = getOwn(starMap, nameSegment);
+                        starI = i;
+                    }
+                }
+
+                if (!foundMap && foundStarMap) {
+                    foundMap = foundStarMap;
+                    foundI = starI;
+                }
+
+                if (foundMap) {
+                    nameParts.splice(0, foundI, foundMap);
+                    name = nameParts.join('/');
+                }
+            }
+
+            // If the name points to a package's name, use
+            // the package main instead.
+            pkgMain = getOwn(config.pkgs, name);
+
+            return pkgMain ? pkgMain : name;
+        }
+
+        function removeScript(name) {
+            if (isBrowser) {
+                each(scripts(), function (scriptNode) {
+                    if (scriptNode.getAttribute('data-requiremodule') === name &&
+                            scriptNode.getAttribute('data-requirecontext') === context.contextName) {
+                        scriptNode.parentNode.removeChild(scriptNode);
+                        return true;
+                    }
+                });
+            }
+        }
+
+        function hasPathFallback(id) {
+            var pathConfig = getOwn(config.paths, id);
+            if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {
+                //Pop off the first array value, since it failed, and
+                //retry
+                pathConfig.shift();
+                context.require.undef(id);
+                context.require([id]);
+                return true;
+            }
+        }
+
+        //Turns a plugin!resource to [plugin, resource]
+        //with the plugin being undefined if the name
+        //did not have a plugin prefix.
+        function splitPrefix(name) {
+            var prefix,
+                index = name ? name.indexOf('!') : -1;
+            if (index > -1) {
+                prefix = name.substring(0, index);
+                name = name.substring(index + 1, name.length);
+            }
+            return [prefix, name];
+        }
+
+        /**
+         * Creates a module mapping that includes plugin prefix, module
+         * name, and path. If parentModuleMap is provided it will
+         * also normalize the name via require.normalize()
+         *
+         * @param {String} name the module name
+         * @param {String} [parentModuleMap] parent module map
+         * for the module name, used to resolve relative names.
+         * @param {Boolean} isNormalized: is the ID already normalized.
+         * This is true if this call is done for a define() module ID.
+         * @param {Boolean} applyMap: apply the map config to the ID.
+         * Should only be true if this map is for a dependency.
+         *
+         * @returns {Object}
+         */
+        function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {
+            var url, pluginModule, suffix, nameParts,
+                prefix = null,
+                parentName = parentModuleMap ? parentModuleMap.name : null,
+                originalName = name,
+                isDefine = true,
+                normalizedName = '';
+
+            //If no name, then it means it is a require call, generate an
+            //internal name.
+            if (!name) {
+                isDefine = false;
+                name = '_@r' + (requireCounter += 1);
+            }
+
+            nameParts = splitPrefix(name);
+            prefix = nameParts[0];
+            name = nameParts[1];
+
+            if (prefix) {
+                prefix = normalize(prefix, parentName, applyMap);
+                pluginModule = getOwn(defined, prefix);
+            }
+
+            //Account for relative paths if there is a base name.
+            if (name) {
+                if (prefix) {
+                    if (pluginModule && pluginModule.normalize) {
+                        //Plugin is loaded, use its normalize method.
+                        normalizedName = pluginModule.normalize(name, function (name) {
+                            return normalize(name, parentName, applyMap);
+                        });
+                    } else {
+                        normalizedName = normalize(name, parentName, applyMap);
+                    }
+                } else {
+                    //A regular module.
+                    normalizedName = normalize(name, parentName, applyMap);
+
+                    //Normalized name may be a plugin ID due to map config
+                    //application in normalize. The map config values must
+                    //already be normalized, so do not need to redo that part.
+                    nameParts = splitPrefix(normalizedName);
+                    prefix = nameParts[0];
+                    normalizedName = nameParts[1];
+                    isNormalized = true;
+
+                    url = context.nameToUrl(normalizedName);
+                }
+            }
+
+            //If the id is a plugin id that cannot be determined if it needs
+            //normalization, stamp it with a unique ID so two matching relative
+            //ids that may conflict can be separate.
+            suffix = prefix && !pluginModule && !isNormalized ?
+                     '_unnormalized' + (unnormalizedCounter += 1) :
+                     '';
+
+            return {
+                prefix: prefix,
+                name: normalizedName,
+                parentMap: parentModuleMap,
+                unnormalized: !!suffix,
+                url: url,
+                originalName: originalName,
+                isDefine: isDefine,
+                id: (prefix ?
+                        prefix + '!' + normalizedName :
+                        normalizedName) + suffix
+            };
+        }
+
+        function getModule(depMap) {
+            var id = depMap.id,
+                mod = getOwn(registry, id);
+
+            if (!mod) {
+                mod = registry[id] = new context.Module(depMap);
+            }
+
+            return mod;
+        }
+
+        function on(depMap, name, fn) {
+            var id = depMap.id,
+                mod = getOwn(registry, id);
+
+            if (hasProp(defined, id) &&
+                    (!mod || mod.defineEmitComplete)) {
+                if (name === 'defined') {
+                    fn(defined[id]);
+                }
+            } else {
+                mod = getModule(depMap);
+                if (mod.error && name === 'error') {
+                    fn(mod.error);
+                } else {
+                    mod.on(name, fn);
+                }
+            }
+        }
+
+        function onError(err, errback) {
+            var ids = err.requireModules,
+                notified = false;
+
+            if (errback) {
+                errback(err);
+            } else {
+                each(ids, function (id) {
+                    var mod = getOwn(registry, id);
+                    if (mod) {
+                        //Set error on module, so it skips timeout checks.
+                        mod.error = err;
+                        if (mod.events.error) {
+                            notified = true;
+                            mod.emit('error', err);
+                        }
+                    }
+                });
+
+                if (!notified) {
+                    req.onError(err);
+                }
+            }
+        }
+
+        /**
+         * Internal method to transfer globalQueue items to this context's
+         * defQueue.
+         */
+        function takeGlobalQueue() {
+            //Push all the globalDefQueue items into the context's defQueue
+            if (globalDefQueue.length) {
+                //Array splice in the values since the context code has a
+                //local var ref to defQueue, so cannot just reassign the one
+                //on context.
+                apsp.apply(defQueue,
+                           [defQueue.length, 0].concat(globalDefQueue));
+                globalDefQueue = [];
+            }
+        }
+
+        handlers = {
+            'require': function (mod) {
+                if (mod.require) {
+                    return mod.require;
+                } else {
+                    return (mod.require = context.makeRequire(mod.map));
+                }
+            },
+            'exports': function (mod) {
+                mod.usingExports = true;
+                if (mod.map.isDefine) {
+                    if (mod.exports) {
+                        return (defined[mod.map.id] = mod.exports);
+                    } else {
+                        return (mod.exports = defined[mod.map.id] = {});
+                    }
+                }
+            },
+            'module': function (mod) {
+                if (mod.module) {
+                    return mod.module;
+                } else {
+                    return (mod.module = {
+                        id: mod.map.id,
+                        uri: mod.map.url,
+                        config: function () {
+                            return  getOwn(config.config, mod.map.id) || {};
+                        },
+                        exports: mod.exports || (mod.exports = {})
+                    });
+                }
+            }
+        };
+
+        function cleanRegistry(id) {
+            //Clean up machinery used for waiting modules.
+            delete registry[id];
+            delete enabledRegistry[id];
+        }
+
+        function breakCycle(mod, traced, processed) {
+            var id = mod.map.id;
+
+            if (mod.error) {
+                mod.emit('error', mod.error);
+            } else {
+                traced[id] = true;
+                each(mod.depMaps, function (depMap, i) {
+                    var depId = depMap.id,
+                        dep = getOwn(registry, depId);
+
+                    //Only force things that have not completed
+                    //being defined, so still in the registry,
+                    //and only if it has not been matched up
+                    //in the module already.
+                    if (dep && !mod.depMatched[i] && !processed[depId]) {
+                        if (getOwn(traced, depId)) {
+                            mod.defineDep(i, defined[depId]);
+                            mod.check(); //pass false?
+                        } else {
+                            breakCycle(dep, traced, processed);
+                        }
+                    }
+                });
+                processed[id] = true;
+            }
+        }
+
+        function checkLoaded() {
+            var err, usingPathFallback,
+                waitInterval = config.waitSeconds * 1000,
+                //It is possible to disable the wait interval by using waitSeconds of 0.
+                expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
+                noLoads = [],
+                reqCalls = [],
+                stillLoading = false,
+                needCycleCheck = true;
+
+            //Do not bother if this call was a result of a cycle break.
+            if (inCheckLoaded) {
+                return;
+            }
+
+            inCheckLoaded = true;
+
+            //Figure out the state of all the modules.
+            eachProp(enabledRegistry, function (mod) {
+                var map = mod.map,
+                    modId = map.id;
+
+                //Skip things that are not enabled or in error state.
+                if (!mod.enabled) {
+                    return;
+                }
+
+                if (!map.isDefine) {
+                    reqCalls.push(mod);
+                }
+
+                if (!mod.error) {
+                    //If the module should be executed, and it has not
+                    //been inited and time is up, remember it.
+                    if (!mod.inited && expired) {
+                        if (hasPathFallback(modId)) {
+                            usingPathFallback = true;
+                            stillLoading = true;
+                        } else {
+                            noLoads.push(modId);
+                            removeScript(modId);
+                        }
+                    } else if (!mod.inited && mod.fetched && map.isDefine) {
+                        stillLoading = true;
+                        if (!map.prefix) {
+                            //No reason to keep looking for unfinished
+                            //loading. If the only stillLoading is a
+                            //plugin resource though, keep going,
+                            //because it may be that a plugin resource
+                            //is waiting on a non-plugin cycle.
+                            return (needCycleCheck = false);
+                        }
+                    }
+                }
+            });
+
+            if (expired && noLoads.length) {
+                //If wait time expired, throw error of unloaded modules.
+                err = makeError('timeout', 'Load timeout for modules: ' + noLoads, null, noLoads);
+                err.contextName = context.contextName;
+                return onError(err);
+            }
+
+            //Not expired, check for a cycle.
+            if (needCycleCheck) {
+                each(reqCalls, function (mod) {
+                    breakCycle(mod, {}, {});
+                });
+            }
+
+            //If still waiting on loads, and the waiting load is something
+            //other than a plugin resource, or there are still outstanding
+            //scripts, then just try back later.
+            if ((!expired || usingPathFallback) && stillLoading) {
+                //Something is still waiting to load. Wait for it, but only
+                //if a timeout is not already in effect.
+                if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) {
+                    checkLoadedTimeoutId = setTimeout(function () {
+                        checkLoadedTimeoutId = 0;
+                        checkLoaded();
+                    }, 50);
+                }
+            }
+
+            inCheckLoaded = false;
+        }
+
+        Module = function (map) {
+            this.events = getOwn(undefEvents, map.id) || {};
+            this.map = map;
+            this.shim = getOwn(config.shim, map.id);
+            this.depExports = [];
+            this.depMaps = [];
+            this.depMatched = [];
+            this.pluginMaps = {};
+            this.depCount = 0;
+
+            /* this.exports this.factory
+               this.depMaps = [],
+               this.enabled, this.fetched
+            */
+        };
+
+        Module.prototype = {
+            init: function (depMaps, factory, errback, options) {
+                options = options || {};
+
+                //Do not do more inits if already done. Can happen if there
+                //are multiple define calls for the same module. That is not
+                //a normal, common case, but it is also not unexpected.
+                if (this.inited) {
+                    return;
+                }
+
+                this.factory = factory;
+
+                if (errback) {
+                    //Register for errors on this module.
+                    this.on('error', errback);
+                } else if (this.events.error) {
+                    //If no errback already, but there are error listeners
+                    //on this module, set up an errback to pass to the deps.
+                    errback = bind(this, function (err) {
+                        this.emit('error', err);
+                    });
+                }
+
+                //Do a copy of the dependency array, so that
+                //source inputs are not modified. For example
+                //"shim" deps are passed in here directly, and
+                //doing a direct modification of the depMaps array
+                //would affect that config.
+                this.depMaps = depMaps && depMaps.slice(0);
+
+                this.errback = errback;
+
+                //Indicate this module has be initialized
+                this.inited = true;
+
+                this.ignore = options.ignore;
+
+                //Could have option to init this module in enabled mode,
+                //or could have been previously marked as enabled. However,
+                //the dependencies are not known until init is called. So
+                //if enabled previously, now trigger dependencies as enabled.
+                if (options.enabled || this.enabled) {
+                    //Enable this module and dependencies.
+                    //Will call this.check()
+                    this.enable();
+                } else {
+                    this.check();
+                }
+            },
+
+            defineDep: function (i, depExports) {
+                //Because of cycles, defined callback for a given
+                //export can be called more than once.
+                if (!this.depMatched[i]) {
+                    this.depMatched[i] = true;
+                    this.depCount -= 1;
+                    this.depExports[i] = depExports;
+                }
+            },
+
+            fetch: function () {
+                if (this.fetched) {
+                    return;
+                }
+                this.fetched = true;
+
+                context.startTime = (new Date()).getTime();
+
+                var map = this.map;
+
+                //If the manager is for a plugin managed resource,
+                //ask the plugin to load it now.
+                if (this.shim) {
+                    context.makeRequire(this.map, {
+                        enableBuildCallback: true
+                    })(this.shim.deps || [], bind(this, function () {
+                        return map.prefix ? this.callPlugin() : this.load();
+                    }));
+                } else {
+                    //Regular dependency.
+                    return map.prefix ? this.callPlugin() : this.load();
+                }
+            },
+
+            load: function () {
+                var url = this.map.url;
+
+                //Regular dependency.
+                if (!urlFetched[url]) {
+                    urlFetched[url] = true;
+                    context.load(this.map.id, url);
+                }
+            },
+
+            /**
+             * Checks if the module is ready to define itself, and if so,
+             * define it.
+             */
+            check: function () {
+                if (!this.enabled || this.enabling) {
+                    return;
+                }
+
+                var err, cjsModule,
+                    id = this.map.id,
+                    depExports = this.depExports,
+                    exports = this.exports,
+                    factory = this.factory;
+
+                if (!this.inited) {
+                    this.fetch();
+                } else if (this.error) {
+                    this.emit('error', this.error);
+                } else if (!this.defining) {
+                    //The factory could trigger another require call
+                    //that would result in checking this module to
+                    //define itself again. If already in the process
+                    //of doing that, skip this work.
+                    this.defining = true;
+
+                    if (this.depCount < 1 && !this.defined) {
+                        if (isFunction(factory)) {
+                            //If there is an error listener, favor passing
+                            //to that instead of throwing an error. However,
+                            //only do it for define()'d  modules. require
+                            //errbacks should not be called for failures in
+                            //their callbacks (#699). However if a global
+                            //onError is set, use that.
+                            if ((this.events.error && this.map.isDefine) ||
+                                req.onError !== defaultOnError) {
+                                try {
+                                    exports = context.execCb(id, factory, depExports, exports);
+                                } catch (e) {
+                                    err = e;
+                                }
+                            } else {
+                                exports = context.execCb(id, factory, depExports, exports);
+                            }
+
+                            // Favor return value over exports. If node/cjs in play,
+                            // then will not have a return value anyway. Favor
+                            // module.exports assignment over exports object.
+                            if (this.map.isDefine && exports === undefined) {
+                                cjsModule = this.module;
+                                if (cjsModule) {
+                                    exports = cjsModule.exports;
+                                } else if (this.usingExports) {
+                                    //exports already set the defined value.
+                                    exports = this.exports;
+                                }
+                            }
+
+                            if (err) {
+                                err.requireMap = this.map;
+                                err.requireModules = this.map.isDefine ? [this.map.id] : null;
+                                err.requireType = this.map.isDefine ? 'define' : 'require';
+                                return onError((this.error = err));
+                            }
+
+                        } else {
+                            //Just a literal value
+                            exports = factory;
+                        }
+
+                        this.exports = exports;
+
+                        if (this.map.isDefine && !this.ignore) {
+                            defined[id] = exports;
+
+                            if (req.onResourceLoad) {
+                                req.onResourceLoad(context, this.map, this.depMaps);
+                            }
+                        }
+
+                        //Clean up
+                        cleanRegistry(id);
+
+                        this.defined = true;
+                    }
+
+                    //Finished the define stage. Allow calling check again
+                    //to allow define notifications below in the case of a
+                    //cycle.
+                    this.defining = false;
+
+                    if (this.defined && !this.defineEmitted) {
+                        this.defineEmitted = true;
+                        this.emit('defined', this.exports);
+                        this.defineEmitComplete = true;
+                    }
+
+                }
+            },
+
+            callPlugin: function () {
+                var map = this.map,
+                    id = map.id,
+                    //Map already normalized the prefix.
+                    pluginMap = makeModuleMap(map.prefix);
+
+                //Mark this as a dependency for this plugin, so it
+                //can be traced for cycles.
+                this.depMaps.push(pluginMap);
+
+                on(pluginMap, 'defined', bind(this, function (plugin) {
+                    var load, normalizedMap, normalizedMod,
+                        bundleId = getOwn(bundlesMap, this.map.id),
+                        name = this.map.name,
+                        parentName = this.map.parentMap ? this.map.parentMap.name : null,
+                        localRequire = context.makeRequire(map.parentMap, {
+                            enableBuildCallback: true
+                        });
+
+                    //If current map is not normalized, wait for that
+                    //normalized name to load instead of continuing.
+                    if (this.map.unnormalized) {
+                        //Normalize the ID if the plugin allows it.
+                        if (plugin.normalize) {
+                            name = plugin.normalize(name, function (name) {
+                                return normalize(name, parentName, true);
+                            }) || '';
+                        }
+
+                        //prefix and name should already be normalized, no need
+                        //for applying map config again either.
+                        normalizedMap = makeModuleMap(map.prefix + '!' + name,
+                                                      this.map.parentMap);
+                        on(normalizedMap,
+                            'defined', bind(this, function (value) {
+                                this.init([], function () { return value; }, null, {
+                                    enabled: true,
+                                    ignore: true
+                                });
+                            }));
+
+                        normalizedMod = getOwn(registry, normalizedMap.id);
+                        if (normalizedMod) {
+                            //Mark this as a dependency for this plugin, so it
+                            //can be traced for cycles.
+                            this.depMaps.push(normalizedMap);
+
+                            if (this.events.error) {
+                                normalizedMod.on('error', bind(this, function (err) {
+                                    this.emit('error', err);
+                                }));
+                            }
+                            normalizedMod.enable();
+                        }
+
+                        return;
+                    }
+
+                    //If a paths config, then just load that file instead to
+                    //resolve the plugin, as it is built into that paths layer.
+                    if (bundleId) {
+                        this.map.url = context.nameToUrl(bundleId);
+                        this.load();
+                        return;
+                    }
+
+                    load = bind(this, function (value) {
+                        this.init([], function () { return value; }, null, {
+                            enabled: true
+                        });
+                    });
+
+                    load.error = bind(this, function (err) {
+                        this.inited = true;
+                        this.error = err;
+                        err.requireModules = [id];
+
+                        //Remove temp unnormalized modules for this module,
+                        //since they will never be resolved otherwise now.
+                        eachProp(registry, function (mod) {
+                            if (mod.map.id.indexOf(id + '_unnormalized') === 0) {
+                                cleanRegistry(mod.map.id);
+                            }
+                        });
+
+                        onError(err);
+                    });
+
+                    //Allow plugins to load other code without having to know the
+                    //context or how to 'complete' the load.
+                    load.fromText = bind(this, function (text, textAlt) {
+                        /*jslint evil: true */
+                        var moduleName = map.name,
+                            moduleMap = makeModuleMap(moduleName),
+                            hasInteractive = useInteractive;
+
+                        //As of 2.1.0, support just passing the text, to reinforce
+                        //fromText only being called once per resource. Still
+                        //support old style of passing moduleName but discard
+                        //that moduleName in favor of the internal ref.
+                        if (textAlt) {
+                            text = textAlt;
+                        }
+
+                        //Turn off interactive script matching for IE for any define
+                        //calls in the text, then turn it back on at the end.
+                        if (hasInteractive) {
+                            useInteractive = false;
+                        }
+
+                        //Prime the system by creating a module instance for
+                        //it.
+                        getModule(moduleMap);
+
+                        //Transfer any config to this other module.
+                        if (hasProp(config.config, id)) {
+                            config.config[moduleName] = config.config[id];
+                        }
+
+                        try {
+                            req.exec(text);
+                        } catch (e) {
+                            return onError(makeError('fromtexteval',
+                                             'fromText eval for ' + id +
+                                            ' failed: ' + e,
+                                             e,
+                                             [id]));
+                        }
+
+                        if (hasInteractive) {
+                            useInteractive = true;
+                        }
+
+                        //Mark this as a dependency for the plugin
+                        //resource
+                        this.depMaps.push(moduleMap);
+
+                        //Support anonymous modules.
+                        context.completeLoad(moduleName);
+
+                        //Bind the value of that module to the value for this
+                        //resource ID.
+                        localRequire([moduleName], load);
+                    });
+
+                    //Use parentName here since the plugin's name is not reliable,
+                    //could be some weird string with no path that actually wants to
+                    //reference the parentName's path.
+                    plugin.load(map.name, localRequire, load, config);
+                }));
+
+                context.enable(pluginMap, this);
+                this.pluginMaps[pluginMap.id] = pluginMap;
+            },
+
+            enable: function () {
+                enabledRegistry[this.map.id] = this;
+                this.enabled = true;
+
+                //Set flag mentioning that the module is enabling,
+                //so that immediate calls to the defined callbacks
+                //for dependencies do not trigger inadvertent load
+                //with the depCount still being zero.
+                this.enabling = true;
+
+                //Enable each dependency
+                each(this.depMaps, bind(this, function (depMap, i) {
+                    var id, mod, handler;
+
+                    if (typeof depMap === 'string') {
+                        //Dependency needs to be converted to a depMap
+                        //and wired up to this module.
+                        depMap = makeModuleMap(depMap,
+                                               (this.map.isDefine ? this.map : this.map.parentMap),
+                                               false,
+                                               !this.skipMap);
+                        this.depMaps[i] = depMap;
+
+                        handler = getOwn(handlers, depMap.id);
+
+                        if (handler) {
+                            this.depExports[i] = handler(this);
+                            return;
+                        }
+
+                        this.depCount += 1;
+
+                        on(depMap, 'defined', bind(this, function (depExports) {
+                            this.defineDep(i, depExports);
+                            this.check();
+                        }));
+
+                        if (this.errback) {
+                            on(depMap, 'error', bind(this, this.errback));
+                        }
+                    }
+
+                    id = depMap.id;
+                    mod = registry[id];
+
+                    //Skip special modules like 'require', 'exports', 'module'
+                    //Also, don't call enable if it is already enabled,
+                    //important in circular dependency cases.
+                    if (!hasProp(handlers, id) && mod && !mod.enabled) {
+                        context.enable(depMap, this);
+                    }
+                }));
+
+                //Enable each plugin that is used in
+                //a dependency
+                eachProp(this.pluginMaps, bind(this, function (pluginMap) {
+                    var mod = getOwn(registry, pluginMap.id);
+                    if (mod && !mod.enabled) {
+                        context.enable(pluginMap, this);
+                    }
+                }));
+
+                this.enabling = false;
+
+                this.check();
+            },
+
+            on: function (name, cb) {
+                var cbs = this.events[name];
+                if (!cbs) {
+                    cbs = this.events[name] = [];
+                }
+                cbs.push(cb);
+            },
+
+            emit: function (name, evt) {
+                each(this.events[name], function (cb) {
+                    cb(evt);
+                });
+                if (name === 'error') {
+                    //Now that the error handler was triggered, remove
+                    //the listeners, since this broken Module instance
+                    //can stay around for a while in the registry.
+                    delete this.events[name];
+                }
+            }
+        };
+
+        function callGetModule(args) {
+            //Skip modules already defined.
+            if (!hasProp(defined, args[0])) {
+                getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]);
+            }
+        }
+
+        function removeListener(node, func, name, ieName) {
+            //Favor detachEvent because of IE9
+            //issue, see attachEvent/addEventListener comment elsewhere
+            //in this file.
+            if (node.detachEvent && !isOpera) {
+                //Probably IE. If not it will throw an error, which will be
+                //useful to know.
+                if (ieName) {
+                    node.detachEvent(ieName, func);
+                }
+            } else {
+                node.removeEventListener(name, func, false);
+            }
+        }
+
+        /**
+         * Given an event from a script node, get the requirejs info from it,
+         * and then removes the event listeners on the node.
+         * @param {Event} evt
+         * @returns {Object}
+         */
+        function getScriptData(evt) {
+            //Using currentTarget instead of target for Firefox 2.0's sake. Not
+            //all old browsers will be supported, but this one was easy enough
+            //to support and still makes sense.
+            var node = evt.currentTarget || evt.srcElement;
+
+            //Remove the listeners once here.
+            removeListener(node, context.onScriptLoad, 'load', 'onreadystatechange');
+            removeListener(node, context.onScriptError, 'error');
+
+            return {
+                node: node,
+                id: node && node.getAttribute('data-requiremodule')
+            };
+        }
+
+        function intakeDefines() {
+            var args;
+
+            //Any defined modules in the global queue, intake them now.
+            takeGlobalQueue();
+
+            //Make sure any remaining defQueue items get properly processed.
+            while (defQueue.length) {
+                args = defQueue.shift();
+                if (args[0] === null) {
+                    return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1]));
+                } else {
+                    //args are id, deps, factory. Should be normalized by the
+                    //define() function.
+                    callGetModule(args);
+                }
+            }
+        }
+
+        context = {
+            config: config,
+            contextName: contextName,
+            registry: registry,
+            defined: defined,
+            urlFetched: urlFetched,
+            defQueue: defQueue,
+            Module: Module,
+            makeModuleMap: makeModuleMap,
+            nextTick: req.nextTick,
+            onError: onError,
+
+            /**
+             * Set a configuration for the context.
+             * @param {Object} cfg config object to integrate.
+             */
+            configure: function (cfg) {
+                //Make sure the baseUrl ends in a slash.
+                if (cfg.baseUrl) {
+                    if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') {
+                        cfg.baseUrl += '/';
+                    }
+                }
+
+                //Save off the paths since they require special processing,
+                //they are additive.
+                var shim = config.shim,
+                    objs = {
+                        paths: true,
+                        bundles: true,
+                        config: true,
+                        map: true
+                    };
+
+                eachProp(cfg, function (value, prop) {
+                    if (objs[prop]) {
+                        if (!config[prop]) {
+                            config[prop] = {};
+                        }
+                        mixin(config[prop], value, true, true);
+                    } else {
+                        config[prop] = value;
+                    }
+                });
+
+                //Reverse map the bundles
+                if (cfg.bundles) {
+                    eachProp(cfg.bundles, function (value, prop) {
+                        each(value, function (v) {
+                            if (v !== prop) {
+                                bundlesMap[v] = prop;
+                            }
+                        });
+                    });
+                }
+
+                //Merge shim
+                if (cfg.shim) {
+                    eachProp(cfg.shim, function (value, id) {
+                        //Normalize the structure
+                        if (isArray(value)) {
+                            value = {
+                                deps: value
+                            };
+                        }
+                        if ((value.exports || value.init) && !value.exportsFn) {
+                            value.exportsFn = context.makeShimExports(value);
+                        }
+                        shim[id] = value;
+                    });
+                    config.shim = shim;
+                }
+
+                //Adjust packages if necessary.
+                if (cfg.packages) {
+                    each(cfg.packages, function (pkgObj) {
+                        var location, name;
+
+                        pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj;
+
+                        name = pkgObj.name;
+                        location = pkgObj.location;
+                        if (location) {
+                            config.paths[name] = pkgObj.location;
+                        }
+
+                        //Save pointer to main module ID for pkg name.
+                        //Remove leading dot in main, so main paths are normalized,
+                        //and remove any trailing .js, since different package
+                        //envs have different conventions: some use a module name,
+                        //some use a file name.
+                        config.pkgs[name] = pkgObj.name + '/' + (pkgObj.main || 'main')
+                                     .replace(currDirRegExp, '')
+                                     .replace(jsSuffixRegExp, '');
+                    });
+                }
+
+                //If there are any "waiting to execute" modules in the registry,
+                //update the maps for them, since their info, like URLs to load,
+                //may have changed.
+                eachProp(registry, function (mod, id) {
+                    //If module already has init called, since it is too
+                    //late to modify them, and ignore unnormalized ones
+                    //since they are transient.
+                    if (!mod.inited && !mod.map.unnormalized) {
+                        mod.map = makeModuleMap(id);
+                    }
+                });
+
+                //If a deps array or a config callback is specified, then call
+                //require with those args. This is useful when require is defined as a
+                //config object before require.js is loaded.
+                if (cfg.deps || cfg.callback) {
+                    context.require(cfg.deps || [], cfg.callback);
+                }
+            },
+
+            makeShimExports: function (value) {
+                function fn() {
+                    var ret;
+                    if (value.init) {
+                        ret = value.init.apply(global, arguments);
+                    }
+                    return ret || (value.exports && getGlobal(value.exports));
+                }
+                return fn;
+            },
+
+            makeRequire: function (relMap, options) {
+                options = options || {};
+
+                function localRequire(deps, callback, errback) {
+                    var id, map, requireMod;
+
+                    if (options.enableBuildCallback && callback && isFunction(callback)) {
+                        callback.__requireJsBuild = true;
+                    }
+
+                    if (typeof deps === 'string') {
+                        if (isFunction(callback)) {
+                            //Invalid call
+                            return onError(makeError('requireargs', 'Invalid require call'), errback);
+                        }
+
+                        //If require|exports|module are requested, get the
+                        //value for them from the special handlers. Caveat:
+                        //this only works while module is being defined.
+                        if (relMap && hasProp(handlers, deps)) {
+                            return handlers[deps](registry[relMap.id]);
+                        }
+
+                        //Synchronous access to one module. If require.get is
+                        //available (as in the Node adapter), prefer that.
+                        if (req.get) {
+                            return req.get(context, deps, relMap, localRequire);
+                        }
+
+                        //Normalize module name, if it contains . or ..
+                        map = makeModuleMap(deps, relMap, false, true);
+                        id = map.id;
+
+                        if (!hasProp(defined, id)) {
+                            return onError(makeError('notloaded', 'Module name "' +
+                                        id +
+                                        '" has not been loaded yet for context: ' +
+                                        contextName +
+                                        (relMap ? '' : '. Use require([])')));
+                        }
+                        return defined[id];
+                    }
+
+                    //Grab defines waiting in the global queue.
+                    intakeDefines();
+
+                    //Mark all the dependencies as needing to be loaded.
+                    context.nextTick(function () {
+                        //Some defines could have been added since the
+                        //require call, collect them.
+                        intakeDefines();
+
+                        requireMod = getModule(makeModuleMap(null, relMap));
+
+                        //Store if map config should be applied to this require
+                        //call for dependencies.
+                        requireMod.skipMap = options.skipMap;
+
+                        requireMod.init(deps, callback, errback, {
+                            enabled: true
+                        });
+
+                        checkLoaded();
+                    });
+
+                    return localRequire;
+                }
+
+                mixin(localRequire, {
+                    isBrowser: isBrowser,
+
+                    /**
+                     * Converts a module name + .extension into an URL path.
+                     * *Requires* the use of a module name. It does not support using
+                     * plain URLs like nameToUrl.
+                     */
+                    toUrl: function (moduleNamePlusExt) {
+                        var ext,
+                            index = moduleNamePlusExt.lastIndexOf('.'),
+                            segment = moduleNamePlusExt.split('/')[0],
+                            isRelative = segment === '.' || segment === '..';
+
+                        //Have a file extension alias, and it is not the
+                        //dots from a relative path.
+                        if (index !== -1 && (!isRelative || index > 1)) {
+                            ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length);
+                            moduleNamePlusExt = moduleNamePlusExt.substring(0, index);
+                        }
+
+                        return context.nameToUrl(normalize(moduleNamePlusExt,
+                                                relMap && relMap.id, true), ext,  true);
+                    },
+
+                    defined: function (id) {
+                        return hasProp(defined, makeModuleMap(id, relMap, false, true).id);
+                    },
+
+                    specified: function (id) {
+                        id = makeModuleMap(id, relMap, false, true).id;
+                        return hasProp(defined, id) || hasProp(registry, id);
+                    }
+                });
+
+                //Only allow undef on top level require calls
+                if (!relMap) {
+                    localRequire.undef = function (id) {
+                        //Bind any waiting define() calls to this context,
+                        //fix for #408
+                        takeGlobalQueue();
+
+                        var map = makeModuleMap(id, relMap, true),
+                            mod = getOwn(registry, id);
+
+                        removeScript(id);
+
+                        delete defined[id];
+                        delete urlFetched[map.url];
+                        delete undefEvents[id];
+
+                        //Clean queued defines too. Go backwards
+                        //in array so that the splices do not
+                        //mess up the iteration.
+                        eachReverse(defQueue, function(args, i) {
+                            if(args[0] === id) {
+                                defQueue.splice(i, 1);
+                            }
+                        });
+
+                        if (mod) {
+                            //Hold on to listeners in case the
+                            //module will be attempted to be reloaded
+                            //using a different config.
+                            if (mod.events.defined) {
+                                undefEvents[id] = mod.events;
+                            }
+
+                            cleanRegistry(id);
+                        }
+                    };
+                }
+
+                return localRequire;
+            },
+
+            /**
+             * Called to enable a module if it is still in the registry
+             * awaiting enablement. A second arg, parent, the parent module,
+             * is passed in for context, when this method is overridden by
+             * the optimizer. Not shown here to keep code compact.
+             */
+            enable: function (depMap) {
+                var mod = getOwn(registry, depMap.id);
+                if (mod) {
+                    getModule(depMap).enable();
+                }
+            },
+
+            /**
+             * Internal method used by environment adapters to complete a load event.
+             * A load event could be a script load or just a load pass from a synchronous
+             * load call.
+             * @param {String} moduleName the name of the module to potentially complete.
+             */
+            completeLoad: function (moduleName) {
+                var found, args, mod,
+                    shim = getOwn(config.shim, moduleName) || {},
+                    shExports = shim.exports;
+
+                takeGlobalQueue();
+
+                while (defQueue.length) {
+                    args = defQueue.shift();
+                    if (args[0] === null) {
+                        args[0] = moduleName;
+                        //If already found an anonymous module and bound it
+                        //to this name, then this is some other anon module
+                        //waiting for its completeLoad to fire.
+                        if (found) {
+                            break;
+                        }
+                        found = true;
+                    } else if (args[0] === moduleName) {
+                        //Found matching define call for this script!
+                        found = true;
+                    }
+
+                    callGetModule(args);
+                }
+
+                //Do this after the cycle of callGetModule in case the result
+                //of those calls/init calls changes the registry.
+                mod = getOwn(registry, moduleName);
+
+                if (!found && !hasProp(defined, moduleName) && mod && !mod.inited) {
+                    if (config.enforceDefine && (!shExports || !getGlobal(shExports))) {
+                        if (hasPathFallback(moduleName)) {
+                            return;
+                        } else {
+                            return onError(makeError('nodefine',
+                                             'No define call for ' + moduleName,
+                                             null,
+                                             [moduleName]));
+                        }
+                    } else {
+                        //A script that does not call define(), so just simulate
+                        //the call for it.
+                        callGetModule([moduleName, (shim.deps || []), shim.exportsFn]);
+                    }
+                }
+
+                checkLoaded();
+            },
+
+            /**
+             * Converts a module name to a file path. Supports cases where
+             * moduleName may actually be just an URL.
+             * Note that it **does not** call normalize on the moduleName,
+             * it is assumed to have already been normalized. This is an
+             * internal API, not a public one. Use toUrl for the public API.
+             */
+            nameToUrl: function (moduleName, ext, skipExt) {
+                var paths, syms, i, parentModule, url,
+                    parentPath, bundleId,
+                    pkgMain = getOwn(config.pkgs, moduleName);
+
+                if (pkgMain) {
+                    moduleName = pkgMain;
+                }
+
+                bundleId = getOwn(bundlesMap, moduleName);
+
+                if (bundleId) {
+                    return context.nameToUrl(bundleId, ext, skipExt);
+                }
+
+                //If a colon is in the URL, it indicates a protocol is used and it is just
+                //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
+                //or ends with .js, then assume the user meant to use an url and not a module id.
+                //The slash is important for protocol-less URLs as well as full paths.
+                if (req.jsExtRegExp.test(moduleName)) {
+                    //Just a plain path, not module name lookup, so just return it.
+                    //Add extension if it is included. This is a bit wonky, only non-.js things pass
+                    //an extension, this method probably needs to be reworked.
+                    url = moduleName + (ext || '');
+                } else {
+                    //A module that needs to be converted to a path.
+                    paths = config.paths;
+
+                    syms = moduleName.split('/');
+                    //For each module name segment, see if there is a path
+                    //registered for it. Start with most specific name
+                    //and work up from it.
+                    for (i = syms.length; i > 0; i -= 1) {
+                        parentModule = syms.slice(0, i).join('/');
+
+                        parentPath = getOwn(paths, parentModule);
+                        if (parentPath) {
+                            //If an array, it means there are a few choices,
+                            //Choose the one that is desired
+                            if (isArray(parentPath)) {
+                                parentPath = parentPath[0];
+                            }
+                            syms.splice(0, i, parentPath);
+                            break;
+                        }
+                    }
+
+                    //Join the path parts together, then figure out if baseUrl is needed.
+                    url = syms.join('/');
+                    url += (ext || (/^data\:|\?/.test(url) || skipExt ? '' : '.js'));
+                    url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
+                }
+
+                return config.urlArgs ? url +
+                                        ((url.indexOf('?') === -1 ? '?' : '&') +
+                                         config.urlArgs) : url;
+            },
+
+            //Delegates to req.load. Broken out as a separate function to
+            //allow overriding in the optimizer.
+            load: function (id, url) {
+                req.load(context, id, url);
+            },
+
+            /**
+             * Executes a module callback function. Broken out as a separate function
+             * solely to allow the build system to sequence the files in the built
+             * layer in the right sequence.
+             *
+             * @private
+             */
+            execCb: function (name, callback, args, exports) {
+                return callback.apply(exports, args);
+            },
+
+            /**
+             * callback for script loads, used to check status of loading.
+             *
+             * @param {Event} evt the event from the browser for the script
+             * that was loaded.
+             */
+            onScriptLoad: function (evt) {
+                //Using currentTarget instead of target for Firefox 2.0's sake. Not
+                //all old browsers will be supported, but this one was easy enough
+                //to support and still makes sense.
+                if (evt.type === 'load' ||
+                        (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {
+                    //Reset interactive script so a script node is not held onto for
+                    //to long.
+                    interactiveScript = null;
+
+                    //Pull out the name of the module and the context.
+                    var data = getScriptData(evt);
+                    context.completeLoad(data.id);
+                }
+            },
+
+            /**
+             * Callback for script errors.
+             */
+            onScriptError: function (evt) {
+                var data = getScriptData(evt);
+                if (!hasPathFallback(data.id)) {
+                    return onError(makeError('scripterror', 'Script error for: ' + data.id, evt, [data.id]));
+                }
+            }
+        };
+
+        context.require = context.makeRequire();
+        return context;
+    }
+
+    /**
+     * Main entry point.
+     *
+     * If the only argument to require is a string, then the module that
+     * is represented by that string is fetched for the appropriate context.
+     *
+     * If the first argument is an array, then it will be treated as an array
+     * of dependency string names to fetch. An optional function callback can
+     * be specified to execute when all of those dependencies are available.
+     *
+     * Make a local req variable to help Caja compliance (it assumes things
+     * on a require that are not standardized), and to give a short
+     * name for minification/local scope use.
+     */
+    req = requirejs = function (deps, callback, errback, optional) {
+
+        //Find the right context, use default
+        var context, config,
+            contextName = defContextName;
+
+        // Determine if have config object in the call.
+        if (!isArray(deps) && typeof deps !== 'string') {
+            // deps is a config object
+            config = deps;
+            if (isArray(callback)) {
+                // Adjust args if there are dependencies
+                deps = callback;
+                callback = errback;
+                errback = optional;
+            } else {
+                deps = [];
+            }
+        }
+
+        if (config && config.context) {
+            contextName = config.context;
+        }
+
+        context = getOwn(contexts, contextName);
+        if (!context) {
+            context = contexts[contextName] = req.s.newContext(contextName);
+        }
+
+        if (config) {
+            context.configure(config);
+        }
+
+        return context.require(deps, callback, errback);
+    };
+
+    /**
+     * Support require.config() to make it easier to cooperate with other
+     * AMD loaders on globally agreed names.
+     */
+    req.config = function (config) {
+        return req(config);
+    };
+
+    /**
+     * Execute something after the current tick
+     * of the event loop. Override for other envs
+     * that have a better solution than setTimeout.
+     * @param  {Function} fn function to execute later.
+     */
+    req.nextTick = typeof setTimeout !== 'undefined' ? function (fn) {
+        setTimeout(fn, 4);
+    } : function (fn) { fn(); };
+
+    /**
+     * Export require as a global, but only if it does not already exist.
+     */
+    if (!require) {
+        require = req;
+    }
+
+    req.version = version;
+
+    //Used to filter out dependencies that are already paths.
+    req.jsExtRegExp = /^\/|:|\?|\.js$/;
+    req.isBrowser = isBrowser;
+    s = req.s = {
+        contexts: contexts,
+        newContext: newContext
+    };
+
+    //Create default context.
+    req({});
+
+    //Exports some context-sensitive methods on global require.
+    each([
+        'toUrl',
+        'undef',
+        'defined',
+        'specified'
+    ], function (prop) {
+        //Reference from contexts instead of early binding to default context,
+        //so that during builds, the latest instance of the default context
+        //with its config gets used.
+        req[prop] = function () {
+            var ctx = contexts[defContextName];
+            return ctx.require[prop].apply(ctx, arguments);
+        };
+    });
+
+    if (isBrowser) {
+        head = s.head = document.getElementsByTagName('head')[0];
+        //If BASE tag is in play, using appendChild is a problem for IE6.
+        //When that browser dies, this can be removed. Details in this jQuery bug:
+        //http://dev.jquery.com/ticket/2709
+        baseElement = document.getElementsByTagName('base')[0];
+        if (baseElement) {
+            head = s.head = baseElement.parentNode;
+        }
+    }
+
+    /**
+     * Any errors that require explicitly generates will be passed to this
+     * function. Intercept/override it if you want custom error handling.
+     * @param {Error} err the error object.
+     */
+    req.onError = defaultOnError;
+
+    /**
+     * Creates the node for the load command. Only used in browser envs.
+     */
+    req.createNode = function (config, moduleName, url) {
+        var node = config.xhtml ?
+                document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :
+                document.createElement('script');
+        node.type = config.scriptType || 'text/javascript';
+        node.charset = 'utf-8';
+        node.async = true;
+        return node;
+    };
+
+    /**
+     * Does the request to load a module for the browser case.
+     * Make this a separate function to allow other environments
+     * to override it.
+     *
+     * @param {Object} context the require context to find state.
+     * @param {String} moduleName the name of the module.
+     * @param {Object} url the URL to the module.
+     */
+    req.load = function (context, moduleName, url) {
+        var config = (context && context.config) || {},
+            node;
+        if (isBrowser) {
+            //In the browser so use a script tag
+            node = req.createNode(config, moduleName, url);
+
+            node.setAttribute('data-requirecontext', context.contextName);
+            node.setAttribute('data-requiremodule', moduleName);
+
+            //Set up load listener. Test attachEvent first because IE9 has
+            //a subtle issue in its addEventListener and script onload firings
+            //that do not match the behavior of all other browsers with
+            //addEventListener support, which fire the onload event for a
+            //script right after the script execution. See:
+            //https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution
+            //UNFORTUNATELY Opera implements attachEvent but does not follow the script
+            //script execution mode.
+            if (node.attachEvent &&
+                    //Check if node.attachEvent is artificially added by custom script or
+                    //natively supported by browser
+                    //read https://github.com/jrburke/requirejs/issues/187
+                    //if we can NOT find [native code] then it must NOT natively supported.
+                    //in IE8, node.attachEvent does not have toString()
+                    //Note the test for "[native code" with no closing brace, see:
+                    //https://github.com/jrburke/requirejs/issues/273
+                    !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
+                    !isOpera) {
+                //Probably IE. IE (at least 6-8) do not fire
+                //script onload right after executing the script, so
+                //we cannot tie the anonymous define call to a name.
+                //However, IE reports the script as being in 'interactive'
+                //readyState at the time of the define call.
+                useInteractive = true;
+
+                node.attachEvent('onreadystatechange', context.onScriptLoad);
+                //It would be great to add an error handler here to catch
+                //404s in IE9+. However, onreadystatechange will fire before
+                //the error handler, so that does not help. If addEventListener
+                //is used, then IE will fire error before load, but we cannot
+                //use that pathway given the connect.microsoft.com issue
+                //mentioned above about not doing the 'script execute,
+                //then fire the script load event listener before execute
+                //next script' that other browsers do.
+                //Best hope: IE10 fixes the issues,
+                //and then destroys all installs of IE 6-9.
+                //node.attachEvent('onerror', context.onScriptError);
+            } else {
+                node.addEventListener('load', context.onScriptLoad, false);
+                node.addEventListener('error', context.onScriptError, false);
+            }
+            node.src = url;
+
+            //For some cache cases in IE 6-8, the script executes before the end
+            //of the appendChild execution, so to tie an anonymous define
+            //call to the module name (which is stored on the node), hold on
+            //to a reference to this node, but clear after the DOM insertion.
+            currentlyAddingScript = node;
+            if (baseElement) {
+                head.insertBefore(node, baseElement);
+            } else {
+                head.appendChild(node);
+            }
+            currentlyAddingScript = null;
+
+            return node;
+        } else if (isWebWorker) {
+            try {
+                //In a web worker, use importScripts. This is not a very
+                //efficient use of importScripts, importScripts will block until
+                //its script is downloaded and evaluated. However, if web workers
+                //are in play, the expectation that a build has been done so that
+                //only one script needs to be loaded anyway. This may need to be
+                //reevaluated if other use cases become common.
+                importScripts(url);
+
+                //Account for anonymous modules
+                context.completeLoad(moduleName);
+            } catch (e) {
+                context.onError(makeError('importscripts',
+                                'importScripts failed for ' +
+                                    moduleName + ' at ' + url,
+                                e,
+                                [moduleName]));
+            }
+        }
+    };
+
+    function getInteractiveScript() {
+        if (interactiveScript && interactiveScript.readyState === 'interactive') {
+            return interactiveScript;
+        }
+
+        eachReverse(scripts(), function (script) {
+            if (script.readyState === 'interactive') {
+                return (interactiveScript = script);
+            }
+        });
+        return interactiveScript;
+    }
+
+    //Look for a data-main script attribute, which could also adjust the baseUrl.
+    if (isBrowser && !cfg.skipDataMain) {
+        //Figure out baseUrl. Get it from the script tag with require.js in it.
+        eachReverse(scripts(), function (script) {
+            //Set the 'head' where we can append children by
+            //using the script's parent.
+            if (!head) {
+                head = script.parentNode;
+            }
+
+            //Look for a data-main attribute to set main script for the page
+            //to load. If it is there, the path to data main becomes the
+            //baseUrl, if it is not already set.
+            dataMain = script.getAttribute('data-main');
+            if (dataMain) {
+                //Preserve dataMain in case it is a path (i.e. contains '?')
+                mainScript = dataMain;
+
+                //Set final baseUrl if there is not already an explicit one.
+                if (!cfg.baseUrl) {
+                    //Pull off the directory of data-main for use as the
+                    //baseUrl.
+                    src = mainScript.split('/');
+                    mainScript = src.pop();
+                    subPath = src.length ? src.join('/')  + '/' : './';
+
+                    cfg.baseUrl = subPath;
+                }
+
+                //Strip off any trailing .js since mainScript is now
+                //like a module name.
+                mainScript = mainScript.replace(jsSuffixRegExp, '');
+
+                 //If mainScript is still a path, fall back to dataMain
+                if (req.jsExtRegExp.test(mainScript)) {
+                    mainScript = dataMain;
+                }
+
+                //Put the data-main script in the files to load.
+                cfg.deps = cfg.deps ? cfg.deps.concat(mainScript) : [mainScript];
+
+                return true;
+            }
+        });
+    }
+
+    /**
+     * The function that handles definitions of modules. Differs from
+     * require() in that a string for the module should be the first argument,
+     * and the function to execute after dependencies are loaded should
+     * return a value to define the module corresponding to the first argument's
+     * name.
+     */
+    define = function (name, deps, callback) {
+        var node, context;
+
+        //Allow for anonymous modules
+        if (typeof name !== 'string') {
+            //Adjust args appropriately
+            callback = deps;
+            deps = name;
+            name = null;
+        }
+
+        //This module may not have dependencies
+        if (!isArray(deps)) {
+            callback = deps;
+            deps = null;
+        }
+
+        //If no name, and callback is a function, then figure out if it a
+        //CommonJS thing with dependencies.
+        if (!deps && isFunction(callback)) {
+            deps = [];
+            //Remove comments from the callback string,
+            //look for require calls, and pull them into the dependencies,
+            //but only if there are function args.
+            if (callback.length) {
+                callback
+                    .toString()
+                    .replace(commentRegExp, '')
+                    .replace(cjsRequireRegExp, function (match, dep) {
+                        deps.push(dep);
+                    });
+
+                //May be a CommonJS thing even without require calls, but still
+                //could use exports, and module. Avoid doing exports and module
+                //work though if it just needs require.
+                //REQUIRES the function to expect the CommonJS variables in the
+                //order listed below.
+                deps = (callback.length === 1 ? ['require'] : ['require', 'exports', 'module']).concat(deps);
+            }
+        }
+
+        //If in IE 6-8 and hit an anonymous define() call, do the interactive
+        //work.
+        if (useInteractive) {
+            node = currentlyAddingScript || getInteractiveScript();
+            if (node) {
+                if (!name) {
+                    name = node.getAttribute('data-requiremodule');
+                }
+                context = contexts[node.getAttribute('data-requirecontext')];
+            }
+        }
+
+        //Always save off evaluating the def call until the script onload handler.
+        //This allows multiple modules to be in a file without prematurely
+        //tracing dependencies, and allows for anonymous module support,
+        //where the module name is not known until the script onload event
+        //occurs. If no context, use the global queue, and get it processed
+        //in the onscript load callback.
+        (context ? context.defQueue : globalDefQueue).push([name, deps, callback]);
+    };
+
+    define.amd = {
+        jQuery: true
+    };
+
+
+    /**
+     * Executes the text. Normally just uses eval, but can be modified
+     * to use a better, environment-specific call. Only used for transpiling
+     * loader plugins, not for plain JS modules.
+     * @param {String} text the text to execute/evaluate.
+     */
+    req.exec = function (text) {
+        /*jslint evil: true */
+        return eval(text);
+    };
+
+    //Set up with config info.
+    req(cfg);
+}(this));
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/image-viewer.html b/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/image-viewer.html
new file mode 100644
index 0000000000000000000000000000000000000000..2571c51e2b6d0691ee1ab9c5bd8fe03b88eab8b4
--- /dev/null
+++ b/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/image-viewer.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Image Viewer</title>
+
+<link rel="stylesheet" href="/openbis-test-screening/resources/lib/bootstrap/css/bootstrap.min.css">
+<link rel="stylesheet" href="/openbis-test-screening/resources/lib/bootstrap-slider/css/bootstrap-slider.min.css">
+<link rel="stylesheet" href="image-viewer.css">
+
+<script type="text/javascript" src="/openbis-test-screening/resources/config.js"></script>
+<script type="text/javascript" src="/openbis-test-screening/resources/require.js"></script>
+
+</head>
+<body>
+	<script>
+		require([ "jquery", "openbis-screening", "components/imageviewer/ImageViewerChooserWidget" ], function($, openbis, ImageViewerChooserWidget) {
+
+			$(document).ready(function() {
+				var facade = new openbis();
+
+				facade.login("admin", "password", function(response) {
+					var widget = new ImageViewerChooserWidget(facade, [ "20140415140347875-53", "20140506132344798-146" ]);
+					$("#container").append(widget.render());
+				});
+			});
+		});
+	</script>
+
+	<div id="container" style="width: 600px; padding: 20px;"></div>
+
+</body>
+</html>
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/image-viewer.js b/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/image-viewer.js
deleted file mode 100644
index 30fd6eaea077372e2ca5211bbf4bd1e1f15721a1..0000000000000000000000000000000000000000
--- a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/image-viewer.js
+++ /dev/null
@@ -1,1919 +0,0 @@
-//
-// ABSTRACT VIEW
-//
-
-function AbstractView(controller) {
-	this.init(controller);
-}
-
-$.extend(AbstractView.prototype, {
-
-	init : function(controller) {
-		this.controller = controller;
-	},
-
-	render : function() {
-		return null;
-	},
-
-	refresh : function() {
-
-	}
-
-});
-
-//
-// ABSTRACT WIDGET
-//
-
-function AbstractWidget(view) {
-	this.init(view);
-}
-
-$.extend(AbstractWidget.prototype, {
-	init : function(view) {
-		this.setView(view);
-		this.listeners = new ListenerManager();
-		this.panel = $("<div>").addClass("widget");
-	},
-
-	load : function(callback) {
-		callback();
-	},
-
-	render : function() {
-		if (this.rendered) {
-			return this.panel;
-		}
-
-		var thisWidget = this;
-
-		this.load(function() {
-			if (thisWidget.getView()) {
-				thisWidget.panel.append(thisWidget.getView().render());
-				thisWidget.rendered = true;
-			}
-		});
-
-		return this.panel;
-	},
-
-	refresh : function() {
-		if (!this.rendered) {
-			return;
-		}
-
-		if (this.getView()) {
-			this.getView().refresh();
-		}
-	},
-
-	getView : function() {
-		return this.view;
-	},
-
-	setView : function(view) {
-		this.view = view;
-		this.refresh();
-	},
-
-	addChangeListener : function(listener) {
-		this.listeners.addListener('change', listener);
-	},
-
-	notifyChangeListeners : function() {
-		this.listeners.notifyListeners('change');
-	}
-});
-
-// TODO do not pollute the global namespace and expose only ImageViewer
-
-//
-// IMAGE VIEWER CHOOSER VIEW
-//
-
-function ImageViewerChooserView(controller) {
-	this.init(controller);
-}
-
-$.extend(ImageViewerChooserView.prototype, AbstractView.prototype, {
-
-	init : function(controller) {
-		AbstractView.prototype.init.call(this, controller);
-		this.panel = $("<div>").addClass("imageViewerChooser");
-	},
-
-	render : function() {
-		this.panel.append(this.createDataSetChooserWidget());
-		this.panel.append(this.createImageViewerContainerWidget());
-
-		this.refresh();
-
-		return this.panel;
-	},
-
-	refresh : function() {
-		var select = this.panel.find(".dataSetChooser").find("select");
-		var container = this.panel.find(".imageViewerContainer");
-
-		if (this.controller.getSelectedDataSetCode() != null) {
-			select.val(this.controller.getSelectedDataSetCode());
-			container.children().detach();
-			container.append(this.createImageViewerWidget(this.controller.getSelectedDataSetCode()));
-		}
-	},
-
-	createDataSetChooserWidget : function() {
-		var thisView = this;
-		var widget = $("<div>").addClass("dataSetChooser").addClass("form-group");
-
-		$("<label>").text("Data set").attr("for", "dataSetChooserSelect").appendTo(widget);
-
-		var select = $("<select>").attr("id", "dataSetChooserSelect").addClass("form-control").appendTo(widget);
-
-		this.controller.getDataSetCodes().forEach(function(dataSetCode) {
-			$("<option>").attr("value", dataSetCode).text(dataSetCode).appendTo(select);
-		});
-
-		select.change(function() {
-			thisView.controller.setSelectedDataSetCode(select.val());
-		});
-
-		return widget;
-	},
-
-	createImageViewerContainerWidget : function() {
-		return $("<div>").addClass("imageViewerContainer");
-	},
-
-	createImageViewerWidget : function(dataSetCode) {
-		if (!this.imageViewerMap) {
-			this.imageViewerMap = {};
-		}
-
-		if (!this.imageViewerMap[dataSetCode]) {
-			this.imageViewerMap[dataSetCode] = new ImageViewerWidget(this.controller.getSessionToken(), dataSetCode, this.controller
-					.getDataStoreUrl(dataSetCode), this.controller.getImageInfo(dataSetCode), this.controller.getImageResolutions(dataSetCode));
-		}
-
-		return this.imageViewerMap[dataSetCode].render();
-	}
-
-});
-
-//
-// IMAGE VIEWER CHOOSER
-//
-
-function ImageViewerChooserWidget(openbis, dataSetCodes) {
-	this.init(openbis, dataSetCodes);
-}
-
-$.extend(ImageViewerChooserWidget.prototype, AbstractWidget.prototype, {
-	init : function(openbis, dataSetCodes) {
-		AbstractWidget.prototype.init.call(this, new ImageViewerChooserView(this));
-		this.facade = new OpenbisFacade(openbis);
-		this.setDataSetCodes(dataSetCodes)
-	},
-
-	load : function(callback) {
-		if (this.loaded) {
-			callback();
-		} else {
-			var thisViewer = this;
-
-			var manager = new CallbackManager(function() {
-				thisViewer.loaded = true;
-				callback();
-			});
-
-			this.facade.getDataStoreBaseURLs(thisViewer.dataSetCodes, manager.registerCallback(function(response) {
-				thisViewer.dataSetCodeToDataStoreUrlMap = response.result;
-			}));
-
-			this.facade.getImageInfo(thisViewer.dataSetCodes, manager.registerCallback(function(response) {
-				thisViewer.dataSetCodeToImageInfoMap = response.result;
-			}));
-
-			this.facade.getImageResolutions(thisViewer.dataSetCodes, manager.registerCallback(function(response) {
-				thisViewer.dataSetCodeToImageResolutionsMap = response.result;
-			}));
-		}
-	},
-
-	getSessionToken : function() {
-		return this.facade.getSession();
-	},
-
-	getImageInfo : function(dataSetCode) {
-		return this.dataSetCodeToImageInfoMap[dataSetCode];
-	},
-
-	getImageResolutions : function(dataSetCode) {
-		return this.dataSetCodeToImageResolutionsMap[dataSetCode];
-	},
-
-	getDataStoreUrl : function(dataSetCode) {
-		return this.dataSetCodeToDataStoreUrlMap[dataSetCode];
-	},
-
-	getDataSetCodes : function() {
-		if (this.dataSetCodes) {
-			return this.dataSetCodes;
-		} else {
-			return [];
-		}
-	},
-
-	setDataSetCodes : function(dataSetCodes) {
-		if (!dataSetCodes) {
-			dataSetCodes = [];
-		}
-		if (this.getDataSetCodes().toString() != dataSetCodes.toString()) {
-			this.dataSetCodes = dataSetCodes;
-			if (dataSetCodes.length > 0) {
-				this.setSelectedDataSetCode(dataSetCodes[0]);
-			}
-			this.refresh();
-		}
-	},
-
-	getSelectedDataSetCode : function() {
-		if (this.selectedDataSetCode != null) {
-			return this.selectedDataSetCode;
-		} else {
-			return null;
-		}
-	},
-
-	setSelectedDataSetCode : function(dataSetCode) {
-		if (this.getSelectedDataSetCode() != dataSetCode) {
-			this.selectedDataSetCode = dataSetCode;
-			this.refresh();
-		}
-	}
-
-});
-
-//
-// IMAGE VIEWER VIEW
-//
-
-function ImageViewerView(controller) {
-	this.init(controller);
-}
-
-$.extend(ImageViewerView.prototype, AbstractView.prototype, {
-	init : function(controller) {
-		AbstractView.prototype.init.call(this, controller);
-		this.imageLoader = new ImageLoader();
-		this.panel = $("<div>").addClass("imageViewer");
-	},
-
-	render : function() {
-		this.panel.append(this.createChannelWidget());
-		this.panel.append(this.createResolutionWidget());
-		this.panel.append(this.createChannelStackWidget());
-		this.panel.append(this.createImageWidget());
-
-		this.refresh();
-
-		return this.panel;
-	},
-
-	refresh : function() {
-		this.channelWidget.setSelectedChannel(this.controller.getSelectedChannel());
-		this.channelWidget.setSelectedMergedChannels(this.controller.getSelectedMergedChannels());
-		this.resolutionWidget.setSelectedResolution(this.controller.getSelectedResolution());
-		this.channelStackWidget.setSelectedChannelStackId(this.controller.getSelectedChannelStackId());
-		this.imageWidget.setImageData(this.controller.getSelectedImageData());
-	},
-
-	createChannelWidget : function() {
-		var thisView = this;
-
-		var widget = new ChannelChooserWidget(this.controller.getChannels());
-		widget.addChangeListener(function() {
-			thisView.controller.setSelectedChannel(thisView.channelWidget.getSelectedChannel());
-			thisView.controller.setSelectedMergedChannels(thisView.channelWidget.getSelectedMergedChannels());
-		});
-
-		this.channelWidget = widget;
-		return widget.render();
-	},
-
-	createResolutionWidget : function() {
-		var thisView = this;
-
-		var widget = new ResolutionChooserWidget(this.controller.getResolutions());
-		widget.addChangeListener(function() {
-			thisView.controller.setSelectedResolution(thisView.resolutionWidget.getSelectedResolution());
-		});
-
-		this.resolutionWidget = widget;
-		return widget.render();
-	},
-
-	createChannelStackWidget : function() {
-		var thisView = this;
-
-		var widget = new ChannelStackChooserWidget(this.controller.getChannelStacks());
-
-		widget.setChannelStackContentLoader(function(channelStack, callback) {
-			var imageData = thisView.controller.getSelectedImageData();
-			imageData.setChannelStackId(channelStack.id);
-			thisView.imageLoader.loadImage(imageData, callback);
-		});
-
-		widget.addChangeListener(function() {
-			thisView.controller.setSelectedChannelStackId(thisView.channelStackWidget.getSelectedChannelStackId());
-		});
-
-		this.channelStackWidget = widget;
-		return widget.render();
-	},
-
-	createImageWidget : function() {
-		this.imageWidget = new ImageWidget(this.imageLoader);
-		return this.imageWidget.render();
-	}
-
-});
-
-//
-// IMAGE VIEWER
-//
-
-function ImageViewerWidget(sessionToken, dataSetCode, dataStoreUrl, imageInfo, imageResolutions) {
-	this.init(sessionToken, dataSetCode, dataStoreUrl, imageInfo, imageResolutions);
-}
-
-$.extend(ImageViewerWidget.prototype, AbstractWidget.prototype, {
-	init : function(sessionToken, dataSetCode, dataStoreUrl, imageInfo, imageResolutions) {
-		AbstractWidget.prototype.init.call(this, new ImageViewerView(this));
-		this.facade = new OpenbisFacade(openbis);
-		this.sessionToken = sessionToken;
-		this.dataSetCode = dataSetCode;
-		this.dataStoreUrl = dataStoreUrl;
-		this.imageInfo = imageInfo;
-		this.imageResolutions = imageResolutions;
-
-		var channels = this.getChannels();
-		if (channels && channels.length > 0) {
-			this.setSelectedMergedChannels(channels.map(function(channel) {
-				return channel.code
-			}));
-		}
-
-		var channelStacks = this.getChannelStacks();
-		if (channelStacks && channelStacks.length > 0) {
-			this.setSelectedChannelStackId(channelStacks[0].id);
-		}
-	},
-
-	getSelectedChannel : function() {
-		if (this.selectedChannel != null) {
-			return this.selectedChannel;
-		} else {
-			return null;
-		}
-	},
-
-	setSelectedChannel : function(channel) {
-		if (this.getSelectedChannel() != channel) {
-			this.selectedChannel = channel;
-			this.refresh();
-		}
-	},
-
-	getSelectedMergedChannels : function() {
-		if (this.selectedMergedChannels != null) {
-			return this.selectedMergedChannels;
-		} else {
-			return [];
-		}
-	},
-
-	setSelectedMergedChannels : function(channels) {
-		if (!channels) {
-			channels = [];
-		}
-
-		if (this.getSelectedMergedChannels().toString() != channels.toString()) {
-			this.selectedMergedChannels = channels;
-			this.refresh();
-		}
-	},
-
-	getSelectedChannelStackId : function() {
-		if (this.selectedChannelStackId != null) {
-			return this.selectedChannelStackId;
-		} else {
-			return null;
-		}
-	},
-
-	setSelectedChannelStackId : function(channelStackId) {
-		if (this.getSelectedChannelStackId() != channelStackId) {
-			this.selectedChannelStackId = channelStackId;
-			this.refresh();
-		}
-	},
-
-	getSelectedResolution : function() {
-		if (this.selectedResolution != null) {
-			return this.selectedResolution;
-		} else {
-			return null;
-		}
-	},
-
-	setSelectedResolution : function(resolution) {
-		if (this.getSelectedResolution() != resolution) {
-			this.selectedResolution = resolution;
-			this.refresh();
-		}
-	},
-
-	getSelectedImageData : function() {
-		var imageData = new ImageData();
-		imageData.setDataStoreUrl(this.dataStoreUrl);
-		imageData.setSessionToken(this.sessionToken);
-		imageData.setDataSetCode(this.dataSetCode);
-		imageData.setChannelStackId(this.getSelectedChannelStackId());
-
-		if (this.getSelectedChannel()) {
-			imageData.setChannels([ this.getSelectedChannel() ]);
-		} else {
-			imageData.setChannels(this.getSelectedMergedChannels());
-		}
-		imageData.setResolution(this.getSelectedResolution());
-		return imageData;
-	},
-
-	getChannels : function() {
-		return this.imageInfo.imageDataset.imageDataset.imageParameters.channels;
-	},
-
-	getChannelStacks : function() {
-		if (this.channelStackManager == null) {
-			this.channelStackManager = new ChannelStackManager(this.imageInfo.channelStacks);
-		}
-		return this.channelStackManager.getChannelStacks();
-	},
-
-	getResolutions : function() {
-		return this.imageResolutions;
-	}
-
-// TODO add listeners for channel, resoluton, channel stack
-
-});
-
-//
-// CHANNEL CHOOSER VIEW
-//
-
-function ChannelChooserView(controller) {
-	this.init(controller);
-}
-
-$.extend(ChannelChooserView.prototype, AbstractView.prototype, {
-
-	init : function(controller) {
-		AbstractView.prototype.init.call(this, controller);
-		this.panel = $("<div>");
-	},
-
-	render : function() {
-		this.panel.append(this.createChannelWidget());
-		this.panel.append(this.createMergedChannelsWidget());
-
-		this.refresh();
-
-		return this.panel;
-	},
-
-	refresh : function() {
-		var thisView = this;
-
-		var select = this.panel.find("select");
-		var mergedChannels = this.panel.find(".mergedChannelsWidget");
-
-		if (this.controller.getSelectedChannel() != null) {
-			select.val(this.controller.getSelectedChannel());
-			mergedChannels.hide();
-		} else {
-			select.val("");
-			mergedChannels.find("input").each(function() {
-				var checkbox = $(this);
-				checkbox.prop("checked", thisView.controller.isMergedChannelSelected(checkbox.val()));
-				checkbox.prop("disabled", !thisView.controller.isMergedChannelEnabled(checkbox.val()));
-			});
-			mergedChannels.show();
-		}
-	},
-
-	createChannelWidget : function() {
-		var thisView = this;
-		var widget = $("<div>").addClass("channelWidget").addClass("form-group");
-
-		$("<label>").text("Channel").attr("for", "channelChooserSelect").appendTo(widget);
-
-		var select = $("<select>").attr("id", "channelChooserSelect").addClass("form-control").appendTo(widget);
-		$("<option>").attr("value", "").text("Merged Channels").appendTo(select);
-
-		this.controller.getChannels().forEach(function(channel) {
-			$("<option>").attr("value", channel.code).text(channel.label).appendTo(select);
-		});
-
-		select.change(function() {
-			if (select.val() == "") {
-				thisView.controller.setSelectedChannel(null);
-			} else {
-				thisView.controller.setSelectedChannel(select.val());
-			}
-		});
-
-		return widget;
-	},
-
-	createMergedChannelsWidget : function() {
-		var thisView = this;
-		var widget = $("<div>").addClass("mergedChannelsWidget").addClass("form-group");
-
-		$("<label>").text("Merged Channels").appendTo(widget);
-
-		var checkboxes = $("<div>").appendTo(widget);
-
-		this.controller.getChannels().forEach(function(channel) {
-			var checkbox = $("<label>").addClass("checkbox-inline").appendTo(checkboxes);
-			$("<input>").attr("type", "checkbox").attr("value", channel.code).appendTo(checkbox);
-			checkbox.append(channel.label);
-		});
-
-		widget.find("input").change(function() {
-			var channels = []
-			widget.find("input:checked").each(function() {
-				channels.push($(this).val());
-			});
-			thisView.controller.setSelectedMergedChannels(channels);
-		});
-
-		return widget;
-	}
-
-});
-
-//
-// CHANNEL CHOOSER
-//
-
-function ChannelChooserWidget(channels) {
-	this.init(channels);
-}
-
-$.extend(ChannelChooserWidget.prototype, AbstractWidget.prototype, {
-
-	init : function(channels) {
-		AbstractWidget.prototype.init.call(this, new ChannelChooserView(this));
-		this.setChannels(channels);
-	},
-
-	getSelectedChannel : function() {
-		if (this.selectedChannel) {
-			return this.selectedChannel;
-		} else {
-			return null;
-		}
-	},
-
-	setSelectedChannel : function(channel) {
-		if (this.getSelectedChannel() != channel) {
-			this.selectedChannel = channel;
-			this.refresh();
-			this.notifyChangeListeners();
-		}
-	},
-
-	getSelectedMergedChannels : function() {
-		if (this.selectedMergedChannels) {
-			return this.selectedMergedChannels;
-		} else {
-			return [];
-		}
-	},
-
-	setSelectedMergedChannels : function(channels) {
-		if (!channels) {
-			channels = [];
-		}
-
-		if (this.getSelectedMergedChannels().toString() != channels.toString()) {
-			this.selectedMergedChannels = channels;
-			this.refresh();
-			this.notifyChangeListeners();
-		}
-	},
-
-	isMergedChannelSelected : function(channel) {
-		return $.inArray(channel, this.getSelectedMergedChannels()) != -1;
-	},
-
-	isMergedChannelEnabled : function(channel) {
-		if (this.getSelectedMergedChannels().length == 1) {
-			return !this.isMergedChannelSelected(channel);
-		} else {
-			return true;
-		}
-	},
-
-	getChannels : function() {
-		if (this.channels) {
-			return this.channels;
-		} else {
-			return [];
-		}
-	},
-
-	setChannels : function(channels) {
-		if (!channels) {
-			channels = [];
-		}
-
-		if (this.getChannels().toString() != channels.toString()) {
-			this.setSelectedChannel(null);
-			this.setSelectedMergedChannels(channels.map(function(channel) {
-				return channel.code;
-			}));
-			this.channels = channels;
-			this.refresh();
-		}
-	}
-
-});
-
-//
-// RESOLUTION CHOOSER VIEW
-//
-
-function ResolutionChooserView(controller) {
-	this.init(controller);
-}
-
-$.extend(ResolutionChooserView.prototype, AbstractView.prototype, {
-
-	init : function(controller) {
-		AbstractView.prototype.init.call(this, controller);
-		this.panel = $("<div>").addClass("resolutionChooserWidget").addClass("form-group");
-	},
-
-	render : function() {
-		var thisView = this;
-
-		$("<label>").text("Resolution").attr("for", "resolutionChooserSelect").appendTo(this.panel);
-
-		var select = $("<select>").attr("id", "resolutionChooserSelect").addClass("form-control").appendTo(this.panel);
-		$("<option>").attr("value", "").text("Default").appendTo(select);
-
-		this.controller.getResolutions().forEach(function(resolution) {
-			var value = resolution.width + "x" + resolution.height;
-			$("<option>").attr("value", value).text(value).appendTo(select);
-		});
-
-		select.change(function() {
-			if (select.val() == "") {
-				thisView.controller.setSelectedResolution(null);
-			} else {
-				thisView.controller.setSelectedResolution(select.val());
-			}
-		});
-
-		this.refresh();
-
-		return this.panel;
-	},
-
-	refresh : function() {
-		var select = this.panel.find("select");
-
-		if (this.controller.getSelectedResolution() != null) {
-			select.val(this.controller.getSelectedResolution());
-		} else {
-			select.val("");
-		}
-	}
-
-});
-
-//
-// RESOLUTION CHOOSER
-//
-
-function ResolutionChooserWidget(resolutions) {
-	this.init(resolutions);
-}
-
-$.extend(ResolutionChooserWidget.prototype, AbstractWidget.prototype, {
-
-	init : function(resolutions) {
-		AbstractWidget.prototype.init.call(this, new ResolutionChooserView(this));
-		this.setResolutions(resolutions);
-	},
-
-	getSelectedResolution : function() {
-		return this.selectedResolution;
-	},
-
-	setSelectedResolution : function(resolution) {
-		if (this.selectedResolution != resolution) {
-			this.selectedResolution = resolution;
-			this.refresh();
-			this.notifyChangeListeners();
-		}
-	},
-
-	getResolutions : function() {
-		if (this.resolutions) {
-			return this.resolutions;
-		} else {
-			return [];
-		}
-	},
-
-	setResolutions : function(resolutions) {
-		if (!resolutions) {
-			resolutions = [];
-		}
-
-		if (this.getResolutions().toString() != resolutions.toString()) {
-			this.resolutions = resolutions;
-			this.refresh();
-			this.notifyChangeListeners();
-		}
-	}
-
-});
-
-//
-// CHANNEL STACK CHOOSER
-//
-
-function ChannelStackChooserWidget(channelStacks) {
-	this.init(channelStacks);
-}
-
-$.extend(ChannelStackChooserWidget.prototype, {
-
-	init : function(channelStacks) {
-		var manager = new ChannelStackManager(channelStacks);
-
-		if (manager.isMatrix()) {
-			this.widget = new ChannelStackMatrixChooserWidget(channelStacks);
-		} else {
-			this.widget = new ChannelStackSeriesChooserWidget(channelStacks);
-		}
-	},
-
-	render : function() {
-		return this.widget.render();
-	},
-
-	getSelectedChannelStackId : function() {
-		return this.widget.getSelectedChannelStackId();
-	},
-
-	setSelectedChannelStackId : function(channelStackId) {
-		this.widget.setSelectedChannelStackId(channelStackId);
-	},
-
-	getChannelStackContentLoader : function() {
-		return this.widget.getChannelStackContentLoader();
-	},
-
-	setChannelStackContentLoader : function(channelStackContentLoader) {
-		return this.widget.setChannelStackContentLoader(channelStackContentLoader);
-	},
-
-	addChangeListener : function(listener) {
-		this.widget.addChangeListener(listener);
-	},
-
-	notifyChangeListeners : function() {
-		this.widget.notifyChangeListeners();
-	}
-
-});
-
-//
-// CHANNEL STACK MATRIX CHOOSER VIEW
-//
-
-function ChannelStackMatrixChooserView(controller) {
-	this.init(controller);
-}
-
-$.extend(ChannelStackMatrixChooserView.prototype, AbstractView.prototype, {
-
-	init : function(controller) {
-		AbstractView.prototype.init.call(this, controller);
-		this.panel = $("<div>").addClass("channelStackChooserWidget").addClass("form-group");
-	},
-
-	render : function() {
-		var thisView = this;
-
-		var slidersRow = $("<div>").addClass("row").appendTo(this.panel);
-		$("<div>").addClass("col-md-6").append(this.createTimePointWidget()).appendTo(slidersRow);
-		$("<div>").addClass("col-md-6").append(this.createDepthWidget()).appendTo(slidersRow);
-
-		var buttonsRow = $("<div>").appendTo(this.panel);
-		buttonsRow.append(this.createTimePointButtonsWidget());
-
-		this.refresh();
-
-		return this.panel;
-	},
-
-	refresh : function() {
-		var time = this.controller.getSelectedTimePoint();
-		var timeLabel = this.panel.find(".timePointWidget label");
-		var timeInput = this.panel.find(".timePointWidget input");
-
-		if (time != null) {
-			var timeCount = this.controller.getTimePoints().length;
-			var timeIndex = this.controller.getTimePoints().indexOf(time);
-
-			timeLabel.text("Time: " + time + " sec (" + (timeIndex + 1) + "/" + timeCount + ")");
-			timeInput.slider("setValue", time);
-
-			this.timePointButtons.setSelectedFrame(timeIndex);
-		}
-
-		var depth = this.controller.getSelectedDepth();
-		var depthLabel = this.panel.find(".depthWidget label");
-		var depthInput = this.panel.find(".depthWidget input");
-
-		if (depth != null) {
-			var depthCount = this.controller.getDepths().length;
-			var depthIndex = this.controller.getDepths().indexOf(depth);
-
-			depthLabel.text("Depth: " + depth + " (" + (depthIndex + 1) + "/" + depthCount + ")");
-			depthInput.slider("setValue", depthIndex);
-		}
-	},
-
-	createTimePointWidget : function() {
-		var thisView = this;
-		var widget = $("<div>").addClass("timePointWidget").addClass("form-group");
-
-		$("<label>").attr("for", "timePointInput").appendTo(widget);
-
-		var timeInput = $("<input>").attr("id", "timePointInput").attr("type", "text").addClass("form-control");
-
-		$("<div>").append(timeInput).appendTo(widget);
-
-		timeInput.slider({
-			"min" : 0,
-			"max" : this.controller.getTimePoints().length - 1,
-			"step" : 1,
-			"tooltip" : "hide"
-		}).on("slide", function(event) {
-			if (!$.isArray(event.value) && !isNaN(event.value)) {
-				var timeIndex = parseInt(event.value);
-				var time = thisView.controller.getTimePoints()[timeIndex];
-				thisView.controller.setSelectedTimePoint(time);
-			}
-		});
-
-		return widget;
-	},
-
-	createDepthWidget : function() {
-		var thisView = this;
-		var widget = $("<div>").addClass("depthWidget").addClass("form-group");
-
-		$("<label>").attr("for", "depthInput").appendTo(widget);
-
-		var depthInput = $("<input>").attr("id", "depthInput").attr("type", "text").addClass("form-control");
-
-		$("<div>").append(depthInput).appendTo(widget);
-
-		depthInput.slider({
-			"min" : 0,
-			"max" : this.controller.getDepths().length - 1,
-			"step" : 1,
-			"tooltip" : "hide"
-		}).on("slide", function(event) {
-			if (!$.isArray(event.value) && !isNaN(event.value)) {
-				var depthIndex = parseInt(event.value);
-				var depth = thisView.controller.getDepths()[depthIndex];
-				thisView.controller.setSelectedDepth(depth);
-			}
-		});
-
-		return widget;
-	},
-
-	createTimePointButtonsWidget : function() {
-		var thisView = this;
-
-		var buttons = new MovieButtonsWidget(this.controller.getTimePoints().length);
-
-		buttons.setFrameContentLoader(function(frameIndex, callback) {
-			var timePoint = thisView.controller.getTimePoints()[frameIndex];
-			var depth = thisView.controller.getSelectedDepth();
-			var channelStack = thisView.controller.getChannelStackByTimePointAndDepth(timePoint, depth);
-			thisView.controller.loadChannelStackContent(channelStack, callback);
-		});
-
-		buttons.addChangeListener(function() {
-			var timePoint = thisView.controller.getTimePoints()[buttons.getSelectedFrame()];
-			thisView.controller.setSelectedTimePoint(timePoint);
-		});
-
-		this.timePointButtons = buttons;
-		return buttons.render();
-	}
-
-});
-
-//
-// CHANNEL STACK MATRIX CHOOSER
-//
-
-function ChannelStackMatrixChooserWidget(channelStacks) {
-	this.init(channelStacks);
-}
-
-$.extend(ChannelStackMatrixChooserWidget.prototype, AbstractWidget.prototype, {
-
-	init : function(channelStacks) {
-		AbstractWidget.prototype.init.call(this, new ChannelStackMatrixChooserView(this));
-		this.channelStackManager = new ChannelStackManager(channelStacks);
-	},
-
-	getTimePoints : function() {
-		return this.channelStackManager.getTimePoints();
-	},
-
-	getDepths : function() {
-		return this.channelStackManager.getDepths();
-	},
-
-	getChannelStacks : function() {
-		return this.channelStackManager.getChannelStacks();
-	},
-
-	getChannelStackById : function(channelStackId) {
-		return this.channelStackManager.getChannelStackById(channelStackId);
-	},
-
-	getChannelStackByTimePointAndDepth : function(timePoint, depth) {
-		return this.channelStackManager.getChannelStackByTimePointAndDepth(timePoint, depth);
-	},
-
-	loadChannelStackContent : function(channelStack, callback) {
-		this.getChannelStackContentLoader()(channelStack, callback);
-	},
-
-	getChannelStackContentLoader : function() {
-		if (this.channelStackContentLoader) {
-			return this.channelStackContentLoader;
-		} else {
-			return function(channelStack, callback) {
-				callback();
-			}
-		}
-	},
-
-	setChannelStackContentLoader : function(channelStackContentLoader) {
-		this.channelStackContentLoader = channelStackContentLoader;
-	},
-
-	getSelectedChannelStackId : function() {
-		return this.selectedChannelStackId;
-	},
-
-	setSelectedChannelStackId : function(channelStackId) {
-		if (this.selectedChannelStackId != channelStackId) {
-			this.selectedChannelStackId = channelStackId;
-			this.refresh();
-			this.notifyChangeListeners();
-		}
-	},
-
-	getSelectedChannelStack : function() {
-		var channelStackId = this.getSelectedChannelStackId();
-
-		if (channelStackId != null) {
-			return this.channelStackManager.getChannelStackById(channelStackId);
-		} else {
-			return null;
-		}
-	},
-
-	setSelectedChannelStack : function(channelStack) {
-		if (channelStack != null) {
-			this.setSelectedChannelStackId(channelStack.id);
-		} else {
-			this.setSelectedChannelStackId(null);
-		}
-	},
-
-	getSelectedTimePoint : function() {
-		var channelStack = this.getSelectedChannelStack();
-		if (channelStack != null) {
-			return channelStack.timePointOrNull;
-		} else {
-			return null;
-		}
-	},
-
-	setSelectedTimePoint : function(timePoint) {
-		if (timePoint != null && this.getSelectedDepth() != null) {
-			var channelStack = this.channelStackManager.getChannelStackByTimePointAndDepth(timePoint, this.getSelectedDepth());
-			this.setSelectedChannelStack(channelStack);
-		} else {
-			this.setSelectedChannelStack(null);
-		}
-	},
-
-	getSelectedDepth : function() {
-		var channelStack = this.getSelectedChannelStack();
-		if (channelStack != null) {
-			return channelStack.depthOrNull;
-		} else {
-			return null;
-		}
-	},
-
-	setSelectedDepth : function(depth) {
-		if (depth != null && this.getSelectedTimePoint() != null) {
-			var channelStack = this.channelStackManager.getChannelStackByTimePointAndDepth(this.getSelectedTimePoint(), depth);
-			this.setSelectedChannelStack(channelStack);
-		} else {
-			this.setSelectedChannelStack(null);
-		}
-	}
-
-});
-
-//
-// CHANNEL STACK SERIES CHOOSER VIEW
-//
-
-function ChannelStackSeriesChooserView(controller) {
-	this.init(controller);
-}
-
-$.extend(ChannelStackSeriesChooserView.prototype, AbstractView.prototype, {
-
-	init : function(controller) {
-		AbstractView.prototype.init.call(this, controller);
-		this.panel = $("<div>").addClass("channelStackChooserWidget").addClass("form-group");
-	},
-
-	render : function() {
-		var thisView = this;
-
-		this.panel.append(this.createSliderWidget());
-		this.panel.append(this.createButtonsWidget());
-
-		this.refresh();
-
-		return this.panel;
-	},
-
-	refresh : function() {
-		var channelStackId = this.controller.getSelectedChannelStackId();
-
-		if (channelStackId != null) {
-			var count = this.controller.getChannelStacks().length;
-			var index = this.controller.getChannelStackIndex(channelStackId);
-
-			var sliderLabel = this.panel.find(".sliderWidget label");
-			sliderLabel.text("Channel Stack: " + index + " (" + (index + 1) + "/" + count + ")");
-
-			var sliderInput = this.panel.find(".sliderWidget input");
-			sliderInput.slider("setValue", index);
-
-			this.buttons.setSelectedFrame(index);
-		}
-	},
-
-	createSliderWidget : function() {
-		var thisView = this;
-		var widget = $("<div>").addClass("sliderWidget").addClass("form-group");
-
-		$("<label>").attr("for", "sliderInput").appendTo(widget);
-
-		var sliderInput = $("<input>").attr("id", "sliderInput").attr("type", "text").addClass("form-control");
-
-		$("<div>").append(sliderInput).appendTo(widget);
-
-		sliderInput.slider({
-			"min" : 0,
-			"max" : this.controller.getChannelStacks().length - 1,
-			"step" : 1,
-			"tooltip" : "hide"
-		}).on("slide", function(event) {
-			if (!$.isArray(event.value) && !isNaN(event.value)) {
-				var index = parseInt(event.value);
-				var channelStack = thisView.controller.getChannelStacks()[index];
-				thisView.controller.setSelectedChannelStackId(channelStack.id);
-			}
-		});
-
-		return widget;
-	},
-
-	createButtonsWidget : function() {
-		var thisView = this;
-
-		var buttons = new MovieButtonsWidget(this.controller.getChannelStacks().length);
-
-		buttons.setFrameContentLoader(function(frameIndex, callback) {
-			var channelStack = thisView.controller.getChannelStacks()[frameIndex];
-			thisView.controller.loadChannelStackContent(channelStack, callback);
-		});
-
-		buttons.addChangeListener(function() {
-			var channelStack = thisView.controller.getChannelStacks()[buttons.getSelectedFrame()];
-			thisView.controller.setSelectedChannelStackId(channelStack.id);
-		});
-
-		this.buttons = buttons;
-		return buttons.render();
-	}
-
-});
-
-//
-// CHANNEL STACK SERIES CHOOSER
-//
-
-function ChannelStackSeriesChooserWidget(channelStacks) {
-	this.init(channelStacks);
-}
-
-$.extend(ChannelStackSeriesChooserWidget.prototype, AbstractWidget.prototype, {
-
-	init : function(channelStacks) {
-		AbstractWidget.prototype.init.call(this, new ChannelStackSeriesChooserView(this));
-		this.channelStackManager = new ChannelStackManager(channelStacks);
-	},
-
-	getChannelStacks : function() {
-		return this.channelStackManager.getChannelStacks();
-	},
-
-	getChannelStackIndex : function(channelStackId) {
-		return this.channelStackManager.getChannelStackIndex(channelStackId);
-	},
-
-	loadChannelStackContent : function(channelStack, callback) {
-		this.getChannelStackContentLoader()(channelStack, callback);
-	},
-
-	getChannelStackContentLoader : function() {
-		if (this.channelStackContentLoader) {
-			return this.channelStackContentLoader;
-		} else {
-			return function(channelStack, callback) {
-				callback();
-			}
-		}
-	},
-
-	setChannelStackContentLoader : function(channelStackContentLoader) {
-		this.channelStackContentLoader = channelStackContentLoader;
-	},
-
-	getSelectedChannelStackId : function() {
-		return this.selectedChannelStackId;
-	},
-
-	setSelectedChannelStackId : function(channelStackId) {
-		if (this.selectedChannelStackId != channelStackId) {
-			this.selectedChannelStackId = channelStackId;
-			this.refresh();
-			this.notifyChangeListeners();
-		}
-	}
-
-});
-
-//
-// MOVIE BUTTONS VIEW
-//
-
-function MovieButtonsView(controller) {
-	this.init(controller);
-}
-
-$.extend(MovieButtonsView.prototype, AbstractView.prototype, {
-
-	init : function(controller) {
-		AbstractView.prototype.init.call(this, controller);
-		this.panel = $("<div>").addClass("movieButtonsWidget").addClass("form-group");
-	},
-
-	render : function() {
-		var thisView = this;
-
-		var row = $("<div>").addClass("row").appendTo(this.panel);
-
-		var buttonsRow = $("<div>").addClass("buttons").addClass("row").appendTo(this.panel);
-		var delayRow = $("<div>").addClass("delay").addClass("form-inline").appendTo(this.panel);
-
-		$("<div>").addClass("col-md-6").append(buttonsRow).appendTo(row);
-		$("<div>").addClass("col-md-6").append(delayRow).appendTo(row);
-
-		var play = $("<button>").addClass("play").addClass("btn").addClass("btn-primary");
-		$("<span>").addClass("glyphicon").addClass("glyphicon-play").appendTo(play);
-		$("<div>").addClass("col-md-3").append(play).appendTo(buttonsRow);
-
-		play.click(function() {
-			thisView.controller.play();
-		});
-
-		var stop = $("<button>").addClass("stop").addClass("btn").addClass("btn-primary");
-		$("<span>").addClass("glyphicon").addClass("glyphicon-stop").appendTo(stop);
-		$("<div>").addClass("col-md-3").append(stop).appendTo(buttonsRow);
-
-		stop.click(function() {
-			thisView.controller.stop();
-		});
-
-		var prev = $("<button>").addClass("prev").addClass("btn").addClass("btn-default");
-		$("<span>").addClass("glyphicon").addClass("glyphicon-backward").appendTo(prev);
-		$("<div>").addClass("col-md-3").append(prev).appendTo(buttonsRow);
-
-		prev.click(function() {
-			thisView.controller.prev();
-		});
-
-		var next = $("<button>").addClass("next").addClass("btn").addClass("btn-default");
-		$("<span>").addClass("glyphicon").addClass("glyphicon-forward").appendTo(next);
-		$("<div>").addClass("col-md-3").append(next).appendTo(buttonsRow);
-
-		next.click(function() {
-			thisView.controller.next();
-		});
-
-		var delayTable = $("<table>").appendTo(delayRow);
-		var delayTr = $("<tr>").appendTo(delayTable);
-
-		$("<td>").append($("<span>").addClass("delayLabel").text("delay:").attr("for", "delayInput")).appendTo(delayTr);
-
-		var delay = $("<input>").attr("id", "delayInput").attr("type", "text").addClass("delay").addClass("form-control");
-		delay.change(function() {
-			thisView.controller.setSelectedDelay(delay.val());
-		});
-		$("<td>").attr("width", "100%").append(delay).appendTo(delayTr);
-
-		$("<td>").append($("<span>").addClass("delayUnit").text("ms")).appendTo(delayTr);
-
-		this.refresh();
-
-		return this.panel;
-	},
-
-	refresh : function() {
-		var play = this.panel.find("button.play");
-		play.prop("disabled", this.controller.isPlaying());
-
-		var stop = this.panel.find("button.stop");
-		stop.prop("disabled", this.controller.isStopped());
-
-		var prev = this.panel.find("button.prev");
-		prev.prop("disabled", this.controller.isFirstFrameSelected());
-
-		var next = this.panel.find("button.next");
-		next.prop("disabled", this.controller.isLastFrameSelected());
-
-		var delay = this.panel.find("input.delay");
-		delay.val(this.controller.getSelectedDelay());
-	}
-
-});
-
-//
-// MOVIE BUTTONS WIDGET
-//
-
-function MovieButtonsWidget(frameCount) {
-	this.init(frameCount);
-}
-
-$.extend(MovieButtonsWidget.prototype, AbstractWidget.prototype, {
-
-	init : function(frameCount) {
-		AbstractWidget.prototype.init.call(this, new MovieButtonsView(this));
-		this.frameCount = frameCount;
-		this.frameContentLoader = function(frameIndex, callback) {
-			callback();
-		};
-		this.frameAction = null;
-		this.selectedDelay = 100;
-		this.selectedFrame = 0;
-	},
-
-	play : function() {
-		if (this.frameAction) {
-			return;
-		}
-
-		if (this.getSelectedFrame() == this.frameCount - 1) {
-			this.setSelectedFrame(0);
-		}
-
-		var thisButtons = this;
-
-		this.frameAction = function() {
-			if (thisButtons.getSelectedFrame() < thisButtons.frameCount - 1) {
-				var frame = thisButtons.getSelectedFrame() + 1;
-				var startTime = Date.now();
-
-				thisButtons.setSelectedFrame(frame, function() {
-					var prefferedDelay = thisButtons.selectedDelay;
-					var actualDelay = Date.now() - startTime;
-
-					setTimeout(function() {
-						if (thisButtons.frameAction) {
-							thisButtons.frameAction();
-						}
-					}, Math.max(1, prefferedDelay - actualDelay));
-				});
-			} else {
-				thisButtons.stop();
-				thisButtons.setSelectedFrame(0);
-			}
-		};
-
-		this.frameAction();
-		this.refresh();
-	},
-
-	stop : function() {
-		if (this.frameAction) {
-			this.frameAction = null;
-			this.refresh();
-		}
-	},
-
-	prev : function() {
-		this.setSelectedFrame(this.getSelectedFrame() - 1);
-	},
-
-	next : function() {
-		this.setSelectedFrame(this.getSelectedFrame() + 1);
-	},
-
-	isPlaying : function() {
-		return this.frameAction != null;
-	},
-
-	isStopped : function() {
-		return this.frameAction == null;
-	},
-
-	isFirstFrameSelected : function() {
-		return this.getSelectedFrame() == 0;
-	},
-
-	isLastFrameSelected : function() {
-		return this.getSelectedFrame() == (this.frameCount - 1)
-	},
-
-	getSelectedDelay : function() {
-		return this.selectedDelay;
-	},
-
-	setSelectedDelay : function(delay) {
-		if (this.selectedDelay != delay) {
-			this.selectedDelay = delay;
-			this.refresh();
-		}
-	},
-
-	getSelectedFrame : function() {
-		return this.selectedFrame;
-	},
-
-	setSelectedFrame : function(frame, callback) {
-		frame = Math.min(Math.max(0, frame), this.frameCount - 1);
-
-		if (this.selectedFrame != frame) {
-			log("Selected frame: " + frame);
-			this.selectedFrame = frame;
-			this.frameContentLoader(frame, callback);
-			this.refresh();
-			this.notifyChangeListeners();
-		}
-	},
-
-	setFrameContentLoader : function(frameContentLoader) {
-		this.frameContentLoader = frameContentLoader;
-	},
-
-	getFrameContentLoader : function(frameContentLoader) {
-		return this.frameContentLoader;
-	}
-
-});
-
-//
-// IMAGE VIEW
-//
-
-function ImageView(controller) {
-	this.init(controller);
-}
-
-$.extend(ImageView.prototype, AbstractView.prototype, {
-
-	init : function(controller) {
-		AbstractView.prototype.init.call(this, controller);
-		this.panel = $("<div>").addClass("imageWidget");
-	},
-
-	render : function() {
-		this.refresh();
-		return this.panel;
-	},
-
-	refresh : function() {
-		var thisView = this;
-
-		if (this.controller.getImageData()) {
-			this.controller.loadImage(this.controller.getImageData(), function(image) {
-				thisView.panel.empty();
-				thisView.panel.append(image);
-			});
-		} else {
-			this.panel.empty();
-		}
-	}
-
-});
-
-//
-// IMAGE WIDGET
-//
-
-function ImageWidget(imageLoader) {
-	this.init(imageLoader);
-}
-
-$.extend(ImageWidget.prototype, AbstractWidget.prototype, {
-
-	init : function(imageLoader) {
-		AbstractWidget.prototype.init.call(this, new ImageView(this));
-		this.imageLoader = imageLoader;
-	},
-
-	loadImage : function(imageData, callback) {
-		this.imageLoader.loadImage(imageData, callback);
-	},
-
-	getImageData : function(imageData) {
-		return this.imageData;
-	},
-
-	setImageData : function(imageData) {
-		this.imageData = imageData;
-		this.refresh();
-	}
-
-});
-
-//
-// FACADE
-//
-
-function OpenbisFacade(openbis) {
-	this.init(openbis);
-}
-
-$.extend(OpenbisFacade.prototype, {
-	init : function(openbis) {
-		this.openbis = openbis;
-	},
-
-	getSession : function() {
-		return this.openbis.getSession();
-	},
-
-	getDataStoreBaseURLs : function(dataSetCodes, action) {
-		this.openbis.getDataStoreBaseURLs(dataSetCodes, function(response) {
-			var dataSetCodeToUrlMap = {};
-
-			if (response.result) {
-				response.result.forEach(function(urlForDataSets) {
-					urlForDataSets.dataSetCodes.forEach(function(dataSetCode) {
-						dataSetCodeToUrlMap[dataSetCode] = urlForDataSets.dataStoreURL;
-					});
-				});
-				response.result = dataSetCodeToUrlMap;
-			}
-
-			action(response);
-		});
-	},
-
-	getImageInfo : function(dataSetCodes, callback) {
-		this.openbis.getImageInfo(dataSetCodes, callback);
-	},
-
-	getImageResolutions : function(dataSetCodes, callback) {
-		this.openbis.getImageResolutions(dataSetCodes, callback);
-	}
-});
-
-//
-// CHANNEL STACK MANAGER
-//
-
-function ChannelStackManager(channelStacks) {
-	this.init(channelStacks);
-}
-
-$.extend(ChannelStackManager.prototype, {
-
-	init : function(channelStacks) {
-		this.channelStacks = channelStacks;
-		this.channelStacks.sort(function(o1, o2) {
-			var s1 = o1.seriesNumberOrNull;
-			var s2 = o2.seriesNumberOrNull;
-			var t1 = o1.timePointOrNull;
-			var t2 = o2.timePointOrNull;
-			var d1 = o1.depthOrNull;
-			var d2 = o2.depthOrNull;
-
-			var compare = function(v1, v2) {
-				if (v1 == null) {
-					if (v2 == null) {
-						return 0;
-					} else {
-						return -1;
-					}
-				} else if (v2 == null) {
-					return 1;
-				} else {
-					if (v1 > v2) {
-						return 1;
-					} else if (v1 < v2) {
-						return -1;
-					} else {
-						return 0;
-					}
-				}
-			}
-
-			return compare(s1, s2) * 100 + compare(t1, t2) * 10 + compare(d1, d2);
-		});
-	},
-
-	isMatrix : function() {
-		/*
-		 * TODO return (!this.isSeriesNumberPresent() ||
-		 * this.getSeriesNumbers().length == 1) && !this.isTimePointMissing() &&
-		 * !this.isDepthMissing() && this.isDepthConsistent();
-		 */
-		return !this.isSeriesNumberPresent() && !this.isTimePointMissing() && !this.isDepthMissing() && this.isDepthConsistent();
-	},
-
-	isSeriesNumberPresent : function() {
-		return this.channelStacks.some(function(channelStack) {
-			return channelStack.seriesNumberOrNull;
-		});
-	},
-
-	isTimePointMissing : function() {
-		return this.channelStacks.some(function(channelStack) {
-			return channelStack.timePointOrNull == null;
-		});
-	},
-
-	isDepthMissing : function() {
-		return this.channelStacks.some(function(channelStack) {
-			return channelStack.depthOrNull == null;
-		});
-	},
-
-	isDepthConsistent : function() {
-		var map = this.getChannelStackByTimePointAndDepthMap();
-		var depthCounts = {};
-
-		for (timePoint in map) {
-			var entry = map[timePoint];
-			var depthCount = Object.keys(entry).length;
-			depthCounts[depthCount] = true;
-		}
-
-		return Object.keys(depthCounts).length == 1;
-	},
-
-	getSeriesNumbers : function() {
-		if (!this.seriesNumbers) {
-			var seriesNumbers = {};
-
-			this.channelStacks.forEach(function(channelStack) {
-				if (channelStack.seriesNumberOrNull != null) {
-					seriesNumbers[channelStack.seriesNumberOrNull] = true;
-				}
-			});
-
-			this.seriesNumbers = Object.keys(seriesNumbers).map(function(seriesNumber) {
-				return parseInt(seriesNumber);
-			}).sort();
-		}
-		return this.seriesNumbers;
-	},
-
-	getSeriesNumber : function(index) {
-		return this.getSeriesNumbers()[index];
-	},
-
-	getTimePoints : function() {
-		if (!this.timePoints) {
-			var timePoints = {};
-
-			this.channelStacks.forEach(function(channelStack) {
-				if (channelStack.timePointOrNull != null) {
-					timePoints[channelStack.timePointOrNull] = true;
-				}
-			});
-
-			this.timePoints = Object.keys(timePoints).map(function(timePoint) {
-				return parseInt(timePoint);
-			}).sort();
-		}
-		return this.timePoints;
-	},
-
-	getTimePoint : function(index) {
-		return this.getTimePoints()[index];
-	},
-
-	getTimePointIndex : function(timePoint) {
-		if (!this.timePointsMap) {
-			var map = {};
-
-			this.getTimePoints().forEach(function(timePoint, index) {
-				map[timePoint] = index;
-			});
-
-			this.timePointsMap = map;
-		}
-
-		return this.timePointsMap[timePoint];
-	},
-
-	getDepths : function() {
-		if (!this.depths) {
-			var depths = {};
-
-			this.channelStacks.forEach(function(channelStack) {
-				if (channelStack.depthOrNull != null) {
-					depths[channelStack.depthOrNull] = true;
-				}
-			});
-
-			this.depths = Object.keys(depths).map(function(depth) {
-				return parseInt(depth);
-			}).sort();
-		}
-		return this.depths;
-	},
-
-	getDepth : function(index) {
-		return this.getDepths()[index];
-	},
-
-	getDepthIndex : function(depth) {
-		if (!this.depthsMap) {
-			var map = {};
-
-			this.getDepths().forEach(function(depth, index) {
-				map[depth] = index;
-			});
-
-			this.depthsMap = map;
-		}
-
-		return this.depthsMap[depth];
-	},
-
-	getChannelStackIndex : function(channelStackId) {
-		if (!this.channelStackMap) {
-			var map = {};
-
-			this.getChannelStacks().forEach(function(channelStack, index) {
-				map[channelStack.id] = index;
-			});
-
-			this.channelStackMap = map;
-		}
-
-		return this.channelStackMap[channelStackId];
-	},
-
-	getChannelStackById : function(channelStackId) {
-		if (!this.channelStackByIdMap) {
-			var map = {};
-			this.channelStacks.forEach(function(channelStack) {
-				map[channelStack.id] = channelStack;
-			});
-			this.channelStackByIdMap = map;
-		}
-		return this.channelStackByIdMap[channelStackId];
-	},
-
-	getChannelStackByTimePointAndDepth : function(timePoint, depth) {
-		var map = this.getChannelStackByTimePointAndDepthMap();
-		var entry = map[timePoint];
-
-		if (entry) {
-			return entry[depth];
-		} else {
-			return null;
-		}
-	},
-
-	getChannelStackByTimePointAndDepthMap : function() {
-		if (!this.channelStackByTimePointAndDepthMap) {
-			var map = {};
-			this.channelStacks.forEach(function(channelStack) {
-				if (channelStack.timePointOrNull != null && channelStack.depthOrNull != null) {
-					var entry = map[channelStack.timePointOrNull];
-					if (!entry) {
-						entry = {};
-						map[channelStack.timePointOrNull] = entry;
-					}
-					entry[channelStack.depthOrNull] = channelStack;
-				}
-			});
-			this.channelStackByTimePointAndDepthMap = map;
-		}
-		return this.channelStackByTimePointAndDepthMap;
-	},
-
-	getChannelStacks : function() {
-		return this.channelStacks;
-	}
-
-});
-
-//
-// IMAGE DATA
-//
-
-function ImageData() {
-	this.init();
-}
-
-$.extend(ImageData.prototype, {
-
-	init : function() {
-	},
-
-	setDataStoreUrl : function(dataStoreUrl) {
-		this.dataStoreUrl = dataStoreUrl;
-	},
-
-	setSessionToken : function(sessionToken) {
-		this.sessionToken = sessionToken;
-	},
-
-	setDataSetCode : function(dataSetCode) {
-		this.dataSetCode = dataSetCode;
-	},
-
-	setChannelStackId : function(channelStackId) {
-		this.channelStackId = channelStackId;
-	},
-
-	setChannels : function(channels) {
-		this.channels = channels;
-	},
-
-	setResolution : function(resolution) {
-		this.resolution = resolution;
-	}
-
-});
-
-//
-// IMAGE LOADER
-//
-
-function ImageLoader() {
-	this.init();
-}
-
-$.extend(ImageLoader.prototype, {
-
-	init : function() {
-	},
-
-	loadImage : function(imageData, callback) {
-		log("loadImage: " + imageData.channelStackId);
-
-		var url = imageData.dataStoreUrl + "/datastore_server_screening";
-		url += "?sessionID=" + imageData.sessionToken;
-		url += "&dataset=" + imageData.dataSetCode;
-		url += "&channelStackId=" + imageData.channelStackId;
-
-		imageData.channels.forEach(function(channel) {
-			url += "&channel=" + channel;
-		});
-
-		if (imageData.resolution) {
-			url += "&mode=thumbnail" + imageData.resolution;
-		} else {
-			url += "&mode=thumbnail480x480";
-		}
-
-		$("<img>").attr("src", url).load(function() {
-			if (callback) {
-				callback(this);
-			}
-		});
-	}
-
-});
-
-//
-// CALLBACK MANAGER
-//
-
-function CallbackManager(callback) {
-	this.init(callback);
-}
-
-$.extend(CallbackManager.prototype, {
-
-	init : function(callback) {
-		this.callback = callback;
-		this.callbacks = {};
-	},
-
-	registerCallback : function(callback) {
-		var manager = this;
-
-		var wrapper = function() {
-			callback.apply(this, arguments);
-
-			delete manager.callbacks[callback]
-
-			for (c in manager.callbacks) {
-				return;
-			}
-
-			manager.callback();
-		}
-
-		this.callbacks[callback] = callback;
-		return wrapper;
-	}
-});
-
-//
-// LISTENER MANAGER
-//
-
-function ListenerManager() {
-	this.init();
-}
-
-$.extend(ListenerManager.prototype, {
-
-	init : function() {
-		this.listeners = {};
-	},
-
-	addListener : function(eventType, listener) {
-		if (!this.listeners[eventType]) {
-			this.listeners[eventType] = []
-		}
-		this.listeners[eventType].push(listener);
-	},
-
-	notifyListeners : function(eventType) {
-		if (this.listeners[eventType]) {
-			this.listeners[eventType].forEach(function(listener) {
-				listener();
-			});
-		}
-	}
-});
-
-function log(msg) {
-	if (console) {
-		var date = new Date();
-		console.log(date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds() + "." + date.getMilliseconds() + " - " + msg);
-	}
-}
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/index.html b/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/index.html
deleted file mode 100644
index 0778636fe34d039c996a65d8c09228ec20c35100..0000000000000000000000000000000000000000
--- a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/index.html
+++ /dev/null
@@ -1,36 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="utf-8">
-<title>Image Viewer</title>
-
-<script src="jquery.js"></script>
-<script src="openbis.js"></script>
-<script src="openbis-screening.js"></script>
-
-<link rel="stylesheet" href="lib/bootstrap/css/bootstrap.min.css">
-<script src="lib/bootstrap/js/bootstrap.min.js"></script>
-
-<link rel="stylesheet" href="lib/bootstrap-slider/css/bootstrap-slider.min.css">
-<script src="lib/bootstrap-slider/js/bootstrap-slider.min.js"></script>
-
-<link rel="stylesheet" href="image-viewer.css">
-<script src="image-viewer.js"></script>
-
-</head>
-<body>
-	<script>
-		$(document).ready(function() {
-			var facade = new openbis();
-
-			facade.login("admin", "password", function(response) {
-				var widget = new ImageViewerChooserWidget(facade, [ "20140415140347875-53", "20140506132344798-146" ]);
-				$("#container").append(widget.render());
-			});
-		});
-	</script>
-
-	<div id="container" style="width: 600px; padding: 20px;"></div>
-
-</body>
-</html>
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/jquery.js b/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/jquery.js
deleted file mode 100644
index 83589daa707a25a1fb3e4112075d382e9a1611ab..0000000000000000000000000000000000000000
--- a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/jquery.js
+++ /dev/null
@@ -1,2 +0,0 @@
-/*! jQuery v1.8.3 jquery.com | jquery.org/license */
-(function(e,t){function _(e){var t=M[e]={};return v.each(e.split(y),function(e,n){t[n]=!0}),t}function H(e,n,r){if(r===t&&e.nodeType===1){var i="data-"+n.replace(P,"-$1").toLowerCase();r=e.getAttribute(i);if(typeof r=="string"){try{r=r==="true"?!0:r==="false"?!1:r==="null"?null:+r+""===r?+r:D.test(r)?v.parseJSON(r):r}catch(s){}v.data(e,n,r)}else r=t}return r}function B(e){var t;for(t in e){if(t==="data"&&v.isEmptyObject(e[t]))continue;if(t!=="toJSON")return!1}return!0}function et(){return!1}function tt(){return!0}function ut(e){return!e||!e.parentNode||e.parentNode.nodeType===11}function at(e,t){do e=e[t];while(e&&e.nodeType!==1);return e}function ft(e,t,n){t=t||0;if(v.isFunction(t))return v.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return v.grep(e,function(e,r){return e===t===n});if(typeof t=="string"){var r=v.grep(e,function(e){return e.nodeType===1});if(it.test(t))return v.filter(t,r,!n);t=v.filter(t,r)}return v.grep(e,function(e,r){return v.inArray(e,t)>=0===n})}function lt(e){var t=ct.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}function Lt(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function At(e,t){if(t.nodeType!==1||!v.hasData(e))return;var n,r,i,s=v._data(e),o=v._data(t,s),u=s.events;if(u){delete o.handle,o.events={};for(n in u)for(r=0,i=u[n].length;r<i;r++)v.event.add(t,n,u[n][r])}o.data&&(o.data=v.extend({},o.data))}function Ot(e,t){var n;if(t.nodeType!==1)return;t.clearAttributes&&t.clearAttributes(),t.mergeAttributes&&t.mergeAttributes(e),n=t.nodeName.toLowerCase(),n==="object"?(t.parentNode&&(t.outerHTML=e.outerHTML),v.support.html5Clone&&e.innerHTML&&!v.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):n==="input"&&Et.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):n==="option"?t.selected=e.defaultSelected:n==="input"||n==="textarea"?t.defaultValue=e.defaultValue:n==="script"&&t.text!==e.text&&(t.text=e.text),t.removeAttribute(v.expando)}function Mt(e){return typeof e.getElementsByTagName!="undefined"?e.getElementsByTagName("*"):typeof e.querySelectorAll!="undefined"?e.querySelectorAll("*"):[]}function _t(e){Et.test(e.type)&&(e.defaultChecked=e.checked)}function Qt(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=Jt.length;while(i--){t=Jt[i]+n;if(t in e)return t}return r}function Gt(e,t){return e=t||e,v.css(e,"display")==="none"||!v.contains(e.ownerDocument,e)}function Yt(e,t){var n,r,i=[],s=0,o=e.length;for(;s<o;s++){n=e[s];if(!n.style)continue;i[s]=v._data(n,"olddisplay"),t?(!i[s]&&n.style.display==="none"&&(n.style.display=""),n.style.display===""&&Gt(n)&&(i[s]=v._data(n,"olddisplay",nn(n.nodeName)))):(r=Dt(n,"display"),!i[s]&&r!=="none"&&v._data(n,"olddisplay",r))}for(s=0;s<o;s++){n=e[s];if(!n.style)continue;if(!t||n.style.display==="none"||n.style.display==="")n.style.display=t?i[s]||"":"none"}return e}function Zt(e,t,n){var r=Rt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function en(e,t,n,r){var i=n===(r?"border":"content")?4:t==="width"?1:0,s=0;for(;i<4;i+=2)n==="margin"&&(s+=v.css(e,n+$t[i],!0)),r?(n==="content"&&(s-=parseFloat(Dt(e,"padding"+$t[i]))||0),n!=="margin"&&(s-=parseFloat(Dt(e,"border"+$t[i]+"Width"))||0)):(s+=parseFloat(Dt(e,"padding"+$t[i]))||0,n!=="padding"&&(s+=parseFloat(Dt(e,"border"+$t[i]+"Width"))||0));return s}function tn(e,t,n){var r=t==="width"?e.offsetWidth:e.offsetHeight,i=!0,s=v.support.boxSizing&&v.css(e,"boxSizing")==="border-box";if(r<=0||r==null){r=Dt(e,t);if(r<0||r==null)r=e.style[t];if(Ut.test(r))return r;i=s&&(v.support.boxSizingReliable||r===e.style[t]),r=parseFloat(r)||0}return r+en(e,t,n||(s?"border":"content"),i)+"px"}function nn(e){if(Wt[e])return Wt[e];var t=v("<"+e+">").appendTo(i.body),n=t.css("display");t.remove();if(n==="none"||n===""){Pt=i.body.appendChild(Pt||v.extend(i.createElement("iframe"),{frameBorder:0,width:0,height:0}));if(!Ht||!Pt.createElement)Ht=(Pt.contentWindow||Pt.contentDocument).document,Ht.write("<!doctype html><html><body>"),Ht.close();t=Ht.body.appendChild(Ht.createElement(e)),n=Dt(t,"display"),i.body.removeChild(Pt)}return Wt[e]=n,n}function fn(e,t,n,r){var i;if(v.isArray(t))v.each(t,function(t,i){n||sn.test(e)?r(e,i):fn(e+"["+(typeof i=="object"?t:"")+"]",i,n,r)});else if(!n&&v.type(t)==="object")for(i in t)fn(e+"["+i+"]",t[i],n,r);else r(e,t)}function Cn(e){return function(t,n){typeof t!="string"&&(n=t,t="*");var r,i,s,o=t.toLowerCase().split(y),u=0,a=o.length;if(v.isFunction(n))for(;u<a;u++)r=o[u],s=/^\+/.test(r),s&&(r=r.substr(1)||"*"),i=e[r]=e[r]||[],i[s?"unshift":"push"](n)}}function kn(e,n,r,i,s,o){s=s||n.dataTypes[0],o=o||{},o[s]=!0;var u,a=e[s],f=0,l=a?a.length:0,c=e===Sn;for(;f<l&&(c||!u);f++)u=a[f](n,r,i),typeof u=="string"&&(!c||o[u]?u=t:(n.dataTypes.unshift(u),u=kn(e,n,r,i,u,o)));return(c||!u)&&!o["*"]&&(u=kn(e,n,r,i,"*",o)),u}function Ln(e,n){var r,i,s=v.ajaxSettings.flatOptions||{};for(r in n)n[r]!==t&&((s[r]?e:i||(i={}))[r]=n[r]);i&&v.extend(!0,e,i)}function An(e,n,r){var i,s,o,u,a=e.contents,f=e.dataTypes,l=e.responseFields;for(s in l)s in r&&(n[l[s]]=r[s]);while(f[0]==="*")f.shift(),i===t&&(i=e.mimeType||n.getResponseHeader("content-type"));if(i)for(s in a)if(a[s]&&a[s].test(i)){f.unshift(s);break}if(f[0]in r)o=f[0];else{for(s in r){if(!f[0]||e.converters[s+" "+f[0]]){o=s;break}u||(u=s)}o=o||u}if(o)return o!==f[0]&&f.unshift(o),r[o]}function On(e,t){var n,r,i,s,o=e.dataTypes.slice(),u=o[0],a={},f=0;e.dataFilter&&(t=e.dataFilter(t,e.dataType));if(o[1])for(n in e.converters)a[n.toLowerCase()]=e.converters[n];for(;i=o[++f];)if(i!=="*"){if(u!=="*"&&u!==i){n=a[u+" "+i]||a["* "+i];if(!n)for(r in a){s=r.split(" ");if(s[1]===i){n=a[u+" "+s[0]]||a["* "+s[0]];if(n){n===!0?n=a[r]:a[r]!==!0&&(i=s[0],o.splice(f--,0,i));break}}}if(n!==!0)if(n&&e["throws"])t=n(t);else try{t=n(t)}catch(l){return{state:"parsererror",error:n?l:"No conversion from "+u+" to "+i}}}u=i}return{state:"success",data:t}}function Fn(){try{return new e.XMLHttpRequest}catch(t){}}function In(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}function $n(){return setTimeout(function(){qn=t},0),qn=v.now()}function Jn(e,t){v.each(t,function(t,n){var r=(Vn[t]||[]).concat(Vn["*"]),i=0,s=r.length;for(;i<s;i++)if(r[i].call(e,t,n))return})}function Kn(e,t,n){var r,i=0,s=0,o=Xn.length,u=v.Deferred().always(function(){delete a.elem}),a=function(){var t=qn||$n(),n=Math.max(0,f.startTime+f.duration-t),r=n/f.duration||0,i=1-r,s=0,o=f.tweens.length;for(;s<o;s++)f.tweens[s].run(i);return u.notifyWith(e,[f,i,n]),i<1&&o?n:(u.resolveWith(e,[f]),!1)},f=u.promise({elem:e,props:v.extend({},t),opts:v.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:qn||$n(),duration:n.duration,tweens:[],createTween:function(t,n,r){var i=v.Tween(e,f.opts,t,n,f.opts.specialEasing[t]||f.opts.easing);return f.tweens.push(i),i},stop:function(t){var n=0,r=t?f.tweens.length:0;for(;n<r;n++)f.tweens[n].run(1);return t?u.resolveWith(e,[f,t]):u.rejectWith(e,[f,t]),this}}),l=f.props;Qn(l,f.opts.specialEasing);for(;i<o;i++){r=Xn[i].call(f,e,l,f.opts);if(r)return r}return Jn(f,l),v.isFunction(f.opts.start)&&f.opts.start.call(e,f),v.fx.timer(v.extend(a,{anim:f,queue:f.opts.queue,elem:e})),f.progress(f.opts.progress).done(f.opts.done,f.opts.complete).fail(f.opts.fail).always(f.opts.always)}function Qn(e,t){var n,r,i,s,o;for(n in e){r=v.camelCase(n),i=t[r],s=e[n],v.isArray(s)&&(i=s[1],s=e[n]=s[0]),n!==r&&(e[r]=s,delete e[n]),o=v.cssHooks[r];if(o&&"expand"in o){s=o.expand(s),delete e[r];for(n in s)n in e||(e[n]=s[n],t[n]=i)}else t[r]=i}}function Gn(e,t,n){var r,i,s,o,u,a,f,l,c,h=this,p=e.style,d={},m=[],g=e.nodeType&&Gt(e);n.queue||(l=v._queueHooks(e,"fx"),l.unqueued==null&&(l.unqueued=0,c=l.empty.fire,l.empty.fire=function(){l.unqueued||c()}),l.unqueued++,h.always(function(){h.always(function(){l.unqueued--,v.queue(e,"fx").length||l.empty.fire()})})),e.nodeType===1&&("height"in t||"width"in t)&&(n.overflow=[p.overflow,p.overflowX,p.overflowY],v.css(e,"display")==="inline"&&v.css(e,"float")==="none"&&(!v.support.inlineBlockNeedsLayout||nn(e.nodeName)==="inline"?p.display="inline-block":p.zoom=1)),n.overflow&&(p.overflow="hidden",v.support.shrinkWrapBlocks||h.done(function(){p.overflow=n.overflow[0],p.overflowX=n.overflow[1],p.overflowY=n.overflow[2]}));for(r in t){s=t[r];if(Un.exec(s)){delete t[r],a=a||s==="toggle";if(s===(g?"hide":"show"))continue;m.push(r)}}o=m.length;if(o){u=v._data(e,"fxshow")||v._data(e,"fxshow",{}),"hidden"in u&&(g=u.hidden),a&&(u.hidden=!g),g?v(e).show():h.done(function(){v(e).hide()}),h.done(function(){var t;v.removeData(e,"fxshow",!0);for(t in d)v.style(e,t,d[t])});for(r=0;r<o;r++)i=m[r],f=h.createTween(i,g?u[i]:0),d[i]=u[i]||v.style(e,i),i in u||(u[i]=f.start,g&&(f.end=f.start,f.start=i==="width"||i==="height"?1:0))}}function Yn(e,t,n,r,i){return new Yn.prototype.init(e,t,n,r,i)}function Zn(e,t){var n,r={height:e},i=0;t=t?1:0;for(;i<4;i+=2-t)n=$t[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}function tr(e){return v.isWindow(e)?e:e.nodeType===9?e.defaultView||e.parentWindow:!1}var n,r,i=e.document,s=e.location,o=e.navigator,u=e.jQuery,a=e.$,f=Array.prototype.push,l=Array.prototype.slice,c=Array.prototype.indexOf,h=Object.prototype.toString,p=Object.prototype.hasOwnProperty,d=String.prototype.trim,v=function(e,t){return new v.fn.init(e,t,n)},m=/[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,g=/\S/,y=/\s+/,b=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,w=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,E=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,S=/^[\],:{}\s]*$/,x=/(?:^|:|,)(?:\s*\[)+/g,T=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,N=/"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,C=/^-ms-/,k=/-([\da-z])/gi,L=function(e,t){return(t+"").toUpperCase()},A=function(){i.addEventListener?(i.removeEventListener("DOMContentLoaded",A,!1),v.ready()):i.readyState==="complete"&&(i.detachEvent("onreadystatechange",A),v.ready())},O={};v.fn=v.prototype={constructor:v,init:function(e,n,r){var s,o,u,a;if(!e)return this;if(e.nodeType)return this.context=this[0]=e,this.length=1,this;if(typeof e=="string"){e.charAt(0)==="<"&&e.charAt(e.length-1)===">"&&e.length>=3?s=[null,e,null]:s=w.exec(e);if(s&&(s[1]||!n)){if(s[1])return n=n instanceof v?n[0]:n,a=n&&n.nodeType?n.ownerDocument||n:i,e=v.parseHTML(s[1],a,!0),E.test(s[1])&&v.isPlainObject(n)&&this.attr.call(e,n,!0),v.merge(this,e);o=i.getElementById(s[2]);if(o&&o.parentNode){if(o.id!==s[2])return r.find(e);this.length=1,this[0]=o}return this.context=i,this.selector=e,this}return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e)}return v.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),v.makeArray(e,this))},selector:"",jquery:"1.8.3",length:0,size:function(){return this.length},toArray:function(){return l.call(this)},get:function(e){return e==null?this.toArray():e<0?this[this.length+e]:this[e]},pushStack:function(e,t,n){var r=v.merge(this.constructor(),e);return r.prevObject=this,r.context=this.context,t==="find"?r.selector=this.selector+(this.selector?" ":"")+n:t&&(r.selector=this.selector+"."+t+"("+n+")"),r},each:function(e,t){return v.each(this,e,t)},ready:function(e){return v.ready.promise().done(e),this},eq:function(e){return e=+e,e===-1?this.slice(e):this.slice(e,e+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(l.apply(this,arguments),"slice",l.call(arguments).join(","))},map:function(e){return this.pushStack(v.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:[].sort,splice:[].splice},v.fn.init.prototype=v.fn,v.extend=v.fn.extend=function(){var e,n,r,i,s,o,u=arguments[0]||{},a=1,f=arguments.length,l=!1;typeof u=="boolean"&&(l=u,u=arguments[1]||{},a=2),typeof u!="object"&&!v.isFunction(u)&&(u={}),f===a&&(u=this,--a);for(;a<f;a++)if((e=arguments[a])!=null)for(n in e){r=u[n],i=e[n];if(u===i)continue;l&&i&&(v.isPlainObject(i)||(s=v.isArray(i)))?(s?(s=!1,o=r&&v.isArray(r)?r:[]):o=r&&v.isPlainObject(r)?r:{},u[n]=v.extend(l,o,i)):i!==t&&(u[n]=i)}return u},v.extend({noConflict:function(t){return e.$===v&&(e.$=a),t&&e.jQuery===v&&(e.jQuery=u),v},isReady:!1,readyWait:1,holdReady:function(e){e?v.readyWait++:v.ready(!0)},ready:function(e){if(e===!0?--v.readyWait:v.isReady)return;if(!i.body)return setTimeout(v.ready,1);v.isReady=!0;if(e!==!0&&--v.readyWait>0)return;r.resolveWith(i,[v]),v.fn.trigger&&v(i).trigger("ready").off("ready")},isFunction:function(e){return v.type(e)==="function"},isArray:Array.isArray||function(e){return v.type(e)==="array"},isWindow:function(e){return e!=null&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return e==null?String(e):O[h.call(e)]||"object"},isPlainObject:function(e){if(!e||v.type(e)!=="object"||e.nodeType||v.isWindow(e))return!1;try{if(e.constructor&&!p.call(e,"constructor")&&!p.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}var r;for(r in e);return r===t||p.call(e,r)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw new Error(e)},parseHTML:function(e,t,n){var r;return!e||typeof e!="string"?null:(typeof t=="boolean"&&(n=t,t=0),t=t||i,(r=E.exec(e))?[t.createElement(r[1])]:(r=v.buildFragment([e],t,n?null:[]),v.merge([],(r.cacheable?v.clone(r.fragment):r.fragment).childNodes)))},parseJSON:function(t){if(!t||typeof t!="string")return null;t=v.trim(t);if(e.JSON&&e.JSON.parse)return e.JSON.parse(t);if(S.test(t.replace(T,"@").replace(N,"]").replace(x,"")))return(new Function("return "+t))();v.error("Invalid JSON: "+t)},parseXML:function(n){var r,i;if(!n||typeof n!="string")return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(s){r=t}return(!r||!r.documentElement||r.getElementsByTagName("parsererror").length)&&v.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&g.test(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(C,"ms-").replace(k,L)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,n,r){var i,s=0,o=e.length,u=o===t||v.isFunction(e);if(r){if(u){for(i in e)if(n.apply(e[i],r)===!1)break}else for(;s<o;)if(n.apply(e[s++],r)===!1)break}else if(u){for(i in e)if(n.call(e[i],i,e[i])===!1)break}else for(;s<o;)if(n.call(e[s],s,e[s++])===!1)break;return e},trim:d&&!d.call("\ufeff\u00a0")?function(e){return e==null?"":d.call(e)}:function(e){return e==null?"":(e+"").replace(b,"")},makeArray:function(e,t){var n,r=t||[];return e!=null&&(n=v.type(e),e.length==null||n==="string"||n==="function"||n==="regexp"||v.isWindow(e)?f.call(r,e):v.merge(r,e)),r},inArray:function(e,t,n){var r;if(t){if(c)return c.call(t,e,n);r=t.length,n=n?n<0?Math.max(0,r+n):n:0;for(;n<r;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,s=0;if(typeof r=="number")for(;s<r;s++)e[i++]=n[s];else while(n[s]!==t)e[i++]=n[s++];return e.length=i,e},grep:function(e,t,n){var r,i=[],s=0,o=e.length;n=!!n;for(;s<o;s++)r=!!t(e[s],s),n!==r&&i.push(e[s]);return i},map:function(e,n,r){var i,s,o=[],u=0,a=e.length,f=e instanceof v||a!==t&&typeof a=="number"&&(a>0&&e[0]&&e[a-1]||a===0||v.isArray(e));if(f)for(;u<a;u++)i=n(e[u],u,r),i!=null&&(o[o.length]=i);else for(s in e)i=n(e[s],s,r),i!=null&&(o[o.length]=i);return o.concat.apply([],o)},guid:1,proxy:function(e,n){var r,i,s;return typeof n=="string"&&(r=e[n],n=e,e=r),v.isFunction(e)?(i=l.call(arguments,2),s=function(){return e.apply(n,i.concat(l.call(arguments)))},s.guid=e.guid=e.guid||v.guid++,s):t},access:function(e,n,r,i,s,o,u){var a,f=r==null,l=0,c=e.length;if(r&&typeof r=="object"){for(l in r)v.access(e,n,l,r[l],1,o,i);s=1}else if(i!==t){a=u===t&&v.isFunction(i),f&&(a?(a=n,n=function(e,t,n){return a.call(v(e),n)}):(n.call(e,i),n=null));if(n)for(;l<c;l++)n(e[l],r,a?i.call(e[l],l,n(e[l],r)):i,u);s=1}return s?e:f?n.call(e):c?n(e[0],r):o},now:function(){return(new Date).getTime()}}),v.ready.promise=function(t){if(!r){r=v.Deferred();if(i.readyState==="complete")setTimeout(v.ready,1);else if(i.addEventListener)i.addEventListener("DOMContentLoaded",A,!1),e.addEventListener("load",v.ready,!1);else{i.attachEvent("onreadystatechange",A),e.attachEvent("onload",v.ready);var n=!1;try{n=e.frameElement==null&&i.documentElement}catch(s){}n&&n.doScroll&&function o(){if(!v.isReady){try{n.doScroll("left")}catch(e){return setTimeout(o,50)}v.ready()}}()}}return r.promise(t)},v.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(e,t){O["[object "+t+"]"]=t.toLowerCase()}),n=v(i);var M={};v.Callbacks=function(e){e=typeof e=="string"?M[e]||_(e):v.extend({},e);var n,r,i,s,o,u,a=[],f=!e.once&&[],l=function(t){n=e.memory&&t,r=!0,u=s||0,s=0,o=a.length,i=!0;for(;a&&u<o;u++)if(a[u].apply(t[0],t[1])===!1&&e.stopOnFalse){n=!1;break}i=!1,a&&(f?f.length&&l(f.shift()):n?a=[]:c.disable())},c={add:function(){if(a){var t=a.length;(function r(t){v.each(t,function(t,n){var i=v.type(n);i==="function"?(!e.unique||!c.has(n))&&a.push(n):n&&n.length&&i!=="string"&&r(n)})})(arguments),i?o=a.length:n&&(s=t,l(n))}return this},remove:function(){return a&&v.each(arguments,function(e,t){var n;while((n=v.inArray(t,a,n))>-1)a.splice(n,1),i&&(n<=o&&o--,n<=u&&u--)}),this},has:function(e){return v.inArray(e,a)>-1},empty:function(){return a=[],this},disable:function(){return a=f=n=t,this},disabled:function(){return!a},lock:function(){return f=t,n||c.disable(),this},locked:function(){return!f},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],a&&(!r||f)&&(i?f.push(t):l(t)),this},fire:function(){return c.fireWith(this,arguments),this},fired:function(){return!!r}};return c},v.extend({Deferred:function(e){var t=[["resolve","done",v.Callbacks("once memory"),"resolved"],["reject","fail",v.Callbacks("once memory"),"rejected"],["notify","progress",v.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return v.Deferred(function(n){v.each(t,function(t,r){var s=r[0],o=e[t];i[r[1]](v.isFunction(o)?function(){var e=o.apply(this,arguments);e&&v.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[s+"With"](this===i?n:this,[e])}:n[s])}),e=null}).promise()},promise:function(e){return e!=null?v.extend(e,r):r}},i={};return r.pipe=r.then,v.each(t,function(e,s){var o=s[2],u=s[3];r[s[1]]=o.add,u&&o.add(function(){n=u},t[e^1][2].disable,t[2][2].lock),i[s[0]]=o.fire,i[s[0]+"With"]=o.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=l.call(arguments),r=n.length,i=r!==1||e&&v.isFunction(e.promise)?r:0,s=i===1?e:v.Deferred(),o=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?l.call(arguments):r,n===u?s.notifyWith(t,n):--i||s.resolveWith(t,n)}},u,a,f;if(r>1){u=new Array(r),a=new Array(r),f=new Array(r);for(;t<r;t++)n[t]&&v.isFunction(n[t].promise)?n[t].promise().done(o(t,f,n)).fail(s.reject).progress(o(t,a,u)):--i}return i||s.resolveWith(f,n),s.promise()}}),v.support=function(){var t,n,r,s,o,u,a,f,l,c,h,p=i.createElement("div");p.setAttribute("className","t"),p.innerHTML="  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",n=p.getElementsByTagName("*"),r=p.getElementsByTagName("a")[0];if(!n||!r||!n.length)return{};s=i.createElement("select"),o=s.appendChild(i.createElement("option")),u=p.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t={leadingWhitespace:p.firstChild.nodeType===3,tbody:!p.getElementsByTagName("tbody").length,htmlSerialize:!!p.getElementsByTagName("link").length,style:/top/.test(r.getAttribute("style")),hrefNormalized:r.getAttribute("href")==="/a",opacity:/^0.5/.test(r.style.opacity),cssFloat:!!r.style.cssFloat,checkOn:u.value==="on",optSelected:o.selected,getSetAttribute:p.className!=="t",enctype:!!i.createElement("form").enctype,html5Clone:i.createElement("nav").cloneNode(!0).outerHTML!=="<:nav></:nav>",boxModel:i.compatMode==="CSS1Compat",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},u.checked=!0,t.noCloneChecked=u.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!o.disabled;try{delete p.test}catch(d){t.deleteExpando=!1}!p.addEventListener&&p.attachEvent&&p.fireEvent&&(p.attachEvent("onclick",h=function(){t.noCloneEvent=!1}),p.cloneNode(!0).fireEvent("onclick"),p.detachEvent("onclick",h)),u=i.createElement("input"),u.value="t",u.setAttribute("type","radio"),t.radioValue=u.value==="t",u.setAttribute("checked","checked"),u.setAttribute("name","t"),p.appendChild(u),a=i.createDocumentFragment(),a.appendChild(p.lastChild),t.checkClone=a.cloneNode(!0).cloneNode(!0).lastChild.checked,t.appendChecked=u.checked,a.removeChild(u),a.appendChild(p);if(p.attachEvent)for(l in{submit:!0,change:!0,focusin:!0})f="on"+l,c=f in p,c||(p.setAttribute(f,"return;"),c=typeof p[f]=="function"),t[l+"Bubbles"]=c;return v(function(){var n,r,s,o,u="padding:0;margin:0;border:0;display:block;overflow:hidden;",a=i.getElementsByTagName("body")[0];if(!a)return;n=i.createElement("div"),n.style.cssText="visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px",a.insertBefore(n,a.firstChild),r=i.createElement("div"),n.appendChild(r),r.innerHTML="<table><tr><td></td><td>t</td></tr></table>",s=r.getElementsByTagName("td"),s[0].style.cssText="padding:0;margin:0;border:0;display:none",c=s[0].offsetHeight===0,s[0].style.display="",s[1].style.display="none",t.reliableHiddenOffsets=c&&s[0].offsetHeight===0,r.innerHTML="",r.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",t.boxSizing=r.offsetWidth===4,t.doesNotIncludeMarginInBodyOffset=a.offsetTop!==1,e.getComputedStyle&&(t.pixelPosition=(e.getComputedStyle(r,null)||{}).top!=="1%",t.boxSizingReliable=(e.getComputedStyle(r,null)||{width:"4px"}).width==="4px",o=i.createElement("div"),o.style.cssText=r.style.cssText=u,o.style.marginRight=o.style.width="0",r.style.width="1px",r.appendChild(o),t.reliableMarginRight=!parseFloat((e.getComputedStyle(o,null)||{}).marginRight)),typeof r.style.zoom!="undefined"&&(r.innerHTML="",r.style.cssText=u+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=r.offsetWidth===3,r.style.display="block",r.style.overflow="visible",r.innerHTML="<div></div>",r.firstChild.style.width="5px",t.shrinkWrapBlocks=r.offsetWidth!==3,n.style.zoom=1),a.removeChild(n),n=r=s=o=null}),a.removeChild(p),n=r=s=o=u=a=p=null,t}();var D=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;v.extend({cache:{},deletedIds:[],uuid:0,expando:"jQuery"+(v.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(e){return e=e.nodeType?v.cache[e[v.expando]]:e[v.expando],!!e&&!B(e)},data:function(e,n,r,i){if(!v.acceptData(e))return;var s,o,u=v.expando,a=typeof n=="string",f=e.nodeType,l=f?v.cache:e,c=f?e[u]:e[u]&&u;if((!c||!l[c]||!i&&!l[c].data)&&a&&r===t)return;c||(f?e[u]=c=v.deletedIds.pop()||v.guid++:c=u),l[c]||(l[c]={},f||(l[c].toJSON=v.noop));if(typeof n=="object"||typeof n=="function")i?l[c]=v.extend(l[c],n):l[c].data=v.extend(l[c].data,n);return s=l[c],i||(s.data||(s.data={}),s=s.data),r!==t&&(s[v.camelCase(n)]=r),a?(o=s[n],o==null&&(o=s[v.camelCase(n)])):o=s,o},removeData:function(e,t,n){if(!v.acceptData(e))return;var r,i,s,o=e.nodeType,u=o?v.cache:e,a=o?e[v.expando]:v.expando;if(!u[a])return;if(t){r=n?u[a]:u[a].data;if(r){v.isArray(t)||(t in r?t=[t]:(t=v.camelCase(t),t in r?t=[t]:t=t.split(" ")));for(i=0,s=t.length;i<s;i++)delete r[t[i]];if(!(n?B:v.isEmptyObject)(r))return}}if(!n){delete u[a].data;if(!B(u[a]))return}o?v.cleanData([e],!0):v.support.deleteExpando||u!=u.window?delete u[a]:u[a]=null},_data:function(e,t,n){return v.data(e,t,n,!0)},acceptData:function(e){var t=e.nodeName&&v.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),v.fn.extend({data:function(e,n){var r,i,s,o,u,a=this[0],f=0,l=null;if(e===t){if(this.length){l=v.data(a);if(a.nodeType===1&&!v._data(a,"parsedAttrs")){s=a.attributes;for(u=s.length;f<u;f++)o=s[f].name,o.indexOf("data-")||(o=v.camelCase(o.substring(5)),H(a,o,l[o]));v._data(a,"parsedAttrs",!0)}}return l}return typeof e=="object"?this.each(function(){v.data(this,e)}):(r=e.split(".",2),r[1]=r[1]?"."+r[1]:"",i=r[1]+"!",v.access(this,function(n){if(n===t)return l=this.triggerHandler("getData"+i,[r[0]]),l===t&&a&&(l=v.data(a,e),l=H(a,e,l)),l===t&&r[1]?this.data(r[0]):l;r[1]=n,this.each(function(){var t=v(this);t.triggerHandler("setData"+i,r),v.data(this,e,n),t.triggerHandler("changeData"+i,r)})},null,n,arguments.length>1,null,!1))},removeData:function(e){return this.each(function(){v.removeData(this,e)})}}),v.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=v._data(e,t),n&&(!r||v.isArray(n)?r=v._data(e,t,v.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=v.queue(e,t),r=n.length,i=n.shift(),s=v._queueHooks(e,t),o=function(){v.dequeue(e,t)};i==="inprogress"&&(i=n.shift(),r--),i&&(t==="fx"&&n.unshift("inprogress"),delete s.stop,i.call(e,o,s)),!r&&s&&s.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return v._data(e,n)||v._data(e,n,{empty:v.Callbacks("once memory").add(function(){v.removeData(e,t+"queue",!0),v.removeData(e,n,!0)})})}}),v.fn.extend({queue:function(e,n){var r=2;return typeof e!="string"&&(n=e,e="fx",r--),arguments.length<r?v.queue(this[0],e):n===t?this:this.each(function(){var t=v.queue(this,e,n);v._queueHooks(this,e),e==="fx"&&t[0]!=="inprogress"&&v.dequeue(this,e)})},dequeue:function(e){return this.each(function(){v.dequeue(this,e)})},delay:function(e,t){return e=v.fx?v.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,s=v.Deferred(),o=this,u=this.length,a=function(){--i||s.resolveWith(o,[o])};typeof e!="string"&&(n=e,e=t),e=e||"fx";while(u--)r=v._data(o[u],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(a));return a(),s.promise(n)}});var j,F,I,q=/[\t\r\n]/g,R=/\r/g,U=/^(?:button|input)$/i,z=/^(?:button|input|object|select|textarea)$/i,W=/^a(?:rea|)$/i,X=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,V=v.support.getSetAttribute;v.fn.extend({attr:function(e,t){return v.access(this,v.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){v.removeAttr(this,e)})},prop:function(e,t){return v.access(this,v.prop,e,t,arguments.length>1)},removeProp:function(e){return e=v.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,s,o,u;if(v.isFunction(e))return this.each(function(t){v(this).addClass(e.call(this,t,this.className))});if(e&&typeof e=="string"){t=e.split(y);for(n=0,r=this.length;n<r;n++){i=this[n];if(i.nodeType===1)if(!i.className&&t.length===1)i.className=e;else{s=" "+i.className+" ";for(o=0,u=t.length;o<u;o++)s.indexOf(" "+t[o]+" ")<0&&(s+=t[o]+" ");i.className=v.trim(s)}}}return this},removeClass:function(e){var n,r,i,s,o,u,a;if(v.isFunction(e))return this.each(function(t){v(this).removeClass(e.call(this,t,this.className))});if(e&&typeof e=="string"||e===t){n=(e||"").split(y);for(u=0,a=this.length;u<a;u++){i=this[u];if(i.nodeType===1&&i.className){r=(" "+i.className+" ").replace(q," ");for(s=0,o=n.length;s<o;s++)while(r.indexOf(" "+n[s]+" ")>=0)r=r.replace(" "+n[s]+" "," ");i.className=e?v.trim(r):""}}}return this},toggleClass:function(e,t){var n=typeof e,r=typeof t=="boolean";return v.isFunction(e)?this.each(function(n){v(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if(n==="string"){var i,s=0,o=v(this),u=t,a=e.split(y);while(i=a[s++])u=r?u:!o.hasClass(i),o[u?"addClass":"removeClass"](i)}else if(n==="undefined"||n==="boolean")this.className&&v._data(this,"__className__",this.className),this.className=this.className||e===!1?"":v._data(this,"__className__")||""})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;n<r;n++)if(this[n].nodeType===1&&(" "+this[n].className+" ").replace(q," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,s=this[0];if(!arguments.length){if(s)return n=v.valHooks[s.type]||v.valHooks[s.nodeName.toLowerCase()],n&&"get"in n&&(r=n.get(s,"value"))!==t?r:(r=s.value,typeof r=="string"?r.replace(R,""):r==null?"":r);return}return i=v.isFunction(e),this.each(function(r){var s,o=v(this);if(this.nodeType!==1)return;i?s=e.call(this,r,o.val()):s=e,s==null?s="":typeof s=="number"?s+="":v.isArray(s)&&(s=v.map(s,function(e){return e==null?"":e+""})),n=v.valHooks[this.type]||v.valHooks[this.nodeName.toLowerCase()];if(!n||!("set"in n)||n.set(this,s,"value")===t)this.value=s})}}),v.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,s=e.type==="select-one"||i<0,o=s?null:[],u=s?i+1:r.length,a=i<0?u:s?i:0;for(;a<u;a++){n=r[a];if((n.selected||a===i)&&(v.support.optDisabled?!n.disabled:n.getAttribute("disabled")===null)&&(!n.parentNode.disabled||!v.nodeName(n.parentNode,"optgroup"))){t=v(n).val();if(s)return t;o.push(t)}}return o},set:function(e,t){var n=v.makeArray(t);return v(e).find("option").each(function(){this.selected=v.inArray(v(this).val(),n)>=0}),n.length||(e.selectedIndex=-1),n}}},attrFn:{},attr:function(e,n,r,i){var s,o,u,a=e.nodeType;if(!e||a===3||a===8||a===2)return;if(i&&v.isFunction(v.fn[n]))return v(e)[n](r);if(typeof e.getAttribute=="undefined")return v.prop(e,n,r);u=a!==1||!v.isXMLDoc(e),u&&(n=n.toLowerCase(),o=v.attrHooks[n]||(X.test(n)?F:j));if(r!==t){if(r===null){v.removeAttr(e,n);return}return o&&"set"in o&&u&&(s=o.set(e,r,n))!==t?s:(e.setAttribute(n,r+""),r)}return o&&"get"in o&&u&&(s=o.get(e,n))!==null?s:(s=e.getAttribute(n),s===null?t:s)},removeAttr:function(e,t){var n,r,i,s,o=0;if(t&&e.nodeType===1){r=t.split(y);for(;o<r.length;o++)i=r[o],i&&(n=v.propFix[i]||i,s=X.test(i),s||v.attr(e,i,""),e.removeAttribute(V?i:n),s&&n in e&&(e[n]=!1))}},attrHooks:{type:{set:function(e,t){if(U.test(e.nodeName)&&e.parentNode)v.error("type property can't be changed");else if(!v.support.radioValue&&t==="radio"&&v.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}},value:{get:function(e,t){return j&&v.nodeName(e,"button")?j.get(e,t):t in e?e.value:null},set:function(e,t,n){if(j&&v.nodeName(e,"button"))return j.set(e,t,n);e.value=t}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(e,n,r){var i,s,o,u=e.nodeType;if(!e||u===3||u===8||u===2)return;return o=u!==1||!v.isXMLDoc(e),o&&(n=v.propFix[n]||n,s=v.propHooks[n]),r!==t?s&&"set"in s&&(i=s.set(e,r,n))!==t?i:e[n]=r:s&&"get"in s&&(i=s.get(e,n))!==null?i:e[n]},propHooks:{tabIndex:{get:function(e){var n=e.getAttributeNode("tabindex");return n&&n.specified?parseInt(n.value,10):z.test(e.nodeName)||W.test(e.nodeName)&&e.href?0:t}}}}),F={get:function(e,n){var r,i=v.prop(e,n);return i===!0||typeof i!="boolean"&&(r=e.getAttributeNode(n))&&r.nodeValue!==!1?n.toLowerCase():t},set:function(e,t,n){var r;return t===!1?v.removeAttr(e,n):(r=v.propFix[n]||n,r in e&&(e[r]=!0),e.setAttribute(n,n.toLowerCase())),n}},V||(I={name:!0,id:!0,coords:!0},j=v.valHooks.button={get:function(e,n){var r;return r=e.getAttributeNode(n),r&&(I[n]?r.value!=="":r.specified)?r.value:t},set:function(e,t,n){var r=e.getAttributeNode(n);return r||(r=i.createAttribute(n),e.setAttributeNode(r)),r.value=t+""}},v.each(["width","height"],function(e,t){v.attrHooks[t]=v.extend(v.attrHooks[t],{set:function(e,n){if(n==="")return e.setAttribute(t,"auto"),n}})}),v.attrHooks.contenteditable={get:j.get,set:function(e,t,n){t===""&&(t="false"),j.set(e,t,n)}}),v.support.hrefNormalized||v.each(["href","src","width","height"],function(e,n){v.attrHooks[n]=v.extend(v.attrHooks[n],{get:function(e){var r=e.getAttribute(n,2);return r===null?t:r}})}),v.support.style||(v.attrHooks.style={get:function(e){return e.style.cssText.toLowerCase()||t},set:function(e,t){return e.style.cssText=t+""}}),v.support.optSelected||(v.propHooks.selected=v.extend(v.propHooks.selected,{get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}})),v.support.enctype||(v.propFix.enctype="encoding"),v.support.checkOn||v.each(["radio","checkbox"],function(){v.valHooks[this]={get:function(e){return e.getAttribute("value")===null?"on":e.value}}}),v.each(["radio","checkbox"],function(){v.valHooks[this]=v.extend(v.valHooks[this],{set:function(e,t){if(v.isArray(t))return e.checked=v.inArray(v(e).val(),t)>=0}})});var $=/^(?:textarea|input|select)$/i,J=/^([^\.]*|)(?:\.(.+)|)$/,K=/(?:^|\s)hover(\.\S+|)\b/,Q=/^key/,G=/^(?:mouse|contextmenu)|click/,Y=/^(?:focusinfocus|focusoutblur)$/,Z=function(e){return v.event.special.hover?e:e.replace(K,"mouseenter$1 mouseleave$1")};v.event={add:function(e,n,r,i,s){var o,u,a,f,l,c,h,p,d,m,g;if(e.nodeType===3||e.nodeType===8||!n||!r||!(o=v._data(e)))return;r.handler&&(d=r,r=d.handler,s=d.selector),r.guid||(r.guid=v.guid++),a=o.events,a||(o.events=a={}),u=o.handle,u||(o.handle=u=function(e){return typeof v=="undefined"||!!e&&v.event.triggered===e.type?t:v.event.dispatch.apply(u.elem,arguments)},u.elem=e),n=v.trim(Z(n)).split(" ");for(f=0;f<n.length;f++){l=J.exec(n[f])||[],c=l[1],h=(l[2]||"").split(".").sort(),g=v.event.special[c]||{},c=(s?g.delegateType:g.bindType)||c,g=v.event.special[c]||{},p=v.extend({type:c,origType:l[1],data:i,handler:r,guid:r.guid,selector:s,needsContext:s&&v.expr.match.needsContext.test(s),namespace:h.join(".")},d),m=a[c];if(!m){m=a[c]=[],m.delegateCount=0;if(!g.setup||g.setup.call(e,i,h,u)===!1)e.addEventListener?e.addEventListener(c,u,!1):e.attachEvent&&e.attachEvent("on"+c,u)}g.add&&(g.add.call(e,p),p.handler.guid||(p.handler.guid=r.guid)),s?m.splice(m.delegateCount++,0,p):m.push(p),v.event.global[c]=!0}e=null},global:{},remove:function(e,t,n,r,i){var s,o,u,a,f,l,c,h,p,d,m,g=v.hasData(e)&&v._data(e);if(!g||!(h=g.events))return;t=v.trim(Z(t||"")).split(" ");for(s=0;s<t.length;s++){o=J.exec(t[s])||[],u=a=o[1],f=o[2];if(!u){for(u in h)v.event.remove(e,u+t[s],n,r,!0);continue}p=v.event.special[u]||{},u=(r?p.delegateType:p.bindType)||u,d=h[u]||[],l=d.length,f=f?new RegExp("(^|\\.)"+f.split(".").sort().join("\\.(?:.*\\.|)")+"(\\.|$)"):null;for(c=0;c<d.length;c++)m=d[c],(i||a===m.origType)&&(!n||n.guid===m.guid)&&(!f||f.test(m.namespace))&&(!r||r===m.selector||r==="**"&&m.selector)&&(d.splice(c--,1),m.selector&&d.delegateCount--,p.remove&&p.remove.call(e,m));d.length===0&&l!==d.length&&((!p.teardown||p.teardown.call(e,f,g.handle)===!1)&&v.removeEvent(e,u,g.handle),delete h[u])}v.isEmptyObject(h)&&(delete g.handle,v.removeData(e,"events",!0))},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(n,r,s,o){if(!s||s.nodeType!==3&&s.nodeType!==8){var u,a,f,l,c,h,p,d,m,g,y=n.type||n,b=[];if(Y.test(y+v.event.triggered))return;y.indexOf("!")>=0&&(y=y.slice(0,-1),a=!0),y.indexOf(".")>=0&&(b=y.split("."),y=b.shift(),b.sort());if((!s||v.event.customEvent[y])&&!v.event.global[y])return;n=typeof n=="object"?n[v.expando]?n:new v.Event(y,n):new v.Event(y),n.type=y,n.isTrigger=!0,n.exclusive=a,n.namespace=b.join("."),n.namespace_re=n.namespace?new RegExp("(^|\\.)"+b.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,h=y.indexOf(":")<0?"on"+y:"";if(!s){u=v.cache;for(f in u)u[f].events&&u[f].events[y]&&v.event.trigger(n,r,u[f].handle.elem,!0);return}n.result=t,n.target||(n.target=s),r=r!=null?v.makeArray(r):[],r.unshift(n),p=v.event.special[y]||{};if(p.trigger&&p.trigger.apply(s,r)===!1)return;m=[[s,p.bindType||y]];if(!o&&!p.noBubble&&!v.isWindow(s)){g=p.delegateType||y,l=Y.test(g+y)?s:s.parentNode;for(c=s;l;l=l.parentNode)m.push([l,g]),c=l;c===(s.ownerDocument||i)&&m.push([c.defaultView||c.parentWindow||e,g])}for(f=0;f<m.length&&!n.isPropagationStopped();f++)l=m[f][0],n.type=m[f][1],d=(v._data(l,"events")||{})[n.type]&&v._data(l,"handle"),d&&d.apply(l,r),d=h&&l[h],d&&v.acceptData(l)&&d.apply&&d.apply(l,r)===!1&&n.preventDefault();return n.type=y,!o&&!n.isDefaultPrevented()&&(!p._default||p._default.apply(s.ownerDocument,r)===!1)&&(y!=="click"||!v.nodeName(s,"a"))&&v.acceptData(s)&&h&&s[y]&&(y!=="focus"&&y!=="blur"||n.target.offsetWidth!==0)&&!v.isWindow(s)&&(c=s[h],c&&(s[h]=null),v.event.triggered=y,s[y](),v.event.triggered=t,c&&(s[h]=c)),n.result}return},dispatch:function(n){n=v.event.fix(n||e.event);var r,i,s,o,u,a,f,c,h,p,d=(v._data(this,"events")||{})[n.type]||[],m=d.delegateCount,g=l.call(arguments),y=!n.exclusive&&!n.namespace,b=v.event.special[n.type]||{},w=[];g[0]=n,n.delegateTarget=this;if(b.preDispatch&&b.preDispatch.call(this,n)===!1)return;if(m&&(!n.button||n.type!=="click"))for(s=n.target;s!=this;s=s.parentNode||this)if(s.disabled!==!0||n.type!=="click"){u={},f=[];for(r=0;r<m;r++)c=d[r],h=c.selector,u[h]===t&&(u[h]=c.needsContext?v(h,this).index(s)>=0:v.find(h,this,null,[s]).length),u[h]&&f.push(c);f.length&&w.push({elem:s,matches:f})}d.length>m&&w.push({elem:this,matches:d.slice(m)});for(r=0;r<w.length&&!n.isPropagationStopped();r++){a=w[r],n.currentTarget=a.elem;for(i=0;i<a.matches.length&&!n.isImmediatePropagationStopped();i++){c=a.matches[i];if(y||!n.namespace&&!c.namespace||n.namespace_re&&n.namespace_re.test(c.namespace))n.data=c.data,n.handleObj=c,o=((v.event.special[c.origType]||{}).handle||c.handler).apply(a.elem,g),o!==t&&(n.result=o,o===!1&&(n.preventDefault(),n.stopPropagation()))}}return b.postDispatch&&b.postDispatch.call(this,n),n.result},props:"attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return e.which==null&&(e.which=t.charCode!=null?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,s,o,u=n.button,a=n.fromElement;return e.pageX==null&&n.clientX!=null&&(r=e.target.ownerDocument||i,s=r.documentElement,o=r.body,e.pageX=n.clientX+(s&&s.scrollLeft||o&&o.scrollLeft||0)-(s&&s.clientLeft||o&&o.clientLeft||0),e.pageY=n.clientY+(s&&s.scrollTop||o&&o.scrollTop||0)-(s&&s.clientTop||o&&o.clientTop||0)),!e.relatedTarget&&a&&(e.relatedTarget=a===e.target?n.toElement:a),!e.which&&u!==t&&(e.which=u&1?1:u&2?3:u&4?2:0),e}},fix:function(e){if(e[v.expando])return e;var t,n,r=e,s=v.event.fixHooks[e.type]||{},o=s.props?this.props.concat(s.props):this.props;e=v.Event(r);for(t=o.length;t;)n=o[--t],e[n]=r[n];return e.target||(e.target=r.srcElement||i),e.target.nodeType===3&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,r):e},special:{load:{noBubble:!0},focus:{delegateType:"focusin"},blur:{delegateType:"focusout"},beforeunload:{setup:function(e,t,n){v.isWindow(this)&&(this.onbeforeunload=n)},teardown:function(e,t){this.onbeforeunload===t&&(this.onbeforeunload=null)}}},simulate:function(e,t,n,r){var i=v.extend(new v.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?v.event.trigger(i,null,t):v.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},v.event.handle=v.event.dispatch,v.removeEvent=i.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]=="undefined"&&(e[r]=null),e.detachEvent(r,n))},v.Event=function(e,t){if(!(this instanceof v.Event))return new v.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?tt:et):this.type=e,t&&v.extend(this,t),this.timeStamp=e&&e.timeStamp||v.now(),this[v.expando]=!0},v.Event.prototype={preventDefault:function(){this.isDefaultPrevented=tt;var e=this.originalEvent;if(!e)return;e.preventDefault?e.preventDefault():e.returnValue=!1},stopPropagation:function(){this.isPropagationStopped=tt;var e=this.originalEvent;if(!e)return;e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=tt,this.stopPropagation()},isDefaultPrevented:et,isPropagationStopped:et,isImmediatePropagationStopped:et},v.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){v.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,s=e.handleObj,o=s.selector;if(!i||i!==r&&!v.contains(r,i))e.type=s.origType,n=s.handler.apply(this,arguments),e.type=t;return n}}}),v.support.submitBubbles||(v.event.special.submit={setup:function(){if(v.nodeName(this,"form"))return!1;v.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=v.nodeName(n,"input")||v.nodeName(n,"button")?n.form:t;r&&!v._data(r,"_submit_attached")&&(v.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),v._data(r,"_submit_attached",!0))})},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&v.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){if(v.nodeName(this,"form"))return!1;v.event.remove(this,"._submit")}}),v.support.changeBubbles||(v.event.special.change={setup:function(){if($.test(this.nodeName)){if(this.type==="checkbox"||this.type==="radio")v.event.add(this,"propertychange._change",function(e){e.originalEvent.propertyName==="checked"&&(this._just_changed=!0)}),v.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),v.event.simulate("change",this,e,!0)});return!1}v.event.add(this,"beforeactivate._change",function(e){var t=e.target;$.test(t.nodeName)&&!v._data(t,"_change_attached")&&(v.event.add(t,"change._change",function(e){this.parentNode&&!e.isSimulated&&!e.isTrigger&&v.event.simulate("change",this.parentNode,e,!0)}),v._data(t,"_change_attached",!0))})},handle:function(e){var t=e.target;if(this!==t||e.isSimulated||e.isTrigger||t.type!=="radio"&&t.type!=="checkbox")return e.handleObj.handler.apply(this,arguments)},teardown:function(){return v.event.remove(this,"._change"),!$.test(this.nodeName)}}),v.support.focusinBubbles||v.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){v.event.simulate(t,e.target,v.event.fix(e),!0)};v.event.special[t]={setup:function(){n++===0&&i.addEventListener(e,r,!0)},teardown:function(){--n===0&&i.removeEventListener(e,r,!0)}}}),v.fn.extend({on:function(e,n,r,i,s){var o,u;if(typeof e=="object"){typeof n!="string"&&(r=r||n,n=t);for(u in e)this.on(u,n,r,e[u],s);return this}r==null&&i==null?(i=n,r=n=t):i==null&&(typeof n=="string"?(i=r,r=t):(i=r,r=n,n=t));if(i===!1)i=et;else if(!i)return this;return s===1&&(o=i,i=function(e){return v().off(e),o.apply(this,arguments)},i.guid=o.guid||(o.guid=v.guid++)),this.each(function(){v.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,s;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,v(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if(typeof e=="object"){for(s in e)this.off(s,n,e[s]);return this}if(n===!1||typeof n=="function")r=n,n=t;return r===!1&&(r=et),this.each(function(){v.event.remove(this,e,r,n)})},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},live:function(e,t,n){return v(this.context).on(e,this.selector,t,n),this},die:function(e,t){return v(this.context).off(e,this.selector||"**",t),this},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return arguments.length===1?this.off(e,"**"):this.off(t,e||"**",n)},trigger:function(e,t){return this.each(function(){v.event.trigger(e,t,this)})},triggerHandler:function(e,t){if(this[0])return v.event.trigger(e,t,this[0],!0)},toggle:function(e){var t=arguments,n=e.guid||v.guid++,r=0,i=function(n){var i=(v._data(this,"lastToggle"+e.guid)||0)%r;return v._data(this,"lastToggle"+e.guid,i+1),n.preventDefault(),t[i].apply(this,arguments)||!1};i.guid=n;while(r<t.length)t[r++].guid=n;return this.click(i)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),v.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,t){v.fn[t]=function(e,n){return n==null&&(n=e,e=null),arguments.length>0?this.on(t,null,e,n):this.trigger(t)},Q.test(t)&&(v.event.fixHooks[t]=v.event.keyHooks),G.test(t)&&(v.event.fixHooks[t]=v.event.mouseHooks)}),function(e,t){function nt(e,t,n,r){n=n||[],t=t||g;var i,s,a,f,l=t.nodeType;if(!e||typeof e!="string")return n;if(l!==1&&l!==9)return[];a=o(t);if(!a&&!r)if(i=R.exec(e))if(f=i[1]){if(l===9){s=t.getElementById(f);if(!s||!s.parentNode)return n;if(s.id===f)return n.push(s),n}else if(t.ownerDocument&&(s=t.ownerDocument.getElementById(f))&&u(t,s)&&s.id===f)return n.push(s),n}else{if(i[2])return S.apply(n,x.call(t.getElementsByTagName(e),0)),n;if((f=i[3])&&Z&&t.getElementsByClassName)return S.apply(n,x.call(t.getElementsByClassName(f),0)),n}return vt(e.replace(j,"$1"),t,n,r,a)}function rt(e){return function(t){var n=t.nodeName.toLowerCase();return n==="input"&&t.type===e}}function it(e){return function(t){var n=t.nodeName.toLowerCase();return(n==="input"||n==="button")&&t.type===e}}function st(e){return N(function(t){return t=+t,N(function(n,r){var i,s=e([],n.length,t),o=s.length;while(o--)n[i=s[o]]&&(n[i]=!(r[i]=n[i]))})})}function ot(e,t,n){if(e===t)return n;var r=e.nextSibling;while(r){if(r===t)return-1;r=r.nextSibling}return 1}function ut(e,t){var n,r,s,o,u,a,f,l=L[d][e+" "];if(l)return t?0:l.slice(0);u=e,a=[],f=i.preFilter;while(u){if(!n||(r=F.exec(u)))r&&(u=u.slice(r[0].length)||u),a.push(s=[]);n=!1;if(r=I.exec(u))s.push(n=new m(r.shift())),u=u.slice(n.length),n.type=r[0].replace(j," ");for(o in i.filter)(r=J[o].exec(u))&&(!f[o]||(r=f[o](r)))&&(s.push(n=new m(r.shift())),u=u.slice(n.length),n.type=o,n.matches=r);if(!n)break}return t?u.length:u?nt.error(e):L(e,a).slice(0)}function at(e,t,r){var i=t.dir,s=r&&t.dir==="parentNode",o=w++;return t.first?function(t,n,r){while(t=t[i])if(s||t.nodeType===1)return e(t,n,r)}:function(t,r,u){if(!u){var a,f=b+" "+o+" ",l=f+n;while(t=t[i])if(s||t.nodeType===1){if((a=t[d])===l)return t.sizset;if(typeof a=="string"&&a.indexOf(f)===0){if(t.sizset)return t}else{t[d]=l;if(e(t,r,u))return t.sizset=!0,t;t.sizset=!1}}}else while(t=t[i])if(s||t.nodeType===1)if(e(t,r,u))return t}}function ft(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function lt(e,t,n,r,i){var s,o=[],u=0,a=e.length,f=t!=null;for(;u<a;u++)if(s=e[u])if(!n||n(s,r,i))o.push(s),f&&t.push(u);return o}function ct(e,t,n,r,i,s){return r&&!r[d]&&(r=ct(r)),i&&!i[d]&&(i=ct(i,s)),N(function(s,o,u,a){var f,l,c,h=[],p=[],d=o.length,v=s||dt(t||"*",u.nodeType?[u]:u,[]),m=e&&(s||!t)?lt(v,h,e,u,a):v,g=n?i||(s?e:d||r)?[]:o:m;n&&n(m,g,u,a);if(r){f=lt(g,p),r(f,[],u,a),l=f.length;while(l--)if(c=f[l])g[p[l]]=!(m[p[l]]=c)}if(s){if(i||e){if(i){f=[],l=g.length;while(l--)(c=g[l])&&f.push(m[l]=c);i(null,g=[],f,a)}l=g.length;while(l--)(c=g[l])&&(f=i?T.call(s,c):h[l])>-1&&(s[f]=!(o[f]=c))}}else g=lt(g===o?g.splice(d,g.length):g),i?i(null,o,g,a):S.apply(o,g)})}function ht(e){var t,n,r,s=e.length,o=i.relative[e[0].type],u=o||i.relative[" "],a=o?1:0,f=at(function(e){return e===t},u,!0),l=at(function(e){return T.call(t,e)>-1},u,!0),h=[function(e,n,r){return!o&&(r||n!==c)||((t=n).nodeType?f(e,n,r):l(e,n,r))}];for(;a<s;a++)if(n=i.relative[e[a].type])h=[at(ft(h),n)];else{n=i.filter[e[a].type].apply(null,e[a].matches);if(n[d]){r=++a;for(;r<s;r++)if(i.relative[e[r].type])break;return ct(a>1&&ft(h),a>1&&e.slice(0,a-1).join("").replace(j,"$1"),n,a<r&&ht(e.slice(a,r)),r<s&&ht(e=e.slice(r)),r<s&&e.join(""))}h.push(n)}return ft(h)}function pt(e,t){var r=t.length>0,s=e.length>0,o=function(u,a,f,l,h){var p,d,v,m=[],y=0,w="0",x=u&&[],T=h!=null,N=c,C=u||s&&i.find.TAG("*",h&&a.parentNode||a),k=b+=N==null?1:Math.E;T&&(c=a!==g&&a,n=o.el);for(;(p=C[w])!=null;w++){if(s&&p){for(d=0;v=e[d];d++)if(v(p,a,f)){l.push(p);break}T&&(b=k,n=++o.el)}r&&((p=!v&&p)&&y--,u&&x.push(p))}y+=w;if(r&&w!==y){for(d=0;v=t[d];d++)v(x,m,a,f);if(u){if(y>0)while(w--)!x[w]&&!m[w]&&(m[w]=E.call(l));m=lt(m)}S.apply(l,m),T&&!u&&m.length>0&&y+t.length>1&&nt.uniqueSort(l)}return T&&(b=k,c=N),x};return o.el=0,r?N(o):o}function dt(e,t,n){var r=0,i=t.length;for(;r<i;r++)nt(e,t[r],n);return n}function vt(e,t,n,r,s){var o,u,f,l,c,h=ut(e),p=h.length;if(!r&&h.length===1){u=h[0]=h[0].slice(0);if(u.length>2&&(f=u[0]).type==="ID"&&t.nodeType===9&&!s&&i.relative[u[1].type]){t=i.find.ID(f.matches[0].replace($,""),t,s)[0];if(!t)return n;e=e.slice(u.shift().length)}for(o=J.POS.test(e)?-1:u.length-1;o>=0;o--){f=u[o];if(i.relative[l=f.type])break;if(c=i.find[l])if(r=c(f.matches[0].replace($,""),z.test(u[0].type)&&t.parentNode||t,s)){u.splice(o,1),e=r.length&&u.join("");if(!e)return S.apply(n,x.call(r,0)),n;break}}}return a(e,h)(r,t,s,n,z.test(e)),n}function mt(){}var n,r,i,s,o,u,a,f,l,c,h=!0,p="undefined",d=("sizcache"+Math.random()).replace(".",""),m=String,g=e.document,y=g.documentElement,b=0,w=0,E=[].pop,S=[].push,x=[].slice,T=[].indexOf||function(e){var t=0,n=this.length;for(;t<n;t++)if(this[t]===e)return t;return-1},N=function(e,t){return e[d]=t==null||t,e},C=function(){var e={},t=[];return N(function(n,r){return t.push(n)>i.cacheLength&&delete e[t.shift()],e[n+" "]=r},e)},k=C(),L=C(),A=C(),O="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",_=M.replace("w","w#"),D="([*^$|!~]?=)",P="\\["+O+"*("+M+")"+O+"*(?:"+D+O+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+_+")|)|)"+O+"*\\]",H=":("+M+")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:"+P+")|[^:]|\\\\.)*|.*))\\)|)",B=":(even|odd|eq|gt|lt|nth|first|last)(?:\\("+O+"*((?:-\\d)?\\d*)"+O+"*\\)|)(?=[^-]|$)",j=new RegExp("^"+O+"+|((?:^|[^\\\\])(?:\\\\.)*)"+O+"+$","g"),F=new RegExp("^"+O+"*,"+O+"*"),I=new RegExp("^"+O+"*([\\x20\\t\\r\\n\\f>+~])"+O+"*"),q=new RegExp(H),R=/^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,U=/^:not/,z=/[\x20\t\r\n\f]*[+~]/,W=/:not\($/,X=/h\d/i,V=/input|select|textarea|button/i,$=/\\(?!\\)/g,J={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),NAME:new RegExp("^\\[name=['\"]?("+M+")['\"]?\\]"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+H),POS:new RegExp(B,"i"),CHILD:new RegExp("^:(only|nth|first|last)-child(?:\\("+O+"*(even|odd|(([+-]|)(\\d*)n|)"+O+"*(?:([+-]|)"+O+"*(\\d+)|))"+O+"*\\)|)","i"),needsContext:new RegExp("^"+O+"*[>+~]|"+B,"i")},K=function(e){var t=g.createElement("div");try{return e(t)}catch(n){return!1}finally{t=null}},Q=K(function(e){return e.appendChild(g.createComment("")),!e.getElementsByTagName("*").length}),G=K(function(e){return e.innerHTML="<a href='#'></a>",e.firstChild&&typeof e.firstChild.getAttribute!==p&&e.firstChild.getAttribute("href")==="#"}),Y=K(function(e){e.innerHTML="<select></select>";var t=typeof e.lastChild.getAttribute("multiple");return t!=="boolean"&&t!=="string"}),Z=K(function(e){return e.innerHTML="<div class='hidden e'></div><div class='hidden'></div>",!e.getElementsByClassName||!e.getElementsByClassName("e").length?!1:(e.lastChild.className="e",e.getElementsByClassName("e").length===2)}),et=K(function(e){e.id=d+0,e.innerHTML="<a name='"+d+"'></a><div name='"+d+"'></div>",y.insertBefore(e,y.firstChild);var t=g.getElementsByName&&g.getElementsByName(d).length===2+g.getElementsByName(d+0).length;return r=!g.getElementById(d),y.removeChild(e),t});try{x.call(y.childNodes,0)[0].nodeType}catch(tt){x=function(e){var t,n=[];for(;t=this[e];e++)n.push(t);return n}}nt.matches=function(e,t){return nt(e,null,null,t)},nt.matchesSelector=function(e,t){return nt(t,null,null,[e]).length>0},s=nt.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(i===1||i===9||i===11){if(typeof e.textContent=="string")return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=s(e)}else if(i===3||i===4)return e.nodeValue}else for(;t=e[r];r++)n+=s(t);return n},o=nt.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?t.nodeName!=="HTML":!1},u=nt.contains=y.contains?function(e,t){var n=e.nodeType===9?e.documentElement:e,r=t&&t.parentNode;return e===r||!!(r&&r.nodeType===1&&n.contains&&n.contains(r))}:y.compareDocumentPosition?function(e,t){return t&&!!(e.compareDocumentPosition(t)&16)}:function(e,t){while(t=t.parentNode)if(t===e)return!0;return!1},nt.attr=function(e,t){var n,r=o(e);return r||(t=t.toLowerCase()),(n=i.attrHandle[t])?n(e):r||Y?e.getAttribute(t):(n=e.getAttributeNode(t),n?typeof e[t]=="boolean"?e[t]?t:null:n.specified?n.value:null:null)},i=nt.selectors={cacheLength:50,createPseudo:N,match:J,attrHandle:G?{}:{href:function(e){return e.getAttribute("href",2)},type:function(e){return e.getAttribute("type")}},find:{ID:r?function(e,t,n){if(typeof t.getElementById!==p&&!n){var r=t.getElementById(e);return r&&r.parentNode?[r]:[]}}:function(e,n,r){if(typeof n.getElementById!==p&&!r){var i=n.getElementById(e);return i?i.id===e||typeof i.getAttributeNode!==p&&i.getAttributeNode("id").value===e?[i]:t:[]}},TAG:Q?function(e,t){if(typeof t.getElementsByTagName!==p)return t.getElementsByTagName(e)}:function(e,t){var n=t.getElementsByTagName(e);if(e==="*"){var r,i=[],s=0;for(;r=n[s];s++)r.nodeType===1&&i.push(r);return i}return n},NAME:et&&function(e,t){if(typeof t.getElementsByName!==p)return t.getElementsByName(name)},CLASS:Z&&function(e,t,n){if(typeof t.getElementsByClassName!==p&&!n)return t.getElementsByClassName(e)}},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace($,""),e[3]=(e[4]||e[5]||"").replace($,""),e[2]==="~="&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),e[1]==="nth"?(e[2]||nt.error(e[0]),e[3]=+(e[3]?e[4]+(e[5]||1):2*(e[2]==="even"||e[2]==="odd")),e[4]=+(e[6]+e[7]||e[2]==="odd")):e[2]&&nt.error(e[0]),e},PSEUDO:function(e){var t,n;if(J.CHILD.test(e[0]))return null;if(e[3])e[2]=e[3];else if(t=e[4])q.test(t)&&(n=ut(t,!0))&&(n=t.indexOf(")",t.length-n)-t.length)&&(t=t.slice(0,n),e[0]=e[0].slice(0,n)),e[2]=t;return e.slice(0,3)}},filter:{ID:r?function(e){return e=e.replace($,""),function(t){return t.getAttribute("id")===e}}:function(e){return e=e.replace($,""),function(t){var n=typeof t.getAttributeNode!==p&&t.getAttributeNode("id");return n&&n.value===e}},TAG:function(e){return e==="*"?function(){return!0}:(e=e.replace($,"").toLowerCase(),function(t){return t.nodeName&&t.nodeName.toLowerCase()===e})},CLASS:function(e){var t=k[d][e+" "];return t||(t=new RegExp("(^|"+O+")"+e+"("+O+"|$)"))&&k(e,function(e){return t.test(e.className||typeof e.getAttribute!==p&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r,i){var s=nt.attr(r,e);return s==null?t==="!=":t?(s+="",t==="="?s===n:t==="!="?s!==n:t==="^="?n&&s.indexOf(n)===0:t==="*="?n&&s.indexOf(n)>-1:t==="$="?n&&s.substr(s.length-n.length)===n:t==="~="?(" "+s+" ").indexOf(n)>-1:t==="|="?s===n||s.substr(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r){return e==="nth"?function(e){var t,i,s=e.parentNode;if(n===1&&r===0)return!0;if(s){i=0;for(t=s.firstChild;t;t=t.nextSibling)if(t.nodeType===1){i++;if(e===t)break}}return i-=r,i===n||i%n===0&&i/n>=0}:function(t){var n=t;switch(e){case"only":case"first":while(n=n.previousSibling)if(n.nodeType===1)return!1;if(e==="first")return!0;n=t;case"last":while(n=n.nextSibling)if(n.nodeType===1)return!1;return!0}}},PSEUDO:function(e,t){var n,r=i.pseudos[e]||i.setFilters[e.toLowerCase()]||nt.error("unsupported pseudo: "+e);return r[d]?r(t):r.length>1?(n=[e,e,"",t],i.setFilters.hasOwnProperty(e.toLowerCase())?N(function(e,n){var i,s=r(e,t),o=s.length;while(o--)i=T.call(e,s[o]),e[i]=!(n[i]=s[o])}):function(e){return r(e,0,n)}):r}},pseudos:{not:N(function(e){var t=[],n=[],r=a(e.replace(j,"$1"));return r[d]?N(function(e,t,n,i){var s,o=r(e,null,i,[]),u=e.length;while(u--)if(s=o[u])e[u]=!(t[u]=s)}):function(e,i,s){return t[0]=e,r(t,null,s,n),!n.pop()}}),has:N(function(e){return function(t){return nt(e,t).length>0}}),contains:N(function(e){return function(t){return(t.textContent||t.innerText||s(t)).indexOf(e)>-1}}),enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return t==="input"&&!!e.checked||t==="option"&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},parent:function(e){return!i.pseudos.empty(e)},empty:function(e){var t;e=e.firstChild;while(e){if(e.nodeName>"@"||(t=e.nodeType)===3||t===4)return!1;e=e.nextSibling}return!0},header:function(e){return X.test(e.nodeName)},text:function(e){var t,n;return e.nodeName.toLowerCase()==="input"&&(t=e.type)==="text"&&((n=e.getAttribute("type"))==null||n.toLowerCase()===t)},radio:rt("radio"),checkbox:rt("checkbox"),file:rt("file"),password:rt("password"),image:rt("image"),submit:it("submit"),reset:it("reset"),button:function(e){var t=e.nodeName.toLowerCase();return t==="input"&&e.type==="button"||t==="button"},input:function(e){return V.test(e.nodeName)},focus:function(e){var t=e.ownerDocument;return e===t.activeElement&&(!t.hasFocus||t.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},active:function(e){return e===e.ownerDocument.activeElement},first:st(function(){return[0]}),last:st(function(e,t){return[t-1]}),eq:st(function(e,t,n){return[n<0?n+t:n]}),even:st(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:st(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:st(function(e,t,n){for(var r=n<0?n+t:n;--r>=0;)e.push(r);return e}),gt:st(function(e,t,n){for(var r=n<0?n+t:n;++r<t;)e.push(r);return e})}},f=y.compareDocumentPosition?function(e,t){return e===t?(l=!0,0):(!e.compareDocumentPosition||!t.compareDocumentPosition?e.compareDocumentPosition:e.compareDocumentPosition(t)&4)?-1:1}:function(e,t){if(e===t)return l=!0,0;if(e.sourceIndex&&t.sourceIndex)return e.sourceIndex-t.sourceIndex;var n,r,i=[],s=[],o=e.parentNode,u=t.parentNode,a=o;if(o===u)return ot(e,t);if(!o)return-1;if(!u)return 1;while(a)i.unshift(a),a=a.parentNode;a=u;while(a)s.unshift(a),a=a.parentNode;n=i.length,r=s.length;for(var f=0;f<n&&f<r;f++)if(i[f]!==s[f])return ot(i[f],s[f]);return f===n?ot(e,s[f],-1):ot(i[f],t,1)},[0,0].sort(f),h=!l,nt.uniqueSort=function(e){var t,n=[],r=1,i=0;l=h,e.sort(f);if(l){for(;t=e[r];r++)t===e[r-1]&&(i=n.push(r));while(i--)e.splice(n[i],1)}return e},nt.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},a=nt.compile=function(e,t){var n,r=[],i=[],s=A[d][e+" "];if(!s){t||(t=ut(e)),n=t.length;while(n--)s=ht(t[n]),s[d]?r.push(s):i.push(s);s=A(e,pt(i,r))}return s},g.querySelectorAll&&function(){var e,t=vt,n=/'|\\/g,r=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,i=[":focus"],s=[":active"],u=y.matchesSelector||y.mozMatchesSelector||y.webkitMatchesSelector||y.oMatchesSelector||y.msMatchesSelector;K(function(e){e.innerHTML="<select><option selected=''></option></select>",e.querySelectorAll("[selected]").length||i.push("\\["+O+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),e.querySelectorAll(":checked").length||i.push(":checked")}),K(function(e){e.innerHTML="<p test=''></p>",e.querySelectorAll("[test^='']").length&&i.push("[*^$]="+O+"*(?:\"\"|'')"),e.innerHTML="<input type='hidden'/>",e.querySelectorAll(":enabled").length||i.push(":enabled",":disabled")}),i=new RegExp(i.join("|")),vt=function(e,r,s,o,u){if(!o&&!u&&!i.test(e)){var a,f,l=!0,c=d,h=r,p=r.nodeType===9&&e;if(r.nodeType===1&&r.nodeName.toLowerCase()!=="object"){a=ut(e),(l=r.getAttribute("id"))?c=l.replace(n,"\\$&"):r.setAttribute("id",c),c="[id='"+c+"'] ",f=a.length;while(f--)a[f]=c+a[f].join("");h=z.test(e)&&r.parentNode||r,p=a.join(",")}if(p)try{return S.apply(s,x.call(h.querySelectorAll(p),0)),s}catch(v){}finally{l||r.removeAttribute("id")}}return t(e,r,s,o,u)},u&&(K(function(t){e=u.call(t,"div");try{u.call(t,"[test!='']:sizzle"),s.push("!=",H)}catch(n){}}),s=new RegExp(s.join("|")),nt.matchesSelector=function(t,n){n=n.replace(r,"='$1']");if(!o(t)&&!s.test(n)&&!i.test(n))try{var a=u.call(t,n);if(a||e||t.document&&t.document.nodeType!==11)return a}catch(f){}return nt(n,null,null,[t]).length>0})}(),i.pseudos.nth=i.pseudos.eq,i.filters=mt.prototype=i.pseudos,i.setFilters=new mt,nt.attr=v.attr,v.find=nt,v.expr=nt.selectors,v.expr[":"]=v.expr.pseudos,v.unique=nt.uniqueSort,v.text=nt.getText,v.isXMLDoc=nt.isXML,v.contains=nt.contains}(e);var nt=/Until$/,rt=/^(?:parents|prev(?:Until|All))/,it=/^.[^:#\[\.,]*$/,st=v.expr.match.needsContext,ot={children:!0,contents:!0,next:!0,prev:!0};v.fn.extend({find:function(e){var t,n,r,i,s,o,u=this;if(typeof e!="string")return v(e).filter(function(){for(t=0,n=u.length;t<n;t++)if(v.contains(u[t],this))return!0});o=this.pushStack("","find",e);for(t=0,n=this.length;t<n;t++){r=o.length,v.find(e,this[t],o);if(t>0)for(i=r;i<o.length;i++)for(s=0;s<r;s++)if(o[s]===o[i]){o.splice(i--,1);break}}return o},has:function(e){var t,n=v(e,this),r=n.length;return this.filter(function(){for(t=0;t<r;t++)if(v.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e,!1),"not",e)},filter:function(e){return this.pushStack(ft(this,e,!0),"filter",e)},is:function(e){return!!e&&(typeof e=="string"?st.test(e)?v(e,this.context).index(this[0])>=0:v.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){var n,r=0,i=this.length,s=[],o=st.test(e)||typeof e!="string"?v(e,t||this.context):0;for(;r<i;r++){n=this[r];while(n&&n.ownerDocument&&n!==t&&n.nodeType!==11){if(o?o.index(n)>-1:v.find.matchesSelector(n,e)){s.push(n);break}n=n.parentNode}}return s=s.length>1?v.unique(s):s,this.pushStack(s,"closest",e)},index:function(e){return e?typeof e=="string"?v.inArray(this[0],v(e)):v.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.prevAll().length:-1},add:function(e,t){var n=typeof e=="string"?v(e,t):v.makeArray(e&&e.nodeType?[e]:e),r=v.merge(this.get(),n);return this.pushStack(ut(n[0])||ut(r[0])?r:v.unique(r))},addBack:function(e){return this.add(e==null?this.prevObject:this.prevObject.filter(e))}}),v.fn.andSelf=v.fn.addBack,v.each({parent:function(e){var t=e.parentNode;return t&&t.nodeType!==11?t:null},parents:function(e){return v.dir(e,"parentNode")},parentsUntil:function(e,t,n){return v.dir(e,"parentNode",n)},next:function(e){return at(e,"nextSibling")},prev:function(e){return at(e,"previousSibling")},nextAll:function(e){return v.dir(e,"nextSibling")},prevAll:function(e){return v.dir(e,"previousSibling")},nextUntil:function(e,t,n){return v.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return v.dir(e,"previousSibling",n)},siblings:function(e){return v.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return v.sibling(e.firstChild)},contents:function(e){return v.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:v.merge([],e.childNodes)}},function(e,t){v.fn[e]=function(n,r){var i=v.map(this,t,n);return nt.test(e)||(r=n),r&&typeof r=="string"&&(i=v.filter(r,i)),i=this.length>1&&!ot[e]?v.unique(i):i,this.length>1&&rt.test(e)&&(i=i.reverse()),this.pushStack(i,e,l.call(arguments).join(","))}}),v.extend({filter:function(e,t,n){return n&&(e=":not("+e+")"),t.length===1?v.find.matchesSelector(t[0],e)?[t[0]]:[]:v.find.matches(e,t)},dir:function(e,n,r){var i=[],s=e[n];while(s&&s.nodeType!==9&&(r===t||s.nodeType!==1||!v(s).is(r)))s.nodeType===1&&i.push(s),s=s[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)e.nodeType===1&&e!==t&&n.push(e);return n}});var ct="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",ht=/ jQuery\d+="(?:null|\d+)"/g,pt=/^\s+/,dt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,vt=/<([\w:]+)/,mt=/<tbody/i,gt=/<|&#?\w+;/,yt=/<(?:script|style|link)/i,bt=/<(?:script|object|embed|option|style)/i,wt=new RegExp("<(?:"+ct+")[\\s/>]","i"),Et=/^(?:checkbox|radio)$/,St=/checked\s*(?:[^=]|=\s*.checked.)/i,xt=/\/(java|ecma)script/i,Tt=/^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,Nt={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]},Ct=lt(i),kt=Ct.appendChild(i.createElement("div"));Nt.optgroup=Nt.option,Nt.tbody=Nt.tfoot=Nt.colgroup=Nt.caption=Nt.thead,Nt.th=Nt.td,v.support.htmlSerialize||(Nt._default=[1,"X<div>","</div>"]),v.fn.extend({text:function(e){return v.access(this,function(e){return e===t?v.text(this):this.empty().append((this[0]&&this[0].ownerDocument||i).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(v.isFunction(e))return this.each(function(t){v(this).wrapAll(e.call(this,t))});if(this[0]){var t=v(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&e.firstChild.nodeType===1)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return v.isFunction(e)?this.each(function(t){v(this).wrapInner(e.call(this,t))}):this.each(function(){var t=v(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=v.isFunction(e);return this.each(function(n){v(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){v.nodeName(this,"body")||v(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(this.nodeType===1||this.nodeType===11)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(this.nodeType===1||this.nodeType===11)&&this.insertBefore(e,this.firstChild)})},before:function(){if(!ut(this[0]))return this.domManip(arguments,!1,function(e){this.parentNode.insertBefore(e,this)});if(arguments.length){var e=v.clean(arguments);return this.pushStack(v.merge(e,this),"before",this.selector)}},after:function(){if(!ut(this[0]))return this.domManip(arguments,!1,function(e){this.parentNode.insertBefore(e,this.nextSibling)});if(arguments.length){var e=v.clean(arguments);return this.pushStack(v.merge(this,e),"after",this.selector)}},remove:function(e,t){var n,r=0;for(;(n=this[r])!=null;r++)if(!e||v.filter(e,[n]).length)!t&&n.nodeType===1&&(v.cleanData(n.getElementsByTagName("*")),v.cleanData([n])),n.parentNode&&n.parentNode.removeChild(n);return this},empty:function(){var e,t=0;for(;(e=this[t])!=null;t++){e.nodeType===1&&v.cleanData(e.getElementsByTagName("*"));while(e.firstChild)e.removeChild(e.firstChild)}return this},clone:function(e,t){return e=e==null?!1:e,t=t==null?e:t,this.map(function(){return v.clone(this,e,t)})},html:function(e){return v.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return n.nodeType===1?n.innerHTML.replace(ht,""):t;if(typeof e=="string"&&!yt.test(e)&&(v.support.htmlSerialize||!wt.test(e))&&(v.support.leadingWhitespace||!pt.test(e))&&!Nt[(vt.exec(e)||["",""])[1].toLowerCase()]){e=e.replace(dt,"<$1></$2>");try{for(;r<i;r++)n=this[r]||{},n.nodeType===1&&(v.cleanData(n.getElementsByTagName("*")),n.innerHTML=e);n=0}catch(s){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(e){return ut(this[0])?this.length?this.pushStack(v(v.isFunction(e)?e():e),"replaceWith",e):this:v.isFunction(e)?this.each(function(t){var n=v(this),r=n.html();n.replaceWith(e.call(this,t,r))}):(typeof e!="string"&&(e=v(e).detach()),this.each(function(){var t=this.nextSibling,n=this.parentNode;v(this).remove(),t?v(t).before(e):v(n).append(e)}))},detach:function(e){return this.remove(e,!0)},domManip:function(e,n,r){e=[].concat.apply([],e);var i,s,o,u,a=0,f=e[0],l=[],c=this.length;if(!v.support.checkClone&&c>1&&typeof f=="string"&&St.test(f))return this.each(function(){v(this).domManip(e,n,r)});if(v.isFunction(f))return this.each(function(i){var s=v(this);e[0]=f.call(this,i,n?s.html():t),s.domManip(e,n,r)});if(this[0]){i=v.buildFragment(e,this,l),o=i.fragment,s=o.firstChild,o.childNodes.length===1&&(o=s);if(s){n=n&&v.nodeName(s,"tr");for(u=i.cacheable||c-1;a<c;a++)r.call(n&&v.nodeName(this[a],"table")?Lt(this[a],"tbody"):this[a],a===u?o:v.clone(o,!0,!0))}o=s=null,l.length&&v.each(l,function(e,t){t.src?v.ajax?v.ajax({url:t.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):v.error("no ajax"):v.globalEval((t.text||t.textContent||t.innerHTML||"").replace(Tt,"")),t.parentNode&&t.parentNode.removeChild(t)})}return this}}),v.buildFragment=function(e,n,r){var s,o,u,a=e[0];return n=n||i,n=!n.nodeType&&n[0]||n,n=n.ownerDocument||n,e.length===1&&typeof a=="string"&&a.length<512&&n===i&&a.charAt(0)==="<"&&!bt.test(a)&&(v.support.checkClone||!St.test(a))&&(v.support.html5Clone||!wt.test(a))&&(o=!0,s=v.fragments[a],u=s!==t),s||(s=n.createDocumentFragment(),v.clean(e,n,s,r),o&&(v.fragments[a]=u&&s)),{fragment:s,cacheable:o}},v.fragments={},v.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){v.fn[e]=function(n){var r,i=0,s=[],o=v(n),u=o.length,a=this.length===1&&this[0].parentNode;if((a==null||a&&a.nodeType===11&&a.childNodes.length===1)&&u===1)return o[t](this[0]),this;for(;i<u;i++)r=(i>0?this.clone(!0):this).get(),v(o[i])[t](r),s=s.concat(r);return this.pushStack(s,e,o.selector)}}),v.extend({clone:function(e,t,n){var r,i,s,o;v.support.html5Clone||v.isXMLDoc(e)||!wt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(kt.innerHTML=e.outerHTML,kt.removeChild(o=kt.firstChild));if((!v.support.noCloneEvent||!v.support.noCloneChecked)&&(e.nodeType===1||e.nodeType===11)&&!v.isXMLDoc(e)){Ot(e,o),r=Mt(e),i=Mt(o);for(s=0;r[s];++s)i[s]&&Ot(r[s],i[s])}if(t){At(e,o);if(n){r=Mt(e),i=Mt(o);for(s=0;r[s];++s)At(r[s],i[s])}}return r=i=null,o},clean:function(e,t,n,r){var s,o,u,a,f,l,c,h,p,d,m,g,y=t===i&&Ct,b=[];if(!t||typeof t.createDocumentFragment=="undefined")t=i;for(s=0;(u=e[s])!=null;s++){typeof u=="number"&&(u+="");if(!u)continue;if(typeof u=="string")if(!gt.test(u))u=t.createTextNode(u);else{y=y||lt(t),c=t.createElement("div"),y.appendChild(c),u=u.replace(dt,"<$1></$2>"),a=(vt.exec(u)||["",""])[1].toLowerCase(),f=Nt[a]||Nt._default,l=f[0],c.innerHTML=f[1]+u+f[2];while(l--)c=c.lastChild;if(!v.support.tbody){h=mt.test(u),p=a==="table"&&!h?c.firstChild&&c.firstChild.childNodes:f[1]==="<table>"&&!h?c.childNodes:[];for(o=p.length-1;o>=0;--o)v.nodeName(p[o],"tbody")&&!p[o].childNodes.length&&p[o].parentNode.removeChild(p[o])}!v.support.leadingWhitespace&&pt.test(u)&&c.insertBefore(t.createTextNode(pt.exec(u)[0]),c.firstChild),u=c.childNodes,c.parentNode.removeChild(c)}u.nodeType?b.push(u):v.merge(b,u)}c&&(u=c=y=null);if(!v.support.appendChecked)for(s=0;(u=b[s])!=null;s++)v.nodeName(u,"input")?_t(u):typeof u.getElementsByTagName!="undefined"&&v.grep(u.getElementsByTagName("input"),_t);if(n){m=function(e){if(!e.type||xt.test(e.type))return r?r.push(e.parentNode?e.parentNode.removeChild(e):e):n.appendChild(e)};for(s=0;(u=b[s])!=null;s++)if(!v.nodeName(u,"script")||!m(u))n.appendChild(u),typeof u.getElementsByTagName!="undefined"&&(g=v.grep(v.merge([],u.getElementsByTagName("script")),m),b.splice.apply(b,[s+1,0].concat(g)),s+=g.length)}return b},cleanData:function(e,t){var n,r,i,s,o=0,u=v.expando,a=v.cache,f=v.support.deleteExpando,l=v.event.special;for(;(i=e[o])!=null;o++)if(t||v.acceptData(i)){r=i[u],n=r&&a[r];if(n){if(n.events)for(s in n.events)l[s]?v.event.remove(i,s):v.removeEvent(i,s,n.handle);a[r]&&(delete a[r],f?delete i[u]:i.removeAttribute?i.removeAttribute(u):i[u]=null,v.deletedIds.push(r))}}}}),function(){var e,t;v.uaMatch=function(e){e=e.toLowerCase();var t=/(chrome)[ \/]([\w.]+)/.exec(e)||/(webkit)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return{browser:t[1]||"",version:t[2]||"0"}},e=v.uaMatch(o.userAgent),t={},e.browser&&(t[e.browser]=!0,t.version=e.version),t.chrome?t.webkit=!0:t.webkit&&(t.safari=!0),v.browser=t,v.sub=function(){function e(t,n){return new e.fn.init(t,n)}v.extend(!0,e,this),e.superclass=this,e.fn=e.prototype=this(),e.fn.constructor=e,e.sub=this.sub,e.fn.init=function(r,i){return i&&i instanceof v&&!(i instanceof e)&&(i=e(i)),v.fn.init.call(this,r,i,t)},e.fn.init.prototype=e.fn;var t=e(i);return e}}();var Dt,Pt,Ht,Bt=/alpha\([^)]*\)/i,jt=/opacity=([^)]*)/,Ft=/^(top|right|bottom|left)$/,It=/^(none|table(?!-c[ea]).+)/,qt=/^margin/,Rt=new RegExp("^("+m+")(.*)$","i"),Ut=new RegExp("^("+m+")(?!px)[a-z%]+$","i"),zt=new RegExp("^([-+])=("+m+")","i"),Wt={BODY:"block"},Xt={position:"absolute",visibility:"hidden",display:"block"},Vt={letterSpacing:0,fontWeight:400},$t=["Top","Right","Bottom","Left"],Jt=["Webkit","O","Moz","ms"],Kt=v.fn.toggle;v.fn.extend({css:function(e,n){return v.access(this,function(e,n,r){return r!==t?v.style(e,n,r):v.css(e,n)},e,n,arguments.length>1)},show:function(){return Yt(this,!0)},hide:function(){return Yt(this)},toggle:function(e,t){var n=typeof e=="boolean";return v.isFunction(e)&&v.isFunction(t)?Kt.apply(this,arguments):this.each(function(){(n?e:Gt(this))?v(this).show():v(this).hide()})}}),v.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Dt(e,"opacity");return n===""?"1":n}}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":v.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(!e||e.nodeType===3||e.nodeType===8||!e.style)return;var s,o,u,a=v.camelCase(n),f=e.style;n=v.cssProps[a]||(v.cssProps[a]=Qt(f,a)),u=v.cssHooks[n]||v.cssHooks[a];if(r===t)return u&&"get"in u&&(s=u.get(e,!1,i))!==t?s:f[n];o=typeof r,o==="string"&&(s=zt.exec(r))&&(r=(s[1]+1)*s[2]+parseFloat(v.css(e,n)),o="number");if(r==null||o==="number"&&isNaN(r))return;o==="number"&&!v.cssNumber[a]&&(r+="px");if(!u||!("set"in u)||(r=u.set(e,r,i))!==t)try{f[n]=r}catch(l){}},css:function(e,n,r,i){var s,o,u,a=v.camelCase(n);return n=v.cssProps[a]||(v.cssProps[a]=Qt(e.style,a)),u=v.cssHooks[n]||v.cssHooks[a],u&&"get"in u&&(s=u.get(e,!0,i)),s===t&&(s=Dt(e,n)),s==="normal"&&n in Vt&&(s=Vt[n]),r||i!==t?(o=parseFloat(s),r||v.isNumeric(o)?o||0:s):s},swap:function(e,t,n){var r,i,s={};for(i in t)s[i]=e.style[i],e.style[i]=t[i];r=n.call(e);for(i in t)e.style[i]=s[i];return r}}),e.getComputedStyle?Dt=function(t,n){var r,i,s,o,u=e.getComputedStyle(t,null),a=t.style;return u&&(r=u.getPropertyValue(n)||u[n],r===""&&!v.contains(t.ownerDocument,t)&&(r=v.style(t,n)),Ut.test(r)&&qt.test(n)&&(i=a.width,s=a.minWidth,o=a.maxWidth,a.minWidth=a.maxWidth=a.width=r,r=u.width,a.width=i,a.minWidth=s,a.maxWidth=o)),r}:i.documentElement.currentStyle&&(Dt=function(e,t){var n,r,i=e.currentStyle&&e.currentStyle[t],s=e.style;return i==null&&s&&s[t]&&(i=s[t]),Ut.test(i)&&!Ft.test(t)&&(n=s.left,r=e.runtimeStyle&&e.runtimeStyle.left,r&&(e.runtimeStyle.left=e.currentStyle.left),s.left=t==="fontSize"?"1em":i,i=s.pixelLeft+"px",s.left=n,r&&(e.runtimeStyle.left=r)),i===""?"auto":i}),v.each(["height","width"],function(e,t){v.cssHooks[t]={get:function(e,n,r){if(n)return e.offsetWidth===0&&It.test(Dt(e,"display"))?v.swap(e,Xt,function(){return tn(e,t,r)}):tn(e,t,r)},set:function(e,n,r){return Zt(e,n,r?en(e,t,r,v.support.boxSizing&&v.css(e,"boxSizing")==="border-box"):0)}}}),v.support.opacity||(v.cssHooks.opacity={get:function(e,t){return jt.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=v.isNumeric(t)?"alpha(opacity="+t*100+")":"",s=r&&r.filter||n.filter||"";n.zoom=1;if(t>=1&&v.trim(s.replace(Bt,""))===""&&n.removeAttribute){n.removeAttribute("filter");if(r&&!r.filter)return}n.filter=Bt.test(s)?s.replace(Bt,i):s+" "+i}}),v(function(){v.support.reliableMarginRight||(v.cssHooks.marginRight={get:function(e,t){return v.swap(e,{display:"inline-block"},function(){if(t)return Dt(e,"marginRight")})}}),!v.support.pixelPosition&&v.fn.position&&v.each(["top","left"],function(e,t){v.cssHooks[t]={get:function(e,n){if(n){var r=Dt(e,t);return Ut.test(r)?v(e).position()[t]+"px":r}}}})}),v.expr&&v.expr.filters&&(v.expr.filters.hidden=function(e){return e.offsetWidth===0&&e.offsetHeight===0||!v.support.reliableHiddenOffsets&&(e.style&&e.style.display||Dt(e,"display"))==="none"},v.expr.filters.visible=function(e){return!v.expr.filters.hidden(e)}),v.each({margin:"",padding:"",border:"Width"},function(e,t){v.cssHooks[e+t]={expand:function(n){var r,i=typeof n=="string"?n.split(" "):[n],s={};for(r=0;r<4;r++)s[e+$t[r]+t]=i[r]||i[r-2]||i[0];return s}},qt.test(e)||(v.cssHooks[e+t].set=Zt)});var rn=/%20/g,sn=/\[\]$/,on=/\r?\n/g,un=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,an=/^(?:select|textarea)/i;v.fn.extend({serialize:function(){return v.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?v.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||an.test(this.nodeName)||un.test(this.type))}).map(function(e,t){var n=v(this).val();return n==null?null:v.isArray(n)?v.map(n,function(e,n){return{name:t.name,value:e.replace(on,"\r\n")}}):{name:t.name,value:n.replace(on,"\r\n")}}).get()}}),v.param=function(e,n){var r,i=[],s=function(e,t){t=v.isFunction(t)?t():t==null?"":t,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};n===t&&(n=v.ajaxSettings&&v.ajaxSettings.traditional);if(v.isArray(e)||e.jquery&&!v.isPlainObject(e))v.each(e,function(){s(this.name,this.value)});else for(r in e)fn(r,e[r],n,s);return i.join("&").replace(rn,"+")};var ln,cn,hn=/#.*$/,pn=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,dn=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,vn=/^(?:GET|HEAD)$/,mn=/^\/\//,gn=/\?/,yn=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,bn=/([?&])_=[^&]*/,wn=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,En=v.fn.load,Sn={},xn={},Tn=["*/"]+["*"];try{cn=s.href}catch(Nn){cn=i.createElement("a"),cn.href="",cn=cn.href}ln=wn.exec(cn.toLowerCase())||[],v.fn.load=function(e,n,r){if(typeof e!="string"&&En)return En.apply(this,arguments);if(!this.length)return this;var i,s,o,u=this,a=e.indexOf(" ");return a>=0&&(i=e.slice(a,e.length),e=e.slice(0,a)),v.isFunction(n)?(r=n,n=t):n&&typeof n=="object"&&(s="POST"),v.ajax({url:e,type:s,dataType:"html",data:n,complete:function(e,t){r&&u.each(r,o||[e.responseText,t,e])}}).done(function(e){o=arguments,u.html(i?v("<div>").append(e.replace(yn,"")).find(i):e)}),this},v.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(e,t){v.fn[t]=function(e){return this.on(t,e)}}),v.each(["get","post"],function(e,n){v[n]=function(e,r,i,s){return v.isFunction(r)&&(s=s||i,i=r,r=t),v.ajax({type:n,url:e,data:r,success:i,dataType:s})}}),v.extend({getScript:function(e,n){return v.get(e,t,n,"script")},getJSON:function(e,t,n){return v.get(e,t,n,"json")},ajaxSetup:function(e,t){return t?Ln(e,v.ajaxSettings):(t=e,e=v.ajaxSettings),Ln(e,t),e},ajaxSettings:{url:cn,isLocal:dn.test(ln[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":Tn},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":e.String,"text html":!0,"text json":v.parseJSON,"text xml":v.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:Cn(Sn),ajaxTransport:Cn(xn),ajax:function(e,n){function T(e,n,s,a){var l,y,b,w,S,T=n;if(E===2)return;E=2,u&&clearTimeout(u),o=t,i=a||"",x.readyState=e>0?4:0,s&&(w=An(c,x,s));if(e>=200&&e<300||e===304)c.ifModified&&(S=x.getResponseHeader("Last-Modified"),S&&(v.lastModified[r]=S),S=x.getResponseHeader("Etag"),S&&(v.etag[r]=S)),e===304?(T="notmodified",l=!0):(l=On(c,w),T=l.state,y=l.data,b=l.error,l=!b);else{b=T;if(!T||e)T="error",e<0&&(e=0)}x.status=e,x.statusText=(n||T)+"",l?d.resolveWith(h,[y,T,x]):d.rejectWith(h,[x,T,b]),x.statusCode(g),g=t,f&&p.trigger("ajax"+(l?"Success":"Error"),[x,c,l?y:b]),m.fireWith(h,[x,T]),f&&(p.trigger("ajaxComplete",[x,c]),--v.active||v.event.trigger("ajaxStop"))}typeof e=="object"&&(n=e,e=t),n=n||{};var r,i,s,o,u,a,f,l,c=v.ajaxSetup({},n),h=c.context||c,p=h!==c&&(h.nodeType||h instanceof v)?v(h):v.event,d=v.Deferred(),m=v.Callbacks("once memory"),g=c.statusCode||{},b={},w={},E=0,S="canceled",x={readyState:0,setRequestHeader:function(e,t){if(!E){var n=e.toLowerCase();e=w[n]=w[n]||e,b[e]=t}return this},getAllResponseHeaders:function(){return E===2?i:null},getResponseHeader:function(e){var n;if(E===2){if(!s){s={};while(n=pn.exec(i))s[n[1].toLowerCase()]=n[2]}n=s[e.toLowerCase()]}return n===t?null:n},overrideMimeType:function(e){return E||(c.mimeType=e),this},abort:function(e){return e=e||S,o&&o.abort(e),T(0,e),this}};d.promise(x),x.success=x.done,x.error=x.fail,x.complete=m.add,x.statusCode=function(e){if(e){var t;if(E<2)for(t in e)g[t]=[g[t],e[t]];else t=e[x.status],x.always(t)}return this},c.url=((e||c.url)+"").replace(hn,"").replace(mn,ln[1]+"//"),c.dataTypes=v.trim(c.dataType||"*").toLowerCase().split(y),c.crossDomain==null&&(a=wn.exec(c.url.toLowerCase()),c.crossDomain=!(!a||a[1]===ln[1]&&a[2]===ln[2]&&(a[3]||(a[1]==="http:"?80:443))==(ln[3]||(ln[1]==="http:"?80:443)))),c.data&&c.processData&&typeof c.data!="string"&&(c.data=v.param(c.data,c.traditional)),kn(Sn,c,n,x);if(E===2)return x;f=c.global,c.type=c.type.toUpperCase(),c.hasContent=!vn.test(c.type),f&&v.active++===0&&v.event.trigger("ajaxStart");if(!c.hasContent){c.data&&(c.url+=(gn.test(c.url)?"&":"?")+c.data,delete c.data),r=c.url;if(c.cache===!1){var N=v.now(),C=c.url.replace(bn,"$1_="+N);c.url=C+(C===c.url?(gn.test(c.url)?"&":"?")+"_="+N:"")}}(c.data&&c.hasContent&&c.contentType!==!1||n.contentType)&&x.setRequestHeader("Content-Type",c.contentType),c.ifModified&&(r=r||c.url,v.lastModified[r]&&x.setRequestHeader("If-Modified-Since",v.lastModified[r]),v.etag[r]&&x.setRequestHeader("If-None-Match",v.etag[r])),x.setRequestHeader("Accept",c.dataTypes[0]&&c.accepts[c.dataTypes[0]]?c.accepts[c.dataTypes[0]]+(c.dataTypes[0]!=="*"?", "+Tn+"; q=0.01":""):c.accepts["*"]);for(l in c.headers)x.setRequestHeader(l,c.headers[l]);if(!c.beforeSend||c.beforeSend.call(h,x,c)!==!1&&E!==2){S="abort";for(l in{success:1,error:1,complete:1})x[l](c[l]);o=kn(xn,c,n,x);if(!o)T(-1,"No Transport");else{x.readyState=1,f&&p.trigger("ajaxSend",[x,c]),c.async&&c.timeout>0&&(u=setTimeout(function(){x.abort("timeout")},c.timeout));try{E=1,o.send(b,T)}catch(k){if(!(E<2))throw k;T(-1,k)}}return x}return x.abort()},active:0,lastModified:{},etag:{}});var Mn=[],_n=/\?/,Dn=/(=)\?(?=&|$)|\?\?/,Pn=v.now();v.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Mn.pop()||v.expando+"_"+Pn++;return this[e]=!0,e}}),v.ajaxPrefilter("json jsonp",function(n,r,i){var s,o,u,a=n.data,f=n.url,l=n.jsonp!==!1,c=l&&Dn.test(f),h=l&&!c&&typeof a=="string"&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Dn.test(a);if(n.dataTypes[0]==="jsonp"||c||h)return s=n.jsonpCallback=v.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,o=e[s],c?n.url=f.replace(Dn,"$1"+s):h?n.data=a.replace(Dn,"$1"+s):l&&(n.url+=(_n.test(f)?"&":"?")+n.jsonp+"="+s),n.converters["script json"]=function(){return u||v.error(s+" was not called"),u[0]},n.dataTypes[0]="json",e[s]=function(){u=arguments},i.always(function(){e[s]=o,n[s]&&(n.jsonpCallback=r.jsonpCallback,Mn.push(s)),u&&v.isFunction(o)&&o(u[0]),u=o=t}),"script"}),v.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(e){return v.globalEval(e),e}}}),v.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),v.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=i.head||i.getElementsByTagName("head")[0]||i.documentElement;return{send:function(s,o){n=i.createElement("script"),n.async="async",e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,i){if(i||!n.readyState||/loaded|complete/.test(n.readyState))n.onload=n.onreadystatechange=null,r&&n.parentNode&&r.removeChild(n),n=t,i||o(200,"success")},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(0,1)}}}});var Hn,Bn=e.ActiveXObject?function(){for(var e in Hn)Hn[e](0,1)}:!1,jn=0;v.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&Fn()||In()}:Fn,function(e){v.extend(v.support,{ajax:!!e,cors:!!e&&"withCredentials"in e})}(v.ajaxSettings.xhr()),v.support.ajax&&v.ajaxTransport(function(n){if(!n.crossDomain||v.support.cors){var r;return{send:function(i,s){var o,u,a=n.xhr();n.username?a.open(n.type,n.url,n.async,n.username,n.password):a.open(n.type,n.url,n.async);if(n.xhrFields)for(u in n.xhrFields)a[u]=n.xhrFields[u];n.mimeType&&a.overrideMimeType&&a.overrideMimeType(n.mimeType),!n.crossDomain&&!i["X-Requested-With"]&&(i["X-Requested-With"]="XMLHttpRequest");try{for(u in i)a.setRequestHeader(u,i[u])}catch(f){}a.send(n.hasContent&&n.data||null),r=function(e,i){var u,f,l,c,h;try{if(r&&(i||a.readyState===4)){r=t,o&&(a.onreadystatechange=v.noop,Bn&&delete Hn[o]);if(i)a.readyState!==4&&a.abort();else{u=a.status,l=a.getAllResponseHeaders(),c={},h=a.responseXML,h&&h.documentElement&&(c.xml=h);try{c.text=a.responseText}catch(p){}try{f=a.statusText}catch(p){f=""}!u&&n.isLocal&&!n.crossDomain?u=c.text?200:404:u===1223&&(u=204)}}}catch(d){i||s(-1,d)}c&&s(u,f,c,l)},n.async?a.readyState===4?setTimeout(r,0):(o=++jn,Bn&&(Hn||(Hn={},v(e).unload(Bn)),Hn[o]=r),a.onreadystatechange=r):r()},abort:function(){r&&r(0,1)}}}});var qn,Rn,Un=/^(?:toggle|show|hide)$/,zn=new RegExp("^(?:([-+])=|)("+m+")([a-z%]*)$","i"),Wn=/queueHooks$/,Xn=[Gn],Vn={"*":[function(e,t){var n,r,i=this.createTween(e,t),s=zn.exec(t),o=i.cur(),u=+o||0,a=1,f=20;if(s){n=+s[2],r=s[3]||(v.cssNumber[e]?"":"px");if(r!=="px"&&u){u=v.css(i.elem,e,!0)||n||1;do a=a||".5",u/=a,v.style(i.elem,e,u+r);while(a!==(a=i.cur()/o)&&a!==1&&--f)}i.unit=r,i.start=u,i.end=s[1]?u+(s[1]+1)*n:n}return i}]};v.Animation=v.extend(Kn,{tweener:function(e,t){v.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;r<i;r++)n=e[r],Vn[n]=Vn[n]||[],Vn[n].unshift(t)},prefilter:function(e,t){t?Xn.unshift(e):Xn.push(e)}}),v.Tween=Yn,Yn.prototype={constructor:Yn,init:function(e,t,n,r,i,s){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=s||(v.cssNumber[n]?"":"px")},cur:function(){var e=Yn.propHooks[this.prop];return e&&e.get?e.get(this):Yn.propHooks._default.get(this)},run:function(e){var t,n=Yn.propHooks[this.prop];return this.options.duration?this.pos=t=v.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):Yn.propHooks._default.set(this),this}},Yn.prototype.init.prototype=Yn.prototype,Yn.propHooks={_default:{get:function(e){var t;return e.elem[e.prop]==null||!!e.elem.style&&e.elem.style[e.prop]!=null?(t=v.css(e.elem,e.prop,!1,""),!t||t==="auto"?0:t):e.elem[e.prop]},set:function(e){v.fx.step[e.prop]?v.fx.step[e.prop](e):e.elem.style&&(e.elem.style[v.cssProps[e.prop]]!=null||v.cssHooks[e.prop])?v.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},Yn.propHooks.scrollTop=Yn.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},v.each(["toggle","show","hide"],function(e,t){var n=v.fn[t];v.fn[t]=function(r,i,s){return r==null||typeof r=="boolean"||!e&&v.isFunction(r)&&v.isFunction(i)?n.apply(this,arguments):this.animate(Zn(t,!0),r,i,s)}}),v.fn.extend({fadeTo:function(e,t,n,r){return this.filter(Gt).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=v.isEmptyObject(e),s=v.speed(t,n,r),o=function(){var t=Kn(this,v.extend({},e),s);i&&t.stop(!0)};return i||s.queue===!1?this.each(o):this.queue(s.queue,o)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return typeof e!="string"&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=e!=null&&e+"queueHooks",s=v.timers,o=v._data(this);if(n)o[n]&&o[n].stop&&i(o[n]);else for(n in o)o[n]&&o[n].stop&&Wn.test(n)&&i(o[n]);for(n=s.length;n--;)s[n].elem===this&&(e==null||s[n].queue===e)&&(s[n].anim.stop(r),t=!1,s.splice(n,1));(t||!r)&&v.dequeue(this,e)})}}),v.each({slideDown:Zn("show"),slideUp:Zn("hide"),slideToggle:Zn("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){v.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),v.speed=function(e,t,n){var r=e&&typeof e=="object"?v.extend({},e):{complete:n||!n&&t||v.isFunction(e)&&e,duration:e,easing:n&&t||t&&!v.isFunction(t)&&t};r.duration=v.fx.off?0:typeof r.duration=="number"?r.duration:r.duration in v.fx.speeds?v.fx.speeds[r.duration]:v.fx.speeds._default;if(r.queue==null||r.queue===!0)r.queue="fx";return r.old=r.complete,r.complete=function(){v.isFunction(r.old)&&r.old.call(this),r.queue&&v.dequeue(this,r.queue)},r},v.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},v.timers=[],v.fx=Yn.prototype.init,v.fx.tick=function(){var e,n=v.timers,r=0;qn=v.now();for(;r<n.length;r++)e=n[r],!e()&&n[r]===e&&n.splice(r--,1);n.length||v.fx.stop(),qn=t},v.fx.timer=function(e){e()&&v.timers.push(e)&&!Rn&&(Rn=setInterval(v.fx.tick,v.fx.interval))},v.fx.interval=13,v.fx.stop=function(){clearInterval(Rn),Rn=null},v.fx.speeds={slow:600,fast:200,_default:400},v.fx.step={},v.expr&&v.expr.filters&&(v.expr.filters.animated=function(e){return v.grep(v.timers,function(t){return e===t.elem}).length});var er=/^(?:body|html)$/i;v.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){v.offset.setOffset(this,e,t)});var n,r,i,s,o,u,a,f={top:0,left:0},l=this[0],c=l&&l.ownerDocument;if(!c)return;return(r=c.body)===l?v.offset.bodyOffset(l):(n=c.documentElement,v.contains(n,l)?(typeof l.getBoundingClientRect!="undefined"&&(f=l.getBoundingClientRect()),i=tr(c),s=n.clientTop||r.clientTop||0,o=n.clientLeft||r.clientLeft||0,u=i.pageYOffset||n.scrollTop,a=i.pageXOffset||n.scrollLeft,{top:f.top+u-s,left:f.left+a-o}):f)},v.offset={bodyOffset:function(e){var t=e.offsetTop,n=e.offsetLeft;return v.support.doesNotIncludeMarginInBodyOffset&&(t+=parseFloat(v.css(e,"marginTop"))||0,n+=parseFloat(v.css(e,"marginLeft"))||0),{top:t,left:n}},setOffset:function(e,t,n){var r=v.css(e,"position");r==="static"&&(e.style.position="relative");var i=v(e),s=i.offset(),o=v.css(e,"top"),u=v.css(e,"left"),a=(r==="absolute"||r==="fixed")&&v.inArray("auto",[o,u])>-1,f={},l={},c,h;a?(l=i.position(),c=l.top,h=l.left):(c=parseFloat(o)||0,h=parseFloat(u)||0),v.isFunction(t)&&(t=t.call(e,n,s)),t.top!=null&&(f.top=t.top-s.top+c),t.left!=null&&(f.left=t.left-s.left+h),"using"in t?t.using.call(e,f):i.css(f)}},v.fn.extend({position:function(){if(!this[0])return;var e=this[0],t=this.offsetParent(),n=this.offset(),r=er.test(t[0].nodeName)?{top:0,left:0}:t.offset();return n.top-=parseFloat(v.css(e,"marginTop"))||0,n.left-=parseFloat(v.css(e,"marginLeft"))||0,r.top+=parseFloat(v.css(t[0],"borderTopWidth"))||0,r.left+=parseFloat(v.css(t[0],"borderLeftWidth"))||0,{top:n.top-r.top,left:n.left-r.left}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||i.body;while(e&&!er.test(e.nodeName)&&v.css(e,"position")==="static")e=e.offsetParent;return e||i.body})}}),v.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);v.fn[e]=function(i){return v.access(this,function(e,i,s){var o=tr(e);if(s===t)return o?n in o?o[n]:o.document.documentElement[i]:e[i];o?o.scrollTo(r?v(o).scrollLeft():s,r?s:v(o).scrollTop()):e[i]=s},e,i,arguments.length,null)}}),v.each({Height:"height",Width:"width"},function(e,n){v.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){v.fn[i]=function(i,s){var o=arguments.length&&(r||typeof i!="boolean"),u=r||(i===!0||s===!0?"margin":"border");return v.access(this,function(n,r,i){var s;return v.isWindow(n)?n.document.documentElement["client"+e]:n.nodeType===9?(s=n.documentElement,Math.max(n.body["scroll"+e],s["scroll"+e],n.body["offset"+e],s["offset"+e],s["client"+e])):i===t?v.css(n,r,i,u):v.style(n,r,i,u)},n,o?i:t,o,null)}})}),e.jQuery=e.$=v,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return v})})(window);
\ No newline at end of file
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/openbis-screening.js b/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/openbis-screening.js
deleted file mode 100644
index a445cba1d6a9c1608ec52b6c4b204979cd97974e..0000000000000000000000000000000000000000
--- a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/openbis-screening.js
+++ /dev/null
@@ -1,681 +0,0 @@
-/**
- * =======================================================
- * OpenBIS screening facade internal code (DO NOT USE!!!)
- * =======================================================
- */
-
-if(typeof openbis == 'undefined' || typeof _openbisInternal == 'undefined'){
-    alert('Loading of openbis-screening.js failed - openbis.js is missing');
-}
-
-var _openbisInternalGeneric = _openbisInternal;
-
-var _openbisInternal = function(openbisUrlOrNull){
-    this.init(openbisUrlOrNull);
-}
-
-$.extend(_openbisInternal.prototype, _openbisInternalGeneric.prototype);
-
-_openbisInternal.prototype.init = function(openbisUrlOrNull){
-    _openbisInternalGeneric.prototype.init.call(this, openbisUrlOrNull);
-    this.screeningUrl = this.openbisUrl + "/rmi-screening-api-v1.json"
-}
-
-_openbisInternal.prototype.getScreeningDataStoreApiUrlForDataStoreUrl = function(dataStoreUrl){
-    return dataStoreUrl + "/rmi-datastore-server-screening-api-v1.json"
-}
-
-var _openbisGeneric = openbis;
-
-/**
- * =========================
- * OpenBIS screening facade 
- * =========================
- * 
- * The facade provides access to the following services:
- * 
- * - all services that the generic OpenBIS facade provides (see openbis.js file)
- * - ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.IScreeningApiServer
- * - ch.systemsx.cisd.openbis.dss.screening.shared.api.v1.IDssServiceRpcScreening
- * 
- */
-
-var openbis = function(openbisUrlOrNull){
-	this._internal = new _openbisInternal(openbisUrlOrNull);
-}
-
-$.extend(openbis.prototype, _openbisGeneric.prototype);
-
-/**
- * ====================================================================================
- * ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.IScreeningApiServer methods
- * ====================================================================================
- */
-
-/**
- * @see IScreeningApiServer.listPlates(String)
- * @method
- */
-openbis.prototype.listPlates = function(action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "listPlates",
-                    "params" : [ this.getSession() ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.listPlates(String, ExperimentIdentifier)
- * @method
- */
-openbis.prototype.listPlatesForExperiment = function(experimentIdentifier, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "listPlates",
-                    "params" : [ this.getSession(), experimentIdentifier ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.getPlateMetadataList(String, List<? extends PlateIdentifier>)
- * @method
- */
-openbis.prototype.getPlateMetadataList = function(plateIdentifiers, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "getPlateMetadataList",
-                    "params" : [ this.getSession(), plateIdentifiers ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.listExperiments(String)
- * @method
- */
-openbis.prototype.listAllExperiments = function(action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "listExperiments",
-                    "params" : [ this.getSession() ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.listExperiments(String, String)
- * @method
- */
-openbis.prototype.listExperimentsVisibleToUser = function(userId, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "listExperiments",
-                    "params" : [ this.getSession(), userId ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.listFeatureVectorDatasets(String, List<? extends PlateIdentifier>)
- * @method
- */
-openbis.prototype.listFeatureVectorDatasets = function(plateIdentifiers, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "listFeatureVectorDatasets",
-                    "params" : [ this.getSession(), plateIdentifiers ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.listImageDatasets(String, List<? extends PlateIdentifier>)
- * @method
- */
-openbis.prototype.listImageDatasets = function(plateIdentifiers, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "listImageDatasets",
-                    "params" : [ this.getSession(), plateIdentifiers ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.getImageInfo(String, List<String>)
- * @method
- */
-openbis.prototype.getImageInfo = function(dataSetCodes, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "getImageInfo",
-                    "params" : [ this.getSession(), dataSetCodes ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.getImageResolutions(String, List<String>)
- * @method
- */
-openbis.prototype.getImageResolutions = function(dataSetCodes, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "getImageResolutions",
-                    "params" : [ this.getSession(), dataSetCodes ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.listRawImageDatasets(String, List<? extends PlateIdentifier>)
- * @method
- */
-openbis.prototype.listRawImageDatasets = function(plateIdentifiers, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "listRawImageDatasets",
-                    "params" : [ this.getSession(), plateIdentifiers ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.listSegmentationImageDatasets(String, List<? extends PlateIdentifier>)
- * @method
- */
-openbis.prototype.listSegmentationImageDatasets = function(plateIdentifiers, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "listSegmentationImageDatasets",
-                    "params" : [ this.getSession(), plateIdentifiers ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.getDatasetIdentifiers(String, List<String>)
- * @method
- */
-openbis.prototype.getDatasetIdentifiers = function(datasetCodes, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "getDatasetIdentifiers",
-                    "params" : [ this.getSession(), datasetCodes ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.listPlateWells(String, ExperimentIdentifier, MaterialIdentifier, boolean)
- * @method
- */
-openbis.prototype.listPlateWellsForExperimentAndMaterial = function(experimentIdentifer, materialIdentifier, findDatasets, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "listPlateWells",
-                    "params" : [ this.getSession(), experimentIdentifer, materialIdentifier, findDatasets ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.listPlateWells(String, MaterialIdentifier, boolean)
- * @method
- */
-openbis.prototype.listPlateWellsForMaterial = function(materialIdentifier, findDatasets, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "listPlateWells",
-                    "params" : [ this.getSession(), materialIdentifier, findDatasets ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.listPlateWells(String, PlateIdentifier)
- * @method
- */
-openbis.prototype.listPlateWells = function(plateIdentifier, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "listPlateWells",
-                    "params" : [ this.getSession(), plateIdentifier ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.getWellSample(String, WellIdentifier)
- * @method
- */
-openbis.prototype.getWellSample = function(wellIdentifier, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "getWellSample",
-                    "params" : [ this.getSession(), wellIdentifier ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.getPlateSample(String, PlateIdentifier)
- * @method
- */
-openbis.prototype.getPlateSample = function(plateIdentifier, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "getPlateSample",
-                    "params" : [ this.getSession(), plateIdentifier ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.listPlateMaterialMapping(String, List<PlateIdentifier>, MaterialTypeIdentifier)
- * @method
- */
-openbis.prototype.listPlateMaterialMapping = function(plateIdentifiers, materialTypeIdentifierOrNull, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "listPlateMaterialMapping",
-                    "params" : [ this.getSession(), plateIdentifiers, materialTypeIdentifierOrNull ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.getExperimentImageMetadata(String, ExperimentIdentifier)
- * @method
- */
-openbis.prototype.getExperimentImageMetadata = function(experimentIdentifer, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "getExperimentImageMetadata",
-                    "params" : [ this.getSession(), experimentIdentifer ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.listAvailableFeatureCodes(String, List<? extends IFeatureVectorDatasetIdentifier>)
- * @method
- */
-openbis.prototype.listAvailableFeatureCodes = function(featureDatasets, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "listAvailableFeatureCodes",
-                    "params" : [ this.getSession(), featureDatasets ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.listAvailableFeatures(String, List<? extends IFeatureVectorDatasetIdentifier>)
- * @method
- */
-openbis.prototype.listAvailableFeatures = function(featureDatasets, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "listAvailableFeatures",
-                    "params" : [ this.getSession(), featureDatasets ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.loadFeatures(String, List<FeatureVectorDatasetReference>, List<String>)
- * @method
- */
-openbis.prototype.loadFeatures = function(featureDatasets, featureCodes, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "loadFeatures",
-                    "params" : [ this.getSession(), featureDatasets, featureCodes ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.loadFeaturesForDatasetWellReferences(String, List<FeatureVectorDatasetWellReference>, List<String>)
- * @method
- */
-openbis.prototype.loadFeaturesForDatasetWellReferences = function(datasetWellReferences, featureCodes, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "loadFeaturesForDatasetWellReferences",
-                    "params" : [ this.getSession(), datasetWellReferences, featureCodes ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.loadImagesBase64(String, List<PlateImageReference>, boolean)
- * @method
- */
-openbis.prototype.loadImagesBase64ForImageReferencesAndImageConversion = function(imageReferences, convertToPng, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "loadImagesBase64",
-                    "params" : {
-                        "sessionToken" : this.getSession(),
-                        "imageReferences" : imageReferences,
-                        "convertToPng" : convertToPng
-                    }
-            },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.loadThumbnailImagesBase64(String, List<PlateImageReference>)
- * @method
- */
-openbis.prototype.loadThumbnailImagesBase64ForImageReferences = function(imageReferences, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "loadThumbnailImagesBase64",
-                    "params" : {
-                        "sessionToken" : this.getSession(), 
-                        "imageReferences" : imageReferences 
-                    } 
-            },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.loadImagesBase64(String, List<PlateImageReference>, ImageSize)
- * @method
- */
-openbis.prototype.loadImagesBase64ForImageReferencesAndImageSize = function(imageReferences, size, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "loadImagesBase64",
-                    "params" : {
-                        "sessionToken" : this.getSession(), 
-                        "imageReferences" : imageReferences,
-                        "size" : size 
-                    } 
-            },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.loadImagesBase64(String, List<PlateImageReference>)
- * @method
- */
-openbis.prototype.loadImagesBase64ForImageReferences = function(imageReferences, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "loadImagesBase64",
-                    "params" : { 
-                        "sessionToken" : this.getSession(),
-                        "imageReferences" : imageReferences 
-                    }
-            },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.loadImagesBase64(String, List<PlateImageReference>, LoadImageConfiguration)
- * @method
- */
-openbis.prototype.loadImagesBase64ForImageReferencesAndImageConfiguration = function(imageReferences, configuration, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "loadImagesBase64",
-                    "params" : { 
-                        "sessionToken" : this.getSession(), 
-                        "imageReferences" : imageReferences, 
-                        "configuration" : configuration 
-                    } 
-            },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.loadImagesBase64(String, List<PlateImageReference>, ImageRepresentationFormat)
- * @method
- */
-openbis.prototype.loadImagesBase64ForImageReferencesAndImageRepresentationFormat = function(imageReferences, format, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "loadImagesBase64",
-                    "params" : {
-                        "sessionToken" : this.getSession(), 
-                        "imageReferences" : imageReferences, 
-                        "format" : format 
-                    } 
-            },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.loadImagesBase64(String, List<PlateImageReference>, IImageRepresentationFormatSelectionCriterion...)
- * @method
- */
-openbis.prototype.loadImagesBase64ForImageReferencesAndImageRepresentationFormatCriteria = function(imageReferences, criteria, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "loadImagesBase64",
-                    "params" : { 
-                        "sessionToken" : this.getSession(), 
-                        "imageReferences" : imageReferences, 
-                        "criteria" : criteria 
-                    } 
-            },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.listImageMetadata(String, List<? extends IImageDatasetIdentifier>)
- * @method
- */
-openbis.prototype.listImageMetadata = function(imageDatasets, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "listImageMetadata",
-                    "params" : [ this.getSession(), imageDatasets ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.listAvailableImageRepresentationFormats(String, List<? extends IDatasetIdentifier>)
- * @method
- */
-openbis.prototype.listAvailableImageRepresentationFormats = function(imageDatasets, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "listAvailableImageRepresentationFormats",
-                    "params" : [ this.getSession(), imageDatasets ] },
-            success: action
-    });
-}
-
-/**
- * @see IScreeningApiServer.loadPhysicalThumbnailsBase64(String, List<PlateImageReference>, ImageRepresentationFormat)
- * @method
- */
-openbis.prototype.loadPhysicalThumbnailsBase64ForImageReferencesAndImageRepresentationFormat = function(imageReferences, format, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.screeningUrl,
-            data: { "method" : "loadPhysicalThumbnailsBase64",
-                    "params" : [ this.getSession(), imageReferences, format ] },
-            success: action
-    });
-}
-
-/**
- * =====================================================================================
- * ch.systemsx.cisd.openbis.dss.screening.shared.api.v1.IDssServiceRpcScreening methods
- * =====================================================================================
- */
-
-/**
- * @see IDssServiceRpcScreening.loadImagesBase64(String, IDatasetIdentifier, List<WellPosition>, String, ImageSize)
- * @method
- */
-openbis.prototype.loadImagesBase64ForDataSetIdentifierAndWellPositionsAndChannelAndImageSize = function(dataSetIdentifier, wellPositions, channel, thumbnailSizeOrNull, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.getScreeningDataStoreApiUrlForDataStoreUrl(dataSetIdentifier.datastoreServerUrl),
-            data: { "method" : "loadImagesBase64",
-                    "params" : { 
-                        "sessionToken" : this.getSession(), 
-                        "dataSetIdentifier" : dataSetIdentifier, 
-                        "wellPositions" : wellPositions, 
-                        "channel" : channel, 
-                        "thumbnailSizeOrNull" : thumbnailSizeOrNull 
-                    } 
-            },
-            success: action
-    });
-}
-
-/**
- * @see IDssServiceRpcScreening.loadImagesBase64(String, IDatasetIdentifier, String, ImageSize)
- * @method
- */
-openbis.prototype.loadImagesBase64ForDataSetIdentifierAndChannelAndImageSize = function(dataSetIdentifier, channel, thumbnailSizeOrNull, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.getScreeningDataStoreApiUrlForDataStoreUrl(dataSetIdentifier.datastoreServerUrl),
-            data: { "method" : "loadImagesBase64",
-                    "params" : { 
-                        "sessionToken" : this.getSession(), 
-                        "dataSetIdentifier" : dataSetIdentifier,
-                        "channel" : channel, 
-                        "thumbnailSizeOrNull" : thumbnailSizeOrNull 
-                    } 
-            },
-            success: action
-    });
-}
-
-/**
- * @see IDssServiceRpcScreening.loadThumbnailImagesBase64(String, IDatasetIdentifier, List<String>)
- * @method
- */
-openbis.prototype.loadThumbnailImagesBase64ForDataSetIdentifierAndChannels = function(dataSetIdentifier, channels, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.getScreeningDataStoreApiUrlForDataStoreUrl(dataSetIdentifier.datastoreServerUrl),
-            data: { "method" : "loadThumbnailImagesBase64",
-                    "params" : { 
-                        "sessionToken" : this.getSession(), 
-                        "dataSetIdentifier" : dataSetIdentifier, 
-                        "channels" : channels 
-                    } 
-            },
-            success: action
-    });
-}
-
-/**
- * @see IDssServiceRpcScreening.listPlateImageReferences(String, IDatasetIdentifier, List<WellPosition>, String)
- * @method
- */
-openbis.prototype.listPlateImageReferencesForDataSetIdentifierAndWellPositionsAndChannel = function(dataSetIdentifier, wellPositions, channel, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.getScreeningDataStoreApiUrlForDataStoreUrl(dataSetIdentifier.datastoreServerUrl),
-            data: { "method" : "listPlateImageReferences",
-                    "params" : { 
-                        "sessionToken" : this.getSession(), 
-                        "dataSetIdentifier" : dataSetIdentifier, 
-                        "wellPositions" : wellPositions, 
-                        "channel" : channel 
-                    } 
-            },
-            success: action
-    });
-}
-
-/**
- * @see IDssServiceRpcScreening.listPlateImageReferences(String, IDatasetIdentifier, List<WellPosition>, List<String>)
- * @method
- */
-openbis.prototype.listPlateImageReferencesForDataSetIdentifierAndWellPositionsAndChannels = function(dataSetIdentifier, wellPositions, channels, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.getScreeningDataStoreApiUrlForDataStoreUrl(dataSetIdentifier.datastoreServerUrl),
-            data: { "method" : "listPlateImageReferences",
-                    "params" : { 
-                        "sessionToken" : this.getSession(), 
-                        "dataSetIdentifier" : dataSetIdentifier, 
-                        "wellPositions" : wellPositions, 
-                        "channels" : channels 
-                    } 
-            },
-            success: action
-    });
-}
-
-/**
- * @see IDssServiceRpcScreening.listImageReferences(String, IDatasetIdentifier, String)
- * @method
- */
-openbis.prototype.listImageReferencesForDataSetIdentifierAndChannel = function(dataSetIdentifier, channel, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.getScreeningDataStoreApiUrlForDataStoreUrl(dataSetIdentifier.datastoreServerUrl),
-            data: { "method" : "listImageReferences",
-                    "params" : { 
-                        "sessionToken" : this.getSession(), 
-                        "dataSetIdentifier" : dataSetIdentifier, 
-                        "channel" : channel 
-                    } 
-            },
-            success: action
-    });
-}
-
-/**
- * @see IDssServiceRpcScreening.listImageReferences(String, IDatasetIdentifier, List<String>)
- * @method
- */
-openbis.prototype.listImageReferencesForDataSetIdentifierAndChannels = function(dataSetIdentifier, channels, action) {
-    this._internal.ajaxRequest({
-            url: this._internal.getScreeningDataStoreApiUrlForDataStoreUrl(dataSetIdentifier.datastoreServerUrl),
-            data: { "method" : "listImageReferences",
-                    "params" : {
-                        "sessionToken" : this.getSession(), 
-                        "dataSetIdentifier" : dataSetIdentifier, 
-                        "channels" : channels 
-                    } 
-            },
-            success: action
-    });
-}
-
-/**
- * @see IDssServiceRpcScreening.listAvailableFeatureLists(String, IFeatureVectorDatasetIdentifier)
- * @method
- */
-openbis.prototype.listAvailableFeatureLists = function(featureVectorDataSet, action) {
-	this._internal.ajaxRequest({
-	        url: this._internal.getScreeningDataStoreApiUrlForDataStoreUrl(featureVectorDataSet.datastoreServerUrl),
-	        data: { "method" : "listAvailableFeatureLists",
- 	                params : [this.getSession(), featureVectorDataSet]
-	        },
-	        success: action
-	});
-};
-
-/**
- * @see IDssServiceRpcScreening.getFeatureList(String, IFeatureVectorDatasetIdentifier, String)
- * @method
- */
-openbis.prototype.getFeatureList = function(featureVectorDataSet, featureListCode, action) {
-	this._internal.ajaxRequest({
-	        url: this._internal.getScreeningDataStoreApiUrlForDataStoreUrl(featureVectorDataSet.datastoreServerUrl),
-	        data: { "method" : "getFeatureList",
- 	                params : [this.getSession(), featureVectorDataSet, featureListCode]
-	        },
-	        success: action
-	});
-};
-
diff --git a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/openbis.js b/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/openbis.js
deleted file mode 100644
index 20d4836efed56980163b5c0745ff3aaa0803953a..0000000000000000000000000000000000000000
--- a/screening/source/core-plugins/microscopy/1/as/webapps/image-viewer/html/openbis.js
+++ /dev/null
@@ -1,2056 +0,0 @@
-/**
- * =============================================
- * OpenBIS facade internal code (DO NOT USE!!!)
- * =============================================
- */
-
-if(typeof $ == 'undefined'){
-	alert('Loading of openbis.js failed - jquery.js is missing');
-}
-
-function _openbisInternal(openbisUrlOrNull){
-	this.init(openbisUrlOrNull);
-}
-
-_openbisInternal.prototype.init = function(openbisUrlOrNull){
-	this.openbisUrl = this.normalizeOpenbisUrl(openbisUrlOrNull);
-	this.generalInfoServiceUrl = this.openbisUrl + "/rmi-general-information-v1.json";
-	this.generalInfoChangingServiceUrl = this.openbisUrl + "/rmi-general-information-changing-v1.json";
-	this.queryServiceUrl = this.openbisUrl + "/rmi-query-v1.json";
-	this.webInfoServiceUrl = this.openbisUrl + "/rmi-web-information-v1.json"
-}
-
-_openbisInternal.prototype.log = function(msg){
-	if(console){
-		console.log(msg);
-	}
-}
-
-_openbisInternal.prototype.normalizeOpenbisUrl = function(openbisUrlOrNull){
-	var parts = this.parseUri(window.location);
-	
-	if(openbisUrlOrNull){
-		var openbisParts = this.parseUri(openbisUrlOrNull);
-		
-		for(openbisPartName in openbisParts){
-			var openbisPartValue = openbisParts[openbisPartName];
-			
-			if(openbisPartValue){
-				parts[openbisPartName] = openbisPartValue;
-			}
-		}
-	}
-	
-	return parts.protocol + "://" + parts.authority + "/openbis/openbis";
-}
-
-_openbisInternal.prototype.jsonRequestData = function(params) {
-	params["id"] = "1";
-	params["jsonrpc"] = "2.0";
-	return JSON.stringify(params)
-}
- 
-_openbisInternal.prototype.ajaxRequest = function(settings) {
-	settings.type = "POST";
-	settings.processData = false;
-	settings.dataType = "json";
-	settings.data = this.jsonRequestData(settings.data);
-	settings.success = this.ajaxRequestSuccess(settings.success);
-	// we call the same settings.success function for backward compatibility
-	settings.error = this.ajaxRequestError(settings.success);
-	$.ajax(settings)
-}
-
-_openbisInternal.prototype.ajaxRequestSuccess = function(action){
-	var openbisObj = this;
-	return function(response){
-		if(response.error){
-			openbisObj.log("Request failed: " + JSON.stringify(response.error));
-		}
-		if(action){
-			action(response);
-		}
-	};
-}
-
-_openbisInternal.prototype.ajaxRequestError = function(action){
-	var openbisObj = this;
-	return function(xhr, status, error){
-		openbisObj.log("Request failed: " + error);
-		if(action){
-			action({
-				"error" : "Request failed: " + error
-			});
-		}
-	};
-}
-
-// Functions for working with cookies (see http://www.quirksmode.org/js/cookies.html)
-
-_openbisInternal.prototype.createCookie = function(name,value,days) {
-	if (days) {
-		var date = new Date();
-		date.setTime(date.getTime()+(days*24*60*60*1000));
-		var expires = "; expires="+date.toGMTString();
-	}
-	else var expires = "";
-	document.cookie = name+"="+value+expires+"; path=/";
-}
-
-_openbisInternal.prototype.readCookie = function(name) {
-	var nameEQ = name + "=";
-	var ca = document.cookie.split(';');
-	for(var i=0;i < ca.length;i++) {
-		var c = ca[i];
-		while (c.charAt(0)==' ') c = c.substring(1,c.length);
-		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
-	}
-	return null;
-}
-
-_openbisInternal.prototype.eraseCookie = function(name) {
-	this.createCookie(name,"",-1);
-}
-
-// parseUri 1.2.2 (c) Steven Levithan <stevenlevithan.com> MIT License (see http://blog.stevenlevithan.com/archives/parseuri)
-
-_openbisInternal.prototype.parseUri = function(str) {
-	var options = {
-		strictMode: false,
-		key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
-		q:   {
-			name:   "queryKey",
-			parser: /(?:^|&)([^&=]*)=?([^&]*)/g
-		},
-		parser: {
-			strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
-			loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
-		}
-	};
-	
-	var	o   = options,
-		m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
-		uri = {},
-		i   = 14;
-
-	while (i--) uri[o.key[i]] = m[i] || "";
-
-	uri[o.q.name] = {};
-	uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
-		if ($1) uri[o.q.name][$1] = $2;
-	});
-
-	return uri;
-}
-
-_openbisInternal.prototype.listDataStores = function(action){
-	this.ajaxRequest({
-		url: this.generalInfoServiceUrl,
-		data: { "method" : "listDataStores",
-				"params" : [ this.sessionToken ] 
-		},
-		success: action
-	});
-}
-
-_openbisInternal.prototype.initDataStores = function(action){
-	var openbisInternal = this;
-	
-	if(typeof this.dataStores === "undefined"){
-		this.listDataStores(function(response){
-			if(response.result){
-				openbisInternal.dataStores = response.result;
-			}else{
-				openbisInternal.dataStores = [];
-			}
-			action();
-		});
-	}else{
-		action();
-	}
-}
-
-_openbisInternal.prototype.getDataStoreUrlForDataStoreCode = function(dataStoreCodeOrNull, action) {
-	var openbisInternal = this;
-	
-	this.initDataStores(function(){
-		if(openbisInternal.dataStores.length == 0){
-			throw "Couldn't get a data store url as there are no data stores configured.";
-		}else{
-			if(dataStoreCodeOrNull){
-				var dataStoreUrl = null;
-				$.each(openbisInternal.dataStores, function(index, dataStore){
-					if(dataStore.code == dataStoreCodeOrNull){
-						dataStoreUrl = dataStore.downloadUrl;
-					}
-				});
-				if(dataStoreUrl){
-					action(dataStoreUrl);
-				}else{
-					throw "Couldn't get a data store url because data store with " + dataStoreCodeOrNull + " code does not exist.";
-				}
-			}else{
-				if(openbisInternal.dataStores.length == 1){
-					action(openbisInternal.dataStores[0].downloadUrl);
-				}else{
-					throw "There is more than one data store configured. Please specify a data store code to get a data store url.";
-				}
-			}
-		}
-	});
-}
-
-_openbisInternal.prototype.getDataStoreUrlForDataSetCode = function(dataSetCode, action) {
-	var openbisInternal = this;
-	
-	this.initDataStores(function(){
-		if(openbisInternal.dataStores.length == 0){
-			throw "Couldn't get a data store url as there are no data stores configured.";
-		}else if(openbisInternal.dataStores.length == 1){
-			action(openbisInternal.dataStores[0].downloadUrl);
-		}else{
-			openbisInternal.ajaxRequest({
-				url: openbisInternal.generalInfoServiceUrl,
-				data: { "method" : "tryGetDataStoreBaseURL",
-						"params" : [ openbisInternal.sessionToken, dataSetCode ] 
-						},
-				success: function(response){
-					var hostUrl = response.result;
-					
-					if(hostUrl){
-						action(hostUrl + "/datastore_server");
-					}else{
-						throw "Couldn't get a data store url for a data set with " + dataSetCode + " code because the data set does not exist.";
-					}
-				}
-			 });
-		}
-	});
-}
-
-_openbisInternal.prototype.getDataStoreApiUrlForDataStoreCode = function(dataStoreCodeOrNull, action) {
-	this.getDataStoreUrlForDataStoreCode(dataStoreCodeOrNull, function(dataStoreUrl){
-		action(dataStoreUrl + "/rmi-dss-api-v1.json");
-	});
-}
-
-_openbisInternal.prototype.getDataStoreApiUrlForDataSetCode = function(dataSetCode, action) {
-	this.getDataStoreUrlForDataSetCode(dataSetCode, function(dataStoreUrl){
-		action(dataStoreUrl + "/rmi-dss-api-v1.json");
-	});
-}
-
-_openbisInternal.prototype.getDataStoreHostForDataStoreCode = function(dataStoreCodeOrNull, action) {
-	var openbisObj = this;
-	
-	this.getDataStoreUrlForDataStoreCode(dataStoreCodeOrNull, function(dataStoreUrl){
-		var parts = openbisObj.parseUri(dataStoreUrl);
-		action(parts.protocol + "://" + parts.authority);
-	});
-}
-
-/**
- * ===============
- * OpenBIS facade
- * ===============
- * 
- * The facade provides access to the following services:
- * 
- * - ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService
- * - ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationChangingService
- * - ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.IQueryApiServer
- * - ch.systemsx.cisd.openbis.generic.shared.api.v1.IWebInformationService
- * - ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.IDssServiceRpcGeneric
- * 
- * @class
- * 
- */
-
-function openbis(openbisUrlOrNull) {
-	this._internal = new _openbisInternal(openbisUrlOrNull);
-}
-
-/**
- * ==================================================================================
- * ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService methods
- * ==================================================================================
- */
-
-/**
- * Log into openBIS.
- * 
- * @see IGeneralInformationService.tryToAuthenticateForAllServices(String, String)
- * @method
- */
-openbis.prototype.login = function(userId, userPassword, action) {
-	var openbisObj = this
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "tryToAuthenticateForAllServices",
-				"params" : [ userId, userPassword ] 
-				},
-		success: 
-			function(loginResponse) {
-				if(loginResponse.error){
-					alert("Login failed");
-				}else{
-					openbisObj._internal.sessionToken = loginResponse.result;
-					openbisObj.rememberSession();
-				}
-				openbisObj._internal.initDataStores(function(){
-					action(loginResponse);	
-				});
-			}
-	 });
-}
-
-/**
- * Stores the current session in a cookie. 
- *
- * @method
- */
-openbis.prototype.rememberSession = function() {
-	this._internal.createCookie('openbis', this.getSession(), 1);
-}
-
-/**
- * Removes the current session from a cookie. 
- *
- * @method
- */
-openbis.prototype.forgetSession = function() {
-	this._internal.eraseCookie('openbis');
-}
-
-/**
- * Restores the current session from a cookie.
- *
- * @method
- */
-openbis.prototype.restoreSession = function() {
-	this._internal.sessionToken = this._internal.readCookie('openbis');
-}
-
-/**
- * Sets the current session.
- *
- * @method
- */
-openbis.prototype.useSession = function(sessionToken){
-	this._internal.sessionToken = sessionToken;
-}
-
-/**
- * Returns the current session.
- * 
- * @method
- */
-openbis.prototype.getSession = function(){
-	return this._internal.sessionToken;
-}
-
-/**
- * Checks whether the current session is still active.
- *
- * @see IGeneralInformationService.isSessionActive(String)
- * @method
- */
-openbis.prototype.isSessionActive = function(action) {
-	if(this.getSession()){
-		this._internal.ajaxRequest({
-			url: this._internal.generalInfoServiceUrl,
-			data: { "method" : "isSessionActive",
-					"params" : [ this.getSession() ] 
-					},
-			success: action
-		});
-	}else{
-		action({ result : false })
-	}
-}
-
-/**
- * Restores the current session from a cookie and executes 
- * the specified action if the session is still active.
- * 
- * @see restoreSession()
- * @see isSessionActive()
- * @method
- */
-openbis.prototype.ifRestoredSessionActive = function(action) {
-	this.restoreSession();
-	this.isSessionActive(function(data) { if (data.result) action(data) });
-}
-
-/**
- * Log out of openBIS.
- * 
- * @see IGeneralInformationService.logout(String)
- * @method
- */
-openbis.prototype.logout = function(action) {
-	this.forgetSession();
-	
-	if(this.getSession()){
-		this._internal.ajaxRequest({
-			url: this._internal.generalInfoServiceUrl,
-			data: { "method" : "logout",
-					"params" : [ this.getSession() ] 
-				  },
-			success: action
-		});
-	}else if(action){
-		action({ result : null });
-	}
-}
-
-/**
- * @see IGeneralInformationService.listNamedRoleSets(String)
- * @method
- */
-openbis.prototype.listNamedRoleSets = function(action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listNamedRoleSets",
-				"params" : [ this.getSession() ] 
-			  },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listSpacesWithProjectsAndRoleAssignments(String, String)
- * @method
- */
-openbis.prototype.listSpacesWithProjectsAndRoleAssignments = function(databaseInstanceCodeOrNull, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listSpacesWithProjectsAndRoleAssignments",
-				"params" : [ this.getSession(),  databaseInstanceCodeOrNull ] 
-			  },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.searchForSamples(String, SearchCriteria)
- * @method
- */
-openbis.prototype.searchForSamples = function(searchCriteria, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "searchForSamples",
-				"params" : [ this.getSession(),
-							 searchCriteria ] },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.searchForSamples(String, SearchCriteria, EnumSet<SampleFetchOption>)
- * @method
- */
-openbis.prototype.searchForSamplesWithFetchOptions = function(searchCriteria, fetchOptions, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { 
-				"method" : "searchForSamples",
-				"params" : [ 
-					this.getSession(),
-					searchCriteria,
-					fetchOptions ] 
-		},
-		success: action
-	 });
-}
-
-/**
- * @see IGeneralInformationService.searchForSamplesOnBehalfOfUser(String, SearchCriteria, EnumSet<SampleFetchOption>, String)
- * @method
- */
-openbis.prototype.searchForSamplesOnBehalfOfUser = function(searchCriteria, fetchOptions, userId, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { 
-				"method" : "searchForSamplesOnBehalfOfUser",
-				"params" : [ 
-					this.getSession(),
-					searchCriteria,
-					fetchOptions,
-					userId ] 
-		},
-		success: action
-	 });
-}
-
-/**
- * @see IGeneralInformationService.filterSamplesVisibleToUser(String, List<Sample>, String)
- * @method
- */
-openbis.prototype.filterSamplesVisibleToUser = function(allSamples, userId, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { 
-				"method" : "filterSamplesVisibleToUser",
-				"params" : [ 
-					this.getSession(),
-					allSamples,
-					userId ] 
-		},
-		success: action
-	 });
-}
-
-/**
- * @see IGeneralInformationService.listSamplesForExperiment(String, String)
- * @method
- */
-openbis.prototype.listSamplesForExperiment = function(experimentIdentifier, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listSamplesForExperiment",
-				"params" : [ this.getSession(), experimentIdentifier ] 
-		},
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listSamplesForExperimentOnBehalfOfUser(String, String, String)
- * @method
- */
-openbis.prototype.listSamplesForExperimentOnBehalfOfUser = function(experimentIdentifier, userId, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listSamplesForExperimentOnBehalfOfUser",
-				"params" : [ this.getSession(), experimentIdentifier, userId ] 
-		},
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listDataSets(String, List<Sample>)
- * @method
- */
-openbis.prototype.listDataSetsForSamples = function(samples, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listDataSets",
-				"params" : [ this.getSession(), samples ] 
-		},
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listExperiments(String, List<Project>, String)
- * @method
- */
-openbis.prototype.listExperiments = function(projects, experimentType, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listExperiments",
-				"params" : [ this.getSession(), projects, experimentType ] 
-			  },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listExperimentsHavingSamples(String, List<Project>, String)
- * @method
- */
-openbis.prototype.listExperimentsHavingSamples = function(projects, experimentType, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listExperimentsHavingSamples",
-				"params" : [ this.getSession(), projects, experimentType ] 
-			  },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listExperimentsHavingDataSets(String, List<Project>, String)
- * @method
- */
-openbis.prototype.listExperimentsHavingDataSets = function(projects, experimentType, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listExperimentsHavingDataSets",
-				"params" : [ this.getSession(), projects, experimentType ] 
-			  },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.filterExperimentsVisibleToUser(String, List<Experiment>, String)
- * @method
- */
-openbis.prototype.filterExperimentsVisibleToUser = function(allExperiments, userId, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "filterExperimentsVisibleToUser",
-				"params" : [ this.getSession(), allExperiments, userId ] 
-			  },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listDataSetsForSample(String, Sample, boolean)
- * @method
- */
-openbis.prototype.listDataSetsForSample = function(sample, restrictToDirectlyConnected, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listDataSetsForSample",
-				"params" : [ this.getSession(), sample, restrictToDirectlyConnected ] 
-		},
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listDataStores(String)
- * @method
- */
-openbis.prototype.listDataStores = function(action) {
-	this._internal.listDataStores(action);
-}
-
-/**
- * @see IGeneralInformationService.getDefaultPutDataStoreBaseURL(String)
- * @method
- */
-openbis.prototype.getDefaultPutDataStoreBaseURL = function(action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "getDefaultPutDataStoreBaseURL",
-				"params" : [ this.getSession() ] 
-		},
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.tryGetDataStoreBaseURL(String)
- * @method
- */
-openbis.prototype.tryGetDataStoreBaseURL = function(dataSetCode, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "tryGetDataStoreBaseURL",
-				"params" : [ this.getSession(), dataSetCode ] 
-		},
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.getDataStoreBaseURLs(String, List<String>)
- * @method
- */
-openbis.prototype.getDataStoreBaseURLs = function(dataSetCodes, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "getDataStoreBaseURLs",
-				"params" : [ this.getSession(), dataSetCodes ] 
-		},
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listDataSetTypes(String)
- * @method
- */
-openbis.prototype.listDataSetTypes = function(action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listDataSetTypes",
-				"params" : [ this.getSession() ] 
-		},
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listSampleTypes(String)
- * @method
- */
-openbis.prototype.listSampleTypes = function(action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listSampleTypes",
-				"params" : [ this.getSession() ] 
-		},
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listExperimentTypes(String)
- * @method
- */
-openbis.prototype.listExperimentTypes = function(action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listExperimentTypes",
-				"params" : [ this.getSession() ] 
-		},
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listVocabularies(String)
- * @method
- */
-openbis.prototype.listVocabularies = function(action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listVocabularies",
-				"params" : [ this.getSession() ] 
-		},
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listDataSets(String, List<Sample>, EnumSet<Connections>)
- * @method
- */
-openbis.prototype.listDataSetsForSamplesWithConnections = function(samples, connectionsToGet, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listDataSets",
-				"params" : [ this.getSession(), samples, connectionsToGet ] 
-		},
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listDataSetsOnBehalfOfUser(String, List<Sample>, EnumSet<Connections>, String)
- * @method
- */
-openbis.prototype.listDataSetsForSamplesOnBehalfOfUser = function(samples, connectionsToGet, userId, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listDataSetsOnBehalfOfUser",
-				"params" : [ this.getSession(), samples, connectionsToGet, userId ] 
-		},
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listDataSetsForExperiments(String, List<Experiment>, EnumSet<Connections>)
- * @method
- */
-openbis.prototype.listDataSetsForExperiments = function(experiments, connectionsToGet, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listDataSetsForExperiments",
-				"params" : [ this.getSession(), experiments, connectionsToGet ] 
-		},
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listDataSetsForExperimentsOnBehalfOfUser(String, List<Experiment>, EnumSet<Connections>, String)
- * @method
- */
-openbis.prototype.listDataSetsForExperimentsOnBehalfOfUser = function(experiments, connectionsToGet, userId, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listDataSetsForExperimentsOnBehalfOfUser",
-				"params" : [ this.getSession(), experiments, connectionsToGet, userId ] 
-		},
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.getDataSetMetaData(String, List<String>)
- * @method
- */
-openbis.prototype.getDataSetMetaData = function(dataSetCodes, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "getDataSetMetaData",
-				"params" : [ this.getSession(), dataSetCodes ] 
-		},
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.getDataSetMetaData(String, List<String>, EnumSet<DataSetFetchOption>)
- * @method
- */
-openbis.prototype.getDataSetMetaDataWithFetchOptions = function(dataSetCodes, fetchOptions, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "getDataSetMetaData",
-				"params" : [ this.getSession(), dataSetCodes, fetchOptions ] 
-		},
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.searchForDataSets(String, SearchCriteria)
- * @method
- */
-openbis.prototype.searchForDataSets = function(searchCriteria, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "searchForDataSets",
-				"params" : [ this.getSession(),
-							 searchCriteria ] },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.searchForDataSetsOnBehalfOfUser(String, SearchCriteria, String)
- * @method
- */
-openbis.prototype.searchForDataSetsOnBehalfOfUser = function(searchCriteria, userId, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "searchForDataSetsOnBehalfOfUser",
-				"params" : [ this.getSession(),
-							 searchCriteria,
-							 userId ] },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.filterDataSetsVisibleToUser(String, List<DataSet>, String)
- * @method
- */
-openbis.prototype.filterDataSetsVisibleToUser = function(allDataSets, userId, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "filterDataSetsVisibleToUser",
-				"params" : [ this.getSession(),
-				             allDataSets,
-							 userId ] },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listExperiments(String, List<String>)
- * @method
- */
-openbis.prototype.listExperimentsForIdentifiers = function(experimentIdentifiers, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listExperiments",
-				"params" : [ this.getSession(),
-				             experimentIdentifiers ] },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.searchForExperiments(String, SearchCriteria)
- * @method
- */
-openbis.prototype.searchForExperiments = function(searchCriteria, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "searchForExperiments",
-				"params" : [ this.getSession(),
-				             searchCriteria ] },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listProjects(String)
- * @method
- */
-openbis.prototype.listProjects = function(action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listProjects",
-				"params" : [ this.getSession() ] 
-			  },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listProjectsOnBehalfOfUser(String, String)
- * @method
- */
-openbis.prototype.listProjectsOnBehalfOfUser = function(userId, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listProjectsOnBehalfOfUser",
-				"params" : [ this.getSession(), userId ] 
-			  },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.getMaterialByCodes(String, List<MaterialIdentifier>)
- * @method
- */
-openbis.prototype.getMaterialByCodes = function(materialIdentifiers, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "getMaterialByCodes",
-				"params" : [ this.getSession(), materialIdentifiers ] 
-			  },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.searchForMaterials(String, SearchCriteria)
- * @method
- */
-openbis.prototype.searchForMaterials = function(searchCriteria, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "searchForMaterials",
-				"params" : [ this.getSession(), searchCriteria ] 
-			  },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listMetaprojects(String)
- * @method
- */
-openbis.prototype.listMetaprojects = function(action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listMetaprojects",
-				"params" : [ this.getSession() ] 
-			  },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listMetaprojectsOnBehalfOfUser(String, String)
- * @method
- */
-openbis.prototype.listMetaprojectsOnBehalfOfUser = function(userId, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listMetaprojectsOnBehalfOfUser",
-				"params" : [ this.getSession(), userId ] 
-			  },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.getMetaproject(String, IMetaprojectId)
- * @method
- */
-openbis.prototype.getMetaproject = function(metaprojectId, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "getMetaproject",
-				"params" : [ this.getSession(), metaprojectId ] 
-			  },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.getMetaprojectOnBehalfOfUser(String, IMetaprojectId, String)
- * @method
- */
-openbis.prototype.getMetaprojectOnBehalfOfUser = function(metaprojectId, userId, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "getMetaprojectOnBehalfOfUser",
-				"params" : [ this.getSession(), metaprojectId, userId ] 
-			  },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listAttachmentsForProject(String, IProjectId, boolean)
- * @method
- */
-openbis.prototype.listAttachmentsForProject = function(projectId, allVersions, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listAttachmentsForProject",
-				"params" : [ this.getSession(), projectId, allVersions ] 
-			  },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listAttachmentsForExperiment(String, IExperimentId, boolean)
- * @method
- */
-openbis.prototype.listAttachmentsForExperiment = function(experimentId, allVersions, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listAttachmentsForExperiment",
-				"params" : [ this.getSession(), experimentId, allVersions ] 
-			  },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationService.listAttachmentsForSample(String, ISampleId, boolean)
- * @method
- */
-openbis.prototype.listAttachmentsForSample = function(sampleId, allVersions, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "listAttachmentsForSample",
-				"params" : [ this.getSession(), sampleId, allVersions ] 
-			  },
-		success: action
-	});
-}
-
-
-/**
- * @see GeneralInformationService.getUserDisplaySettings(String)
- * @method
- */
-openbis.prototype.getUserDisplaySettings = function(action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoServiceUrl,
-		data: { "method" : "getUserDisplaySettings",
-				"params" : [ this.getSession()] },
-		success: action
-	});
-}
-
-/**
- * ==========================================================================================
- * ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationChangingService methods
- * ==========================================================================================
- */
-
-/**
- * @see IGeneralInformationChangingService.updateSampleProperties(String, long, Map<String,String>)
- * @method
- */
-openbis.prototype.updateSampleProperties = function(sampleId, properties, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoChangingServiceUrl,
-		data: { "method" : "updateSampleProperties",
-				"params" : [ this.getSession(), sampleId, properties ] 
-			  },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationChangingService.addUnofficialVocabularyTerm(String, Long, NewVocabularyTerm)
- * @method
- */
-openbis.prototype.addUnofficialVocabularyTerm = function(vocabularyId, term, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoChangingServiceUrl,
-		data: { "method" : "addUnofficialVocabularyTerm",
-				"params" : [ this.getSession(), vocabularyId, term ] 
-			  },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationChangingService.getWebAppSettings(String, String)
- * @method
- */
-openbis.prototype.getWebAppSettings = function(webappId, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoChangingServiceUrl,
-		data: { "method" : "getWebAppSettings",
-		params : [ this.getSession(), webappId ] },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationChangingService.setWebAppSettings(String, WebAppSettings)
- * @method
- */
-openbis.prototype.setWebAppSettings = function(webappSettings, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoChangingServiceUrl,
-		data: { "method" : "setWebAppSettings",
-		params : [ this.getSession(), webappSettings ] },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationChangingService.createMetaproject(String, String, String)
- * @method
- */
-openbis.prototype.createMetaproject = function(name, descriptionOrNull, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoChangingServiceUrl,
-		data: { "method" : "createMetaproject",
-		params : [ this.getSession(), name, descriptionOrNull ] },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationChangingService.updateMetaproject(String, IMetaprojectId, String, String)
- * @method
- */
-openbis.prototype.updateMetaproject = function(metaprojectId, name, descriptionOrNull, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoChangingServiceUrl,
-		data: { "method" : "updateMetaproject",
-		params : [ this.getSession(), metaprojectId, name, descriptionOrNull ] },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationChangingService.deleteMetaproject(String, IMetaprojectId)
- * @method
- */
-openbis.prototype.deleteMetaproject = function(metaprojectId, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoChangingServiceUrl,
-		data: { "method" : "deleteMetaproject",
-		params : [ this.getSession(), metaprojectId ] },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationChangingService.addToMetaproject(String, IMetaprojectId, MetaprojectAssignmentsIds)
- * @method
- */
-openbis.prototype.addToMetaproject = function(metaprojectId, assignmentsToAdd, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoChangingServiceUrl,
-		data: { "method" : "addToMetaproject",
-		params : [ this.getSession(), metaprojectId, assignmentsToAdd ] },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationChangingService.removeFromMetaproject(String, IMetaprojectId, MetaprojectAssignmentsIds)
- * @method
- */
-openbis.prototype.removeFromMetaproject = function(metaprojectId, assignmentsToRemove, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoChangingServiceUrl,
-		data: { "method" : "removeFromMetaproject",
-		params : [ this.getSession(), metaprojectId, assignmentsToRemove ] },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationChangingService.registerSamples(String, String, String, String)
- * @method
- */
-openbis.prototype.registerSamples = function(sampleTypeCode, sessionKey, defaultGroupIdentifier, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoChangingServiceUrl,
-		data: { "method" : "registerSamples",
-				"params" : [ this.getSession(),
-							 sampleTypeCode,
-							 sessionKey,
-							 defaultGroupIdentifier] },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationChangingService.registerSamples(String, String, String, String)
- * @method
- */
-openbis.prototype.updateSamples = function(sampleTypeCode, sessionKey, defaultGroupIdentifier, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoChangingServiceUrl,
-		data: { "method" : "updateSamples",
-				"params" : [ this.getSession(),
-							 sampleTypeCode,
-							 sessionKey,
-							 defaultGroupIdentifier] },
-		success: action
-	});
-}
-
-/**
- * @see IGeneralInformationChangingService.registerSamples(String, String, String)
- * @method
- */
-openbis.prototype.uploadedSamplesInfo = function(sampleTypeCode, sessionKey, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.generalInfoChangingServiceUrl,
-		data: { "method" : "uploadedSamplesInfo",
-				"params" : [ this.getSession(),
-							 sampleTypeCode,
-							 sessionKey] },
-		success: action
-	});
-}
-
-/**
- * ============================================================================
- * ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.IQueryApiServer methods
- * ============================================================================
- */
-
-/**
- * @see IQueryApiServer.listQueries(String)
- * @method
- */
-openbis.prototype.listQueries = function(action) {
-	this._internal.ajaxRequest({
-		url: this._internal.queryServiceUrl,
-		data: { "method" : "listQueries",
-				"params" : [ this.getSession() ] },
-		success: action
-	});
-}
-
-/**
- * @see IQueryApiServer.executeQuery(String, long, Map<String, String>)
- * @method
- */
-openbis.prototype.executeQuery = function(queryId, parameterBindings, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.queryServiceUrl,
-		data: { "method" : "executeQuery",
-				"params" : [ this.getSession(), queryId, parameterBindings ] },
-		success: action
-	});
-}
-
-/**
- * @see IQueryApiServer.listTableReportDescriptions(String)
- * @method
- */
-openbis.prototype.listTableReportDescriptions = function(action) {
-	this._internal.ajaxRequest({
-		url: this._internal.queryServiceUrl,
-		data: { "method" : "listTableReportDescriptions",
-				"params" : [ this.getSession() ] },
-		success: action
-	});
-}
-
-/**
- * @see IQueryApiServer.createReportFromDataSets(String, String, String, List<String>)
- * @method
- */
-openbis.prototype.createReportFromDataSets = function(dataStoreCode, serviceKey, dataSetCodes, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.queryServiceUrl,
-		data: { "method" : "createReportFromDataSets",
-		params : [ this.getSession(), dataStoreCode, serviceKey, dataSetCodes ] },
-		success: action
-	});
-}
-
-/**
- * @see IQueryApiServer.listAggregationServices(String)
- * @method
- */
-openbis.prototype.listAggregationServices = function(action) {
-	this._internal.ajaxRequest({
-		url: this._internal.queryServiceUrl,
-		data: { "method" : "listAggregationServices",
-		params : [ this.getSession() ] },
-		success: action
-	});
-}
-
-/**
- * @see IQueryApiServer.createReportFromAggregationService(String, String, String, Map<String, Object>)
- * @method
- */
-openbis.prototype.createReportFromAggregationService = function(dataStoreCode, serviceKey, parameters, action) {
-	this._internal.ajaxRequest({
-		url: this._internal.queryServiceUrl,
-		data: { "method" : "createReportFromAggregationService",
-		params : [ this.getSession(), dataStoreCode, serviceKey, parameters ] },
-		success: action
-	});
-}
-
-
-/**
- * ==============================================================================
- * ch.systemsx.cisd.openbis.generic.shared.api.v1.IWebInformationService methods
- * ==============================================================================
- */
-
-/**
- * Returns the current server side session.
- * 
- * @see IWebInformationService.getSessionToken()
- * @method
- */
-openbis.prototype.getSessionTokenFromServer = function(action) {
-	this._internal.ajaxRequest({
-		url: this._internal.webInfoServiceUrl,
-		data: { "method" : "getSessionToken" },
-		success: action
-	 });
-}
-
-/**
- * =================================================================================
- * ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.IDssServiceRpcGeneric methods
- * =================================================================================
- */
-
-/**
- * @see IDssServiceRpcGeneric.listFilesForDataSet(String, DataSetFileDTO)
- * @method
- */
-openbis.prototype.listFilesForDataSetFile = function(fileOrFolder, action) {
-	var openbisObj = this;
-	this._internal.getDataStoreApiUrlForDataSetCode(fileOrFolder.dataSetCode, function(dataStoreApiUrl){
-		openbisObj._internal.ajaxRequest({
-			url: dataStoreApiUrl,
-			data: { "method" : "listFilesForDataSet",
-					"params" : [ openbisObj.getSession(), fileOrFolder ] },
-			success: action
-		});
-	});
-}
-
-/**
- * @see IDssServiceRpcGeneric.getDownloadUrlForFileForDataSet(String, DataSetFileDTO)
- * @method
- */
-openbis.prototype.getDownloadUrlForFileForDataSetFile = function(fileOrFolder, action) {
-	var openbisObj = this;
-	this._internal.getDataStoreApiUrlForDataSetCode(fileOrFolder.dataSetCode, function(dataStoreApiUrl){
-		openbisObj._internal.ajaxRequest({
-			url: dataStoreApiUrl,
-			data: { "method" : "getDownloadUrlForFileForDataSet",
-					"params" : [ openbisObj.getSession(), fileOrFolder ] },
-			success: action
-		});
-	});
-}
-
-/**
- * Returns a download url that is valid as long as the user session is valid.
- * @method
- */
-openbis.prototype.getDownloadUrlForFileForDataSetFileInSession = function(fileOrFolder, action) {
-	this.getDownloadUrlForFileForDataSetInSession(fileOrFolder.dataSetCode, fileOrFolder.path, action);
-}
-
-/**
- * @see IDssServiceRpcGeneric.getDownloadUrlForFileForDataSetWithTimeout(String, DataSetFileDTO, long)
- * @method
- */
-openbis.prototype.getDownloadUrlForFileForDataSetFileWithTimeout = function(fileOrFolder, validityDurationInSeconds, action) {
-	var openbisObj = this;
-	this._internal.getDataStoreApiUrlForDataSetCode(fileOrFolder.dataSetCode, function(dataStoreApiUrl){
-		openbisObj._internal.ajaxRequest({
-			url: dataStoreApiUrl,
-			data: { "method" : "getDownloadUrlForFileForDataSetWithTimeout",
-					"params" : [ openbisObj.getSession(), fileOrFolder, validityDurationInSeconds ] },
-			success: action
-		});
-	});
-}
-
-/**
- * @see IDssServiceRpcGeneric.listFilesForDataSet(String, String, String, boolean)
- * @method
- */
-openbis.prototype.listFilesForDataSet = function(dataSetCode, path, recursive, action) {
-	var openbisObj = this;
-	this._internal.getDataStoreApiUrlForDataSetCode(dataSetCode, function(dataStoreApiUrl){
-		openbisObj._internal.ajaxRequest({
-			url: dataStoreApiUrl,
-			data: { "method" : "listFilesForDataSet",
-					"params" : [ openbisObj.getSession(), dataSetCode, path, recursive ] },
-			success: action
-		});
-	});
-}
-
-/**
- * @see IDssServiceRpcGeneric.getDownloadUrlForFileForDataSet(String, String, String)
- * @method
- */
-openbis.prototype.getDownloadUrlForFileForDataSet = function(dataSetCode, path, action) {
-	var openbisObj = this;
-	this._internal.getDataStoreApiUrlForDataSetCode(dataSetCode, function(dataStoreApiUrl){
-		openbisObj._internal.ajaxRequest({
-			url: dataStoreApiUrl,
-			data: { "method" : "getDownloadUrlForFileForDataSet",
-					"params" : [ openbisObj.getSession(), dataSetCode, path ] },
-			success: action
-		});
-	});
-}
-
-/**
- * Returns a download url that is valid as long as the user session is valid.
- * @method
- */
-openbis.prototype.getDownloadUrlForFileForDataSetInSession = function(dataSetCode, path, action) {
-	var openbisObj = this;
-	this._internal.getDataStoreUrlForDataSetCode(dataSetCode, function(dataStoreUrl){
-		var pathWithoutSlash = path.charAt(0) == "/" ? path.substr(1) : path;
-		var url = dataStoreUrl + "/" + dataSetCode + "/" + pathWithoutSlash + "?sessionID=" + openbisObj.getSession();
-		action(url);
-	});
-}
-
-/**
- * @see IDssServiceRpcGeneric.getDownloadUrlForFileForDataSetWithTimeout(String, String, String, long)
- * @method
- */
-openbis.prototype.getDownloadUrlForFileForDataSetWithTimeout = function(dataSetCode, path, validityDurationInSeconds, action) {
-	var openbisObj = this;
-	this._internal.getDataStoreApiUrlForDataSetCode(dataSetCode, function(dataStoreApiUrl){
-		openbisObj._internal.ajaxRequest({
-			url: dataStoreApiUrl,
-			data: { "method" : "getDownloadUrlForFileForDataSetWithTimeout",
-					"params" : [ openbisObj.getSession(), dataSetCode, path, validityDurationInSeconds ] },
-			success: action
-		});
-	});
-}
-
-/**
- * Creates a session workspace file uploader inside the specified uploaderContainer element and for the default data store.
- * @method
- */
-openbis.prototype.createSessionWorkspaceUploader = function(uploaderContainer, oncomplete, uploaderSettings){
-	this.createSessionWorkspaceUploaderForDataStore(uploaderContainer, null, oncomplete, uploaderSettings);
-}
-
-/**
- * Creates a session workspace file uploader inside the specified uploaderContainer element and for the specified data store.
- * @method
- */
-openbis.prototype.createSessionWorkspaceUploaderForDataStore = function(uploaderContainer, dataStoreCodeOrNull, oncomplete, uploaderSettings){
-	var uploaderSupported = window.File && window.FileReader && window.XMLHttpRequest;
-
-	if(!uploaderSupported){
-		alert("Uploader is not supported by your browser.");
-		return;
-	}
-	
-	var $this = this;
-	this._internal.getDataStoreUrlForDataStoreCode(dataStoreCodeOrNull, function(dataStoreUrl){
-		// figure out what is the location of the openbis.js script and assume that uploader resources are served by the same server
-		var openbisScriptLocation = $('script[src*=openbis\\.js]').attr('src');
-		var uploaderDirectoryLocation = jsFileLocation = openbisScriptLocation.replace(/js\/openbis\.js/g, 'uploader');
-		
-		$('head').append('<link rel="stylesheet" media="screen" type="text/css" href="' + uploaderDirectoryLocation + '/css/src/upload.css" />');
-		$('head').append('<script charset="utf-8" type="text/javascript" src="' + uploaderDirectoryLocation + '/js/src/upload.js" />');
-		
-		$(uploaderContainer).load(uploaderDirectoryLocation + "/index.html", function(){
-			var finalSettings = {
-				       smart_mode: true,
-				       chunk_size: 1000*1024,
-				       file_upload_url: dataStoreUrl + "/session_workspace_file_upload",
-				       form_upload_url: dataStoreUrl + "/session_workspace_form_upload",
-				       file_download_url: dataStoreUrl + "/session_workspace_file_download",
-				       oncomplete: oncomplete,
-				       sessionID: $this.getSession()
-			};
-			
-			if(uploaderSettings) {
-				for(var key in uploaderSettings) {
-					finalSettings[key] = uploaderSettings[key];
-				}
-			}
-			
-			Uploader.init(finalSettings);
-		});
-	});
-}
-
-/**
- * Creates a session workspace download url for a file with the specified filePath and for the default data store.
- * @method
- */
-openbis.prototype.createSessionWorkspaceDownloadUrl = function(filePath, action){
-	return this.createSessionWorkspaceDownloadUrlForDataStore(filePath, null, action);
-}
-
-/**
- * Creates a session workspace download url for a file with the specified filePath and for the specified data store.
- * @method
- */
-openbis.prototype.createSessionWorkspaceDownloadUrlForDataStore = function(filePath, dataStoreCodeOrNull, action){
-	var openbisObj = this;
-	
-	this._internal.getDataStoreUrlForDataStoreCode(dataStoreCodeOrNull, function(dataStoreUrl){
-		var downloadUrl = dataStoreUrl + "/session_workspace_file_download?sessionID=" + openbisObj.getSession() + "&filePath=" + filePath;
-		action(downloadUrl);
-	});
-}
-
-/**
- * Create a session workspace download link for a file with the specified filePath at the default data store.
- * @method
- */
-openbis.prototype.createSessionWorkspaceDownloadLink = function(filePath, linkText, action){
-	return this.createSessionWorkspaceDownloadLinkForDataStore(filePath, linkText, null, action);
-}
-
-/**
- * Create a session workspace download link for a file with the specified filePath at the specified data store.
- * @method
- */
-openbis.prototype.createSessionWorkspaceDownloadLinkForDataStore = function(filePath, linkText, dataStoreCodeOrNull, action){
-	this.createSessionWorkspaceDownloadUrlForDataStore(filePath, dataStoreCodeOrNull, function(downloadUrl){
-		var link = $("<a href='" + downloadUrl + "'>" + (linkText ? linkText : filePath) + "</a>");
-		action(link);
-	});
-}
-
-/**
- * Downloads a session workspace file with the specified filePath from the default data store.
- * @method
- */
-openbis.prototype.downloadSessionWorkspaceFile = function(filePath, action) {
-	this.downloadSessionWorkspaceFileForDataStore(filePath, null, action);
-}
-
-/**
- * Downloads a session workspace file with the specified filePath from the specified data store.
- * @method
- */
-openbis.prototype.downloadSessionWorkspaceFileForDataStore = function(filePath, dataStoreCodeOrNull, action) {
-	var openbisObj = this;
-	
-	this.createSessionWorkspaceDownloadUrlForDataStore(filePath, dataStoreCodeOrNull, function(downloadUrl){
-		$.ajax({
-			type: "GET",
-			dataType: "text",
-			url: downloadUrl,
-			success: openbisObj._internal.ajaxRequestSuccess(action),
-			error: openbisObj._internal.ajaxRequestError(action)
-		});
-	});
-}
-
-/**
- * Deletes a session workspace file with the specified filePath from the default data store.
- * @method
- */
-openbis.prototype.deleteSessionWorkspaceFile = function(filePath, action) {
-	this.deleteSessionWorkspaceFileForDataStore(filePath, null, action)
-}
-
-/**
- * Deletes a session workspace file with the specified filePath from the specified data store.
- * @method
- */
-openbis.prototype.deleteSessionWorkspaceFileForDataStore = function(filePath, dataStoreCodeOrNull, action) {
-	var openbisObj = this;
-	
-	this._internal.getDataStoreApiUrlForDataStoreCode(dataStoreCodeOrNull, function(dataStoreApiUrl){
-		openbisObj._internal.ajaxRequest({
-			url: dataStoreApiUrl,
-			data: {
-				"method" : "deleteSessionWorkspaceFile",
-				"params" : [ openbisObj.getSession(), filePath ]
-			},
-			success: action
-		});
-	});
-}
-
-/**
- * @see IDssServiceRpcGeneric.getPathToDataSet(String, String, String)
- * @method
- */
-openbis.prototype.getPathToDataSet = function(dataSetCode, overrideStoreRootPathOrNull, action) {
-	var openbisObj = this;
-	this._internal.getDataStoreApiUrlForDataSetCode(dataSetCode, function(dataStoreApiUrl){
-		openbisObj._internal.ajaxRequest({
-			url: dataStoreApiUrl,
-			data: { "method" : "getPathToDataSet",
-					"params" : [ openbisObj.getSession(), dataSetCode, overrideStoreRootPathOrNull ] },
-			success: action
-		});
-	});
-}
-
-/**
- * @see IDssServiceRpcGeneric.tryGetPathToDataSet(String, String, String)
- * @method
- */
-openbis.prototype.tryGetPathToDataSet = function(dataSetCode, overrideStoreRootPathOrNull, action) {
-	var openbisObj = this;
-	this._internal.getDataStoreApiUrlForDataSetCode(dataSetCode, function(dataStoreApiUrl){
-		openbisObj._internal.ajaxRequest({
-			url: dataStoreApiUrl,
-			data: { "method" : "tryGetPathToDataSet",
-					"params" : [ openbisObj.getSession(), dataSetCode, overrideStoreRootPathOrNull ] },
-			success: action
-		});
-	});
-}
-
-/**
- * List shares from the default data store.
- * 
- * @see IDssServiceRpcGeneric.listAllShares(String)
- * @method
- */
-openbis.prototype.listAllShares = function(action) {
-	this.listAllSharesForDataStore(null, action);
-}
-
-/**
- * List shares from the specified data store.
- * 
- * @see IDssServiceRpcGeneric.listAllShares(String)
- * @method
- */
-openbis.prototype.listAllSharesForDataStore = function(dataStoreCodeOrNull, action) {
-	var openbisObj = this;
-	
-	this._internal.getDataStoreApiUrlForDataStoreCode(dataStoreCodeOrNull, function(dataStoreApiUrl){
-		openbisObj._internal.ajaxRequest({
-			url: dataStoreApiUrl,
-			data: {
-				"method" : "listAllShares",
-				"params" : [ openbisObj.getSession() ]
-			},
-			success: action
-		});
-	});
-}
-
-/**
- * @see IDssServiceRpcGeneric.shuffleDataSet(String, String, String)
- * @method
- */
-openbis.prototype.shuffleDataSet = function(dataSetCode, shareId, action) {
-	var openbisObj = this;
-	this._internal.getDataStoreApiUrlForDataSetCode(dataSetCode, function(dataStoreApiUrl){
-		openbisObj._internal.ajaxRequest({
-			url: dataStoreApiUrl,
-			data: { "method" : "shuffleDataSet",
-					"params" : [ openbisObj.getSession(), dataSetCode, shareId ] },
-			success: action
-		});
-	});
-}
-
-/**
- * Get a validation script from the default data store.
- * 
- * @see IDssServiceRpcGeneric.getValidationScript(String, String)
- * @method
- */
-openbis.prototype.getValidationScript = function(dataSetTypeOrNull, action) {
-	this.getValidationScriptForDataStore(dataSetTypeOrNull, null, action);
-}
-
-/**
- * Get a validation script from the specified data store.
- * 
- * @see IDssServiceRpcGeneric.getValidationScript(String, String)
- * @method
- */
-openbis.prototype.getValidationScriptForDataStore = function(dataSetTypeOrNull, dataStoreCodeOrNull, action) {
-	var openbisObj = this;
-	
-	this._internal.getDataStoreApiUrlForDataStoreCode(dataStoreCodeOrNull, function(dataStoreApiUrl){
-		openbisObj._internal.ajaxRequest({
-			url: dataStoreApiUrl,
-			data: {
-				"method" : "getValidationScript",
-				"params" : [ openbisObj.getSession(), dataSetTypeOrNull ]
-			},
-			success: action
-		});
-	});
-}
-
-/**
- * Get a url that will produce a graph with the given configuration at the default data store.
- *
- * @method
- */
-openbis.prototype.getGraphUrl = function(graphConfig, action) {
-	this.getGraphUrlForDataStore(graphConfig, null, action);
-}
-
-/**
- * Get a url that will produce a graph with the given configuration at the specified data store.
- *
- * @method
- */
-openbis.prototype.getGraphUrlForDataStore = function(graphConfig, dataStoreCodeOrNull, action) {
-	var openbisObj = this;
-	
-	this._internal.getDataStoreHostForDataStoreCode(dataStoreCodeOrNull, function(dataStoreHost) {
-		var graphUrl = dataStoreHost + "/graphservice/?sessionID=" + openbisObj.getSession();
-		for (prop in graphConfig) {
-			graphUrl += "&" + prop + "=" + encodeURIComponent(graphConfig[prop]);
-		}
-		action(graphUrl);
-	});
-}
-
-/**
- * =====================
- * OpenBIS graph config
- * =====================
- * 
- * Defines the configuration for a graph generated by the server's graphservice.
- * 
- * To use, set properties on the object with keys that match the name of the servlet
- * parameters of the graphservice and then call the method getGraphUrl on the openbis
- * object. Do *not* set the sessionID paramter -- this will be filled in by the openbis 
- * object.
- *
- * The graphservice is documented here: https://wiki-bsse.ethz.ch/display/openBISDoc/Configuring+Graphs+and+Plots
- * 
- * @class
- * 
- */
-function openbisGraphConfig(filename, graphtype, title) {
-	this.file = filename;
-	this["graph-type"] =  graphtype;
-	this.title = title;
-}
-
-
-/**
- * =====================================================
- * OpenBIS webapp context internal code (DO NOT USE!!!)
- * =====================================================
- */
-
-function _openbisWebAppContextInternal(){
-	this.webappCode = this.getParameter("webapp-code");
-	this.sessionId = this.getParameter("session-id");
-	this.entityKind = this.getParameter("entity-kind");
-	this.entityType = this.getParameter("entity-type");
-	this.entityIdentifier = this.getParameter("entity-identifier");
-	this.entityPermId = this.getParameter("entity-perm-id");
-}
-
-_openbisWebAppContextInternal.prototype.getParameter = function(parameterName){
-	var match = location.search.match(RegExp("[?|&]"+parameterName+'=(.+?)(&|$)'));
-	if(match && match[1]){
-		return decodeURIComponent(match[1].replace(/\+/g,' '));
-	}else{
-		return null;
-	}
-}
-
-/**
- * =======================
- * OpenBIS webapp context 
- * =======================
- * 
- * Provides a context information for webapps that are embedded inside the OpenBIS UI.
- * 
- * @class
- * 
- */
-function openbisWebAppContext(){
-	this._internal = new _openbisWebAppContextInternal();
-}
-
-openbisWebAppContext.prototype.getWebappCode = function(){
-	return this._internal.webappCode;
-}
-
-openbisWebAppContext.prototype.getSessionId = function(){
-	return this._internal.sessionId;
-}
-
-openbisWebAppContext.prototype.getEntityKind = function(){
-	return this._internal.entityKind;
-}
-
-openbisWebAppContext.prototype.getEntityType = function(){
-	return this._internal.entityType;
-}
-
-openbisWebAppContext.prototype.getEntityIdentifier = function(){
-	return this._internal.entityIdentifier;
-}
-
-openbisWebAppContext.prototype.getEntityPermId = function(){
-	return this._internal.entityPermId;
-}
-
-openbisWebAppContext.prototype.getParameter = function(parameterName){
-	return this._internal.getParameter(parameterName);
-}
-
-/**
- * =======================
- * OpenBIS Search Criteria
- * =======================
- *
- * Methods and classes for constructing search criteria objects for use in searches.
- */
-
-/**
- * It is easier to construct instances of match clauses using one of the factory methods:
- *
- * 		createPropertyMatch
- * 		createAttributeMatch
- * 		createTimeAttributeMatch
- * 		createAnyPropertyMatch
- * 		createAnyFieldMatch
- *
- * @see ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClause
- * @class
- */
-function SearchCriteriaMatchClause(type, fieldType, fieldCode, desiredValue) {
-	this["@type"] = type;
-	this["fieldType"] = fieldType;
-	this["fieldCode"] = fieldCode;
-	this["desiredValue"] = desiredValue;
-	// compareMode should be one of "LESS_THAN_OR_EQUAL", "EQUALS", "GREATER_THAN_OR_EQUAL"
-	this["compareMode"] = "EQUALS";
-}
-
-/**
- * Factory method to create a match for a property.
- * 
- * @param propertyCode The code of the property to compare against
- * @param desiredValue The value used in the comparison
- * @see ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClause.createPropertyMatch(String, String)
- * @method
- */
-SearchCriteriaMatchClause.createPropertyMatch = function(propertyCode, desiredValue) {
-	var matchClause = new SearchCriteriaMatchClause("PropertyMatchClause", "PROPERTY", propertyCode, desiredValue);
-	matchClause["propertyCode"] = propertyCode;
-	return matchClause;
-}
-
-/**
- * Factory method to create a match for an attribute.
- *
- * @param attribute Should be a valid ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClauseAttribute.
- *   It should come from this list:
- *      // common
- *      "CODE", "TYPE", "PERM_ID",
- *      // for sample or experiment
- *      "SPACE",
- *      // for experiment
- *      "PROJECT",
- *      // for all types of entities
- *      "METAPROJECT"
- * @param desiredValue The value used in the comparison 
- * @see ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClause.createAttributeMatch(MatchClauseAttribute, String)
- * @method
- */
-SearchCriteriaMatchClause.createAttributeMatch = function(attribute, desiredValue) {
-	var matchClause = new SearchCriteriaMatchClause("AttributeMatchClause", "ATTRIBUTE", attribute, desiredValue);
-	matchClause["attribute"] = attribute;
-	return matchClause;
-}
-
-/**
- * Factory method to create a MatchClause matching against registration or modification
- * date.
- * 
- * @param attribute Should be a valid ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClauseTimeAttribute
- * 	It should come from this list: REGISTRATION_DATE, MODIFICATION_DATE
- *
- * @param mode One of "LESS_THAN_OR_EQUAL", "EQUALS", "GREATER_THAN_OR_EQUAL"
- * @param date The date to compare against, format YYYY-MM-DD
- * @timezone The time zone of the date ("+1", "-5", "0", etc.)
- * @see ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClause.createAttributeMatch(MatchClauseTimeAttribute, CompareMode, String, String)
- * @method
- */
-SearchCriteriaMatchClause.createTimeAttributeMatch = function(attribute, mode, date, timezone)
-{
-    var matchClause = new SearchCriteriaMatchClause("TimeAttributeMatchClause", "ATTRIBUTE", attribute, date);
-	matchClause["attribute"] = attribute;
-	matchClause["compareMode"] = mode;
-	matchClause["timeZone"] = timezone;
-	return matchClause;
-}
-
-/**
- * Factory method to create a match for against any property.
- * 
- * @param desiredValue The value used in the comparison
- * @see ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClause.createAnyPropertyMatch(String)
- * @method
- */
-SearchCriteriaMatchClause.createAnyPropertyMatch = function(desiredValue) {
-	var matchClause = new SearchCriteriaMatchClause("AnyPropertyMatchClause", "ANY_PROPERTY", null, desiredValue);
-	return matchClause;
-}
-
-/**
- * Factory method to create a match for against any field (property or attribute).
- * 
- * @param desiredValue The value used in the comparison
- * @see ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClause.createAnyFieldMatch(String)
- * @method
- */
-SearchCriteriaMatchClause.createAnyFieldMatch = function(desiredValue) {
-	var matchClause = new SearchCriteriaMatchClause("AnyFieldMatchClause", "ANY_FIELD", null, desiredValue);
-	return matchClause;
-}
-
-/**
- * @see ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria
- * @class
- */
-function SearchCriteria() {
-	this["@type"] =  "SearchCriteria";
-	// operator should be either of "MATCH_ALL_CLAUSES" or "MATCH_ANY_CLAUSES"
-	this["operator"] = "MATCH_ALL_CLAUSES";
-	this["matchClauses"] = [];
-	this["subCriterias"] = [];
-}
-
-/**
- * @see ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.addMatchClause(MatchClause)
- * @method
- */
-SearchCriteria.prototype.addMatchClause = function(matchClause) {
-	this["matchClauses"].push(matchClause);
-};
-
-/**
- * @see ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.addSubCriteria(SearchSubCriteria)
- * @method
- */
-SearchCriteria.prototype.addSubCriteria = function(subCriteria) {
-	this["subCriterias"].push(subCriteria);
-};
-
-
-/**
- * It is easier to construct instances of sub criteria using one of the factory methods:
- *
- * 		createSampleParentCriteria
- * 		createSampleChildCriteria
- * 		createSampleContainerCriteria
- * 		createSampleCriteria
- * 		createExperimentCriteria
- * 		createDataSetContainerCriteria
- * 		createDataSetParentCriteria
- * 		createDataSetChildCriteria
- *
- * @see ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchSubCriteria
- * @class
- */
-function SearchSubCriteria(targetEntityKind, searchCriteria) {
-	this["@type"] = "SearchSubCriteria";
-	this["targetEntityKind"] = targetEntityKind;	
-	this["criteria"] = searchCriteria;
-}
-
-/**
- * Factory method to create a match for a sample parent.
- * 
- * @see ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchSubCriteria.createSampleParentCriteria(SearchCriteria)
- * @method
- */
-SearchSubCriteria.createSampleParentCriteria = function(searchCriteria) {
-	return new SearchSubCriteria("SAMPLE_PARENT", searchCriteria)
-}
-
-/**
- * Factory method to create a match for a sample child.
- * 
- * @see ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchSubCriteria.createSampleChildCriteria(SearchCriteria)
- * @method
- */
-SearchSubCriteria.createSampleChildCriteria = function(searchCriteria) {
-	return new SearchSubCriteria("SAMPLE_CHILD", searchCriteria)
-}
-
-/**
- * Factory method to create a match for a sample container.
- * 
- * @see ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchSubCriteria.createSampleContainerCriteria(SearchCriteria)
- * @method
- */
-SearchSubCriteria.createSampleContainerCriteria = function(searchCriteria) {
-	return new SearchSubCriteria("SAMPLE_CONTAINER", searchCriteria)
-}
-
-/**
- * Factory method to create a match for a sample.
- * 
- * @see ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchSubCriteria.createSampleCriteria(SearchCriteria)
- * @method
- */
-SearchSubCriteria.createSampleCriteria = function(searchCriteria) {
-	return new SearchSubCriteria("SAMPLE", searchCriteria)
-}
-
-/**
- * Factory method to create a match for an experiment.
- * 
- * @see ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchSubCriteria.createExperimentCriteria(SearchCriteria)
- * @method
- */
-SearchSubCriteria.createExperimentCriteria = function(searchCriteria) {
-	return new SearchSubCriteria("EXPERIMENT", searchCriteria)
-}
-
-/**
- * Factory method to create a match for a data set container.
- * 
- * @see ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchSubCriteria.createDataSetContainerCriteria(SearchCriteria)
- * @method
- */
-SearchSubCriteria.createDataSetContainerCriteria = function(searchCriteria) {
-	return new SearchSubCriteria("DATA_SET_CONTAINER", searchCriteria)
-}
-
-/**
- * Factory method to create a match for a data set parent.
- * 
- * @see ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchSubCriteria.createDataSetParentCriteria(SearchCriteria)
- * @method
- */
-SearchSubCriteria.createDataSetParentCriteria = function(searchCriteria) {
-	return new SearchSubCriteria("DATA_SET_PARENT", searchCriteria)
-}
-
-/**
- * Factory method to create a match for a data set child.
- * 
- * @see ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchSubCriteria.createDataSetChildCriteria(SearchCriteria)
- * @method
- */
-SearchSubCriteria.createDataSetChildCriteria = function(searchCriteria) {
-	return new SearchSubCriteria("DATA_SET_CHILD", searchCriteria)
-}
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/AbstractView.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/AbstractView.js
new file mode 100644
index 0000000000000000000000000000000000000000..795a1fb9ea0abe7c07d4f758354585ef3add5a28
--- /dev/null
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/AbstractView.js
@@ -0,0 +1,29 @@
+define([ "jquery" ], function($) {
+
+	//
+	// ABSTRACT VIEW
+	//
+
+	function AbstractView(controller) {
+		this.init(controller);
+	}
+
+	$.extend(AbstractView.prototype, {
+
+		init : function(controller) {
+			this.controller = controller;
+		},
+
+		render : function() {
+			return null;
+		},
+
+		refresh : function() {
+
+		}
+
+	});
+
+	return AbstractView;
+
+});
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/AbstractWidget.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/AbstractWidget.js
new file mode 100644
index 0000000000000000000000000000000000000000..3e9c0ed87999f73986705a02ee2e1a65b9d4dc92
--- /dev/null
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/AbstractWidget.js
@@ -0,0 +1,69 @@
+define([ "jquery", "components/common/ListenerManager" ], function($, ListenerManager) {
+
+	//
+	// ABSTRACT WIDGET
+	//
+
+	function AbstractWidget(view) {
+		this.init(view);
+	}
+
+	$.extend(AbstractWidget.prototype, {
+		init : function(view) {
+			this.setView(view);
+			this.listeners = new ListenerManager();
+			this.panel = $("<div>").addClass("widget");
+		},
+
+		load : function(callback) {
+			callback();
+		},
+
+		render : function() {
+			if (this.rendered) {
+				return this.panel;
+			}
+
+			var thisWidget = this;
+
+			this.load(function() {
+				if (thisWidget.getView()) {
+					thisWidget.panel.append(thisWidget.getView().render());
+					thisWidget.rendered = true;
+				}
+			});
+
+			return this.panel;
+		},
+
+		refresh : function() {
+			if (!this.rendered) {
+				return;
+			}
+
+			if (this.getView()) {
+				this.getView().refresh();
+			}
+		},
+
+		getView : function() {
+			return this.view;
+		},
+
+		setView : function(view) {
+			this.view = view;
+			this.refresh();
+		},
+
+		addChangeListener : function(listener) {
+			this.listeners.addListener('change', listener);
+		},
+
+		notifyChangeListeners : function() {
+			this.listeners.notifyListeners('change');
+		}
+	});
+
+	return AbstractWidget;
+
+});
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelChooserWidget.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelChooserWidget.js
new file mode 100644
index 0000000000000000000000000000000000000000..496f615607360032651567c4fab452ee3dc166d6
--- /dev/null
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelChooserWidget.js
@@ -0,0 +1,188 @@
+define([ "jquery", "components/imageviewer/AbstractView", "components/imageviewer/AbstractWidget" ], function($, AbstractView, AbstractWidget) {
+
+	//
+	// CHANNEL CHOOSER VIEW
+	//
+
+	function ChannelChooserView(controller) {
+		this.init(controller);
+	}
+
+	$.extend(ChannelChooserView.prototype, AbstractView.prototype, {
+
+		init : function(controller) {
+			AbstractView.prototype.init.call(this, controller);
+			this.panel = $("<div>");
+		},
+
+		render : function() {
+			this.panel.append(this.createChannelWidget());
+			this.panel.append(this.createMergedChannelsWidget());
+
+			this.refresh();
+
+			return this.panel;
+		},
+
+		refresh : function() {
+			var thisView = this;
+
+			var select = this.panel.find("select");
+			var mergedChannels = this.panel.find(".mergedChannelsWidget");
+
+			if (this.controller.getSelectedChannel() != null) {
+				select.val(this.controller.getSelectedChannel());
+				mergedChannels.hide();
+			} else {
+				select.val("");
+				mergedChannels.find("input").each(function() {
+					var checkbox = $(this);
+					checkbox.prop("checked", thisView.controller.isMergedChannelSelected(checkbox.val()));
+					checkbox.prop("disabled", !thisView.controller.isMergedChannelEnabled(checkbox.val()));
+				});
+				mergedChannels.show();
+			}
+		},
+
+		createChannelWidget : function() {
+			var thisView = this;
+			var widget = $("<div>").addClass("channelWidget").addClass("form-group");
+
+			$("<label>").text("Channel").attr("for", "channelChooserSelect").appendTo(widget);
+
+			var select = $("<select>").attr("id", "channelChooserSelect").addClass("form-control").appendTo(widget);
+			$("<option>").attr("value", "").text("Merged Channels").appendTo(select);
+
+			this.controller.getChannels().forEach(function(channel) {
+				$("<option>").attr("value", channel.code).text(channel.label).appendTo(select);
+			});
+
+			select.change(function() {
+				if (select.val() == "") {
+					thisView.controller.setSelectedChannel(null);
+				} else {
+					thisView.controller.setSelectedChannel(select.val());
+				}
+			});
+
+			return widget;
+		},
+
+		createMergedChannelsWidget : function() {
+			var thisView = this;
+			var widget = $("<div>").addClass("mergedChannelsWidget").addClass("form-group");
+
+			$("<label>").text("Merged Channels").appendTo(widget);
+
+			var checkboxes = $("<div>").appendTo(widget);
+
+			this.controller.getChannels().forEach(function(channel) {
+				var checkbox = $("<label>").addClass("checkbox-inline").appendTo(checkboxes);
+				$("<input>").attr("type", "checkbox").attr("value", channel.code).appendTo(checkbox);
+				checkbox.append(channel.label);
+			});
+
+			widget.find("input").change(function() {
+				var channels = []
+				widget.find("input:checked").each(function() {
+					channels.push($(this).val());
+				});
+				thisView.controller.setSelectedMergedChannels(channels);
+			});
+
+			return widget;
+		}
+
+	});
+
+	//
+	// CHANNEL CHOOSER
+	//
+
+	function ChannelChooserWidget(channels) {
+		this.init(channels);
+	}
+
+	$.extend(ChannelChooserWidget.prototype, AbstractWidget.prototype, {
+
+		init : function(channels) {
+			AbstractWidget.prototype.init.call(this, new ChannelChooserView(this));
+			this.setChannels(channels);
+		},
+
+		getSelectedChannel : function() {
+			if (this.selectedChannel) {
+				return this.selectedChannel;
+			} else {
+				return null;
+			}
+		},
+
+		setSelectedChannel : function(channel) {
+			if (this.getSelectedChannel() != channel) {
+				this.selectedChannel = channel;
+				this.refresh();
+				this.notifyChangeListeners();
+			}
+		},
+
+		getSelectedMergedChannels : function() {
+			if (this.selectedMergedChannels) {
+				return this.selectedMergedChannels;
+			} else {
+				return [];
+			}
+		},
+
+		setSelectedMergedChannels : function(channels) {
+			if (!channels) {
+				channels = [];
+			}
+
+			if (this.getSelectedMergedChannels().toString() != channels.toString()) {
+				this.selectedMergedChannels = channels;
+				this.refresh();
+				this.notifyChangeListeners();
+			}
+		},
+
+		isMergedChannelSelected : function(channel) {
+			return $.inArray(channel, this.getSelectedMergedChannels()) != -1;
+		},
+
+		isMergedChannelEnabled : function(channel) {
+			if (this.getSelectedMergedChannels().length == 1) {
+				return !this.isMergedChannelSelected(channel);
+			} else {
+				return true;
+			}
+		},
+
+		getChannels : function() {
+			if (this.channels) {
+				return this.channels;
+			} else {
+				return [];
+			}
+		},
+
+		setChannels : function(channels) {
+			if (!channels) {
+				channels = [];
+			}
+
+			if (this.getChannels().toString() != channels.toString()) {
+				this.setSelectedChannel(null);
+				this.setSelectedMergedChannels(channels.map(function(channel) {
+					return channel.code;
+				}));
+				this.channels = channels;
+				this.refresh();
+			}
+		}
+
+	});
+
+	return ChannelChooserWidget;
+
+});
\ No newline at end of file
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackChooserWidget.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackChooserWidget.js
new file mode 100644
index 0000000000000000000000000000000000000000..553523314be5fc3f7604f588300b53c302da9002
--- /dev/null
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackChooserWidget.js
@@ -0,0 +1,57 @@
+define([ "jquery", "components/imageviewer/ChannelStackManager", "components/imageviewer/ChannelStackMatrixChooserWidget",
+		"components/imageviewer/ChannelStackSeriesChooserWidget" ], function($, ChannelStackManager, ChannelStackMatrixChooserWidget,
+		ChannelStackSeriesChooserWidget) {
+
+	//
+	// CHANNEL STACK CHOOSER
+	//
+
+	function ChannelStackChooserWidget(channelStacks) {
+		this.init(channelStacks);
+	}
+
+	$.extend(ChannelStackChooserWidget.prototype, {
+
+		init : function(channelStacks) {
+			var manager = new ChannelStackManager(channelStacks);
+
+			if (manager.isMatrix()) {
+				this.widget = new ChannelStackMatrixChooserWidget(channelStacks);
+			} else {
+				this.widget = new ChannelStackSeriesChooserWidget(channelStacks);
+			}
+		},
+
+		render : function() {
+			return this.widget.render();
+		},
+
+		getSelectedChannelStackId : function() {
+			return this.widget.getSelectedChannelStackId();
+		},
+
+		setSelectedChannelStackId : function(channelStackId) {
+			this.widget.setSelectedChannelStackId(channelStackId);
+		},
+
+		getChannelStackContentLoader : function() {
+			return this.widget.getChannelStackContentLoader();
+		},
+
+		setChannelStackContentLoader : function(channelStackContentLoader) {
+			return this.widget.setChannelStackContentLoader(channelStackContentLoader);
+		},
+
+		addChangeListener : function(listener) {
+			this.widget.addChangeListener(listener);
+		},
+
+		notifyChangeListeners : function() {
+			this.widget.notifyChangeListeners();
+		}
+
+	});
+
+	return ChannelStackChooserWidget;
+
+});
\ No newline at end of file
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackManager.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackManager.js
new file mode 100644
index 0000000000000000000000000000000000000000..1925294ff0b4b1118f3e68bac5272ef8fcf41df7
--- /dev/null
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackManager.js
@@ -0,0 +1,241 @@
+define([ "jquery" ], function($) {
+
+	//
+	// CHANNEL STACK MANAGER
+	//
+
+	function ChannelStackManager(channelStacks) {
+		this.init(channelStacks);
+	}
+
+	$.extend(ChannelStackManager.prototype, {
+
+		init : function(channelStacks) {
+			this.channelStacks = channelStacks;
+			this.channelStacks.sort(function(o1, o2) {
+				var s1 = o1.seriesNumberOrNull;
+				var s2 = o2.seriesNumberOrNull;
+				var t1 = o1.timePointOrNull;
+				var t2 = o2.timePointOrNull;
+				var d1 = o1.depthOrNull;
+				var d2 = o2.depthOrNull;
+
+				var compare = function(v1, v2) {
+					if (v1 == null) {
+						if (v2 == null) {
+							return 0;
+						} else {
+							return -1;
+						}
+					} else if (v2 == null) {
+						return 1;
+					} else {
+						if (v1 > v2) {
+							return 1;
+						} else if (v1 < v2) {
+							return -1;
+						} else {
+							return 0;
+						}
+					}
+				}
+
+				return compare(s1, s2) * 100 + compare(t1, t2) * 10 + compare(d1, d2);
+			});
+		},
+
+		isMatrix : function() {
+			/*
+			 * TODO return (!this.isSeriesNumberPresent() ||
+			 * this.getSeriesNumbers().length == 1) &&
+			 * !this.isTimePointMissing() && !this.isDepthMissing() &&
+			 * this.isDepthConsistent();
+			 */
+			return !this.isSeriesNumberPresent() && !this.isTimePointMissing() && !this.isDepthMissing() && this.isDepthConsistent();
+		},
+
+		isSeriesNumberPresent : function() {
+			return this.channelStacks.some(function(channelStack) {
+				return channelStack.seriesNumberOrNull;
+			});
+		},
+
+		isTimePointMissing : function() {
+			return this.channelStacks.some(function(channelStack) {
+				return channelStack.timePointOrNull == null;
+			});
+		},
+
+		isDepthMissing : function() {
+			return this.channelStacks.some(function(channelStack) {
+				return channelStack.depthOrNull == null;
+			});
+		},
+
+		isDepthConsistent : function() {
+			var map = this.getChannelStackByTimePointAndDepthMap();
+			var depthCounts = {};
+
+			for (timePoint in map) {
+				var entry = map[timePoint];
+				var depthCount = Object.keys(entry).length;
+				depthCounts[depthCount] = true;
+			}
+
+			return Object.keys(depthCounts).length == 1;
+		},
+
+		getSeriesNumbers : function() {
+			if (!this.seriesNumbers) {
+				var seriesNumbers = {};
+
+				this.channelStacks.forEach(function(channelStack) {
+					if (channelStack.seriesNumberOrNull != null) {
+						seriesNumbers[channelStack.seriesNumberOrNull] = true;
+					}
+				});
+
+				this.seriesNumbers = Object.keys(seriesNumbers).map(function(seriesNumber) {
+					return parseInt(seriesNumber);
+				}).sort();
+			}
+			return this.seriesNumbers;
+		},
+
+		getSeriesNumber : function(index) {
+			return this.getSeriesNumbers()[index];
+		},
+
+		getTimePoints : function() {
+			if (!this.timePoints) {
+				var timePoints = {};
+
+				this.channelStacks.forEach(function(channelStack) {
+					if (channelStack.timePointOrNull != null) {
+						timePoints[channelStack.timePointOrNull] = true;
+					}
+				});
+
+				this.timePoints = Object.keys(timePoints).map(function(timePoint) {
+					return parseInt(timePoint);
+				}).sort();
+			}
+			return this.timePoints;
+		},
+
+		getTimePoint : function(index) {
+			return this.getTimePoints()[index];
+		},
+
+		getTimePointIndex : function(timePoint) {
+			if (!this.timePointsMap) {
+				var map = {};
+
+				this.getTimePoints().forEach(function(timePoint, index) {
+					map[timePoint] = index;
+				});
+
+				this.timePointsMap = map;
+			}
+
+			return this.timePointsMap[timePoint];
+		},
+
+		getDepths : function() {
+			if (!this.depths) {
+				var depths = {};
+
+				this.channelStacks.forEach(function(channelStack) {
+					if (channelStack.depthOrNull != null) {
+						depths[channelStack.depthOrNull] = true;
+					}
+				});
+
+				this.depths = Object.keys(depths).map(function(depth) {
+					return parseInt(depth);
+				}).sort();
+			}
+			return this.depths;
+		},
+
+		getDepth : function(index) {
+			return this.getDepths()[index];
+		},
+
+		getDepthIndex : function(depth) {
+			if (!this.depthsMap) {
+				var map = {};
+
+				this.getDepths().forEach(function(depth, index) {
+					map[depth] = index;
+				});
+
+				this.depthsMap = map;
+			}
+
+			return this.depthsMap[depth];
+		},
+
+		getChannelStackIndex : function(channelStackId) {
+			if (!this.channelStackMap) {
+				var map = {};
+
+				this.getChannelStacks().forEach(function(channelStack, index) {
+					map[channelStack.id] = index;
+				});
+
+				this.channelStackMap = map;
+			}
+
+			return this.channelStackMap[channelStackId];
+		},
+
+		getChannelStackById : function(channelStackId) {
+			if (!this.channelStackByIdMap) {
+				var map = {};
+				this.channelStacks.forEach(function(channelStack) {
+					map[channelStack.id] = channelStack;
+				});
+				this.channelStackByIdMap = map;
+			}
+			return this.channelStackByIdMap[channelStackId];
+		},
+
+		getChannelStackByTimePointAndDepth : function(timePoint, depth) {
+			var map = this.getChannelStackByTimePointAndDepthMap();
+			var entry = map[timePoint];
+
+			if (entry) {
+				return entry[depth];
+			} else {
+				return null;
+			}
+		},
+
+		getChannelStackByTimePointAndDepthMap : function() {
+			if (!this.channelStackByTimePointAndDepthMap) {
+				var map = {};
+				this.channelStacks.forEach(function(channelStack) {
+					if (channelStack.timePointOrNull != null && channelStack.depthOrNull != null) {
+						var entry = map[channelStack.timePointOrNull];
+						if (!entry) {
+							entry = {};
+							map[channelStack.timePointOrNull] = entry;
+						}
+						entry[channelStack.depthOrNull] = channelStack;
+					}
+				});
+				this.channelStackByTimePointAndDepthMap = map;
+			}
+			return this.channelStackByTimePointAndDepthMap;
+		},
+
+		getChannelStacks : function() {
+			return this.channelStacks;
+		}
+
+	});
+
+	return ChannelStackManager;
+
+});
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackMatrixChooserWidget.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackMatrixChooserWidget.js
new file mode 100644
index 0000000000000000000000000000000000000000..98b83688aba9115ba87589a6de903cbf6c6724ab
--- /dev/null
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackMatrixChooserWidget.js
@@ -0,0 +1,261 @@
+define([ "jquery", "bootstrap", "bootstrap-slider", "components/imageviewer/AbstractView", "components/imageviewer/AbstractWidget",
+		"components/imageviewer/ChannelStackManager", "components/imageviewer/MovieButtonsWidget" ], function($, bootstrap, bootstrapSlider,
+		AbstractView, AbstractWidget, ChannelStackManager, MovieButtonsWidget) {
+
+	//
+	// CHANNEL STACK MATRIX CHOOSER VIEW
+	//
+
+	function ChannelStackMatrixChooserView(controller) {
+		this.init(controller);
+	}
+
+	$.extend(ChannelStackMatrixChooserView.prototype, AbstractView.prototype, {
+
+		init : function(controller) {
+			AbstractView.prototype.init.call(this, controller);
+			this.panel = $("<div>").addClass("channelStackChooserWidget").addClass("form-group");
+		},
+
+		render : function() {
+			var thisView = this;
+
+			var slidersRow = $("<div>").addClass("row").appendTo(this.panel);
+			$("<div>").addClass("col-md-6").append(this.createTimePointWidget()).appendTo(slidersRow);
+			$("<div>").addClass("col-md-6").append(this.createDepthWidget()).appendTo(slidersRow);
+
+			var buttonsRow = $("<div>").appendTo(this.panel);
+			buttonsRow.append(this.createTimePointButtonsWidget());
+
+			this.refresh();
+
+			return this.panel;
+		},
+
+		refresh : function() {
+			var time = this.controller.getSelectedTimePoint();
+			var timeLabel = this.panel.find(".timePointWidget label");
+			var timeInput = this.panel.find(".timePointWidget input");
+
+			if (time != null) {
+				var timeCount = this.controller.getTimePoints().length;
+				var timeIndex = this.controller.getTimePoints().indexOf(time);
+
+				timeLabel.text("Time: " + time + " sec (" + (timeIndex + 1) + "/" + timeCount + ")");
+				timeInput.slider("setValue", time);
+
+				this.timePointButtons.setSelectedFrame(timeIndex);
+			}
+
+			var depth = this.controller.getSelectedDepth();
+			var depthLabel = this.panel.find(".depthWidget label");
+			var depthInput = this.panel.find(".depthWidget input");
+
+			if (depth != null) {
+				var depthCount = this.controller.getDepths().length;
+				var depthIndex = this.controller.getDepths().indexOf(depth);
+
+				depthLabel.text("Depth: " + depth + " (" + (depthIndex + 1) + "/" + depthCount + ")");
+				depthInput.slider("setValue", depthIndex);
+			}
+		},
+
+		createTimePointWidget : function() {
+			var thisView = this;
+			var widget = $("<div>").addClass("timePointWidget").addClass("form-group");
+
+			$("<label>").attr("for", "timePointInput").appendTo(widget);
+
+			var timeInput = $("<input>").attr("id", "timePointInput").attr("type", "text").addClass("form-control");
+
+			$("<div>").append(timeInput).appendTo(widget);
+
+			timeInput.slider({
+				"min" : 0,
+				"max" : this.controller.getTimePoints().length - 1,
+				"step" : 1,
+				"tooltip" : "hide"
+			}).on("slide", function(event) {
+				if (!$.isArray(event.value) && !isNaN(event.value)) {
+					var timeIndex = parseInt(event.value);
+					var time = thisView.controller.getTimePoints()[timeIndex];
+					thisView.controller.setSelectedTimePoint(time);
+				}
+			});
+
+			return widget;
+		},
+
+		createDepthWidget : function() {
+			var thisView = this;
+			var widget = $("<div>").addClass("depthWidget").addClass("form-group");
+
+			$("<label>").attr("for", "depthInput").appendTo(widget);
+
+			var depthInput = $("<input>").attr("id", "depthInput").attr("type", "text").addClass("form-control");
+
+			$("<div>").append(depthInput).appendTo(widget);
+
+			depthInput.slider({
+				"min" : 0,
+				"max" : this.controller.getDepths().length - 1,
+				"step" : 1,
+				"tooltip" : "hide"
+			}).on("slide", function(event) {
+				if (!$.isArray(event.value) && !isNaN(event.value)) {
+					var depthIndex = parseInt(event.value);
+					var depth = thisView.controller.getDepths()[depthIndex];
+					thisView.controller.setSelectedDepth(depth);
+				}
+			});
+
+			return widget;
+		},
+
+		createTimePointButtonsWidget : function() {
+			var thisView = this;
+
+			var buttons = new MovieButtonsWidget(this.controller.getTimePoints().length);
+
+			buttons.setFrameContentLoader(function(frameIndex, callback) {
+				var timePoint = thisView.controller.getTimePoints()[frameIndex];
+				var depth = thisView.controller.getSelectedDepth();
+				var channelStack = thisView.controller.getChannelStackByTimePointAndDepth(timePoint, depth);
+				thisView.controller.loadChannelStackContent(channelStack, callback);
+			});
+
+			buttons.addChangeListener(function() {
+				var timePoint = thisView.controller.getTimePoints()[buttons.getSelectedFrame()];
+				thisView.controller.setSelectedTimePoint(timePoint);
+			});
+
+			this.timePointButtons = buttons;
+			return buttons.render();
+		}
+
+	});
+
+	//
+	// CHANNEL STACK MATRIX CHOOSER
+	//
+
+	function ChannelStackMatrixChooserWidget(channelStacks) {
+		this.init(channelStacks);
+	}
+
+	$.extend(ChannelStackMatrixChooserWidget.prototype, AbstractWidget.prototype, {
+
+		init : function(channelStacks) {
+			AbstractWidget.prototype.init.call(this, new ChannelStackMatrixChooserView(this));
+			this.channelStackManager = new ChannelStackManager(channelStacks);
+		},
+
+		getTimePoints : function() {
+			return this.channelStackManager.getTimePoints();
+		},
+
+		getDepths : function() {
+			return this.channelStackManager.getDepths();
+		},
+
+		getChannelStacks : function() {
+			return this.channelStackManager.getChannelStacks();
+		},
+
+		getChannelStackById : function(channelStackId) {
+			return this.channelStackManager.getChannelStackById(channelStackId);
+		},
+
+		getChannelStackByTimePointAndDepth : function(timePoint, depth) {
+			return this.channelStackManager.getChannelStackByTimePointAndDepth(timePoint, depth);
+		},
+
+		loadChannelStackContent : function(channelStack, callback) {
+			this.getChannelStackContentLoader()(channelStack, callback);
+		},
+
+		getChannelStackContentLoader : function() {
+			if (this.channelStackContentLoader) {
+				return this.channelStackContentLoader;
+			} else {
+				return function(channelStack, callback) {
+					callback();
+				}
+			}
+		},
+
+		setChannelStackContentLoader : function(channelStackContentLoader) {
+			this.channelStackContentLoader = channelStackContentLoader;
+		},
+
+		getSelectedChannelStackId : function() {
+			return this.selectedChannelStackId;
+		},
+
+		setSelectedChannelStackId : function(channelStackId) {
+			if (this.selectedChannelStackId != channelStackId) {
+				this.selectedChannelStackId = channelStackId;
+				this.refresh();
+				this.notifyChangeListeners();
+			}
+		},
+
+		getSelectedChannelStack : function() {
+			var channelStackId = this.getSelectedChannelStackId();
+
+			if (channelStackId != null) {
+				return this.channelStackManager.getChannelStackById(channelStackId);
+			} else {
+				return null;
+			}
+		},
+
+		setSelectedChannelStack : function(channelStack) {
+			if (channelStack != null) {
+				this.setSelectedChannelStackId(channelStack.id);
+			} else {
+				this.setSelectedChannelStackId(null);
+			}
+		},
+
+		getSelectedTimePoint : function() {
+			var channelStack = this.getSelectedChannelStack();
+			if (channelStack != null) {
+				return channelStack.timePointOrNull;
+			} else {
+				return null;
+			}
+		},
+
+		setSelectedTimePoint : function(timePoint) {
+			if (timePoint != null && this.getSelectedDepth() != null) {
+				var channelStack = this.channelStackManager.getChannelStackByTimePointAndDepth(timePoint, this.getSelectedDepth());
+				this.setSelectedChannelStack(channelStack);
+			} else {
+				this.setSelectedChannelStack(null);
+			}
+		},
+
+		getSelectedDepth : function() {
+			var channelStack = this.getSelectedChannelStack();
+			if (channelStack != null) {
+				return channelStack.depthOrNull;
+			} else {
+				return null;
+			}
+		},
+
+		setSelectedDepth : function(depth) {
+			if (depth != null && this.getSelectedTimePoint() != null) {
+				var channelStack = this.channelStackManager.getChannelStackByTimePointAndDepth(this.getSelectedTimePoint(), depth);
+				this.setSelectedChannelStack(channelStack);
+			} else {
+				this.setSelectedChannelStack(null);
+			}
+		}
+
+	});
+
+	return ChannelStackMatrixChooserWidget;
+
+});
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackSeriesChooserWidget.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackSeriesChooserWidget.js
new file mode 100644
index 0000000000000000000000000000000000000000..68a1225e2a51dd21ea1ec22c69617f45414b3793
--- /dev/null
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ChannelStackSeriesChooserWidget.js
@@ -0,0 +1,152 @@
+define([ "jquery", "bootstrap", "bootstrap-slider", "components/imageviewer/AbstractView", "components/imageviewer/AbstractWidget",
+		"components/imageviewer/MovieButtonsWidget", "components/imageviewer/ChannelStackManager" ], function($, bootstrap, bootstrapSlider,
+		AbstractView, AbstractWidget, MovieButtonsWidget, ChannelStackManager) {
+
+	//
+	// CHANNEL STACK SERIES CHOOSER VIEW
+	//
+
+	function ChannelStackSeriesChooserView(controller) {
+		this.init(controller);
+	}
+
+	$.extend(ChannelStackSeriesChooserView.prototype, AbstractView.prototype, {
+
+		init : function(controller) {
+			AbstractView.prototype.init.call(this, controller);
+			this.panel = $("<div>").addClass("channelStackChooserWidget").addClass("form-group");
+		},
+
+		render : function() {
+			var thisView = this;
+
+			this.panel.append(this.createSliderWidget());
+			this.panel.append(this.createButtonsWidget());
+
+			this.refresh();
+
+			return this.panel;
+		},
+
+		refresh : function() {
+			var channelStackId = this.controller.getSelectedChannelStackId();
+
+			if (channelStackId != null) {
+				var count = this.controller.getChannelStacks().length;
+				var index = this.controller.getChannelStackIndex(channelStackId);
+
+				var sliderLabel = this.panel.find(".sliderWidget label");
+				sliderLabel.text("Channel Stack: " + index + " (" + (index + 1) + "/" + count + ")");
+
+				var sliderInput = this.panel.find(".sliderWidget input");
+				sliderInput.slider("setValue", index);
+
+				this.buttons.setSelectedFrame(index);
+			}
+		},
+
+		createSliderWidget : function() {
+			var thisView = this;
+			var widget = $("<div>").addClass("sliderWidget").addClass("form-group");
+
+			$("<label>").attr("for", "sliderInput").appendTo(widget);
+
+			var sliderInput = $("<input>").attr("id", "sliderInput").attr("type", "text").addClass("form-control");
+
+			$("<div>").append(sliderInput).appendTo(widget);
+
+			sliderInput.slider({
+				"min" : 0,
+				"max" : this.controller.getChannelStacks().length - 1,
+				"step" : 1,
+				"tooltip" : "hide"
+			}).on("slide", function(event) {
+				if (!$.isArray(event.value) && !isNaN(event.value)) {
+					var index = parseInt(event.value);
+					var channelStack = thisView.controller.getChannelStacks()[index];
+					thisView.controller.setSelectedChannelStackId(channelStack.id);
+				}
+			});
+
+			return widget;
+		},
+
+		createButtonsWidget : function() {
+			var thisView = this;
+
+			var buttons = new MovieButtonsWidget(this.controller.getChannelStacks().length);
+
+			buttons.setFrameContentLoader(function(frameIndex, callback) {
+				var channelStack = thisView.controller.getChannelStacks()[frameIndex];
+				thisView.controller.loadChannelStackContent(channelStack, callback);
+			});
+
+			buttons.addChangeListener(function() {
+				var channelStack = thisView.controller.getChannelStacks()[buttons.getSelectedFrame()];
+				thisView.controller.setSelectedChannelStackId(channelStack.id);
+			});
+
+			this.buttons = buttons;
+			return buttons.render();
+		}
+
+	});
+
+	//
+	// CHANNEL STACK SERIES CHOOSER
+	//
+
+	function ChannelStackSeriesChooserWidget(channelStacks) {
+		this.init(channelStacks);
+	}
+
+	$.extend(ChannelStackSeriesChooserWidget.prototype, AbstractWidget.prototype, {
+
+		init : function(channelStacks) {
+			AbstractWidget.prototype.init.call(this, new ChannelStackSeriesChooserView(this));
+			this.channelStackManager = new ChannelStackManager(channelStacks);
+		},
+
+		getChannelStacks : function() {
+			return this.channelStackManager.getChannelStacks();
+		},
+
+		getChannelStackIndex : function(channelStackId) {
+			return this.channelStackManager.getChannelStackIndex(channelStackId);
+		},
+
+		loadChannelStackContent : function(channelStack, callback) {
+			this.getChannelStackContentLoader()(channelStack, callback);
+		},
+
+		getChannelStackContentLoader : function() {
+			if (this.channelStackContentLoader) {
+				return this.channelStackContentLoader;
+			} else {
+				return function(channelStack, callback) {
+					callback();
+				}
+			}
+		},
+
+		setChannelStackContentLoader : function(channelStackContentLoader) {
+			this.channelStackContentLoader = channelStackContentLoader;
+		},
+
+		getSelectedChannelStackId : function() {
+			return this.selectedChannelStackId;
+		},
+
+		setSelectedChannelStackId : function(channelStackId) {
+			if (this.selectedChannelStackId != channelStackId) {
+				this.selectedChannelStackId = channelStackId;
+				this.refresh();
+				this.notifyChangeListeners();
+			}
+		}
+
+	});
+
+	return ChannelStackSeriesChooserWidget;
+
+});
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ImageData.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ImageData.js
new file mode 100644
index 0000000000000000000000000000000000000000..53a86d9c3cac4ceab6a988fb62b36ec8e7f0e7b5
--- /dev/null
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ImageData.js
@@ -0,0 +1,44 @@
+define([ "jquery" ], function($) {
+
+	//
+	// IMAGE DATA
+	//
+
+	function ImageData() {
+		this.init();
+	}
+
+	$.extend(ImageData.prototype, {
+
+		init : function() {
+		},
+
+		setDataStoreUrl : function(dataStoreUrl) {
+			this.dataStoreUrl = dataStoreUrl;
+		},
+
+		setSessionToken : function(sessionToken) {
+			this.sessionToken = sessionToken;
+		},
+
+		setDataSetCode : function(dataSetCode) {
+			this.dataSetCode = dataSetCode;
+		},
+
+		setChannelStackId : function(channelStackId) {
+			this.channelStackId = channelStackId;
+		},
+
+		setChannels : function(channels) {
+			this.channels = channels;
+		},
+
+		setResolution : function(resolution) {
+			this.resolution = resolution;
+		}
+
+	});
+
+	return ImageData;
+
+});
\ No newline at end of file
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ImageLoader.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ImageLoader.js
new file mode 100644
index 0000000000000000000000000000000000000000..95ff0bf63b1c8ad5cafd14cab5e30a3bbd60212d
--- /dev/null
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ImageLoader.js
@@ -0,0 +1,45 @@
+define([ "jquery" ], function($) {
+
+	//
+	// IMAGE LOADER
+	//
+
+	function ImageLoader() {
+		this.init();
+	}
+
+	$.extend(ImageLoader.prototype, {
+
+		init : function() {
+		},
+
+		loadImage : function(imageData, callback) {
+			// log("loadImage: " + imageData.channelStackId);
+
+			var url = imageData.dataStoreUrl + "/datastore_server_screening";
+			url += "?sessionID=" + imageData.sessionToken;
+			url += "&dataset=" + imageData.dataSetCode;
+			url += "&channelStackId=" + imageData.channelStackId;
+
+			imageData.channels.forEach(function(channel) {
+				url += "&channel=" + channel;
+			});
+
+			if (imageData.resolution) {
+				url += "&mode=thumbnail" + imageData.resolution;
+			} else {
+				url += "&mode=thumbnail480x480";
+			}
+
+			$("<img>").attr("src", url).load(function() {
+				if (callback) {
+					callback(this);
+				}
+			});
+		}
+
+	});
+
+	return ImageLoader;
+
+});
\ No newline at end of file
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ImageViewerChooserWidget.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ImageViewerChooserWidget.js
new file mode 100644
index 0000000000000000000000000000000000000000..d1eb26a919cded4e91c360551fab452711b98bbf
--- /dev/null
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ImageViewerChooserWidget.js
@@ -0,0 +1,174 @@
+define([ "jquery", "components/common/CallbackManager", "components/imageviewer/AbstractView", "components/imageviewer/AbstractWidget",
+		"components/imageviewer/ImageViewerWidget", "components/imageviewer/OpenbisFacade" ], function($, CallbackManager, AbstractView,
+		AbstractWidget, ImageViewerWidget, OpenbisFacade) {
+
+	//
+	// IMAGE VIEWER CHOOSER VIEW
+	//
+
+	function ImageViewerChooserView(controller) {
+		this.init(controller);
+	}
+
+	$.extend(ImageViewerChooserView.prototype, AbstractView.prototype, {
+
+		init : function(controller) {
+			AbstractView.prototype.init.call(this, controller);
+			this.panel = $("<div>").addClass("imageViewerChooser");
+		},
+
+		render : function() {
+			this.panel.append(this.createDataSetChooserWidget());
+			this.panel.append(this.createImageViewerContainerWidget());
+
+			this.refresh();
+
+			return this.panel;
+		},
+
+		refresh : function() {
+			var select = this.panel.find(".dataSetChooser").find("select");
+			var container = this.panel.find(".imageViewerContainer");
+
+			if (this.controller.getSelectedDataSetCode() != null) {
+				select.val(this.controller.getSelectedDataSetCode());
+				container.children().detach();
+				container.append(this.createImageViewerWidget(this.controller.getSelectedDataSetCode()));
+			}
+		},
+
+		createDataSetChooserWidget : function() {
+			var thisView = this;
+			var widget = $("<div>").addClass("dataSetChooser").addClass("form-group");
+
+			$("<label>").text("Data set").attr("for", "dataSetChooserSelect").appendTo(widget);
+
+			var select = $("<select>").attr("id", "dataSetChooserSelect").addClass("form-control").appendTo(widget);
+
+			this.controller.getDataSetCodes().forEach(function(dataSetCode) {
+				$("<option>").attr("value", dataSetCode).text(dataSetCode).appendTo(select);
+			});
+
+			select.change(function() {
+				thisView.controller.setSelectedDataSetCode(select.val());
+			});
+
+			return widget;
+		},
+
+		createImageViewerContainerWidget : function() {
+			return $("<div>").addClass("imageViewerContainer");
+		},
+
+		createImageViewerWidget : function(dataSetCode) {
+			if (!this.imageViewerMap) {
+				this.imageViewerMap = {};
+			}
+
+			if (!this.imageViewerMap[dataSetCode]) {
+				this.imageViewerMap[dataSetCode] = new ImageViewerWidget(this.controller.getSessionToken(), dataSetCode, this.controller
+						.getDataStoreUrl(dataSetCode), this.controller.getImageInfo(dataSetCode), this.controller.getImageResolutions(dataSetCode));
+			}
+
+			return this.imageViewerMap[dataSetCode].render();
+		}
+
+	});
+
+	//
+	// IMAGE VIEWER CHOOSER
+	//
+
+	function ImageViewerChooserWidget(openbis, dataSetCodes) {
+		this.init(openbis, dataSetCodes);
+	}
+
+	$.extend(ImageViewerChooserWidget.prototype, AbstractWidget.prototype, {
+		init : function(openbis, dataSetCodes) {
+			AbstractWidget.prototype.init.call(this, new ImageViewerChooserView(this));
+			this.facade = new OpenbisFacade(openbis);
+			this.setDataSetCodes(dataSetCodes)
+		},
+
+		load : function(callback) {
+			if (this.loaded) {
+				callback();
+			} else {
+				var thisViewer = this;
+
+				var manager = new CallbackManager(function() {
+					thisViewer.loaded = true;
+					callback();
+				});
+
+				this.facade.getDataStoreBaseURLs(thisViewer.dataSetCodes, manager.registerCallback(function(response) {
+					thisViewer.dataSetCodeToDataStoreUrlMap = response.result;
+				}));
+
+				this.facade.getImageInfo(thisViewer.dataSetCodes, manager.registerCallback(function(response) {
+					thisViewer.dataSetCodeToImageInfoMap = response.result;
+				}));
+
+				this.facade.getImageResolutions(thisViewer.dataSetCodes, manager.registerCallback(function(response) {
+					thisViewer.dataSetCodeToImageResolutionsMap = response.result;
+				}));
+			}
+		},
+
+		getSessionToken : function() {
+			return this.facade.getSession();
+		},
+
+		getImageInfo : function(dataSetCode) {
+			return this.dataSetCodeToImageInfoMap[dataSetCode];
+		},
+
+		getImageResolutions : function(dataSetCode) {
+			return this.dataSetCodeToImageResolutionsMap[dataSetCode];
+		},
+
+		getDataStoreUrl : function(dataSetCode) {
+			return this.dataSetCodeToDataStoreUrlMap[dataSetCode];
+		},
+
+		getDataSetCodes : function() {
+			if (this.dataSetCodes) {
+				return this.dataSetCodes;
+			} else {
+				return [];
+			}
+		},
+
+		setDataSetCodes : function(dataSetCodes) {
+			if (!dataSetCodes) {
+				dataSetCodes = [];
+			}
+			if (this.getDataSetCodes().toString() != dataSetCodes.toString()) {
+				this.dataSetCodes = dataSetCodes;
+				if (dataSetCodes.length > 0) {
+					this.setSelectedDataSetCode(dataSetCodes[0]);
+				}
+				this.refresh();
+			}
+		},
+
+		getSelectedDataSetCode : function() {
+			if (this.selectedDataSetCode != null) {
+				return this.selectedDataSetCode;
+			} else {
+				return null;
+			}
+		},
+
+		setSelectedDataSetCode : function(dataSetCode) {
+			if (this.getSelectedDataSetCode() != dataSetCode) {
+				this.selectedDataSetCode = dataSetCode;
+				this.refresh();
+			}
+		}
+
+	});
+
+	return ImageViewerChooserWidget;
+
+});
\ No newline at end of file
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ImageViewerWidget.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ImageViewerWidget.js
new file mode 100644
index 0000000000000000000000000000000000000000..5b40edc810bf7ef8477c19f0065fffb5f0c89628
--- /dev/null
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ImageViewerWidget.js
@@ -0,0 +1,224 @@
+define([ "jquery", "components/imageviewer/AbstractView", "components/imageviewer/AbstractWidget", "components/imageviewer/ChannelChooserWidget",
+		"components/imageviewer/ResolutionChooserWidget", "components/imageviewer/ChannelStackChooserWidget",
+		"components/imageviewer/ChannelStackManager", "components/imageviewer/ImageLoader", "components/imageviewer/ImageWidget",
+		"components/imageviewer/ImageData", "components/imageviewer/OpenbisFacade" ], function($, AbstractView, AbstractWidget, ChannelChooserWidget,
+		ResolutionChooserWidget, ChannelStackChooserWidget, ChannelStackManager, ImageLoader, ImageWidget, ImageData, OpenbisFacade) {
+
+	//
+	// IMAGE VIEWER VIEW
+	//
+
+	function ImageViewerView(controller) {
+		this.init(controller);
+	}
+
+	$.extend(ImageViewerView.prototype, AbstractView.prototype, {
+		init : function(controller) {
+			AbstractView.prototype.init.call(this, controller);
+			this.imageLoader = new ImageLoader();
+			this.panel = $("<div>").addClass("imageViewer");
+		},
+
+		render : function() {
+			this.panel.append(this.createChannelWidget());
+			this.panel.append(this.createResolutionWidget());
+			this.panel.append(this.createChannelStackWidget());
+			this.panel.append(this.createImageWidget());
+
+			this.refresh();
+
+			return this.panel;
+		},
+
+		refresh : function() {
+			this.channelWidget.setSelectedChannel(this.controller.getSelectedChannel());
+			this.channelWidget.setSelectedMergedChannels(this.controller.getSelectedMergedChannels());
+			this.resolutionWidget.setSelectedResolution(this.controller.getSelectedResolution());
+			this.channelStackWidget.setSelectedChannelStackId(this.controller.getSelectedChannelStackId());
+			this.imageWidget.setImageData(this.controller.getSelectedImageData());
+		},
+
+		createChannelWidget : function() {
+			var thisView = this;
+
+			var widget = new ChannelChooserWidget(this.controller.getChannels());
+			widget.addChangeListener(function() {
+				thisView.controller.setSelectedChannel(thisView.channelWidget.getSelectedChannel());
+				thisView.controller.setSelectedMergedChannels(thisView.channelWidget.getSelectedMergedChannels());
+			});
+
+			this.channelWidget = widget;
+			return widget.render();
+		},
+
+		createResolutionWidget : function() {
+			var thisView = this;
+
+			var widget = new ResolutionChooserWidget(this.controller.getResolutions());
+			widget.addChangeListener(function() {
+				thisView.controller.setSelectedResolution(thisView.resolutionWidget.getSelectedResolution());
+			});
+
+			this.resolutionWidget = widget;
+			return widget.render();
+		},
+
+		createChannelStackWidget : function() {
+			var thisView = this;
+
+			var widget = new ChannelStackChooserWidget(this.controller.getChannelStacks());
+
+			widget.setChannelStackContentLoader(function(channelStack, callback) {
+				var imageData = thisView.controller.getSelectedImageData();
+				imageData.setChannelStackId(channelStack.id);
+				thisView.imageLoader.loadImage(imageData, callback);
+			});
+
+			widget.addChangeListener(function() {
+				thisView.controller.setSelectedChannelStackId(thisView.channelStackWidget.getSelectedChannelStackId());
+			});
+
+			this.channelStackWidget = widget;
+			return widget.render();
+		},
+
+		createImageWidget : function() {
+			this.imageWidget = new ImageWidget(this.imageLoader);
+			return this.imageWidget.render();
+		}
+
+	});
+
+	//
+	// IMAGE VIEWER
+	//
+
+	function ImageViewerWidget(sessionToken, dataSetCode, dataStoreUrl, imageInfo, imageResolutions) {
+		this.init(sessionToken, dataSetCode, dataStoreUrl, imageInfo, imageResolutions);
+	}
+
+	$.extend(ImageViewerWidget.prototype, AbstractWidget.prototype, {
+		init : function(sessionToken, dataSetCode, dataStoreUrl, imageInfo, imageResolutions) {
+			AbstractWidget.prototype.init.call(this, new ImageViewerView(this));
+			this.facade = new OpenbisFacade(openbis);
+			this.sessionToken = sessionToken;
+			this.dataSetCode = dataSetCode;
+			this.dataStoreUrl = dataStoreUrl;
+			this.imageInfo = imageInfo;
+			this.imageResolutions = imageResolutions;
+
+			var channels = this.getChannels();
+			if (channels && channels.length > 0) {
+				this.setSelectedMergedChannels(channels.map(function(channel) {
+					return channel.code
+				}));
+			}
+
+			var channelStacks = this.getChannelStacks();
+			if (channelStacks && channelStacks.length > 0) {
+				this.setSelectedChannelStackId(channelStacks[0].id);
+			}
+		},
+
+		getSelectedChannel : function() {
+			if (this.selectedChannel != null) {
+				return this.selectedChannel;
+			} else {
+				return null;
+			}
+		},
+
+		setSelectedChannel : function(channel) {
+			if (this.getSelectedChannel() != channel) {
+				this.selectedChannel = channel;
+				this.refresh();
+			}
+		},
+
+		getSelectedMergedChannels : function() {
+			if (this.selectedMergedChannels != null) {
+				return this.selectedMergedChannels;
+			} else {
+				return [];
+			}
+		},
+
+		setSelectedMergedChannels : function(channels) {
+			if (!channels) {
+				channels = [];
+			}
+
+			if (this.getSelectedMergedChannels().toString() != channels.toString()) {
+				this.selectedMergedChannels = channels;
+				this.refresh();
+			}
+		},
+
+		getSelectedChannelStackId : function() {
+			if (this.selectedChannelStackId != null) {
+				return this.selectedChannelStackId;
+			} else {
+				return null;
+			}
+		},
+
+		setSelectedChannelStackId : function(channelStackId) {
+			if (this.getSelectedChannelStackId() != channelStackId) {
+				this.selectedChannelStackId = channelStackId;
+				this.refresh();
+			}
+		},
+
+		getSelectedResolution : function() {
+			if (this.selectedResolution != null) {
+				return this.selectedResolution;
+			} else {
+				return null;
+			}
+		},
+
+		setSelectedResolution : function(resolution) {
+			if (this.getSelectedResolution() != resolution) {
+				this.selectedResolution = resolution;
+				this.refresh();
+			}
+		},
+
+		getSelectedImageData : function() {
+			var imageData = new ImageData();
+			imageData.setDataStoreUrl(this.dataStoreUrl);
+			imageData.setSessionToken(this.sessionToken);
+			imageData.setDataSetCode(this.dataSetCode);
+			imageData.setChannelStackId(this.getSelectedChannelStackId());
+
+			if (this.getSelectedChannel()) {
+				imageData.setChannels([ this.getSelectedChannel() ]);
+			} else {
+				imageData.setChannels(this.getSelectedMergedChannels());
+			}
+			imageData.setResolution(this.getSelectedResolution());
+			return imageData;
+		},
+
+		getChannels : function() {
+			return this.imageInfo.imageDataset.imageDataset.imageParameters.channels;
+		},
+
+		getChannelStacks : function() {
+			if (this.channelStackManager == null) {
+				this.channelStackManager = new ChannelStackManager(this.imageInfo.channelStacks);
+			}
+			return this.channelStackManager.getChannelStacks();
+		},
+
+		getResolutions : function() {
+			return this.imageResolutions;
+		}
+
+	// TODO add listeners for channel, resoluton, channel stack
+
+	});
+
+	return ImageViewerWidget;
+
+});
\ No newline at end of file
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ImageWidget.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ImageWidget.js
new file mode 100644
index 0000000000000000000000000000000000000000..33f9617603d4788f321b70e13f15db284a03b6fc
--- /dev/null
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ImageWidget.js
@@ -0,0 +1,70 @@
+define([ "jquery", "components/imageviewer/AbstractView", "components/imageviewer/AbstractWidget" ], function($, AbstractView, AbstractWidget) {
+
+	//
+	// IMAGE VIEW
+	//
+
+	function ImageView(controller) {
+		this.init(controller);
+	}
+
+	$.extend(ImageView.prototype, AbstractView.prototype, {
+
+		init : function(controller) {
+			AbstractView.prototype.init.call(this, controller);
+			this.panel = $("<div>").addClass("imageWidget");
+		},
+
+		render : function() {
+			this.refresh();
+			return this.panel;
+		},
+
+		refresh : function() {
+			var thisView = this;
+
+			if (this.controller.getImageData()) {
+				this.controller.loadImage(this.controller.getImageData(), function(image) {
+					thisView.panel.empty();
+					thisView.panel.append(image);
+				});
+			} else {
+				this.panel.empty();
+			}
+		}
+
+	});
+
+	//
+	// IMAGE WIDGET
+	//
+
+	function ImageWidget(imageLoader) {
+		this.init(imageLoader);
+	}
+
+	$.extend(ImageWidget.prototype, AbstractWidget.prototype, {
+
+		init : function(imageLoader) {
+			AbstractWidget.prototype.init.call(this, new ImageView(this));
+			this.imageLoader = imageLoader;
+		},
+
+		loadImage : function(imageData, callback) {
+			this.imageLoader.loadImage(imageData, callback);
+		},
+
+		getImageData : function(imageData) {
+			return this.imageData;
+		},
+
+		setImageData : function(imageData) {
+			this.imageData = imageData;
+			this.refresh();
+		}
+
+	});
+
+	return ImageWidget;
+
+});
\ No newline at end of file
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/MovieButtonsWidget.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/MovieButtonsWidget.js
new file mode 100644
index 0000000000000000000000000000000000000000..fb3b4b3c5c4a6290015ad805780418813828776a
--- /dev/null
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/MovieButtonsWidget.js
@@ -0,0 +1,225 @@
+define([ "jquery", "components/imageviewer/AbstractView", "components/imageviewer/AbstractWidget" ], function($, AbstractView, AbstractWidget) {
+
+	//
+	// MOVIE BUTTONS VIEW
+	//
+
+	function MovieButtonsView(controller) {
+		this.init(controller);
+	}
+
+	$.extend(MovieButtonsView.prototype, AbstractView.prototype, {
+
+		init : function(controller) {
+			AbstractView.prototype.init.call(this, controller);
+			this.panel = $("<div>").addClass("movieButtonsWidget").addClass("form-group");
+		},
+
+		render : function() {
+			var thisView = this;
+
+			var row = $("<div>").addClass("row").appendTo(this.panel);
+
+			var buttonsRow = $("<div>").addClass("buttons").addClass("row").appendTo(this.panel);
+			var delayRow = $("<div>").addClass("delay").addClass("form-inline").appendTo(this.panel);
+
+			$("<div>").addClass("col-md-6").append(buttonsRow).appendTo(row);
+			$("<div>").addClass("col-md-6").append(delayRow).appendTo(row);
+
+			var play = $("<button>").addClass("play").addClass("btn").addClass("btn-primary");
+			$("<span>").addClass("glyphicon").addClass("glyphicon-play").appendTo(play);
+			$("<div>").addClass("col-md-3").append(play).appendTo(buttonsRow);
+
+			play.click(function() {
+				thisView.controller.play();
+			});
+
+			var stop = $("<button>").addClass("stop").addClass("btn").addClass("btn-primary");
+			$("<span>").addClass("glyphicon").addClass("glyphicon-stop").appendTo(stop);
+			$("<div>").addClass("col-md-3").append(stop).appendTo(buttonsRow);
+
+			stop.click(function() {
+				thisView.controller.stop();
+			});
+
+			var prev = $("<button>").addClass("prev").addClass("btn").addClass("btn-default");
+			$("<span>").addClass("glyphicon").addClass("glyphicon-backward").appendTo(prev);
+			$("<div>").addClass("col-md-3").append(prev).appendTo(buttonsRow);
+
+			prev.click(function() {
+				thisView.controller.prev();
+			});
+
+			var next = $("<button>").addClass("next").addClass("btn").addClass("btn-default");
+			$("<span>").addClass("glyphicon").addClass("glyphicon-forward").appendTo(next);
+			$("<div>").addClass("col-md-3").append(next).appendTo(buttonsRow);
+
+			next.click(function() {
+				thisView.controller.next();
+			});
+
+			var delayTable = $("<table>").appendTo(delayRow);
+			var delayTr = $("<tr>").appendTo(delayTable);
+
+			$("<td>").append($("<span>").addClass("delayLabel").text("delay:").attr("for", "delayInput")).appendTo(delayTr);
+
+			var delay = $("<input>").attr("id", "delayInput").attr("type", "text").addClass("delay").addClass("form-control");
+			delay.change(function() {
+				thisView.controller.setSelectedDelay(delay.val());
+			});
+			$("<td>").attr("width", "100%").append(delay).appendTo(delayTr);
+
+			$("<td>").append($("<span>").addClass("delayUnit").text("ms")).appendTo(delayTr);
+
+			this.refresh();
+
+			return this.panel;
+		},
+
+		refresh : function() {
+			var play = this.panel.find("button.play");
+			play.prop("disabled", this.controller.isPlaying());
+
+			var stop = this.panel.find("button.stop");
+			stop.prop("disabled", this.controller.isStopped());
+
+			var prev = this.panel.find("button.prev");
+			prev.prop("disabled", this.controller.isFirstFrameSelected());
+
+			var next = this.panel.find("button.next");
+			next.prop("disabled", this.controller.isLastFrameSelected());
+
+			var delay = this.panel.find("input.delay");
+			delay.val(this.controller.getSelectedDelay());
+		}
+
+	});
+
+	//
+	// MOVIE BUTTONS WIDGET
+	//
+
+	function MovieButtonsWidget(frameCount) {
+		this.init(frameCount);
+	}
+
+	$.extend(MovieButtonsWidget.prototype, AbstractWidget.prototype, {
+
+		init : function(frameCount) {
+			AbstractWidget.prototype.init.call(this, new MovieButtonsView(this));
+			this.frameCount = frameCount;
+			this.frameContentLoader = function(frameIndex, callback) {
+				callback();
+			};
+			this.frameAction = null;
+			this.selectedDelay = 100;
+			this.selectedFrame = 0;
+		},
+
+		play : function() {
+			if (this.frameAction) {
+				return;
+			}
+
+			if (this.getSelectedFrame() == this.frameCount - 1) {
+				this.setSelectedFrame(0);
+			}
+
+			var thisButtons = this;
+
+			this.frameAction = function() {
+				if (thisButtons.getSelectedFrame() < thisButtons.frameCount - 1) {
+					var frame = thisButtons.getSelectedFrame() + 1;
+					var startTime = Date.now();
+
+					thisButtons.setSelectedFrame(frame, function() {
+						var prefferedDelay = thisButtons.selectedDelay;
+						var actualDelay = Date.now() - startTime;
+
+						setTimeout(function() {
+							if (thisButtons.frameAction) {
+								thisButtons.frameAction();
+							}
+						}, Math.max(1, prefferedDelay - actualDelay));
+					});
+				} else {
+					thisButtons.stop();
+					thisButtons.setSelectedFrame(0);
+				}
+			};
+
+			this.frameAction();
+			this.refresh();
+		},
+
+		stop : function() {
+			if (this.frameAction) {
+				this.frameAction = null;
+				this.refresh();
+			}
+		},
+
+		prev : function() {
+			this.setSelectedFrame(this.getSelectedFrame() - 1);
+		},
+
+		next : function() {
+			this.setSelectedFrame(this.getSelectedFrame() + 1);
+		},
+
+		isPlaying : function() {
+			return this.frameAction != null;
+		},
+
+		isStopped : function() {
+			return this.frameAction == null;
+		},
+
+		isFirstFrameSelected : function() {
+			return this.getSelectedFrame() == 0;
+		},
+
+		isLastFrameSelected : function() {
+			return this.getSelectedFrame() == (this.frameCount - 1)
+		},
+
+		getSelectedDelay : function() {
+			return this.selectedDelay;
+		},
+
+		setSelectedDelay : function(delay) {
+			if (this.selectedDelay != delay) {
+				this.selectedDelay = delay;
+				this.refresh();
+			}
+		},
+
+		getSelectedFrame : function() {
+			return this.selectedFrame;
+		},
+
+		setSelectedFrame : function(frame, callback) {
+			frame = Math.min(Math.max(0, frame), this.frameCount - 1);
+
+			if (this.selectedFrame != frame) {
+				// log("Selected frame: " + frame);
+				this.selectedFrame = frame;
+				this.frameContentLoader(frame, callback);
+				this.refresh();
+				this.notifyChangeListeners();
+			}
+		},
+
+		setFrameContentLoader : function(frameContentLoader) {
+			this.frameContentLoader = frameContentLoader;
+		},
+
+		getFrameContentLoader : function(frameContentLoader) {
+			return this.frameContentLoader;
+		}
+
+	});
+
+	return MovieButtonsWidget;
+
+});
\ No newline at end of file
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/OpenbisFacade.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/OpenbisFacade.js
new file mode 100644
index 0000000000000000000000000000000000000000..a226f5e679050885b92ed3f851425e7649cf8886
--- /dev/null
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/OpenbisFacade.js
@@ -0,0 +1,48 @@
+define([ "jquery" ], function($) {
+
+	//
+	// FACADE
+	//
+
+	function OpenbisFacade(openbis) {
+		this.init(openbis);
+	}
+
+	$.extend(OpenbisFacade.prototype, {
+		init : function(openbis) {
+			this.openbis = openbis;
+		},
+
+		getSession : function() {
+			return this.openbis.getSession();
+		},
+
+		getDataStoreBaseURLs : function(dataSetCodes, action) {
+			this.openbis.getDataStoreBaseURLs(dataSetCodes, function(response) {
+				var dataSetCodeToUrlMap = {};
+
+				if (response.result) {
+					response.result.forEach(function(urlForDataSets) {
+						urlForDataSets.dataSetCodes.forEach(function(dataSetCode) {
+							dataSetCodeToUrlMap[dataSetCode] = urlForDataSets.dataStoreURL;
+						});
+					});
+					response.result = dataSetCodeToUrlMap;
+				}
+
+				action(response);
+			});
+		},
+
+		getImageInfo : function(dataSetCodes, callback) {
+			this.openbis.getImageInfo(dataSetCodes, callback);
+		},
+
+		getImageResolutions : function(dataSetCodes, callback) {
+			this.openbis.getImageResolutions(dataSetCodes, callback);
+		}
+	});
+
+	return OpenbisFacade;
+
+});
\ No newline at end of file
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ResolutionChooserWidget.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ResolutionChooserWidget.js
new file mode 100644
index 0000000000000000000000000000000000000000..8a3ceb69f57dd9049f077984b6bd5ed5dc1edbff
--- /dev/null
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/ResolutionChooserWidget.js
@@ -0,0 +1,107 @@
+define([ "jquery", "components/imageviewer/AbstractView", "components/imageviewer/AbstractWidget" ], function($, AbstractView, AbstractWidget) {
+
+	//
+	// RESOLUTION CHOOSER VIEW
+	//
+
+	function ResolutionChooserView(controller) {
+		this.init(controller);
+	}
+
+	$.extend(ResolutionChooserView.prototype, AbstractView.prototype, {
+
+		init : function(controller) {
+			AbstractView.prototype.init.call(this, controller);
+			this.panel = $("<div>").addClass("resolutionChooserWidget").addClass("form-group");
+		},
+
+		render : function() {
+			var thisView = this;
+
+			$("<label>").text("Resolution").attr("for", "resolutionChooserSelect").appendTo(this.panel);
+
+			var select = $("<select>").attr("id", "resolutionChooserSelect").addClass("form-control").appendTo(this.panel);
+			$("<option>").attr("value", "").text("Default").appendTo(select);
+
+			this.controller.getResolutions().forEach(function(resolution) {
+				var value = resolution.width + "x" + resolution.height;
+				$("<option>").attr("value", value).text(value).appendTo(select);
+			});
+
+			select.change(function() {
+				if (select.val() == "") {
+					thisView.controller.setSelectedResolution(null);
+				} else {
+					thisView.controller.setSelectedResolution(select.val());
+				}
+			});
+
+			this.refresh();
+
+			return this.panel;
+		},
+
+		refresh : function() {
+			var select = this.panel.find("select");
+
+			if (this.controller.getSelectedResolution() != null) {
+				select.val(this.controller.getSelectedResolution());
+			} else {
+				select.val("");
+			}
+		}
+
+	});
+
+	//
+	// RESOLUTION CHOOSER
+	//
+
+	function ResolutionChooserWidget(resolutions) {
+		this.init(resolutions);
+	}
+
+	$.extend(ResolutionChooserWidget.prototype, AbstractWidget.prototype, {
+
+		init : function(resolutions) {
+			AbstractWidget.prototype.init.call(this, new ResolutionChooserView(this));
+			this.setResolutions(resolutions);
+		},
+
+		getSelectedResolution : function() {
+			return this.selectedResolution;
+		},
+
+		setSelectedResolution : function(resolution) {
+			if (this.selectedResolution != resolution) {
+				this.selectedResolution = resolution;
+				this.refresh();
+				this.notifyChangeListeners();
+			}
+		},
+
+		getResolutions : function() {
+			if (this.resolutions) {
+				return this.resolutions;
+			} else {
+				return [];
+			}
+		},
+
+		setResolutions : function(resolutions) {
+			if (!resolutions) {
+				resolutions = [];
+			}
+
+			if (this.getResolutions().toString() != resolutions.toString()) {
+				this.resolutions = resolutions;
+				this.refresh();
+				this.notifyChangeListeners();
+			}
+		}
+
+	});
+
+	return ResolutionChooserWidget;
+
+});
\ No newline at end of file
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/css/image-viewer.css b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/css/image-viewer.css
new file mode 100644
index 0000000000000000000000000000000000000000..52a64d474bd8d2d87dde76392b8e9b52bb447626
--- /dev/null
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/components/imageviewer/css/image-viewer.css
@@ -0,0 +1,23 @@
+.imageViewer .slider.slider-horizontal {
+	width: 100%;
+}
+
+.imageViewer .movieButtonsWidget .delay input {
+	width: 100%;
+}
+
+.imageViewer .movieButtonsWidget .delayLabel {
+	padding-right: 5px;
+}
+
+.imageViewer .movieButtonsWidget .delayUnit {
+	padding-left: 5px;
+}
+
+.imageViewer .movieButtonsWidget button {
+	width: 100%;
+}
+
+.imageViewer .imageWidget {
+	margin-top: 20px;
+}
\ No newline at end of file
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/js/openbis-screening.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/js/openbis-screening.js
index f8e4a23229724052c9675de30b6f61b343a8585c..a445cba1d6a9c1608ec52b6c4b204979cd97974e 100644
--- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/js/openbis-screening.js
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/js/openbis-screening.js
@@ -144,27 +144,27 @@ openbis.prototype.listImageDatasets = function(plateIdentifiers, action) {
 }
 
 /**
- * @see IScreeningApiServer.getImageInfo(String, String, WellLocation)
+ * @see IScreeningApiServer.getImageInfo(String, List<String>)
  * @method
  */
-openbis.prototype.getImageInfo = function(dataSetCode, wellLocation, action) {
+openbis.prototype.getImageInfo = function(dataSetCodes, action) {
     this._internal.ajaxRequest({
             url: this._internal.screeningUrl,
             data: { "method" : "getImageInfo",
-                    "params" : [ this.getSession(), dataSetCode, wellLocation ] },
+                    "params" : [ this.getSession(), dataSetCodes ] },
             success: action
     });
 }
 
 /**
- * @see IScreeningApiServer.getImageResolutions(String, String)
+ * @see IScreeningApiServer.getImageResolutions(String, List<String>)
  * @method
  */
-openbis.prototype.getImageResolutions = function(dataSetCode, action) {
+openbis.prototype.getImageResolutions = function(dataSetCodes, action) {
     this._internal.ajaxRequest({
             url: this._internal.screeningUrl,
             data: { "method" : "getImageResolutions",
-                    "params" : [ this.getSession(), dataSetCode ] },
+                    "params" : [ this.getSession(), dataSetCodes ] },
             success: action
     });
 }