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 + '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 title
	loadItem: function(classPath, setup, root) {
		if(!root)
			root = document.body;
		root = $(root);
		
		var _this = this;
		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 = setup.font;
			var title = element.get('text').replace(/\r/g, ''); // Remove \r to avoid double newlines in flash
			
			// 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
			};
			for(var a in setup) {
				if(a != 'font' && a != 'texttransform' && a != 'setheight')
					args[a] = setup[a];
			}

			// 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);
		});
	},
		
	// Load all titles on the page
	scanPage: function(root) {
		var _this = this;
		for(var classPath in this.setup) {
			this.loadItem(classPath, this.setup[classPath], root);
		}
	}
};

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 || 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.Ajax = {
	Popup: {
		// Get popup holder div
		getHolder: function() {
			var el = $('popup-holder');
			if(!el) {
				el = new Element('div', {
					id:'popup-holder',
					styles:{
						position:'absolute',
						left:0,
						top:0,
						'z-index':1000,
						'visibility':'hidden'
					}
				});
				el.inject(document.body, 'top');
				
				el.set('opacity', 0);
				
				var fx = new Fx.Tween(el, {link:'cancel', duration:Mnet.getDuration(750)});
				el.store('fxTween', fx);
			}
			return el;
		},
		// Hide popup
		hide: function(skipTween, skipOverlay) {
			var _this = Mnet.Ajax.Popup;
			var popup = _this.getHolder();
			
			if(skipTween) {
				popup.setStyles({visibility:'hidden'});
				popup.empty();
			}
			else {
				var fx = popup.retrieve('fxTween');
				fx.start('opacity', 0).chain(function() { _this.hide(true, skipOverlay); });
			}
			
			if(!skipOverlay)
				_this.hideOverlay(skipTween);
		},
		// Show popup
		show: function(url) {
			var _this = Mnet.Ajax.Popup;
			this.hide(true);
			Mnet.Ajax.doRequest(url, null, _this._showOnSuccess);
		},
		// Reshow popup (no ajax call)
		reshow: function(responseNode) {
			var _this = Mnet.Ajax.Popup;

			_this.hide(true, true);
			_this._showOnSuccess(responseNode, false, true);	
		},
		// On success method
		_showOnSuccess: function(responseNode, skipTween, skipOverlay) {
			var _this = Mnet.Ajax.Popup;
			
			var popup = _this.getHolder();
			popup.empty();
			responseNode.inject(popup);
			
			popup.position();
			
			if(skipTween) {
				popup.setStyles({visibility:'visible'});
			}
			else {
				popup.set('opacity', 0);
				popup.setStyles({visibility:'visible'});

				var fx = popup.retrieve('fxTween');
				fx.start('opacity', 1);
			}

			if(!skipOverlay)
				_this.showOverlay(skipTween);
			
	        Mnet.Ajax.scanHtml(responseNode, _this.reshow);
		},
		// Get overlay
		getOverlay: function() {
			var el = $('popup-overlay');
			if(!el) {
				var _this = Mnet.Ajax.Popup;
				el = new Element('div', {
					id:'popup-overlay',
					styles:{
						position:'absolute',
						left:0,
						top:0,
						width:'100%',
						'z-index':990,
						'visibility':'hidden',
						'background-color':'#000'
					}
				});
				el.inject(document.body, 'top');
				
				el.set('opacity', 0);
				
				var fx = new Fx.Tween(el, {link:'cancel', duration:Mnet.getDuration(500)});
				el.store('fxTween', fx);
				
				el.addEvent('click', function() { _this.hide(); });
			}
			return el;
		},
		// Show overlay
		showOverlay: function(skipTween) {
			var _this = Mnet.Ajax.Popup;
			var overlay = _this.getOverlay();
			var op = 0.6;
			
			overlay.setStyles({display:'block'});
			
			if(skipTween)
				overlay.set('opacity', op);
			else {
				var fx = overlay.retrieve('fxTween');
				fx.start('opacity', op);
			}
			
			_this._moveOverlay();
			window.addEvent("scroll", _this._moveOverlay);
		},
		// Hide overlay
		hideOverlay: function(skipTween) {
			var _this = Mnet.Ajax.Popup;
			var overlay = _this.getOverlay();
			
			if(skipTween) {
				window.removeEvent("scroll", _this._moveOverlay);
				
				overlay.setStyles({display:'none'});
				overlay.set('opacity', 0);
			}
			else {
				var fx = overlay.retrieve('fxTween');
				fx.start('opacity', 0).chain(function() { _this.hideOverlay(true); });
			}
		},
		// Move overlay
		_moveOverlay: function() {
			var _this = Mnet.Ajax.Popup;
			var overlay = _this.getOverlay();
			
			overlay.setStyles({
				left: window.getScrollLeft(), 
				top: window.getScrollTop(),
				height: window.getHeight()
			});
		}
	},
	// Scan HTML and update flash titles and make forms ajax calls
	scanHtml: function(responseNode, onSuccess) {
		Mnet.FlashTitles.scanPage(responseNode);
		//Slimbox.scanPage(elBody);
		
		// Update forms to be ajax
        var elements = responseNode.getElements('form');
		elements.each(function(form) {
			var onsubmit = form.onsubmit;
			form.onsubmit = function() {
				var ret = onsubmit ? onsubmit.run(null, this) : true;
				if(ret) {
					Mnet.Ajax.doRequest(this.action, $(this), onSuccess);
				}
				return false;
			};
		});
	},
	// Send request
	doRequest: function(url, data, onSuccess) {
		var aurl = Mnet.String.urlArgReplace(url, {poutput:'ajax'});
		
		// Cancel request if any
		if(this.request)
			this.request.cancel();
		
		var _this = this;
		this.request = new Request.HTML({
			evalScripts:false,
			evalResponse:false,
			noCache:true,
			onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript) {
				var responseNode = new Element('div', {html: responseHTML});

				//loader.hide();
				
				if(onSuccess)
					onSuccess.run(responseNode);
				
				$exec(responseJavaScript);
			},
			onFailure: function(xhr) {
				//loader.hide();
				alert('Unable to perform request');
			}
		});

		//loader.show();
		
		var args = {url: aurl}; 
		if(data) {
			args.method = 'post';
			args.data = $(data);
			this.request.onFailure = function(xhr) {
				//loader.hide();
				alert('Unable to post form. Please try again');
			};
		}
		else {
			args.method = 'get';
			this.request.onFailure = function(xhr) {
				//loader.hide();
				document.location.href = url;
			};
		}

		this.request.send(args);
	},	
	// Javascript
	javascript: function(url) {
		if(!this.javascriptCount)
			this.javascriptCount = 0;
		this.javascriptCount++;
		Asset.javascript(url,{onload:this.javascriptLoaded.bind(this)});
	},
	// Called when a script has loaded
	javascriptLoaded: function(checkOnly) {
		if(!checkOnly)
			this.javascriptCount--;
		// All scripts loaded? run on ready
		if(this.javascriptCount == null || this.javascriptCount == 0) {
			if(this.onReadyEvents) {
				for(var i = 0; i < this.onReadyEvents.length; i++) {
					this.onReadyEvents[i].run();
				}
				this.onReadyEvents = [];
			}
		}
	},
	// Add onready functions
	addOnReady: function(func) {
		if(!this.onReadyEvents)
			this.onReadyEvents = [];
		this.onReadyEvents.push(func);
	}
};
/*
	String methods
*/
Mnet.String = {
	urlParseCache: '',
	
	// Parse url into parts (pass null to use previous URL)
	urlParse: function(url) {
		if(url == null)
			return this.urlParseCache;
			
		var parts = url.split('?');
		var base = parts.shift();
		var qs = parts.join('?')
			
		var args = {};
		if(qs != '') {
			var pairs = qs.split("&");
			for(var i = 0; i < pairs.length; i++) {
				pair = pairs[i].split('=');
				name = pair.shift();
				args[name] = unescape(pair.join('='));
			}
		}
		
		var purl = {
			'base':base,
			'sep':qs != '' ? '&' : '?',
			'qs':qs,
			'args':args
		};
		
		// Cache for reuse
		this.urlParseCache = purl;
	
		return purl;
	},
	// Put parts back together
	urlCompile: function(purl) {
		var args = '';
		var sep = '?';
		for(var name in purl.args) {
			args += sep + name + '=' + escape(purl.args[name])
			if(sep == '?')
				sep = '&';
		}
		
		// Re-Cache since it's changed
		this.urlParseCache = purl;
		
		return purl.base + args;
	},
	// Append or replace arg
	urlArgReplace: function(url, args) {
		purl = this.urlParse(url);
		for(var name in args)
			purl.args[name] = args[name];
		return this.urlCompile(purl);
	},
	// Get arg
	urlArgGet: function(url, arg) {
		purl = this.urlParse(url);
		return purl.args[arg];
		/*
		arg = arg.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
		
		var regexS = "[\\?&]"+arg+"=([^&#]*)";
		var regex = new RegExp(regexS);
		var results = regex.exec(url);
		
		if(results == null)
			return "";
		else
			return results[1];
		*/
	}
};

Mnet.anchorFooter = function() {
	var el = $('footer');
	var pos = el.getStyle('position');
	if(pos == 'fixed')
		el.setStyle('position', 'absolute');
	else
		el.setStyle('position', 'fixed');
}

Mnet.init = function() {
	// Skip transitions on ipod 
	if(Browser.Platform.ipod)
		Mnet.showTransitions = false;

	// Hide galleries while loading
	var sheet = new Stylesheet();
	sheet.addRules({
		'#images-holder' : { height:0, visibility:'hidden' }
	});

	// Hide flash titles
	if(Browser.Plugins.Flash.version >= 6) {
		if(!Mnet.testing.flashTitles) {
			sheet.addRules({
				'.flash-title' : { visibility:'hidden' }
			});
		}
	}

	window.addEvent('domready', function() {
		Mnet.FlashTitles.scanPage();
		//Slimbox.scanPage();
	});
};

Mnet.testing =  {
	flashTitles:false // Set to false to avoid delay in setting the flash titles
}
					
Mnet.FlashTitles.setup = {
	// Homepage H1
	'h1.ft-homepage':{font:'ft_din',textsize:23,textcolour:'04564a',textspacing:1.7,setheight:true},
	// H1
	'h1.flash-title':{font:'ft_din',textsize:42,textcolour:'c7dc4a',textspacing:-2.5,setheight:true},
	// H2
	'h2.flash-title':{font:'ft_din',textsize:22,textcolour:'ebebeb',textspacing:-1.5,setheight:true}
};

/*!
	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)}});
