var Mnet = new Class();			
	
// Use this method for any duration to allow transitions to be turned off
Mnet.showTransitions = true;
Mnet.getDuration = function(duration) {
	return Mnet.showTransitions && $defined(duration) ? duration : 0;
};

/* Debug */
if(!window.console) {
	window.console = {
		init: function() {
			if(!document.body)
				return false;
				
			if(!$defined(this.el)) {
				this.el = new Element('div', { id:'debug', style:'position:fixed; top:0px; left:0px; background-color:#FFFFFF; color:#000; ' +
					' width:200px; height:12px; z-index:10; text-align:left; line-height:12px; font-size:10px;' }); 
					
				var elClose = new Element('a', { href:'javascript:console.clear();', html:'[X]', style:'position:absolute; right:0px; color:#000;' });
				this.el.appendChild(elClose);
		
				this.elText = new Element('div', {  });
				this.el.appendChild(this.elText);
				
				document.body.appendChild(this.el);
			}
			else
				this.el.setStyle('visibility', 'visible');
				
			return true;
		},
		log: function() {
			if(!this.init()) return; 
				
			var txt = this.elText.get('html');
			if(txt != '')
				txt = txt + '<br/>' + txt;
				
			this.el.setStyle('height', this.elText.getStyle('height').toInt() + 12);
			this.set(txt);
		},
		set: function(txt) {
			if(!this.init()) return;
			this.elText.set('html', txt);
		},
		clear: function() {
			if(!this.init()) return;
			this.set('');
			this.el.setStyle('height', 12);
			this.el.setStyle('visibility', 'hidden');
		}
	};
};

/* Flash class */
Mnet.Flash = new Class();
Mnet.Flash.installed = (Browser.Plugins.Flash.version >= 6);
Mnet.Flash.object = function(container, src, width, height, params, vars, events) {
	if(!Mnet.Flash.installed)
		return null;

	if(!$defined(Mnet.rootUrl))
		Mnet.rootUrl = '';

	if(!$defined(params)) params = {};
	if(!$defined(vars)) vars = {};

	var options = {
	    width: width,
	    height: height,
		container: container,
	   	params: params, 
	    vars: vars,
		events: events
	};

	if(!src.match(/^\w+:\/\/|^\//))
		src = Mnet.rootUrl + 'Denny/flash/' + src + '.swf';
	
	if(params.makeVisible && $(container).getStyle('visibility') == 'hidden')
		$(container).setStyle('visibility', 'visible');

	var o = new Swiff(src, options);
	return o;
}

// Flash titles
Mnet.FlashTitles = {
	currentId:0,
	
	// Load all titles on the page
	scanPage: function(root) {
		if(!root)
			root = document.body;
		root = $(root);
		
		var _this = this;
		for(var classPath in this.setup) {
			var setup = this.setup[classPath];
			var elements = root.getElements(classPath);
			
			elements.each(function(element) {
				// Make sure not already updated
				if(element.retrieve('Mnet.FlashTitles.implemented'))
					return;
					
				if(!element.id)
					element.id = 'ft_auto_'+(++_this.currentId);
				
				var width = element.offsetWidth;
				var height = element.offsetHeight;
				var font = 'ft_' + setup.font;
				// Get content (strip all but break tags)
				var title = element.get('html').replace(/<br\s*\/?>/ig, '{{BR}}').replace(/<([^>]+)>/g, '').replace(/{{BR}}/g, '<br/>');

				// No title, skip it
				if(title == '')
					return;
					
				if(setup.texttransform == 'uppercase')
					title = title.toUpperCase();
				else if(setup.texttransform == 'lowercase')
					title = title.toLowerCase();
				
				/*
				var res = "";
				for (i=0;i < title.length; i++) {
				    res += title.charCodeAt(i) + ',';
				}
				res = res.substr(0, res.length - 1);
				*/
				
				var args = {
					title:title,
					textsize:setup.textsize,
					textcolour:setup.textcolour,
					textspacing:setup.textspacing,
					lineheight:setup.lineheight
				};

				// Add link if set
				if(element.get('tag') == 'a')
					args.link = element.href;

				// Remove any padding
				width -= element.getStyle('padding-left').toInt() + element.getStyle('padding-right').toInt();;
				height -= element.getStyle('padding-top').toInt() + element.getStyle('padding-bottom').toInt();;
				
				if(setup.setheight) {
					element.setStyle('height', height + 'px');
				}
				
				if(Mnet.testing.flashTitles)
					Mnet.Flash.object.delay(1000, Mnet.Flash, [element.id,font,width,height,{makeVisible:true},args]);
				else
					Mnet.Flash.object(element.id,font,width,height,{makeVisible:true},args);
				
				// Store so if matched again it won't update title again
				element.store('Mnet.FlashTitles.implemented', true);
			});
		}
	}
};

Element.implement({
	getFullHeight: function() {
		return this.offsetHeight.toInt() +
			this.getStyle('marginTop').toInt() +
			this.getStyle('marginBottom').toInt();
	},
	getFullWidth: function() {
		return this.offsetWidth.toInt() + 
			this.getStyle('marginLeft').toInt() +
			this.getStyle('marginRight').toInt();
	}
});

/* Image loader */
Mnet.SerialImageLoader = new Class({
	imageIndex: 0,
	
	initialize: function(options) {
		if(!$defined(options))
			options = {}

		this.onProgress = $defined(options.onProgress) ? options.onProgress : $empty;
		this.onComplete = $defined(options.onComplete) ? options.onComplete : $empty;
	},
	
	addImages: function(images) {
		if(!$defined(this.imageArray))
			this.imageArray = [];
		
		this.imageArray.extend(images);
	},
	
	load: function() {
		this.imageCount = this.imageArray.length;
		this.imageIndex = -1;
		
		// Call onload method - first time will init and load first image
		this.onLoad();
	},
	
	onLoad: function() {
		// First load call? init images array and skip event calling
		if(!$defined(this.images))
			this.images = [];
		else {
			this.onProgress(this.images[this.imageIndex], this.imageIndex, this.imageCount);
		}
		
		// More images to load?
		if(++this.imageIndex < this.imageCount) {
			var image = this.imageArray[this.imageIndex];
			var src = null;
			if($type(image) == 'string')
				src = image;
			else if(image.tagName.toLowerCase() == 'img')
				src = image.src;
			else {
				var img = image.getElement('img');
				if(img)
					src = img.src;
			}

			if(src != null)
				this.images.push(new Asset.image(src, {onload:this.onLoad.bind(this)}));
			else {
				// No image found, add null object
				this.images.push(null);
				this.onLoad();
			}
		}
		else
			this.onComplete(this.imageCount);
	}
});

/* Gallery */
Mnet.Gallery = new Class({
	Implements: Options,
	
	options: {
		fadeDuration:700,
		display:0,
		thumbFaded:0.5,
		thumbFadeDuration:200,
		addHolderLink:true,
		imageElements:'img',
		align:'left'
	},
	
	initialize: function(holder, thumbnails, thumbnailHolder, options) {
		this.setOptions(options);
		
		this.holder = $(holder);
		this.images = this.holder.getElements(this.options.imageElements);
		
		if($defined(thumbnails))				
			this.thumbnails = $(thumbnails).getElements(thumbnailHolder);				
		
		this.currentIndex = -1;
		this.maxIndex = this.images.length - 1;
		
		if(this.maxIndex < 0)
			return;
		
		var align = (this.options.align == 'right') ? 'right' : 'left';
		
		this.images.each(function(item, index) {
			item = item.setStyles({
				position:'absolute',
				//left:'0px',	
				//top:'0px',
				opacity:0
			});
			
			if(align != 'left')
			item.setStyle(align, '0px');
			item.set('tween', {'link':'cancel','duration': Mnet.getDuration(this.options.fadeDuration)});
			
			if(item.get('tag') == 'a' || item.getParent().get('tag') == 'a')
				this.options.addHolderLink = false;
		}, this);
		
		// If images don't already have links on them, add next() link to holder
		if(this.options.addHolderLink) {
			this.holder.setStyles({
				cursor:'pointer'
			}).addEvent('click', this.next.bind(this));
		}
				
		if($defined(this.thumbnails)) {
			this.thumbnails.each(function(item, index) {
				item
				.setStyles({cursor:'pointer','opacity':this.options.thumbFaded})
				.set('tween', {'link':'cancel','duration': Mnet.getDuration(this.options.thumbFadeDuration)})
				.addEvent('click', function() {
					this.display(index);	
				}.bind(this))
				.addEvent('mouseover', function() {
					item.tween('opacity', 1);
				}.bind(this))
				.addEvent('mouseout', function() {
					if(index != this.currentIndex)
						item.tween('opacity', this.options.thumbFaded);
				}.bind(this));
			}, this);
		}
		
		// Make sure image is loaded before displaying
		var img = this.images[this.options.display];
		if(img.get('tag') != 'img')
			img = img.getElement('img');
		if(img.complete) this.display(this.options.display, true);
		else img.onload = this.display.bind(this, [this.options.display, true]);
	},
	
	display: function(index, firstTime) {
		if(this.currentIndex == index)
			return;
		
		// Update holder height		
		this.holder.setStyle('height', this.images[index].getFullHeight());
				
		if(this.currentIndex >= 0) {
			this.images[this.currentIndex].tween('opacity', 0);
			if($defined(this.thumbnails))
				this.thumbnails[this.currentIndex].tween('opacity', this.options.thumbFaded);
		}
		
		if(firstTime)
			this.images[index].setStyle('opacity', 1);
		else
		this.images[index].tween('opacity', 1);
		if($defined(this.thumbnails))
			this.thumbnails[index].set('opacity', 1);
		
		this.currentIndex = index;
		
		if(this.options.onDisplay)
			this.options.onDisplay.run([index, this.images[index]], this);
	},
	
	prev: function() {
		var index = this.currentIndex - 1;
		this.display(index < 0 ? this.maxIndex : index);
	},
	
	next: function() {
		var index = this.currentIndex + 1;
		this.display(index > this.maxIndex ? 0 : index);
	},
	
	link: function() {
		var item = this.images[this.currentIndex];
		var parent = item.getParent();
		
		if(parent.get('tag') == 'a') {
			if(parent.hasEvent('click'))
				parent.fireEvent('click');
			else {
				var href = parent.href;
				if($type(href) == 'function')
					(href)();
				else if($type(href) == 'string' && href != '')
					document.location.href = href;
			}
		}
	},
	// Unload
	unload: function() {
		this.holder = null;
		this.images = null;
		this.thumbnails = null;
	}
});

Mnet.Gallery2 = new Class({
	Implements: Options,
	
	options: {
		fadeDuration:700,
		display:0,
		thumbFaded:0.5,
		thumbFadeDuration:200,
		addHolderLink:true,
		thumbnailLink:'a',
		align:'left',
		alignOffset:0
	},
	
	initialize: function(holder, thumbnails, options) {
		this.setOptions(options);
		
		this.holder = $(holder);
		this.thumbnails = $(thumbnails).getElements(this.options.thumbnailLink);				
		this.loader = this.holder.getElement('.loader');
			
		this.images = {};
		
		this.currentIndex = -1;
		this.maxIndex = this.thumbnails.length - 1;
		
		if(this.maxIndex < 0)
			return;
		
		// setOptions i think clones objects rather that using its reference
		if(options && options.eventReference)
			this.options.eventReference = options.eventReference;
			
		this.thumbnails.each(function(item, index) {
			item
			.setStyles({cursor:'pointer','opacity':this.options.thumbFaded})
			.set('tween', {'link':'cancel','duration': Mnet.getDuration(this.options.thumbFadeDuration)})
			.addEvent('click', function(e) {
				e.preventDefault();

				// Make sure event should happen (e.g shouldn't do if dragging) 
				if(!$defined(this.options.eventReference) || !this.options.eventReference.checkEvent('click')) {
					//console log('gallery click');
					this.display(index);
				}
				else {
					if($defined(this.options.eventReference))
						this.options.eventReference.clearEvent('click');
					//console log('skip');
				}
			}.bind(this))
			.addEvent('mouseover', function() {
				item.tween('opacity', 1);
			}.bind(this))
			.addEvent('mouseout', function() {
				if(index != this.currentIndex)
					item.tween('opacity', this.options.thumbFaded);
			}.bind(this));
		}, this);

		if(this.options.display >= 0 && this.options.display <= this.maxIndex)
			this.display(this.options.display);
	},
	
	display: function(index, firstTime, checkIndex) {
		if(!this.images || this.currentIndex == index)
			return;
			
		if(!this.images[index]) {
			if(this.loader)
				this.loader.setStyle('display', 'block');
				
			var thumb = this.thumbnails[index];
			var src = thumb.href;
			
			// Get image url
			var img = new Element('img', {
				src:src,
				events:{
					load:this.display.bind(this, [index, firstTime, this.currentIndex])
				},
				styles:{
					position:'absolute',
					//left:'0px',
					//top:'0px',
					opacity:0
				}
			});
			this.images[index] = img;
			
			var align = (this.options.align == 'right') ? 'right' : 'left';
			if(align != 'left')
				img.setStyle(align, this.options.alignOffset + 'px');
			img.set('tween', {'link':'cancel','duration': Mnet.getDuration(this.options.fadeDuration)});

			img.inject(this.holder);
		}
		// If index has changed while image was loading don't display the old image
		else if(checkIndex == null || checkIndex == this.currentIndex) { //if(this.images[index].complete) {
			// If not complete wait 1s (mainly for ie)
			if(!this.images[index].complete) {
				if(this.loader)
					this.loader.setStyle('display', 'block');
				this.display.delay(1000, this, [index, firstTime, checkIndex])
				return;
			}

			// Hide loader 
			if(this.loader)
				this.loader.setStyle('display', 'none');
			
			// Update holder height		
			//this.holder.setStyle('height', this.images[index].getFullHeight());

			if(this.currentIndex >= 0) {
				this.images[this.currentIndex].tween('opacity', 0);
				this.thumbnails[this.currentIndex].tween('opacity', this.options.thumbFaded);
			}
			
			if(firstTime)
				this.images[index].setStyle('opacity', 1);
			else
				this.images[index].tween('opacity', 1);
	
			this.thumbnails[index].set('opacity', 1);
			
			this.currentIndex = index;
			
			if(this.options.onDisplay)
				this.options.onDisplay(index);
		}
	},
	
	prev: function() {
		var index = this.currentIndex - 1;
		this.display(index < 0 ? this.maxIndex : index);
	},
	
	next: function() {
		var index = this.currentIndex + 1;
		this.display(index > this.maxIndex ? 0 : index);
	},
	
	link: function() {
		var item = this.images[this.currentIndex];
		var parent = item.getParent();
		
		if(parent.get('tag') == 'a') {
			if(parent.hasEvent('click'))
				parent.fireEvent('click');
			else {
				var href = parent.href;
				if($type(href) == 'function')
					(href)();
				else if($type(href) == 'string' && href != '')
					document.location.href = href;
			}
		}
	},
	// Unload
	unload: function() {
		this.holder = null;
		this.images = null;
		this.thumbnails = null;
	}
});

Mnet.Gallery3 = new Class({
	Implements: Options,
	
	options: {
		fadeDuration:700,
		align:'left',
		alignOffset:0
	},
	
	initialize: function(holder, options) {
		this.setOptions(options);
		
		this.holder = $(holder);
		this.loader = this.holder.getElement('.loader');
		this.currentSrc = null;
		
		this.images = {};
	},
	
	display: function(src, firstTime, checkSrc) {
		if(this.currentSrc == src)
			return;
			
		if(!this.images[src]) {
			if(this.loader)
				this.loader.setStyle('display', 'block');
			
			// Get image url
			var img = new Element('img', {
				src:src,
				events:{
					load:this.display.bind(this, [src, firstTime, this.currentSrc])
				},
				styles:{
					position:'absolute',
					//left:'0px',
					//top:'0px',
					opacity:0
				}
			});
			this.images[src] = img;
			
			var align = (this.options.align == 'right') ? 'right' : 'left';
			if(align != 'left')
				img.setStyle(align, this.options.alignOffset + 'px');
			img.set('tween', {'link':'cancel','duration': Mnet.getDuration(this.options.fadeDuration)});

			img.inject(this.holder);
		}
		// If index has changed while image was loading don't display the old image
		else if(checkSrc == null || checkSrc == this.currentSrc) { //if(this.images[index].complete) {
			// If not complete wait 1s (mainly for ie)
			if(!this.images[src].complete) {
				if(this.loader)
					this.loader.setStyle('display', 'block');
				this.display.delay(1000, this, [src, firstTime, checkSrc])
				return;
			}

			// Hide loader 
			if(this.loader)
				this.loader.setStyle('display', 'none');
			
			// Update holder height		
			//this.holder.setStyle('height', this.images[index].getFullHeight());

			if(this.currentSrc != null)
				this.images[this.currentSrc].tween('opacity', 0);
			
			if(firstTime)
				this.images[src].setStyle('opacity', 1);
			else
				this.images[src].tween('opacity', 1);
	
			this.currentSrc = src;
			
			if(this.options.onDisplay)
				this.options.onDisplay(src);
		}
	},
	
	prev: function() {
		var index = this.currentIndex - 1;
		this.display(index < 0 ? this.maxIndex : index);
	},
	
	next: function() {
		var index = this.currentIndex + 1;
		this.display(index > this.maxIndex ? 0 : index);
	},
	
	link: function() {
		var item = this.images[this.currentIndex];
		var parent = item.getParent();
		
		if(parent.get('tag') == 'a') {
			if(parent.hasEvent('click'))
				parent.fireEvent('click');
			else {
				var href = parent.href;
				if($type(href) == 'function')
					(href)();
				else if($type(href) == 'string' && href != '')
					document.location.href = href;
			}
		}
	},
	// Unload
	unload: function() {
		this.holder = null;
		this.images = null;
	}
});

Mnet.VariableSizeObjectLoopScroller = new Class({
	Implements: Options,
	
	options:{
		duration:500,
		delay:-1,
		transition:Fx.Transitions.Sine.easeInOut,
		link:'chain',
		show:0,
		onReady:$empty,
		maxHeight:-1,
		objects:'img',
		direction:'left',
		wrap:true,
		fullWidth:false,
		allowDrag:false,
		leftOffset:0,
		loadImages:true,
		alwaysScrollable:false,
		autoLoad:true
	},
		
	initialize: function(id, options) {
		this.setOptions(options);

		this.contentWrapper = $(id);
		
		this.contentDiv = $(id + '-body');
		
		this.mover = new Fx.Morph(this.contentDiv, {
			duration: Mnet.getDuration(this.options.duration), 
			transition: this.options.transition,
			link: this.options.link
		});

		this.contentSize = 0;
		this.contentVSize = 0;
 		
		switch(this.options.direction) {
		default:
		case 'left':
		case 'right':
			this.moveStyle = 'left';
			this.offsetSizeStyle = 'offsetWidth';
			this.sizeStyle = 'width';
			this.sizeVStyle = 'height';
			this.directionReverse = (this.options.direction == 'right');
		break;
		case 'up':
		case 'down':
			this.moveStyle = 'top';
			this.offsetSizeStyle = 'offsetHeight';
			this.sizeStyle = 'height';
			this.sizeVStyle = 'width';
			this.directionReverse = (this.options.direction == 'down');
		break;
		}
		
		// Make sure div isn't set to auto (ie problem)
		if(isNaN(this.contentDiv.getStyle(this.moveStyle).toInt()))
			this.contentDiv.setStyle(this.moveStyle, '0');

		this.contentWrapperSize = this.contentWrapper[this.offsetSizeStyle];
		
		this.items = this.contentDiv.getElements(this.options.objects);
		this.itemSizes = [];
				
		this.itemCount = 0;
		this.itemIndex = 0;

		if(this.options.leftOffset)
			this.contentDiv.setStyle(this.moveStyle, this.options.leftOffset);

		this.eventFlags = {};

		if(this.options.autoLoad)
			this.load();
	},

	load: function() {
		if(this.options.loadImages) {
			this.imageLoader = new Mnet.SerialImageLoader({ onProgress:this.onProgress.bind(this) });
			this.imageLoader.addImages(this.items);
			this.imageLoader.load();
		}
		else {
			this.items.each(function(item, index) {
				this.onProgress(item, index, this.items.length);
			}.bind(this));
		}
	},
	
	setEvent: function(eventName) { this.eventFlags[eventName] = true; },
	checkEvent: function(eventName) { return this.eventFlags[eventName]; },
	clearEvent: function(eventName) { delete this.eventFlags[eventName]; },
	
	onProgress: function(item, index, count, reload) {
		if(!this.items)
			return;
			
		this.itemCount++;
		
		item = $(this.items[index]);
		
		var size = (this.moveStyle == 'left') ? item.getFullWidth() : item.getFullHeight();
		
		// Set width/height for the item in case in % value
		if(this.options.forceItemSize) {
			item.setStyle(this.sizeStyle, (this.moveStyle == 'left' ? item.offsetWidth : item.offsetHeight) + 'px');
		}
		
		if(this.options.wrap)
			this.itemSizes[index] = size;
		else
			this.itemSizes[index] = size;
			//this.itemSizes[index] = this.contentSize;
		this.contentSize += size;
		
		//if(height > this.contentHeight)
		//	this.contentHeight = height;
		
		// Ready? set size and start scroll
		if(index == count - 1) {
			this.contentDiv.setStyle(this.sizeStyle, this.contentSize + 1000);

			if(!reload) {
				// Reverse the order of the items?
				if(this.directionReverse && this.items.length > 1) {
					size = this.itemSizes[this.items.length - 1];
					for(var i = this.items.length - 2; i >= 1; i--) {
						item = this.contentDiv.removeChild(this.items[i]);
						this.contentDiv.appendChild(item);
						//this.items[i] =  item;
						if(i > 0)
							size += this.itemSizes[index];
					}
					
					//this.contentDiv.setStyle(this.moveStyle, -size);
				}

				//this.contentVSize = (this.moveStyle == 'left') ? this.contentWrapper.getFullHeight() : this.contentWrapper.getFullWidth();
				this.contentVSize = (this.moveStyle == 'left') ? this.contentWrapper.offsetHeight : this.contentWrapper.offsetWidth;
				
				if(this.options.maxHeight > 0 && this.contentVSize > this.options.maxHeight)
					this.contentVSize = this.options.maxHeight;
					
				// Set wrapper height and make content movable
				this.contentWrapper.setStyle(this.sizeVStyle, this.contentVSize);
				this.contentDiv.setStyle('position', 'absolute');
				
				//this.contentWrapper.setStyle('height', this.contentHeight);
				
				this.ready = true;
				this.scrollable = this.options.alwaysScrollable || (this.contentSize > this.contentWrapperSize);
				
				//console log(this.contentSize +":"+ this.contentWrapperSize + ":" + this.scrollable);
				
				// If scrollable and full width set expanded wrapper
				if(this.options.fullWidth && this.scrollable) {
					// Get new offset, width and scrollable flag
					this.options.leftOffset += this.contentWrapper.offsetLeft;
					this.contentWrapper.setStyle('position', 'absolute');

					this.contentWrapperSize = this.contentWrapper[this.offsetSizeStyle];
					this.scrollable = this.options.alwaysScrollable || (this.contentSize > this.contentWrapperSize);
					
					if(this.options.leftOffset)
						this.contentDiv.setStyle(this.moveStyle, this.options.leftOffset);
				}

				this.updateLastIndex();
				
				if(this.options.allowDrag && this.scrollable) {
					var _this = this;
					

					/*.
					addEvent('mouseup', function(e) {
						 console log(this);
					});
					*/

					this.drag = new Mnet.Drag(this.contentDiv, {
						preventDefault: true,
					    snap: 5,
						limit: this.getDragLimit(),
						onBeforeStart: function() {
							_this.contentDiv.addClass('dragging');
						},
						onStart: function(el, e) {
							_this.dragging = true;
							_this.setEvent('click');
						},
						onRelease: function(el, e) {
							// Delay to make sure click events are fired before dragging flag is cleared
							(function() { _this.dragging = false; _this.clearEvent('click'); }).delay(1);
						},
					    onComplete: function(el, e){
							_this.contentDiv.removeClass('dragging');
							
							// Update target position
							_this.updateIndex(_this.contentDiv.getStyle(_this.moveStyle).toInt());
		
							//_this.dragComplete(el, e);
							//console log('complete');
							//e.stop();
							//e.preventDefault();
					    },
						onCancel: function(el, e){
							_this.dragging = false;
							_this.contentDiv.removeClass('dragging');
					    }
					});
										
				}
				
				if(this.options.delay > 0)
					this.play();
				
				this.options.onReady.bind(this)();
			}
		}
	},
	// Update last move to index
	updateLastIndex: function() {
		var lastIndex = this.itemCount - 1;
		
		if(!this.options.wrap) {
			var size = this.contentWrapperSize;
			while(lastIndex >= 0 && size > 0) {
				size -= this.itemSizes[lastIndex];
				if(size > 0)
					lastIndex--;
				//console log(size + ":" + lastIndex);
			}
			lastIndex++;
		}
		
		this.lastIndex = lastIndex;
	},
	// Update content wrapper size
	updateSize: function() {
		if(!this.ready)
			return;

		var newSize = this.contentWrapper[this.offsetSizeStyle];
		if(newSize == this.contentWrapperSize)
			return; 
		
		this.contentWrapperSize = newSize;
		
		//console log(this.contentSize +":"+ this.contentWrapperSize);
		
		// Check if scrollable
		this.scrollable = this.options.alwaysScrollable || (this.contentSize > this.contentWrapperSize);

		this.updateLastIndex();

		if(this.drag) {
			this.drag.options.limit = this.getDragLimit();
		}
		
		// Call on ready method
		this.options.onReady.bind(this)();
	},
	// Reload content items
	reload: function() {
		this.contentSize = 0;
		this.itemCount = 0;
		
		var count = this.items.length;
		for(var i = 0; i < count; i++) {
			this.onProgress(null, i, count, true);
		}
	},
	// Play/pause
	playPause: function() {
		if(this.playing())
			this.pause();
		else
			this.play();
	},
	// Playing flag
	playing: function() { return (this.timerId != null); },
	// Play
	play: function() { 
		if(!this.ready) return;
		
		// Only scroll if needed
		if(!this.playing() && this.scrollable)
			this.timerId = this.next.periodical(this.options.delay, this);
	},
	// Pause
	pause: function() { 
		if(!this.ready) return;
			
		if(this.playing()) {
			$clear(this.timerId);
			this.timerId = null;
		}
	},
	// Move prev/next/to
	prev: function() { this.move(this.itemIndex - 1); },
	next: function() { this.move(this.itemIndex + 1); },
	moveTo: function(index) { this.move(index); },
	// Move chain method
	move2: function() {
		var item = this.items[this.prevIndex];
		
		// Get node right under content div
		while(item.parentNode != this.contentDiv)
			item = item.parentNode;
				
		this.contentDiv.appendChild(this.contentDiv.removeChild(item));
		
		// Reset div position		
		this.contentDiv.setStyle(this.moveStyle, this.options.leftOffset);
				
		this.move3();
	},
	// Move chain method
	move3: function() {
		this.moving = false;

		if(this.targetIndex != this.itemIndex)
			this.move(this.targetIndex);
	},
	// Move
	move: function(nextIndex) {
		if(!this.ready || this.moving || !this.scrollable) return false;
		
		var thisIndex = this.itemIndex;
		//var nextIndex = (thisIndex + direction);
		
		direction = nextIndex - thisIndex;
		if(direction == 0)
			return;

		// Store target index
		this.targetIndex = nextIndex;
		if(this.options.wrap)
			this.targetIndex = (nextIndex + this.itemCount) % this.itemCount;
		else if(nextIndex < 0)
			this.targetIndex = 0;
		else if(nextIndex > this.lastIndex)
			this.targetIndex = this.lastIndex;
		else
			this.targetIndex = nextIndex;
		
		if(direction > 1)
			nextIndex = thisIndex + 1;
		else if(direction < -1)
			nextIndex = thisIndex - 1;
			 
		//console log(this.itemIndex +":" + nextIndex +":" + direction);
		
		//console log(nextIndex +":" + direction);
		
		if(this.options.wrap)
			nextIndex = (nextIndex + this.itemCount) % this.itemCount;
		else {
			if(nextIndex < 0 || nextIndex >= this.itemCount)
				return false;
			else if(nextIndex > this.lastIndex)
				nextIndex = this.lastIndex;
		}

		this.moving = true;

		this.prevIndex = thisIndex;
		this.itemIndex = nextIndex;
		
		if(this.options.wrap) {
			if(this.directionReverse)
				direction = -direction;

			if(direction >= 0) {
				var args = {}; args[this.moveStyle] = -this.itemSizes[thisIndex] + this.options.leftOffset;
				this.mover.start(args).chain(
					this.move2.bind(this)
				);
			}
			else {
				var item = this.items[nextIndex];
					
				// Get node right under content div
				while(item.parentNode != this.contentDiv)
					item = item.parentNode;

				var i = this.contentDiv.removeChild(item);		
				i.inject(this.contentDiv, 'top');
						
				//var i = this.contentDiv.removeChild(item);		
				//i.inject(this.contentDiv, 'top');
				
				// Reset div position		
				this.contentDiv.setStyle(this.moveStyle, -this.itemSizes[nextIndex]);

				// Scroll
				var args = {}; args[this.moveStyle] = this.options.leftOffset;
				this.mover.start(args).chain(
					this.move3.bind(this)
				);
			}
		}
		else {
			var left = 0;
			for(var i = 0; i < nextIndex; i++)
				left += this.itemSizes[i];
			//console log(nextIndex + ":"+  this.itemSizes[0] + ":"+ this.moveStyle);
			
			var args = {}; args[this.moveStyle] = -left + this.options.leftOffset;
			this.mover.start(args).chain(
				this.move3.bind(this)
			);
		}

		if($defined(this.options.onChange))
			this.options.onChange.run(this.itemIndex, this);
		
		return true;
	},
	// Get drag limits
	getDragLimit: function() {
		var left = 0;
		for(var i = 0; i < this.lastIndex; i++)
			left += this.itemSizes[i];

		return {
			//x:[-(this.contentSize - this.contentWrapperSize),this.options.leftOffset], 
			//x:[-(this.contentSize - this.itemSizes[this.itemSizes.length - 1]) + this.options.leftOffset,this.options.leftOffset],
			x:[-left + this.options.leftOffset,this.options.leftOffset],
			y:[0,0]
		}
	},
	// Update scroller with new item size
	updateItemSize: function(el) {
		var index = this.items.indexOf(el);
		if(index < 0)
			return;

		//console log("Before: " + index + ":" + this.itemSizes[index] + ":" + this.contentSize);

		this.itemSizes[index] = (this.moveStyle == 'left') ? el.getFullWidth() : el.getFullHeight();
		
		// Update content size
		var size = 0;
		for(var i = 0; i < this.itemSizes.length; i++)
			size += this.itemSizes[i];
		this.contentSize = size;
		
		this.updateLastIndex();
		//console log("After: " + index + ":" + this.itemSizes[index] + ":" + this.contentSize);
		
		if(this.drag) {
			this.drag.options.limit = this.getDragLimit();
		}
	},
	// Update current index from current item positions
	updateIndex: function(offsetLeft) {
		if(offsetLeft == null)
			offsetLeft = this.contentDiv[this.offsetSizeStyle];
			
		// Find current index
		var left = this.options.leftOffset - offsetLeft;
		var size = 0;
		var index = -1;
		
		offsetLeft = this.options.leftOffset;
		while(index < this.itemSizes.length-1 && size <= (left + this.itemSizes[index+1]/2) ) { 
			index++;
			size += this.itemSizes[index];
			
			if(size <= (left + this.itemSizes[index]/2))
				offsetLeft -= this.itemSizes[index];
			//console log('y:' + index + ":" + left + ":" + size + ":" + this.itemSizes[index]);
		}
		
		//console log(left + ":" + index);
		
		if(index >= 0 && index < this.itemSizes.length)
			this.itemIndex = index;
			//console log(this.itemIndex);
			
		return offsetLeft;
	},
	// Unload
	unload: function() {
		this.pause();
		this.ready = false;
		
		if(this.mover) {
			this.mover.cancel();
			this.mover = null;
		}
		
		this.items = null;
		if(this.drag)
			this.drag.detach();
		this.drag = null;
	}
});

Mnet.Drag = new Class({
	Extends: Drag,

	initialize: function(element, options) {
		this.parent(element, options);
	},
	
	start: function(event){
		// If select tag, don't do drag
		if(event.target.tagName.toLowerCase() == 'select')
			return;
		
		if (this.options.preventDefault) event.preventDefault();
		this.mouse.start = event.page;
		this.fireEvent('beforeStart', this.element);
		var limit = this.options.limit;
		this.limit = {x: [], y: []};
		for (var z in this.options.modifiers){
			if (!this.options.modifiers[z]) continue;
			if (this.options.style) this.value.now[z] = this.element.getStyle(this.options.modifiers[z]).toInt();
			else this.value.now[z] = this.element[this.options.modifiers[z]];
			if (this.options.invert) this.value.now[z] *= -1;
			this.mouse.pos[z] = event.page[z] - this.value.now[z];
			if (limit && limit[z]){
				for (var i = 2; i--; i){
					if ($chk(limit[z][i])) this.limit[z][i] = $lambda(limit[z][i])();
				}
			}
		}
		if ($type(this.options.grid) == 'number') this.options.grid = {x: this.options.grid, y: this.options.grid};
		this.document.addEvents({mousemove: this.bound.check, mouseup: this.bound.cancel});
		this.document.addEvent(this.selection, this.bound.eventStop);
	},

	move: function() {
		if(!this.moving) {
			this.moveEase = 3;
			this.movePrevX = this.moveX = this.element.getStyle('left').toInt();
			
			this.moving = true;
			this.moveTimeoutId = this.move.periodical(20, this);
		}
		
		if(this.moveX != this.targetX) {
			this.movePrevX = this.moveX;

			var dx = (this.targetX - this.moveX);
			if(Math.abs(dx) < 0.5)
				this.moveX = this.targetX;
			else 
				this.moveX += dx / this.moveEase;
		
			//console log(this.moveX +":" + this.targetX);
			
			this.element.setStyle('left', Math.round(this.moveX) + 'px');
		}
		else {
			//this.fx.options.duration = d;
			//this.fx.start({left: [current, to]});

			$clear(this.moveTimeoutId);
			this.moving = false;
			
			// Fire end event
			if(this.moveEndEvent) {
				this.fireEvent('complete', [this.element, this.moveEndEvent]);
				this.moveEndEvent = null;
			}
		}
	},
	
	moveUpdateTarget: function() {
		var diff = this.moveX - this.movePrevX;
		var distance = Math.abs(diff);
		
		//var prevX = this.targetX;
		
		if(distance > 20) {
			this.targetX = this.limitX(this.targetX + diff * 1);
			//console log('Throw: f:'+this.movePrevX+", t:"+this.moveX+":"+diff);//+":"+prevX+":"+this.targetX);
		}
	},
	
	limitX: function(x) {
		var z = 'x';
		if (this.options.limit && this.limit[z]){
			if ($chk(this.limit[z][1]) && (x > this.limit[z][1])){
				x = this.limit[z][1];
			} else if ($chk(this.limit[z][0]) && (x < this.limit[z][0])){
				x = this.limit[z][0];
			}
		}
		return x;
	},
	
	drag: function(event){
		if (this.options.preventDefault) event.preventDefault();
		this.mouse.now = event.page;
		
		var z = 'x';

		this.value.now[z] = this.mouse.now[z] - this.mouse.pos[z];
		if (this.options.invert) this.value.now[z] *= -1;
		this.value.now[z] = this.limitX(this.value.now[z]);
		
		/*
		if (this.options.limit && this.limit[z]){
			if ($chk(this.limit[z][1]) && (this.value.now[z] > this.limit[z][1])){
				this.value.now[z] = this.limit[z][1];
			} else if ($chk(this.limit[z][0]) && (this.value.now[z] < this.limit[z][0])){
				this.value.now[z] = this.limit[z][0];
			}
		}
		*/
		if (this.options.grid[z]) this.value.now[z] -= ((this.value.now[z] - (this.limit[z][0]||0)) % this.options.grid[z]);
		//if (this.options.style) this.element.setStyle(this.options.modifiers[z], this.value.now[z] + this.options.unit);
		//else this.element[this.options.modifiers[z]] = this.value.now[z];
		
		this.targetX = this.value.now[z];
		
		// Start moving if not already
		if(!this.moving)
			this.move();

		this.fireEvent('drag', [this.element, event]);
	},

	stop: function(event){
		this.document.removeEvent(this.selection, this.bound.eventStop);
		this.document.removeEvent('mousemove', this.bound.drag);
		this.document.removeEvent('mouseup', this.bound.stop);
		
		if(event) {
			// Fire release event
			this.fireEvent('release', [this.element, event]);
			
			// If still moving, let it finish first
			if(this.moving) {
				this.moveEndEvent = event;
				this.moveUpdateTarget();
			}
			else
				this.fireEvent('complete', [this.element, event]);
		}
	}
});

Mnet.ContentScroller = new Class({
	Implements: Options,
	
	options:{
		delay:3000
	},

	initialize: function(id, options) {
		this.setOptions(options);
		
		this.scrollersReady = 0;
		this.scrollers = [];

		/*
		this.navPrev = $(id + '-nav-prev');
		this.navNext = $(id + '-nav-next');
		this.navPlay = $(id + '-nav-play');

		this.navNext.addEvent('click', this.next.bind(this));
		this.navPrev.addEvent('click', this.prev.bind(this));
		this.navPlay.addEvent('click', this.play.bind(this));
		*/
		
		this.options.currentDelay = this.options.delay;

		//this.hideNav();
	},
	
	addScroller: function(holder, contentElements, options) {
		var index = this.scrollers.length;

		var _this = this;
		options.delay = -1;
		options.objects = contentElements;
		options.onReady = function() { _this.scrollerReady(index); };
		options.onChange = function() { _this.scrollerChange(index); };
		options.autoLoad = false;
		
		var scroller = new Mnet.VariableSizeObjectLoopScroller(holder, options);
		this.scrollers.push(scroller);
	},

	load: function() {
		this.scrollers.each(function(item) { item.load(); });
	},
	
	scrollerReady: function(index) {
		this.scrollersReady++;	
		if(this.scrollersReady == this.scrollers.length)
			this.onReady();
	},
	
	onReady: function() {
		// Get delay from first scroller
		if(this.scrollers.length > 0)
			this.options.currentDelay = this.scrollers[0].options.currentDelay;
		
		//this.showNav();
		if($defined(this.options.onReady))
			this.options.onReady.run(null, this);
	},
	
	onChange: function() {
		if($defined(this.options.onChange))
			this.options.onChange.run(this.currentIndex, this);
	},
	
	showNav: function() {
		this.navPrev.setStyle('visibility', 'visible');
		this.navNext.setStyle('visibility', 'visible');
		this.navPlay.setStyle('visibility', 'visible');
	},

	hideNav: function() {
		this.navPrev.setStyle('visibility', 'hidden');
		this.navNext.setStyle('visibility', 'hidden');
		this.navPlay.setStyle('visibility', 'hidden');
	},

	move: function(type, newIndex, onTimer) {
		// Prepare
		this.scrollers.each(function(item, index) {
			if(type == 'prev') 
				item.prev();
			else if(type == 'next')
				item.next();
			else
				item.moveTo(newIndex);
				
			if(index == 0) {
				this.options.currentDelay = item.options.currentDelay ? item.options.currentDelay : this.options.delay;
			}
		}, this);

		// Run
		/*
		this.scrollers.each(function(item) { 
			item.runStep(); 
		});
		*/
		
		// If playing and called by user, reset the timer
		if($defined(this.timerId) && (!onTimer || type != 'next')) {
			$clear(this.timerId);
			this.timerId = this.next.periodical(this.options.currentDelay, this, true);
		}
	},
	
	scrollerChange: function(index) {
		if(index == 0) {
			this.currentIndex = this.scrollers[index].itemIndex;
			this.onChange();
		}
	},
	
	moveTo: function(newIndex) { this.move('moveTo', newIndex); },
	next: function(event, onTimer) { this.move('next', null, onTimer); },
	prev: function() { this.move('prev'); },

	// Pause
	pause: function() {
		if($defined(this.timerId)) {
			$clear(this.timerId);
			this.timerId = null;
			
			if($defined(this.options.onPlayPause))
				this.options.onPlayPause.run(false, this);
		}
	},
	// Play
	play: function() {
		if(!$defined(this.timerId)) {
			this.timerId = this.next.periodical(this.options.currentDelay ? this.options.currentDelay : this.options.delay, this, true);
			
			if($defined(this.options.onPlayPause))
				this.options.onPlayPause.run(true, this);
		}
	},
	// Play/pause
	playPause: function() {
		// Pause
		if($defined(this.timerId))
			this.pause();
		// Play
		else
			this.play();
	},
	// Unload	
	unload: function() {
		this.pause();
		this.scrollers.each(function(item) {
			item.unload();
		});
		this.scrollers = null;
	}
});

Mnet.Tooltips = {
	show: function(id, html, source) {
		var obj = $(id);
		obj.set('html', html != null ? '* ' + html : '');
		
		if(source) {
			source = $(source);
			
			var hide = (html == null);
			
			if(hide)
				source.removeClass('selected');
			else
				source.addClass('selected');
			
			var oTitle = source.getElement('.tt-title');
			if(oTitle) {
				var title = oTitle.get('html');
				
				if(hide)
					title = title.replace(/ \*$/, '');
				else
					title = title + ' *';
					
				oTitle.set('html', title);
			}
		}
	},
	
	hide: function(id, source) {
		this.show(id, null, source);
	}
};

Mnet.Tabs = {
	prevTab: null,
	
	show: function(id, defaultId) {
		if(this.prevTab == id)
			return;

		if(this.prevTab == null)
			this.prevTab = defaultId;
		
		var tab = $(id);
		var content = $(id + '_tab');
		
		this.hide(this.prevTab);
		
		tab.addClass('selected');
		content.setStyle('display', 'block');
		
		this.prevTab = id;
	},
	
	hide: function(id) {
		var tab = $(id);
		var content = $(id + '_tab');

		tab.removeClass('selected');
		content.setStyle('display', 'none');	
	}
};

Mnet.init = function(rootUrl) {
	if(Mnet.initialized)
		return;
		
	if(Mnet.rootUrl == null && rootUrl != null)
		Mnet.rootUrl = rootUrl;
	
	// Skip transitions on ipod 
	if(Browser.Platform.ipod)
		Mnet.showTransitions = false;

	// Hide flash titles
	if(Browser.Plugins.Flash.version >= 6) {
		if(!Mnet.testing.flashTitles) {
		   var sheet = new Stylesheet();
			sheet.addRules({
				'.flash-title' : { visibility:'hidden' }
			});
		}
	}
		
	/*
	// Hide images while loading
	document.write(
		'<' + 'style type="text/css" media="screen">' +
		'	#images-holder, #right-images-holder { height:0px; overflow:hidden; } ' +
		'<' + '/' + 'style>'
	);
	*/
						
	window.addEvent('domready', function() {
		//Mnet.Ajax.scanLinks();		
		Mnet.FlashTitles.scanPage();
		//Slimbox.scanPage();
	});

	// Add hover class for li elements on ie
	/*
	if (window.attachEvent) {
		window.attachEvent("onload", function() {
			var elements = $$('li');
			elements.addEvents({
				mouseover: function(e) { this.addClass('hover'); },
				mouseout: function(e) { this.removeClass('hover'); }
			});
			
			$$('.enablehover').addEvents({
				mouseenter: function(e) { this.addClass('hover'); },
				mouseleave: function(e) { this.removeClass('hover'); }
			});
		});
	}
	*/
	window.addEvent('domready', function() {
		$$('.enablehover').addEvents({
			mouseenter: function(e) { this.addClass('hover'); },
			mouseleave: function(e) { this.removeClass('hover'); }
		});
	});
	
	Mnet.initialized = true;
};

Mnet.testing =  {
	flashTitles:false
}

Mnet.FlashTitles.setup = {
	// Info panel h1
	'#homepage .info-panel h1.flash-title':{font:'italia',textsize:52,textcolour:'0886c0',lineheight:-7,setheight:false},
	// Info panel h1
	'.content-middle .info-panel h1.flash-title':{font:'italia',textsize:52,textcolour:'0886c0',lineheight:-17,setheight:false},
	// Info panel sub-title
	'.info-panel div.flash-title':{font:'italia',textsize:24,textcolour:'173571',lineheight:0,setheight:false}
};
										
/*!
	Slimbox v1.64 - The ultimate lightweight Lightbox clone
	(c) 2007-2008 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.
*/
//var Slimbox;(function(){var g=0,options,images,activeImage,prevImage,nextImage,top,fx,preload,preloadPrev=new Image(),preloadNext=new Image(),overlay,center,image,prevLink,nextLink,bottomContainer,bottom,caption,number;window.addEvent("domready",function(){$(document.body).adopt($$([overlay=new Element("div",{id:"lbOverlay"}).addEvent("click",close),center=new Element("div",{id:"lbCenter"}),bottomContainer=new Element("div",{id:"lbBottomContainer"})]).setStyle("display","none"));image=new Element("div",{id:"lbImage"}).injectInside(center).adopt(prevLink=new Element("a",{id:"lbPrevLink",href:"#"}).addEvent("click",previous),nextLink=new Element("a",{id:"lbNextLink",href:"#"}).addEvent("click",next));bottom=new Element("div",{id:"lbBottom"}).injectInside(bottomContainer).adopt(new Element("a",{id:"lbCloseLink",href:"#"}).addEvent("click",close),caption=new Element("div",{id:"lbCaption"}),number=new Element("div",{id:"lbNumber"}),new Element("div",{styles:{clear:"both"}}));fx={overlay:new Fx.Tween(overlay,{property:"opacity",duration:500}).set(0),image:new Fx.Tween(image,{property:"opacity",duration:500,onComplete:nextEffect}),bottom:new Fx.Tween(bottom,{property:"margin-top",duration:400})}});Slimbox={open:function(a,b,c){options=$extend({loop:false,overlayOpacity:0.8,resizeDuration:400,resizeTransition:false,initialWidth:250,initialHeight:250,animateCaption:true,showCounter:true,counterText:"Image {x} of {y}"},c||{});if(typeof a=="string"){a=[[a,b]];b=0}images=a;options.loop=options.loop&&(images.length>1);position();setup(true);top=window.getScrollTop()+(window.getHeight()/15);fx.resize=new Fx.Morph(center,$extend({duration:options.resizeDuration,onComplete:nextEffect},options.resizeTransition?{transition:options.resizeTransition}:{}));center.setStyles({top:top,width:options.initialWidth,height:options.initialHeight,marginLeft:-(options.initialWidth/2),display:""});fx.overlay.start(options.overlayOpacity);g=1;return changeImage(b)}};Element.implement({slimbox:function(a,b){$$(this).slimbox(a,b);return this}});Elements.implement({slimbox:function(b,c,d){c=c||function(a){return[a.href,a.title]};d=d||function(){return true};var e=this;e.removeEvents("click").addEvent("click",function(){var a=e.filter(d,this);return Slimbox.open(a.map(c),a.indexOf(this),b)});return e}});function position(){overlay.setStyles({top:window.getScrollTop(),height:window.getHeight()})}function setup(c){["object",window.ie?"select":"embed"].forEach(function(b){Array.forEach(document.getElementsByTagName(b),function(a){if(c)a._slimbox=a.style.visibility;a.style.visibility=c?"hidden":a._slimbox})});overlay.style.display=c?"":"none";var d=c?"addEvent":"removeEvent";window[d]("scroll",position)[d]("resize",position);document[d]("keydown",keyDown)}function keyDown(a){switch(a.code){case 27:case 88:case 67:close();break;case 37:case 80:previous();break;case 39:case 78:next()}return false}function previous(){return changeImage(prevImage)}function next(){return changeImage(nextImage)}function changeImage(a){if((g==1)&&(a>=0)){g=2;activeImage=a;prevImage=((activeImage||!options.loop)?activeImage:images.length)-1;nextImage=activeImage+1;if(nextImage==images.length)nextImage=options.loop?0:-1;$$(prevLink,nextLink,image,bottomContainer).setStyle("display","none");fx.bottom.cancel().set(0);fx.image.set(0);center.className="lbLoading";preload=new Image();preload.onload=nextEffect;preload.src=images[a][0]}return false}function nextEffect(){switch(g++){case 2:center.className="";image.setStyles({backgroundImage:"url("+images[activeImage][0]+")",display:""});$$(image,bottom).setStyle("width",preload.width);$$(image,prevLink,nextLink).setStyle("height",preload.height);caption.set('html',images[activeImage][1]||"");number.set('html',(options.showCounter&&(images.length>1))?options.counterText.replace(/{x}/,activeImage+1).replace(/{y}/,images.length):"");if(prevImage>=0)preloadPrev.src=images[prevImage][0];if(nextImage>=0)preloadNext.src=images[nextImage][0];if(center.clientHeight!=image.offsetHeight){fx.resize.start({height:image.offsetHeight});break}g++;case 3:if(center.clientWidth!=image.offsetWidth){fx.resize.start({width:image.offsetWidth,marginLeft:-image.offsetWidth/2});break}g++;case 4:bottomContainer.setStyles({top:top+center.clientHeight,marginLeft:center.style.marginLeft,visibility:"hidden",display:""});fx.image.start(1);break;case 5:if(prevImage>=0)prevLink.style.display="";if(nextImage>=0)nextLink.style.display="";if(options.animateCaption){fx.bottom.set(-bottom.offsetHeight).start(0)}bottomContainer.style.visibility="";g=1}}function close(){if(g){g=0;preload.onload=$empty;for(var f in fx)fx[f].cancel();$$(center,bottomContainer).setStyle("display","none");fx.overlay.chain(setup).start(0)}return false}})();Slimbox.scanPage=function(root){if(!root)root=document.body;var b=root.getElements("a").filter(function(a){return a.rel&&a.rel.test(/^lightbox/i)});var c={overlayOpacity:0.6,resizeDuration:Mnet.getDuration(500),resizeTransition:Fx.Transitions.Pow.easeOut,counterText:"Image {x} of {y}",loop:true};$$(b).slimbox(c,null,function(a){return(this==a)||((this.rel.length>8)&&(this.rel==a.rel))})};

/*
---
name: Stylesheet
description: js stylesheet
license: MIT-Style License (http://mifjs.net/license.txt)
copyright: Anton Samoylov (http://mifjs.net)
authors: Anton Samoylov (http://mifjs.net)
requires: core:1.2.4:*
provides: Stylesheet
...
*/
var Stylesheet=new Class({version:"0.9",initialize:function(){this.createSheet();this.rules={};this.styles={};this.index=[];this.temp=new Element("div")},createSheet:function(){var a=new Element("style").inject(document.head);this.sheet=a.styleSheet||a.sheet},addRule:function(a,d){a=a.trim();if(a.contains(",")){var c=a.split(",");c.each(function(f){this.addRule(f,d)},this);return this}var d=($type(d)=="string")?d:this.stylesToString(d);if(!d){return}var b=this.sheet;if(b.addRule){b.addRule(a,d)}else{b.insertRule(a+"{"+d+"}",b.cssRules.length)}var e=this.getRules();this.rules[a]=e.getLast();this.styles[a]=d;this.index.push(a);return this},addRules:function(a){for(selector in a){this.addRule(selector,a[selector])}return this},stylesToString:function(b){this.temp.setStyles(b);var a=this.temp.style.cssText;this.temp.style.cssText="";return a},removeRule:function(b){var d=this.sheet;if($type(b)=="string"){var a=b.trim();if(a.contains(",")){var c=a.split(",");c.each(function(e){this.removeRule(e)},this);return this}var b=this.getRules().indexOf(this.getRule(a));if(b<0){return this}}d.removeRule?d.removeRule(b):d.deleteRule(b);var a=this.index[b];this.index.erase(a);delete this.rules[a];delete this.styles[a];return this},getRule:function(a){return $type(a)=="string"?this.rules[a]:this.getRules()[a]},getRules:function(){return $A(this.sheet.cssRules||this.sheet.rules)}});