/**
 * RokBox - Pops up all sort of media types, html, images, videos, audio, iframes.
 * 
 * @version		1.3.1 for mootools 1.2
 * 
 * @author		Djamil Legato <djamil@rockettheme.com>
 * @copyright	Andy Miller @ Rockettheme, LLC
 */


Element.implement({
	'show': function () {
		return this.setStyle('display', '')
	},
	'hide': function () {
		return this.setStyle('display', 'none')
	}
});
String.implement({
	'sameDomain': function () {
		var a = /^(http|https):\/\/([a-z-.0-9]+)[\/]{0,1}/i.exec(window.location);
		var b = /^(http|https):\/\/([a-z-.0-9]+)[\/]{0,1}/i.exec(this);
		return a[2] === b[2]
	}
});
var RokBox = new Class({
	Implements: [Options, Chain],
	version: '1.3.1-moo1.2',
	options: {
		'className': 'rokbox',
		'theme': 'default',
		'transition': Fx.Transitions.Quad.easeOut,
		'duration': 200,
		'chase': 40,
		'effect': 'quicksilver',
		'captions': true,
		'captionsDelay': 800,
		'scrolling': false,
		'keyEvents': true,
		overlay: {
			'background': '#000',
			'opacity': 0.85,
			'zIndex': 65550,
			'duration': 200,
			'transition': Fx.Transitions.Quad.easeInOut
		},
		'frame-border': 0,
		'content-padding': 0,
		'arrows-height': 50,
		defaultSize: {
			'width': 640,
			'height': 460
		},
		'autoplay': 'true',
		'controller': 'false',
		'bgcolor': '#f3f3f3',
		'youtubeAutoplay': false,
		'youtubeHighQuality': false,
		'vimeoColor': '00adef',
		'vimeoPortrait': false,
		'vimeoTitle': false,
		'vimeoFullScreen': true,
		'vimeoByline': false
	},
	initialize: function (f) {
		this.setOptions(f);
		var g = new RegExp("^" + this.options.className),
		cls = this.options.className,
		self = this;
		this.current = [];
		this.groups = new Hash({});
		this.changeGroup = false;
		this.swtch = false;
		this.elements = $$('a').filter(function (a) {
			var b = a.getProperty('rel'),
			group = false,
			len = false,
			module = false;
			var c = (b || '').test(g);
			if (c) {
				if (b) group = b.match(/\([a-z0-9A-Z]+\)/g) || false;
				if (b) module = b.match(/\[module\=(.+)+\]/) || false;
				if (module[1]) {
					a.module = module[1]
				} else {
					a.module = false
				};
				if (group[0]) {
					group = group[0].replace("(", "").replace(")", "");
					if (!this.groups.has(group)) this.groups.set(group, []);
					var d = this.groups.get(group);
					d.push(a);
					len = d.length;
					this.groups.set(group, d)
				};
				a.group = group;
				a.idx = len;
				a.addEvent('click', this.click.bindWithEvent(a, [a.title, a.href, a.rel, this]))
			};
			return c
		}.bind(this));
		var h = $merge(this.options.overlay, {
			'id': cls + '-overlay',
			'class': cls + '-overlay'
		});
		this.overlayObj = new Rokverlay(false, h).addEvent('onShow', function () {
			self.open(self.current)
		}).addEvent('onHide', function () {
			if (self.changeGroup) {
				self.changeGroup = false;
				var e = self.nextGroup[0],
				selfLink = self.nextGroup[1],
				list = self.nextGroup[2],
				index = self.nextGroup[3],
				what;
				if (selfLink.getProperty('id').test('next')) what = list[index];
				else what = list[index - 2];
				self.click.delay(100, self, [false, what.title, what.href, what.rel, self, what])
			}
		});
		this.overlay = this.overlayObj.overlay.addEvent('click', function () {
			self.swtch = false;
			self.close()
		});
		this.wrapper = new Element('div', {
			'id': cls + '-wrapper',
			'class': cls + '-' + this.options.theme
		}).inject(document.body).setStyles({
			'position': 'absolute',
			'zIndex': 65555,
			'opacity': 0
		}).hide();
		var i = new Element('div', {
			'id': cls + '-top',
			'class': cls + '-left'
		}).inject(this.wrapper);
		var j = new Element('div', {
			'class': cls + '-right'
		}).inject(i);
		var k = new Element('div', {
			'class': cls + '-center'
		}).inject(j);
		var l = new Element('div', {
			'id': cls + '-middle',
			'class': cls + '-left'
		}).inject(this.wrapper);
		var m = new Element('div', {
			'class': cls + '-right'
		}).inject(l);
		this.center = new Element('div', {
			'class': cls + '-center'
		}).inject(m);
		var n = new Element('div', {
			'id': cls + '-bottom',
			'class': cls + '-left'
		}).inject(this.wrapper);
		var o = new Element('div', {
			'class': cls + '-right'
		}).inject(n);
		var p = new Element('div', {
			'class': cls + '-center'
		}).inject(o);
		new Element('div', {
			'class': 'clr'
		}).inject(this.wrapper);
		this.closeButton = new Element('a', {
			'id': cls + '-close',
			'href': '#'
		}).set('html', '<span>[x] close</span>').inject(this.center);
		this.closeButton.addEvent('click', function (e) {
			new Event(e).stop();
			self.swtch = false;
			self.close(e)
		});
		this.fx = {
			'wrapper': new Fx.Morph(this.wrapper, {
				'duration': this.options.duration,
				wait: true,
				'transition': this.options.transition,
				onComplete: function () {
					if (self.type == 'image') return;
					if (!this.element.getStyle('opacity') && self.overlayObj.open) {
						self.wrapper.hide();
						if (!self.swtch) {
							self.overlayObj.hide()
						} else {
							if (self.changeGroup) {
								self.changeGroup = false;
								var e = self.nextGroup[0],
								selfLink = self.nextGroup[1],
								list = self.nextGroup[2],
								index = self.nextGroup[3],
								what;
								if (selfLink.getProperty('id').test('next')) what = list[index];
								else what = list[index - 2];
								self.click.delay(100, self, [false, what.title, what.href, what.rel, self, what])
							}
						}
					} else {
						self.loadVideo.delay(50, self)
					}
				}
			}),
			'center': new Fx.Morph(this.center, {
				'duration': this.options.duration,
				wait: true,
				'transition': this.options.transition
			}),
			'height': new Fx.Tween(this.center, 'height', {
				'duration': this.options.duration,
				wait: true,
				'transition': this.options.transition
			})
		};
		window.addEvent('resize', function () {
			self.reposition(self.wrapper);
			self.overlayObj.reposition()
		});
		if (this.options.scrolling) window.addEvent('scroll', function () {
			self.reposition(self.wrapper)
		})
	},
	click: function (e, a, b, c, d, f) {
		if (e) new Event(e).stop();
		var g = '';
		var h = c.match(/([0-9]+\s?[0-9]+)/g) || [''];
		h = h[0].split(" ");
		var h = c.match(/([0-9%]+\s?[0-9%]+)/g) || [''];
		g = h[0].split(" ");
		h = h[0].split(" ");
		if (c.match(/fullscreen/g)) g = 'fullscreen';
		var i = d.overflow();
		if (!f) f = false;
		var j = this.group || f.group;
		var k = d.closeButton.getStyle('height').toInt() || d.closeButton.getSize().y || 0;
		var l = d.options['arrows-height'] || 0;
		h[0] = (h[0]) ? h[0] : '';
		h[1] = (h[1]) ? h[1] : '';
		if ((!h[0].contains("%") && !h[1].contains("%")) && !h[0].length || !h[1].length) {
			if (b.match(/youtube\.com\/watch/i)) {
				h[0] = 640;
				h[1] = 385
			} else if (b.match(/dailymotion\./i)) {
				h[0] = 420;
				h[1] = 339
			} else if (b.match(/metacafe\.com\/watch/i)) {
				h[0] = 400;
				h[1] = 345
			} else if (b.match(/google\.com\/videoplay/i)) {
				h[0] = 400;
				h[1] = 326
			} else if (b.match(/vimeo\.com\/[0-9]{1,}/i)) {
				h[0] = 400;
				h[1] = 225
			} else if (b.match(/\.(mov|qt|mpeg|divx|avi|xvid|wmv|wma|wax|wvx|asx|asf)$/i)) {
				h[0] = 504;
				h[1] = 336
			} else if (b.match(/\.(mp3|wav)$/i)) {
				h[0] = 320;
				h[1] = 45
			}
		};
		var m = window.getSize();
		if (h[0] > ((window.opera) ? window.innerWidth: m.x) || g == 'fullscreen') h[0] = ((window.opera) ? window.innerWidth: m.x) - d.overflow(true) - 20;
		if (h[1] > ((window.opera) ? window.innerHeight: m.y) || g == 'fullscreen') h[1] = ((window.opera) ? window.innerHeight: m.y) - d.overflow() - k - l - 20;
		if ($type(h[0]) != 'number' && $type(h[1]) != 'number') {
			if (h[0].contains("%") && h[1].contains("%")) {
				var n = (window.opera) ? window.innerWidth: m.x;
				var o = (window.opera) ? window.innerHeight: m.y;
				h[0] = h[0].replace("%", "").toInt();
				h[1] = h[1].replace("%", "").toInt();
				h[0] = h[0] > 100 ? 100 : h[0];
				h[1] = h[1] > 100 ? 100 : h[1];
				h[0] = n * h[0] / 100;
				h[1] = o * h[1] / 100;
				h[0] = h[0] - d.overflow(true) - 20;
				h[1] = h[1] - d.overflow() - k - l - 20
			}
		}
		c = {
			width: (h[0] || d.options.defaultSize.width).toInt(),
			height: (h[1] || d.options.defaultSize.height).toInt()
		};
		options2 = {
			width: (h[0] || d.options.defaultSize.width).toInt() + d.overflow(true),
			height: (h[1] || d.options.defaultSize.height).toInt() + d.overflow() + k
		};
		d.current = [this, a, b, c, j, this.idx || f.idx, options2, this.module];
		if (!d.swtch) d.overlayObj.toggle();
		else d.open(d.current)
	},
	overflow: function (a) {
		var b = (this.options['frame-border'] * 2) + (this.options['content-padding'] * 2);
		return b
	},
	open: function () {
		arguments = arguments[0];
		var b = arguments;
		var c = arguments[0],
		i = arguments[1],
		href = arguments[2],
		size = arguments[3],
		options = arguments[6],
		module = arguments[7],
		self = this;
		this.closeButton.setStyle('visibility', 'visible');
		var d = self.closeButton.getStyle('height').toInt() || self.closeButton.getSize().y || self.closeButton.currentStyle.height.toInt() || 0;
		var e = self.options['arrows-height'] || 0;
		this.wrapper.setStyles({
			'width': options.width,
			'height': options.height + e + d
		}).show();
		this.center.setStyles({
			'width': size.width,
			'height': size.height + d + e
		});
		if (self.options.captions && !this.caption) {
			var g = self.getCaption(i) || [false, false];
			var i = g[0],
			description = g[1];
			this.caption = new Element('div', {
				'id': this.options.className + '-caption'
			}).inject(this.center).setStyle('opacity', 0).adopt(i, description)
		};
		if (self.options.captions && this.caption) this.caption.hide().setStyle('height', 0);
		if (self.container) self.container.empty();
		var j = this.reposition(this.wrapper, options)[1];
		this.fx.wrapper.start(this.effects(this.options.effect, j).start).chain(function () {
			if (self.options.captions && self.caption) { (function () {
					var a = self.caption.getSize().y || 0;
					var b = self.center.getStyle('height').toInt();
					self.fx.height.start('height', b + a - e).chain(function () {
						self.caption.fade('in');
						if (self.options.keyEvents) {
							self.evt = self.keyEvents.bindWithEvent(self);
							document.addEvent('keyup', self.evt)
						}
					})
				}).delay(self.options.captionsDelay)
			}
		});
		var h = size.height + d + e;
		var f = this.effects(this.options.effect, j).start;
		if (f.width || f.height) this.fx.center.start({
			'width': ($type(f.width) == 'array') ? [0, size.width] : size.width,
			'height': ($type(f.height) == 'array') ? [0, h] : h
		});
		else this.center.setStyles({
			'width': size.width,
			'height': h
		})
	},
	close: function (a, b) {
		var c = this,
		effect;
		var d = {
			'left': this.wrapper.getStyle('left').toInt(),
			'top': this.wrapper.getStyle('top').toInt()
		};
		this.closeButton.setStyle('visibility', 'hidden');
		this.container.removeClass('spinner');
		this.unloadVideo();
		effect = this.effects((b) ? b: this.options.effect, d).end;
		if (this.options.captions) this.caption.fade('out');
		if (this.options.keyEvents) document.removeEvent('keyup', c.evt);
		if (this.arrows) this.arrows.dispose();
		this.arrows = false;
		var e = {};
		if ($chk(effect.width)) e.width = Math.abs(effect.width - c.overflow());
		if ($chk(effect.height)) e.height = Math.abs(effect.height);
		this.fx.center.start(e).chain(function () {
			c.fx.height.cancel();
			if (c.caption) c.caption.setStyle('height', '');
			c.center.setStyles({
				'width': '',
				'height': ''
			});
			c.container.setStyles({
				'width': '',
				'height': ''
			})
		});
		this.fx.wrapper.start(effect);
		return this
	},
	keyEvents: function (e) {
		switch (e.key) {
		case 'left':
			if (this.arrows) this.prevArrow.fireEvent('click', e);
			break;
		case 'right':
			if (this.arrows) this.nextArrow.fireEvent('click', e);
			break;
		case 'esc':
			this.close(e, 'growl');
			break
		}
	},
	reposition: function (a, b) {
		var c = window.getSize(),
		winScroll = window.getScroll();
		if (!a) a = document.id(this.wrapper);
		if (!b) {
			var d = a.getSize();
			b = {
				'width': d.x,
				'height': d.y
			}
		};
		var e = this.options['arrows-height'];
		var f = {
			'top': winScroll.y + (((window.opera) ? window.innerHeight: c.y) / 2) - (b.height / 2) - a.getStyle('padding-top').toInt() - (e / 2),
			'left': winScroll.x + (((window.opera) ? window.innerWidth: c.x) / 2) - (b.width / 2) - a.getStyle('padding-left').toInt()
		};
		return [a.setStyles(f), f]
	},
	loadVideo: function () {
		if (this.container) this.container.dispose();
		if (this.caption) this.caption.hide();
		var c = this.current[1],
		url = this.current[2],
		size = this.current[3],
		group = this.current[4],
		index = this.current[5],
		cls = this.options.className;
		var d = this.current[7];
		var f = this.closeButton.getStyle('height').toInt() || this.closeButton.getSize().size.y || 0;
		var g = this.options['arrows-height'] || 0;
		this.type = false;
		if (d) {
			this.type = 'module';
			this.object = document.id(d)
		} else if (url.match(/\.(gif|jpg|jpeg|png|bmp)$/i) || this.current[0].alt == 'image') {
			this.type = 'image';
			var h = this;
			this.object = new Asset.image(url, {
				id: 'rokboxobject',
				onload: function () {
					size.width = this.width;
					size.height = this.height;
					h.container.setStyles(size);
					var a = this,
					winSize = window.getSize(),
					winScroll = window.getScroll();
					var b = winScroll.y + (winSize.y / 2) - (this.height / 2) - h.wrapper.getStyle('padding-top').toInt();
					if (b < 0) b = 0;
					h.fx.wrapper.start({
						'left': winScroll.x + (winSize.x / 2) - (this.width / 2) - (h.overflow(true) / 2) - h.wrapper.getStyle('padding-left').toInt(),
						'width': this.width + h.overflow(true),
						'height': this.height + h.overflow() + g + f
					}).chain(function () {
						h.container.removeClass('spinner');
						a.inject(h.container)
					})
				}
			})
		} else if (url.match(/\.(mov|qt|mpeg|divx|avi|xvid|mv4|m4v)$/i)) {
			this.type = 'qt';
			if (navigator.plugins && navigator.plugins.length) {
				this.object = '<object id="rokboxobject" standby="loading..." type="video/quicktime" codebase="http://www.apple.com/qtactivex/qtplugin.cab" data="' + url + '" width="' + size.width + '" height="' + size.height + '"><param name="src" value="' + url + '" /><param name="scale" value="aspect" /><param name="controller" value="' + this.options.controller + '" /><param name="autoplay" value="' + this.options.autoplay + '" /><param name="bgcolor" value="' + this.options.bgcolor + '" /><param name="enablejavascript" value="true" /></object>'
			} else {
				this.object = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" standby="loading..." codebase="http://www.apple.com/qtactivex/qtplugin.cab" type="video/quicktime" width="' + size.width + '" height="' + size.height + '" id="rokboxobject"><param name="src" value="' + url + '" /><param name="scale" value="aspect" /><param name="controller" value="' + this.options.controller + '" /><param name="autoplay" value="' + this.options.autoplay + '" /><param name="bgcolor" value="' + this.options.bgcolor + '" /><param name="enablejavascript" value="true" /></object>'
			}
		} else if (url.match(/\.(wmv|wma|wax|wvx|asx|asf)$/i)) {
			this.type = 'wmv';
			if (navigator.plugins && navigator.plugins.length) {
				this.object = '<object id="rokboxobject" standby="loading..." type="application/x-oleobject" data="' + url + '" width="' + size.width + '" height="' + size.height + '" /><param name="src" value="' + url + '" /><param name="autoStart" value="' + this.options.autoplay + '" /><param name="bgcolor" value="' + this.options.bgcolor + '" /></object>'
			} else {
				this.object = '<object id="rokboxobject" standby="loading..." classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" type="application/x-oleobject" data="' + url + '" width="' + size.width + '" height="' + size.height + '" /><param name="filename" value="' + url + '" /><param name="showcontrols" value="' + this.options.controller + '"><param name="autoStart" value="' + this.options.autoplay + '" /><param name="bgcolor" value="' + this.options.bgcolor + '" /><param name="stretchToFit" value="true" /></object>'
			}
		} else if (url.match(/youtube\.com\/watch/i)) {
			this.type = 'flash';
			var i = url.split('=');
			this.videoID = i[1];
			this.options.youtubeAutoplay = (this.options.youtubeAutoplay) ? 1 : 0;
			this.options.youtubeHighQuality = (this.options.youtubeHighQuality) ? '&ap=%26fmt=22': '';
			this.object = new SWFObject("http://www.youtube.com/v/" + this.videoID + "&autoplay=" + this.options.youtubeAutoplay + this.options.youtubeHighQuality, "rokboxobject", size.width, size.height, "9", this.options.bgcolor, "wmode", "transparent");
			this.object.addParam('allowscriptaccess', 'always');
			this.object.addParam('allowfullscreen', 'true')
		} else if (url.match(/dailymotion\./i)) {
			this.type = 'flash';
			var i = url.split("_")[0].split('/');
			this.videoId = i[i.length - 1];
			this.object = new SWFObject("http://www.dailymotion.com/swf/" + this.videoId + "&v3=1&colors=background:DDDDDD;glow:FFFFFF;foreground:333333;special:FFC300;&autoPlay=1&related=0", "rokboxobject", size.width, size.height, "9", this.options.bgcolor);
			this.object.addParam('allowscriptaccess', 'always');
			this.object.addParam('allowfullscreen', 'true')
		} else if (url.match(/metacafe\.com\/watch/i)) {
			this.type = 'flash';
			var i = url.split('/');
			this.videoID = i[4];
			this.object = new SWFObject("http://www.metacafe.com/fplayer/" + this.videoID + "/.swf", "rokboxobject", size.width, size.height, "9", this.options.bgcolor, "wmode", "transparent");
			this.object.addParam('allowscriptaccess', 'always');
			this.object.addParam('allowfullscreen', 'true')
		} else if (url.match(/google\.com\/videoplay/i)) {
			this.type = 'flash';
			var i = url.split('=');
			this.videoID = i[1];
			this.object = new SWFObject("http://video.google.com/googleplayer.swf?docId=" + this.videoID + "&autoplay=1&hl=en", "rokboxobject", size.width, size.height, "9", this.options.bgcolor, "wmode", "transparent");
			this.object.addParam('allowscriptaccess', 'always');
			this.object.addParam('allowfullscreen', 'true')
		} else if (url.match(/vimeo\.com\/[0-9]{1,}/i)) {
			this.type = 'flash';
			var i = url.split('/');
			this.videoID = i[3];
			this.options.vimeoFullScreen = (this.options.vimeoFullScreen) ? 1 : 0;
			this.options.vimeoTitle = (this.options.vimeoTitle) ? 1 : 0;
			this.options.vimeoByline = (this.options.vimeoByline) ? 1 : 0;
			this.options.vimeoPortrait = (this.options.vimeoPortrait) ? 1 : 0;
			this.options.vimeoColor = (this.options.vimeoColor.match(/[0-9]{6}/)) ? this.options.vimeoColor: '00adef';
			this.object = new SWFObject("http://www.vimeo.com/moogaloop.swf?clip_id=" + this.videoID + "&amp;server=www.vimeo.com&amp;fullscreen=" + this.options.vimeoFullScreen + "&amp;show_title=" + this.options.vimeoTitle + "&amp;show_byline=" + this.options.vimeoByline + "&amp;show_portrait=" + this.options.vimeoPortrait + "&amp;color=" + this.options.vimeoColor + "", "rokboxobject", size.width, size.height, "9", this.options.bgcolor);
			this.object.addParam('allowscriptaccess', 'always');
			this.object.addParam('allowfullscreen', 'true')
		} else if (url.match(/\.swf/i)) {
			this.type = 'flash';
			this.object = new SWFObject(url, "rokboxobject", size.width, size.height, "9", this.options.bgcolor, "wmode", "transparent");
			this.object.addParam('allowscriptaccess', 'always');
			this.object.addParam('allowfullscreen', 'true')
		} else if (url.match(/\.(mp3|m4a)$/i)) {
			this.type = 'audio';
			this.object = '<object id="rokboxobject"" width="' + size.width + '" height="' + size.height + '" data="' + url + '"" type="' + ((window.ie) ? 'application/x-mplayer2': 'audio/mpeg') + '"><param value="' + url + '" name="src"/><param value="' + url + '" name="filename"/><param value="' + ((window.ie) ? 'application/x-mplayer2': 'audio/mpeg') + '" name="type"/><param name="bgcolor" value="' + this.options.bgcolor + '" /><p>No plugin matched for playing: ' + url + '</p></object>'
		} else if (url.match(/\.wav$/i)) {
			this.type = 'audio';
			this.object = '<object id="rokboxobject"" width="' + size.width + '" height="' + size.height + '" data="' + url + '"" type="' + ((window.ie) ? 'application/x-mplayer2': 'audio/wav') + '"><param value="' + url + '" name="src"/><param value="' + url + '" name="filename"/><param value="' + ((window.ie) ? 'application/x-mplayer2': 'audio/wav') + '" name="type"/><param name="bgcolor" value="' + this.options.bgcolor + '" /><p>No plugin matched for playing: ' + url + '</p></object>'
		} else {
			this.type = 'iframe';
			var j = "rokboxobject" + $time() + $random(0, 100);
			this.object = new Element('iframe').setProperties({
				id: j,
				width: size.width,
				height: size.height,
				frameBorder: 0,
				scrolling: 'auto',
				src: url
			});
			var h = this;
			this.object.onload = function () {
				h.container.removeClass('spinner')
			}
		}
		this.movie = document.id('rokboxobject');
		if (this.type) {
			this.container = new Element('div', {
				'id': cls + '-container',
				'class': cls + '-container'
			}).addClass('spinner').setStyles(size).injectInside(this.center);
			if (this.type == 'flash') this.object.write(this.container);
			else if (this.type == 'module') {
				this.object.clone(true).inject(this.container.removeClass('spinner')).setStyle('display', 'block')
			} else if (this.type == 'html') {
				this.object.inject(this.container);
				new Ajax(url, {
					'method': 'get',
					'evalScripts': true,
					'update': this.object,
					onComplete: function () {
						this.container.removeClass('spinner')
					}.bind(this)
				}).request()
			} else if (this.type == 'iframe') {
				this.object.inject(this.container)
			} else if (this.type != 'image') this.container.removeClass('spinner').set('html', this.object);
			if (group) {
				var k = this.groups.get(group),
				h = this;
				if (k.length > 1) {
					if (!this.arrows) {
						this.arrows = new Element('div', {
							'id': this.options.className + '-arrows'
						}).inject(this.center).hide();
						if (index != 1) {
							this.prevArrow = new Element('a', {
								'id': this.options.className + '-previous'
							}).inject(this.arrows).set('html', '<span>&lt; previous</span>');
							this.prevArrow.setProperties({
								'href': k[index - 2].getProperty('href'),
								'title': k[index - 2].getProperty('title')
							})
						};
						if (index != k.length) {
							this.nextArrow = new Element('a', {
								'id': this.options.className + '-next'
							}).inject(this.arrows).set('html', '<span>next &gt;</span>');
							this.nextArrow.setProperties({
								'href': k[index].getProperty('href'),
								'title': k[index].getProperty('title')
							})
						};
						if (index == 1) this.prevArrow = new Element('a', {
							'id': this.options.className + '-previous',
							'class': 'inactive',
							'href': '#'
						}).inject(this.arrows, 'top').set('html', '<span>&lt; previous</span>');
						if (index == k.length) this.nextArrow = new Element('a', {
							'id': this.options.className + '-next',
							'class': 'inactive',
							'href': '#'
						}).inject(this.arrows).set('html', '<span>next &gt;</span>');
						this.prevArrow.addEvent('click', function (e) {
							e = new Event(e).stop();
							if (!this.hasClass('inactive')) {
								h.changeGroup = true;
								h.nextGroup = [e, this, k, index];
								h.swtch = true;
								h.close(e, 'growl')
							}
						});
						this.nextArrow.addEvent('click', function (e) {
							e = new Event(e).stop();
							if (!this.hasClass('inactive')) {
								h.changeGroup = true;
								h.nextGroup = [e, this, k, index];
								h.swtch = true;
								h.close(e, 'growl')
							}
						})
					};
					this.arrows.show()
				}
			};
			if (this.options.captions) {
				var l = this.getCaption(c) || [false, false];
				var m = l[0],
				description = l[1];
				if (this.caption) this.caption.empty().dispose();
				this.caption = new Element('div', {
					'id': this.options.className + '-caption'
				}).inject(this.center).setStyle('opacity', 0).adopt(m, description)
			}
		}
	},
	unloadVideo: function () {
		if (this.type) this.container.innerHTML = '';
		this.movie = null;
		this.type = false
	},
	getCaption: function (a) {
		a = a.split(" :: ") || false;
		switch (a.length) {
		case 0:
			return false;
			break;
		case 1:
			var b = false;
			var c = new Element('p').set('text', a[0]);
			break;
		case 2:
			var b = new Element('h2').set('text', a[0]);
			var c = new Element('p').set('text', a[1]);
			break
		}
		return [b, c]
	},
	getGroup: function (a) {
		var b = a.getProperty('rel'),
		group = false;
		if (b) group = b.match(/\([a-z0-9A-Z]+\)/g) || false;
		if (group[0]) group = group[0].replace("(", "").replace(")", "");
		else group = false;
		return group
	}
});
var Rokverlay = new Class({
	Implements: [Options, Events],
	options: {
		'id': false,
		'class': false,
		'background': '#000000',
		'opacity': 0.7,
		'zIndex': 65555,
		'duration': 200,
		'transition': Fx.Transitions.Quad.easeInOut
	},
	initialize: function (a, b) {
		this.where = document.id(a) || document.id(document.body);
		this.setOptions(b);
		this.overlay = new Element('div', {
			'id': this.options.id || ('rokverlay-' + $random(1, 1000)),
			'class': this.options.id || ('rokverlay-' + $random(1, 1000)),
			'styles': {
				'opacity': 0,
				'display': 'none',
				'position': 'absolute',
				'top': 0,
				'left': 0,
				'cursor': 'pointer',
				'background-color': this.options.background,
				'z-index': this.options.zIndex
			}
		}).inject(document.body);
		this.fx = new Fx.Tween(this.overlay, 'opacity', {
			duration: this.options.duration,
			transition: this.options.transition
		});
		this.open = false;
		return this
	},
	reposition: function (a) {
		var b = this.where;
		a = a || window.getScrollSize();
		this.overlay.setStyles({
			top: b.getPosition().y || 0,
			left: b.getPosition().x || 0,
			width: window.getSize().x,
			height: a.y
		});
		return this
	},
	show: function () {
		var a = this.overlay,
		self = this;
		this.overlay.setStyle('display', '');
		this.open = true;
		this.reposition().fx.start('opacity', this.options.opacity).chain(function () {
			self.fireEvent('onShow', a)
		});
		return this
	},
	hide: function () {
		var a = this.overlay,
		self = this;
		this.open = false;
		this.reposition().fx.start('opacity', 0).chain(function () {
			a.setStyle('display', 'none');
			self.fireEvent('onHide', a)
		});
		return this
	},
	toggle: function () {
		this[this.open ? 'hide': 'show']();
		return this
	}
});
if (typeof deconcept == "undefined") {
	var deconcept = new Object()
}
if (typeof deconcept.util == "undefined") {
	deconcept.util = new Object()
}
if (typeof deconcept.SWFObjectUtil == "undefined") {
	deconcept.SWFObjectUtil = new Object()
}
deconcept.SWFObject = function (a, b, w, h, d, c, e, f, g, i) {
	if (!document.getElementById) {
		return
	}
	this.DETECT_KEY = i ? i: "detectflash";
	this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
	this.params = new Object();
	this.variables = new Object();
	this.attributes = new Array();
	if (a) {
		this.setAttribute("swf", a)
	}
	if (b) {
		this.setAttribute("id", b)
	}
	if (w) {
		this.setAttribute("width", w)
	}
	if (h) {
		this.setAttribute("height", h)
	}
	if (d) {
		this.setAttribute("version", new deconcept.PlayerVersion(d.toString().split(".")))
	}
	this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
	if (!window.opera && document.all && this.installedVer.major > 7) {
		deconcept.SWFObject.doPrepUnload = true
	}
	if (c) {
		this.addParam("bgcolor", c)
	}
	var q = e ? e: "high";
	this.addParam("quality", q);
	this.setAttribute("useExpressInstall", false);
	this.setAttribute("doExpressInstall", false);
	var j = (f) ? f: window.location;
	this.setAttribute("xiRedirectUrl", j);
	this.setAttribute("redirectUrl", "");
	if (g) {
		this.setAttribute("redirectUrl", g)
	}
};
deconcept.SWFObject.prototype = {
	useExpressInstall: function (a) {
		this.xiSWFPath = !a ? "expressinstall.swf": a;
		this.setAttribute("useExpressInstall", true)
	},
	setAttribute: function (a, b) {
		this.attributes[a] = b
	},
	getAttribute: function (a) {
		return this.attributes[a]
	},
	addParam: function (a, b) {
		this.params[a] = b
	},
	getParams: function () {
		return this.params
	},
	addVariable: function (a, b) {
		this.variables[a] = b
	},
	getVariable: function (a) {
		return this.variables[a]
	},
	getVariables: function () {
		return this.variables
	},
	getVariablePairs: function () {
		var a = new Array();
		var b;
		var c = this.getVariables();
		for (b in c) {
			a[a.length] = b + "=" + c[b]
		}
		return a
	},
	getSWFHTML: function () {
		var a = "";
		if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "PlugIn");
				this.setAttribute("swf", this.xiSWFPath)
			}
			a = "<embed type=\"application/x-shockwave-flash\" src=\"" + this.getAttribute("swf") + "\" width=\"" + this.getAttribute("width") + "\" height=\"" + this.getAttribute("height") + "\" style=\"" + this.getAttribute("style") + "\"";
			a += " id=\"" + this.getAttribute("id") + "\" name=\"" + this.getAttribute("id") + "\" ";
			var b = this.getParams();
			for (var c in b) {
				a += [c] + "=\"" + b[c] + "\" "
			}
			var d = this.getVariablePairs().join("&");
			if (d.length > 0) {
				a += "flashvars=\"" + d + "\""
			}
			a += "/>"
		} else {
			if (this.getAttribute("doExpressInstall")) {
				this.addVariable("MMplayerType", "ActiveX");
				this.setAttribute("swf", this.xiSWFPath)
			}
			a = "<object id=\"" + this.getAttribute("id") + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"" + this.getAttribute("width") + "\" height=\"" + this.getAttribute("height") + "\" style=\"" + this.getAttribute("style") + "\">";
			a += "<param name=\"movie\" value=\"" + this.getAttribute("swf") + "\" />";
			var e = this.getParams();
			for (var c in e) {
				a += "<param name=\"" + c + "\" value=\"" + e[c] + "\" />"
			}
			var f = this.getVariablePairs().join("&");
			if (f.length > 0) {
				a += "<param name=\"flashvars\" value=\"" + f + "\" />"
			}
			a += "</object>"
		}
		return a
	},
	write: function (a) {
		if (this.getAttribute("useExpressInstall")) {
			var b = new deconcept.PlayerVersion([6, 0, 65]);
			if (this.installedVer.versionIsValid(b) && !this.installedVer.versionIsValid(this.getAttribute("version"))) {
				this.setAttribute("doExpressInstall", true);
				this.addVariable("MMredirectURL", escape(this.getAttribute("xiRedirectUrl")));
				document.title = document.title.slice(0, 47) + " - Flash Player Installation";
				this.addVariable("MMdoctitle", document.title)
			}
		}
		if (this.skipDetect || this.getAttribute("doExpressInstall") || this.installedVer.versionIsValid(this.getAttribute("version"))) {
			var n = (typeof a == "string") ? document.getElementById(a) : a;
			n.innerHTML = this.getSWFHTML();
			return true
		} else {
			if (this.getAttribute("redirectUrl") != "") {
				document.location.replace(this.getAttribute("redirectUrl"))
			}
		}
		return false
	}
};
deconcept.SWFObjectUtil.getPlayerVersion = function () {
	var a = new deconcept.PlayerVersion([0, 0, 0]);
	if (navigator.plugins && navigator.mimeTypes.length) {
		var x = navigator.plugins["Shockwave Flash"];
		if (x && x.description) {
			a = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."))
		}
	} else {
		if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0) {
			var b = 1;
			var c = 3;
			while (b) {
				try {
					c++;
					b = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + c);
					a = new deconcept.PlayerVersion([c, 0, 0])
				} catch(e) {
					b = null
				}
			}
		} else {
			try {
				var b = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")
			} catch(e) {
				try {
					var b = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
					a = new deconcept.PlayerVersion([6, 0, 21]);
					b.AllowScriptAccess = "always"
				} catch(e) {
					if (a.major == 6) {
						return a
					}
				}
				try {
					b = new ActiveXObject("ShockwaveFlash.ShockwaveFlash")
				} catch(e) {}
			}
			if (b != null) {
				a = new deconcept.PlayerVersion(b.GetVariable("$version").split(" ")[1].split(","))
			}
		}
	}
	return a
};
deconcept.PlayerVersion = function (a) {
	this.major = a[0] != null ? parseInt(a[0], 10) : 0;
	this.minor = a[1] != null ? parseInt(a[1], 10) : 0;
	this.rev = a[2] != null ? parseInt(a[2], 10) : 0
};
deconcept.PlayerVersion.prototype.versionIsValid = function (a) {
	if (this.major < a.major) {
		return false
	}
	if (this.major > a.major) {
		return true
	}
	if (this.minor < a.minor) {
		return false
	}
	if (this.minor > a.minor) {
		return true
	}
	if (this.rev < a.rev) {
		return false
	}
	return true
};
deconcept.util = {
	getRequestParameter: function (a) {
		var q = document.location.search || document.location.hash;
		if (a == null) {
			return q
		}
		if (q) {
			var b = q.substring(1).split("&");
			for (var i = 0; i < b.length; i++) {
				if (b[i].substring(0, b[i].indexOf("=")) == a) {
					return b[i].substring((b[i].indexOf("=") + 1))
				}
			}
		}
		return ""
	}
};
deconcept.SWFObjectUtil.cleanupSWFs = function () {
	var a = document.getElementsByTagName("OBJECT");
	for (var i = a.length - 1; i >= 0; i--) {
		a[i].style.display = "none";
		for (var x in a[i]) {
			if (typeof a[i][x] == "function") {
				a[i][x] = function () {}
			}
		}
	}
};
if (deconcept.SWFObject.doPrepUnload) {
	if (!deconcept.unloadSet) {
		deconcept.SWFObjectUtil.prepUnload = function () {
			__flash_unloadHandler = function () {};
			__flash_savedUnloadHandler = function () {};
			window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs)
		};
		window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload);
		deconcept.unloadSet = true
	}
}
if (!document.getElementById && document.all) {
	document.getElementById = function (a) {
		return document.all[a]
	}
}
var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject;
var SWFObject = deconcept.SWFObject;
RokBox.implement({
	effects: function (a, b) {
		var c = {};
		if (!b) b = 0;
		switch (a) {
		case 'growl':
			c = {
				'start': {
					'top': [b.top - this.options.chase, b.top],
					'opacity': 1
				},
				'end': {
					'top': this.wrapper.getStyle('top').toInt() + this.options.chase,
					'opacity': 0
				}
			};
			break;
		case 'quicksilver':
			var d = this.wrapper.getStyle('height').toInt(),
			width = this.wrapper.getStyle('width').toInt();
			c = {
				'start': {
					'top': [b.top + (d / 2), b.top],
					'height': [0, d],
					'opacity': 1
				},
				'end': {
					'top': b.top + (d / 2),
					'left': window.getSize().x / 2 - ((window.getScrollSize().x - 10) / 2),
					'width': window.getScrollSize().x - 30,
					'height': 0,
					'opacity': 0
				}
			};
			break;
		case 'explode':
			var d = this.wrapper.getStyle('height').toInt(),
			width = this.wrapper.getStyle('width').toInt();
			c = {
				'start': {
					'height': [0, d],
					'width': [0, width],
					'opacity': 1,
					'top': [(window.getSize().y / 2) + window.getScroll().y, b.top],
					'left': [(window.getSize().x / 2) + window.getScroll().x, b.left]
				},
				'end': {
					'height': 0,
					'width': 0,
					'opacity': 0,
					'top': (window.getSize().y / 2) + window.getScroll().y,
					'left': (window.getSize().x / 2) + window.getScroll().x
				}
			};
			break;
		case 'fade':
			c = {
				'start': {
					'opacity': 1
				},
				'end': {
					'opacity': 0
				}
			}
		}
		return c
	}
});
