PageSourceSearch

https://oslarija.si/components/com_eventgallery/media/js/mediaboxAdv-1.3.4b.js?v=2.6.3

js oslarija.si collected 2026-10-06 16:15:58 UTC 48,219 bytes, 1,212 lines download raw bytes

1/*
2---
3description: Left and right swipe events for touch devices.
4
5license: MIT-style.
6
7authors:
8- Caleb Troughton
9https://github.com/imakewebthings/mooswipe/
10
11requires:
12  core/1.2.4:
13  - Element.Event
14  - Class
15  - Class.Extras
16
17provides:
18- MooSwipe
19
20...
21*/
22var MooSwipe = MooSwipe || new Class({
23	Implements: [Options, Events],
24
25	options: {
26		//onSwipeLeft: $empty,
27		//onSwipeRight: $empty,
28		//onSwipe: $empty,
29		tolerance: 20,
30		preventDefaults: true
31	},
32
33	element: null,
34	startX: null,
35	isMoving: false,
36
37	initialize: function(el, options) {
38		this.setOptions(options);
39		this.element = $(el);
40		this.element.addEvent('touchstart', this.onTouchStart.bind(this));
41	},
42
43	cancelTouch: function() {
44		this.element.removeEvent('touchmove', this.onTouchMove);
45		this.startX = null;
46		this.isMoving = false;
47	},
48
49	onTouchMove: function(e) {
50		this.options.preventDefaults && e.preventDefault();
51		if (this.isMoving) {
52			var x = e.touches[0].pageX;
53			var dx = this.startX - x;
54			if (Math.abs(dx) >= this.options.tolerance) {
55				this.cancelTouch();
56				this.fireEvent(dx > 0 ? 'swipeLeft' : 'swipeRight');
57				this.fireEvent('swipe', dx > 0 ? 'left' : 'right');
58			}
59		}		
60	},
61
62	onTouchStart: function(e) {
63		this.options.preventDefaults && e.preventDefault();
64		if (e.touches.length == 1) {
65			this.startX = e.touches[0].pageX;
66			this.isMoving = true;
67			this.element.addEvent('touchmove', this.onTouchMove.bind(this));
68		}
69	}
70});
71
72/*
73	mediaboxAdvanced v1.3.4b - The ultimate extension of Slimbox and Mediabox; an all-media script
74	updated 2010.09.21
75		(c) 2007-2010 John Einselen <http://iaian7.com>
76	based on Slimbox v1.64 - The ultimate lightweight Lightbox clone
77		(c) 2007-2008 Christophe Beyls <http://www.digitalia.be>
78	MIT-style license.
79
80	modified by me ;-)
81
82*/
83var mediaBoxImages  = null;
84
85var Mediabox;
86
87(function() {
88	// Global variables, accessible to Mediabox only
89	var timer, options, images, activeImage, prevImage, nextImage, top, mTop, left, mLeft, winWidth, winHeight, fx, preload, preloadPrev = new Image(), preloadNext = new Image(), foxfix = false, iefix = false,
90	// DOM elements
91	overlay, center, image, bottom, captionSplit, title, caption, prevLink, number, nextLink,
92	// Mediabox specific vars
93	URL, WH, WHL, elrel, mediaWidth, mediaHeight, mediaType = "none", mediaSplit, mediaId = "mediaBox", mediaFmt, margin;
94
95	/*	Initialization	*/
96
97	window.addEvent("domready", function() {
98		// Create and append the Mediabox HTML code at the bottom of the document
99		document.id(document.body).adopt(
100			$$([
101				overlay = new Element("div", {id: "mbOverlay"}).addEvent("click", close),
102				center = new Element("div", {id: "mbCenter"})
103			]).setStyle("display", "none")
104		);
105
106		image = new Element("div", {id: "mbImage"}).inject(center);
107		bottom = new Element("div", {id: "mbBottom"}).inject(center).adopt(
108			closeLink = new Element("a", {id: "mbCloseLink", href: "#"}).addEvent("click", close),
109			nextLink = new Element("a", {id: "mbNextLink", href: "#"}).addEvent("click", next),
110			prevLink = new Element("a", {id: "mbPrevLink", href: "#"}).addEvent("click", previous),
111			title = new Element("div", {id: "mbTitle"}),
112			number = new Element("div", {id: "mbNumber"}),
113			caption = new Element("div", {id: "mbCaption"})
114		);
115
116		new MooSwipe('mbImage', {
117		    onSwipeLeft: next,
118		    onSwipeRight: previous
119		});
120
121		fx = {
122			overlay: new Fx.Tween(overlay, {property: "opacity", duration: 360}).set(0),
123			image: new Fx.Tween(image, {property: "opacity", duration: 360, onComplete: captionAnimate}),
124			bottom: new Fx.Tween(bottom, {property: "opacity", duration: 240}).set(0)
125		};
126	});
127
128	/*	API		*/
129
130	Mediabox = {
131		getRelation: function()  {
132
133		},
134
135		isActive: function() {
136			return center.getStyle('display')!='none';
137		},
138
139
140		close: function(){
141			close();	// Thanks to Yosha on the google group for fixing the close function API!
142		},
143
144		open: function(_images, startImage, _options) {
145			options = Object.append({
146				text: ['<big>&laquo;</big>','<big>&raquo;</big>','<big>&times;</big>'],		// Set "previous", "next", and "close" button content (HTML code should be written as entity codes or properly escaped)
147//				text: ['<big>«</big>','<big>»</big>','<big>×</big>'],		// Set "previous", "next", and "close" button content (HTML code should be written as entity codes or properly escaped)
148//	example		text: ['<b>P</b>rev','<b>N</b>ext','<b>C</b>lose'],
149				loop: false,					// Allows to navigate between first and last images
150				keyboard: true,					// Enables keyboard control; escape key, left arrow, and right arrow
151				alpha: true,					// Adds 'x', 'c', 'p', and 'n' when keyboard control is also set to true
152				stopKey: true,					// Stops all default keyboard actions while overlay is open (such as up/down arrows)
153													// Does not apply to iFrame content, does not affect mouse scrolling
154				preventScrolling: true,
155				overlayOpacity: 0.7,			// 1 is opaque, 0 is completely transparent (change the color in the CSS file)
156				resizeOpening: true,			// Determines if box opens small and grows (true) or starts at larger size (false)
157				resizeDuration: 240,			// Duration of each of the box resize animations (in milliseconds)
158				resizeTransition: false,		// Mootools transition effect (false leaves it at the default)
159				initialWidth: 320,				// Initial width of the box (in pixels)
160				initialHeight: 180,				// Initial height of the box (in pixels)
161				defaultWidth: 640,				// Default width of the box (in pixels) for undefined media (MP4, FLV, etc.)
162				defaultHeight: 360,				// Default height of the box (in pixels) for undefined media (MP4, FLV, etc.)
163				showCaption: true,				// Display the title and caption, true / false
164				showCounter: true,				// If true, a counter will only be shown if there is more than 1 image to display
165				counterText: '({x} of {y})',	// Translate or change as you wish
166//			Image options
167				imgBackground: false,		// Embed images as CSS background (true) or <img> tag (false)
168											// CSS background is naturally non-clickable, preventing downloads
169											// IMG tag allows automatic scaling for smaller screens
170											// (all images have no-click code applied, albeit not Opera compatible. To remove, comment lines 212 and 822)
171				imgPadding: 100 ,			// Clearance necessary for images larger than the window size (only used when imgBackground is false)
172				imgPaddingFullscreen: 10,
173											// Change this number only if the CSS style is significantly divergent from the original, and requires different sizes
174			    showFullscreen: false,
175//			Inline options
176				overflow: 'auto',			// If set, overides CSS settings for inline content only
177//			Global media options
178				html5: 'true',				// HTML5 settings for YouTube and Vimeo, false = off, true = on
179				scriptaccess: 'true',		// Allow script access to flash files
180				fullscreen: 'true',			// Use fullscreen
181				fullscreenNum: '1',			// 1 = true
182				autoplay: 'true',			// Plays the video as soon as it's opened
183				autoplayNum: '1',			// 1 = true
184				autoplayYes: 'yes',			// yes = true
185				volume: '100',				// 0-100, used for NonverBlaster and Quicktime players
186				medialoop: 'true',			// Loop video playback, true / false, used for NonverBlaster and Quicktime players
187				bgcolor: '#000000',			// Background color, used for flash and QT media
188				wmode: 'opaque',			// Background setting for Adobe Flash ('opaque' and 'transparent' are most common)
189//			NonverBlaster
190				useNB: true,				// use NonverBlaster (true) or JW Media Player (false) for .flv and .mp4 files
191				playerpath: '/js/NonverBlaster.swf',	// Path to NonverBlaster.swf
192				controlColor: '0xFFFFFF',	// set the controlbar color
193				controlBackColor: '0x000000',	// set the controlbar color
194				showTimecode: 'false',		// turn timecode display off or on
195//			JW Media Player settings and options
196				JWplayerpath: '/js/player.swf',	// Path to the mediaplayer.swf or flvplayer.swf file
197				backcolor:	'000000',		// Base color for the controller, color name / hex value (0x000000)
198				frontcolor: '999999',		// Text and button color for the controller, color name / hex value (0x000000)
199				lightcolor: '000000',		// Rollover color for the controller, color name / hex value (0x000000)
200				screencolor: '000000',		// Rollover color for the controller, color name / hex value (0x000000)
201				controlbar: 'over',			// bottom, over, none (this setting is ignored when playing audio files)
202//			Quicktime options
203				controller: 'true',			// Show controller, true / false
204//			Flickr options
205				flInfo: 'true',				// Show title and info at video start
206//			Revver options
207				revverID: '187866',			// Revver affiliate ID, required for ad revinue sharing
208				revverFullscreen: 'true',	// Fullscreen option
209				revverBack: '000000',		// Background color
210				revverFront: 'ffffff',		// Foreground color
211				revverGrad: '000000',		// Gradation color
212//			Ustream options
213				usViewers: 'true',				// Show online viewer count (true/false)
214//			Youtube options
215				ytBorder: '0',				// Outline				(1=true, 0=false)
216				ytColor1: '000000',			// Outline color
217				ytColor2: '333333',			// Base interface color (highlight colors stay consistent)
218				ytQuality: '&ap=%2526fmt%3D18', // Leave empty for standard quality, use '&ap=%2526fmt%3D18' for high quality, and '&ap=%2526fmt%3D22' for HD (note that not all videos are availible in high quality, and very few in HD)
219				ytRel: '0',					// Show related videos	(1=true, 0=false)
220				ytInfo: '1',				// Show video info		(1=true, 0=false)
221				ytSearch: '0',				// Show search field	(1=true, 0=false)
222//			Viddyou options
223				vuPlayer: 'basic',			// Use 'full' or 'basic' players
224//			Vimeo options
225				vmTitle: '1',				// Show video title
226				vmByline: '1',				// Show byline
227				vmPortrait: '1',			// Show author portrait
228				vmColor: 'ffffff'			// Custom controller colors, hex value minus the # sign, defult is 5ca0b5
229			}, _options || {});
230
231			if ( _images[startImage][2] != null && _images[startImage][2].indexOf('fullscreen') != -1) {
232				options.showFullscreen=true;				
233			}
234
235
236			prevLink.set('html', options.text[0]);
237			nextLink.set('html', options.text[1]);
238			closeLink.set('html', options.text[2]);
239
240			margin = center.getStyle('padding-left').toInt()+image.getStyle('margin-left').toInt()+image.getStyle('padding-left').toInt();
241
242
243			if ((Browser.firefox) && (Browser.Engine) && (Browser.Engine.version<2)) {	// Fixes Firefox 2 and Camino 1.6 incompatibility with opacity + flash
244				foxfix = true;
245				options.overlayOpacity = 1;
246				overlay.className = 'mbOverlayFF';
247			}
248
249			if ((Browser.ie) && (Browser.version<5)) {	// Fixes IE 6 and earlier incompatibilities with CSS position: fixed;
250				iefix = true;
251				overlay.className = 'mbOverlayIE';
252				overlay.setStyle("position", "absolute");
253				position();
254			}
255
256			if (options.showFullscreen) {
257				overlay.addClass("fullscreen");
258			} else {
259				overlay.removeClass("fullscreen");
260			}
261
262			if (typeof _images == "string") {	// Used for single images only, with URL and Title as first two arguments
263				_images = [[_images,startImage,_options]];
264				startImage = 0;
265			}
266
267
268			// prevent scrolling and touch scrolling if the lightbox is active
269			var stopEvent = function(e) {
270				e.preventDefault();
271			};
272
273			if (options.preventScrolling) {
274				overlay.addEvent('mousewheel', stopEvent).addEvent('touchmove', stopEvent);
275				center.addEvent('mousewheel', stopEvent).addEvent('touchmove', stopEvent);
276			} else {
277				overlay.removeEvent('mousewheel', stopEvent).removeEvent('touchmove', stopEvent);
278				center.removeEvent('mousewheel', stopEvent).removeEvent('touchmove', stopEvent);
279			}
280
281			images = _images;
282			mediaBoxImages = images;
283			mediaBoxChangeImage = changeImage;
284			options.loop = options.loop && (images.length > 1);
285
286			size();
287			setup(true);
288			setCenterPosition();
289			fx.overlay.start(options.showFullscreen?1:options.overlayOpacity);
290			
291			window.addEvent('resize', refreshCenter);
292			window.addEvent('scroll', refreshCenter);
293			
294			return changeImage(startImage);
295		}
296	};
297
298	Element.implement({
299		mediabox: function(_options, linkMapper) {
300			$$(this).mediabox(_options, linkMapper);	// The processing of a single element is similar to the processing of a collection with a single element
301
302			return this;
303		}
304	});
305
306	Elements.implement({
307		/*
308			options:	Optional options object, see Mediabox.open()
309			linkMapper:	Optional function taking a link DOM element and an index as arguments and returning an array containing 3 elements:
310						the image URL and the image caption (may contain HTML)
311			linksFilter:Optional function taking a link DOM element and an index as arguments and returning true if the element is part of
312						the image collection that will be shown on click, false if not. "this" refers to the element that was clicked.
313						This function must always return true when the DOM element argument is "this".
314		*/
315		mediabox: function(_options, linkMapper, linksFilter) {
316			linkMapper = linkMapper || function(el) {
317				elrel = el.getAttribute('rel').split(/[\[\]]/);
318				elrel = elrel[1];
319
320				var title = $(el).getAttribute('data-title');
321
322				if (!title) {
323					title = el.title;
324				} else {
325					try {
326						title = decodeURIComponent(title);
327					}
328					catch (err) {
329						//console.log(err)
330					}
331				}
332				return [el.getAttribute('href'), title, elrel];
333			};
334
335			linksFilter = linksFilter || function() {
336				return true;
337			};
338
339			var links = this;
340
341			links.addEvent('contextmenu', function(e){
342				//if (this.toString().match(/\.gif|\.jpg|\.jpeg|\.png/i)) e.stop();
343			});
344
345			links.removeEvents("click").addEvent("click", function() {
346				// Build the list of images that will be displayed
347				var filteredArray = links.filter(linksFilter, this);
348				var filteredLinks = [];
349				var filteredHrefs = [];
350
351				filteredArray.each(function(item, index){
352					if(filteredHrefs.indexOf(item.toString()) < 0) {
353						filteredLinks.include(filteredArray[index]);
354						filteredHrefs.include(filteredArray[index].toString());
355					};
356				});
357
358				return Mediabox.open(filteredLinks.map(linkMapper), filteredHrefs.indexOf(this.toString()), _options);
359			});
360
361			return links;
362		}
363	});
364
365	function refreshCenter() {
366		window.clearTimeout(timer);
367			  
368		timer = (function(){
369		    setCenterPosition();
370	  		changeImage(activeImage);			  
371		}).delay(500);			  
372	}
373
374	/*	Internal functions	*/
375	function setCenterPosition() {
376		top = window.getScrollTop() + (window.getHeight()/2);
377		left = window.getScrollLeft() + (window.getWidth()/2);
378		fx.resize = new Fx.Morph(center, Object.append({duration: options.resizeDuration, onComplete: imageAnimate}, options.resizeTransition ? {transition: options.resizeTransition} : {}));
379		center.setStyles({top: top, left: left, width: options.initialWidth, height: options.initialHeight, marginTop: -(options.initialHeight/2)-margin, marginLeft: -(options.initialWidth/2)-margin, display: ""});
380	}
381
382	function position() {
383		overlay.setStyles({top: window.getScrollTop(), left: window.getScrollLeft()});
384	}
385
386	function size() {
387		winWidth = window.getWidth();
388		winHeight = window.getHeight();
389		overlay.setStyles({width: winWidth, height: winHeight});
390	}
391
392	function setup(open) {
393		// Hides on-page objects and embeds while the overlay is open, nessesary to counteract Firefox stupidity
394		if (Browser.firefox) {
395			["object", window.ie ? "select" : "embed"].forEach(function(tag) {
396				Array.forEach(document.getElementsByTagName(tag), function(el) {
397					if (open) el._mediabox = el.style.visibility;
398					el.style.visibility = open ? "hidden" : el._mediabox;
399				});
400			});
401		}
402
403		overlay.style.display = open ? "" : "none";
404
405		var fn = open ? "addEvent" : "removeEvent";
406		if (iefix) window[fn]("scroll", position);
407		window[fn]("resize", size);
408		if (options.keyboard) document[fn]("keydown", keyDown);
409	}
410
411	function keyDown(event) {
412		if (options.alpha) {
413			switch(event.code) {
414				case 8:	    // Backspace
415				case 27:	// Esc
416				case 88:	// 'x'
417				case 67:	// 'c'
418					close();
419					break;
420				case 37:	// Left arrow
421				case 80:	// 'p'
422					previous();
423					break;
424				case 39:	// Right arrow
425				case 78:	// 'n'
426					next();
427			}
428		} else {
429			switch(event.code) {
430				case 8:     // Backspace
431				case 27:	// Esc
432					close();
433					break;
434				case 37:	// Left arrow
435					previous();
436					break;
437				case 39:	// Right arrow
438					next();
439			}
440		}
441
442		if (options.stopKey) { return false; };
443	}
444
445	function previous() {
446		return changeImage(prevImage);
447	}
448
449	function next() {
450		return changeImage(nextImage);
451	}
452
453	function changeImage(imageIndex) {
454		if (imageIndex >= 0) {
455			image.set('html', '');
456			activeImage = imageIndex;
457			prevImage = ((activeImage || !options.loop) ? activeImage : images.length) - 1;
458			nextImage = activeImage + 1;
459			if (nextImage == images.length) nextImage = options.loop ? 0 : -1;
460			stop();
461			center.className = "mbLoading";
462
463	/*	mediaboxAdvanced link formatting and media support	*/
464
465			if (!images[imageIndex][2]) images[imageIndex][2] = '';	// Thanks to Leo Feyer for offering this fix
466			WH = images[imageIndex][2].split(' ');
467			WHL = WH.length;
468			if (WHL>1) {
469				mediaWidth = (WH[WHL-2].match("%")) ? (window.getWidth()*((WH[WHL-2].replace("%", ""))*0.01))+"px" : WH[WHL-2]+"px";
470				mediaHeight = (WH[WHL-1].match("%")) ? (window.getHeight()*((WH[WHL-1].replace("%", ""))*0.01))+"px" : WH[WHL-1]+"px";
471			} else {
472				mediaWidth = "";
473				mediaHeight = "";
474			}
475			URL = images[imageIndex][0];
476			URL = URL.replace("(","%28").replace(")","%29");
477			captionSplit = images[activeImage][1].split('::');
478
479// Quietube and yFrog support
480			if (URL.match(/quietube\.com/i)) {
481				mediaSplit = URL.split('v.php/');
482				URL = mediaSplit[1];
483			} else if (URL.match(/\/\/yfrog/i)) {
484				mediaType = (URL.substring(URL.length-1));
485				if (mediaType.match(/b|g|j|p|t/i)) mediaType = 'image';
486				if (mediaType == 's') mediaType = 'flash';
487				if (mediaType.match(/f|z/i)) mediaType = 'video';
488				URL = URL+":iphone";
489			
490
491	/*	Specific Media Types	*/
492// INLINE (moved there to override image findings)
493			} else if (URL.match(/\#mb_/i)) {
494				mediaType = 'inline';
495				mediaWidth = mediaWidth || options.defaultWidth;
496				mediaHeight = mediaHeight || options.defaultHeight;
497				URLsplit = URL.split('#');
498				preload = document.id(URLsplit[1]).get('html');
499				startEffect();
500// GIF, JPG, PNG
501			} else if (URL.match(/\.gif|\.jpg|\.jpeg|\.png|twitpic\.com/i) || mediaType == 'image') {
502				mediaType = 'img';
503				URL = URL.replace(/twitpic\.com/i, "twitpic.com/show/full");
504				preload = new Image();
505				preload.onload = startEffect;
506				preload.src = URL;
507// FLV, MP4
508			} else if (URL.match(/\.flv|\.mp4/i) || mediaType == 'video') {
509				mediaType = 'obj';
510				mediaWidth = mediaWidth || options.defaultWidth;
511				mediaHeight = mediaHeight || options.defaultHeight;
512				if (options.useNB) {
513				preload = new Swiff(''+options.playerpath+'?mediaURL='+URL+'&allowSmoothing=true&autoPlay='+options.autoplay+'&buffer=6&showTimecode='+options.showTimecode+'&loop='+options.medialoop+'&controlColor='+options.controlColor+'&controlBackColor='+options.controlBackColor+'&defaultVolume='+options.volume+'&scaleIfFullScreen=true&showScalingButton=true&crop=false', {
514					id: 'MediaboxSWF',
515					width: mediaWidth,
516					height: mediaHeight,
517					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
518					});
519				} else {
520				preload = new Swiff(''+options.JWplayerpath+'?file='+URL+'&backcolor='+options.backcolor+'&frontcolor='+options.frontcolor+'&lightcolor='+options.lightcolor+'&screencolor='+options.screencolor+'&autostart='+options.autoplay+'&controlbar='+options.controlbar, {
521					id: 'MediaboxSWF',
522					width: mediaWidth,
523					height: mediaHeight,
524					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
525					});
526				}
527				startEffect();
528// MP3, AAC
529			} else if (URL.match(/\.mp3|\.aac|tweetmic\.com|tmic\.fm/i) || mediaType == 'audio') {
530				mediaType = 'obj';
531				mediaWidth = mediaWidth || options.defaultWidth;
532				mediaHeight = mediaHeight || "20px";
533				if (URL.match(/tweetmic\.com|tmic\.fm/i)) {
534					URL = URL.split('/');
535					URL[4] = URL[4] || URL[3];
536					URL = "http://media4.fjarnet.net/tweet/tweetmicapp-"+URL[4]+'.mp3';
537				}
538				if (options.useNB) {
539				preload = new Swiff(''+options.playerpath+'?mediaURL='+URL+'&allowSmoothing=true&autoPlay='+options.autoplay+'&buffer=6&showTimecode='+options.showTimecode+'&loop='+options.medialoop+'&controlColor='+options.controlColor+'&controlBackColor='+options.controlBackColor+'&defaultVolume='+options.volume+'&scaleIfFullScreen=true&showScalingButton=true&crop=false', {
540					id: 'MediaboxSWF',
541					width: mediaWidth,
542					height: mediaHeight,
543					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
544					});
545				} else {
546				preload = new Swiff(''+options.JWplayerpath+'?file='+URL+'&backcolor='+options.backcolor+'&frontcolor='+options.frontcolor+'&lightcolor='+options.lightcolor+'&screencolor='+options.screencolor+'&autostart='+options.autoplay, {
547					id: 'MediaboxSWF',
548					width: mediaWidth,
549					height: mediaHeight,
550					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
551					});
552				}
553				startEffect();
554// SWF
555			} else if (URL.match(/\.swf/i) || mediaType == 'flash') {
556				mediaType = 'obj';
557				mediaWidth = mediaWidth || options.defaultWidth;
558				mediaHeight = mediaHeight || options.defaultHeight;
559				preload = new Swiff(URL, {
560					id: 'MediaboxSWF',
561					width: mediaWidth,
562					height: mediaHeight,
563					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
564					});
565				startEffect();
566// MOV, M4V, M4A, MP4, AIFF, etc.
567			} else if (URL.match(/\.mov|\.m4v|\.m4a|\.aiff|\.avi|\.caf|\.dv|\.mid|\.m3u|\.mp3|\.mp2|\.mp4|\.qtz/i) || mediaType == 'qt') {
568				mediaType = 'qt';
569				mediaWidth = mediaWidth || options.defaultWidth;
570				mediaHeight = (parseInt(mediaHeight)+16)+"px" || options.defaultHeight;
571				preload = new Quickie(URL, {
572					id: 'MediaboxQT',
573					width: mediaWidth,
574					height: mediaHeight,
575					container: 'mbImage',
576					attributes: {controller: options.controller, autoplay: options.autoplay, volume: options.volume, loop: options.medialoop, bgcolor: options.bgcolor}
577					});
578				startEffect();
579
580	/*	Social Media Sites	*/
581
582// Blip.tv
583			} else if (URL.match(/blip\.tv/i)) {
584				mediaType = 'obj';
585				mediaWidth = mediaWidth || "640px";
586				mediaHeight = mediaHeight || "390px";
587				preload = new Swiff(URL, {
588					src: URL,
589					width: mediaWidth,
590					height: mediaHeight,
591					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
592					});
593				startEffect();
594// Break.com
595			} else if (URL.match(/break\.com/i)) {
596				mediaType = 'obj';
597				mediaWidth = mediaWidth || "464px";
598				mediaHeight = mediaHeight || "376px";
599				mediaId = URL.match(/\d{6}/g);
600				preload = new Swiff('http://embed.break.com/'+mediaId, {
601					width: mediaWidth,
602					height: mediaHeight,
603					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
604					});
605				startEffect();
606// DailyMotion
607			} else if (URL.match(/dailymotion\.com/i)) {
608				mediaType = 'obj';
609				mediaWidth = mediaWidth || "480px";
610				mediaHeight = mediaHeight || "381px";
611				preload = new Swiff(URL, {
612					id: mediaId,
613					width: mediaWidth,
614					height: mediaHeight,
615					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
616					});
617				startEffect();
618// Facebook
619			} else if (URL.match(/facebook\.com/i)) {
620				mediaType = 'obj';
621				mediaWidth = mediaWidth || "320px";
622				mediaHeight = mediaHeight || "240px";
623				mediaSplit = URL.split('v=');
624				mediaSplit = mediaSplit[1].split('&');
625				mediaId = mediaSplit[0];
626				preload = new Swiff('http://www.facebook.com/v/'+mediaId, {
627					movie: 'http://www.facebook.com/v/'+mediaId,
628					classid: 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000',
629					width: mediaWidth,
630					height: mediaHeight,
631					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
632					});
633				startEffect();
634// Flickr
635			} else if (URL.match(/flickr\.com/i)) {
636				mediaType = 'obj';
637				mediaWidth = mediaWidth || "500px";
638				mediaHeight = mediaHeight || "375px";
639				mediaSplit = URL.split('/');
640				mediaId = mediaSplit[5];
641				preload = new Swiff('http://www.flickr.com/apps/video/stewart.swf', {
642					id: mediaId,
643					classid: 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000',
644					width: mediaWidth,
645					height: mediaHeight,
646					params: {flashvars: 'photo_id='+mediaId+'&amp;show_info_box='+options.flInfo, wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
647					});
648				startEffect();
649// GameTrailers Video
650			} else if (URL.match(/gametrailers\.com/i)) {
651				mediaType = 'obj';
652				mediaWidth = mediaWidth || "480px";
653				mediaHeight = mediaHeight || "392px";
654				mediaId = URL.match(/\d{5}/g);
655				preload = new Swiff('http://www.gametrailers.com/remote_wrap.php?mid='+mediaId, {
656					id: mediaId,
657					width: mediaWidth,
658					height: mediaHeight,
659					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
660					});
661				startEffect();
662// Google Video
663			} else if (URL.match(/google\.com\/videoplay/i)) {
664				mediaType = 'obj';
665				mediaWidth = mediaWidth || "400px";
666				mediaHeight = mediaHeight || "326px";
667				mediaSplit = URL.split('=');
668				mediaId = mediaSplit[1];
669				preload = new Swiff('http://video.google.com/googleplayer.swf?docId='+mediaId+'&autoplay='+options.autoplayNum, {
670					id: mediaId,
671					width: mediaWidth,
672					height: mediaHeight,
673					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
674					});
675				startEffect();
676// Megavideo - Thanks to Robert Jandreu for suggesting this code!
677			} else if (URL.match(/megavideo\.com/i)) {
678				mediaType = 'obj';
679				mediaWidth = mediaWidth || "640px";
680				mediaHeight = mediaHeight || "360px";
681				mediaSplit = URL.split('=');
682				mediaId = mediaSplit[1];
683				preload = new Swiff('http://wwwstatic.megavideo.com/mv_player.swf?v='+mediaId, {
684					id: mediaId,
685					width: mediaWidth,
686					height: mediaHeight,
687					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
688					});
689				startEffect();
690// Metacafe
691			} else if (URL.match(/metacafe\.com\/watch/i)) {
692				mediaType = 'obj';
693				mediaWidth = mediaWidth || "400px";
694				mediaHeight = mediaHeight || "345px";
695				mediaSplit = URL.split('/');
696				mediaId = mediaSplit[4];
697				preload = new Swiff('http://www.metacafe.com/fplayer/'+mediaId+'/.swf?playerVars=autoPlay='+options.autoplayYes, {
698					id: mediaId,
699					width: mediaWidth,
700					height: mediaHeight,
701					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
702					});
703				startEffect();
704// Myspace
705			} else if (URL.match(/vids\.myspace\.com/i)) {
706				mediaType = 'obj';
707				mediaWidth = mediaWidth || "425px";
708				mediaHeight = mediaHeight || "360px";
709				preload = new Swiff(URL, {
710					id: mediaId,
711					width: mediaWidth,
712					height: mediaHeight,
713					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
714					});
715				startEffect();
716// Revver
717			} else if (URL.match(/revver\.com/i)) {
718				mediaType = 'obj';
719				mediaWidth = mediaWidth || "480px";
720				mediaHeight = mediaHeight || "392px";
721				mediaSplit = URL.split('/');
722				mediaId = mediaSplit[4];
723				preload = new Swiff('http://flash.revver.com/player/1.0/player.swf?mediaId='+mediaId+'&affiliateId='+options.revverID+'&allowFullScreen='+options.revverFullscreen+'&autoStart='+options.autoplay+'&backColor=#'+options.revverBack+'&frontColor=#'+options.revverFront+'&gradColor=#'+options.revverGrad+'&shareUrl=revver', {
724					id: mediaId,
725					width: mediaWidth,
726					height: mediaHeight,
727					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
728					});
729				startEffect();
730// Rutube
731			} else if (URL.match(/rutube\.ru/i)) {
732				mediaType = 'obj';
733				mediaWidth = mediaWidth || "470px";
734				mediaHeight = mediaHeight || "353px";
735				mediaSplit = URL.split('=');
736				mediaId = mediaSplit[1];
737				preload = new Swiff('http://video.rutube.ru/'+mediaId, {
738					movie: 'http://video.rutube.ru/'+mediaId,
739					width: mediaWidth,
740					height: mediaHeight,
741					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
742					});
743				startEffect();
744// Seesmic
745			} else if (URL.match(/seesmic\.com/i)) {
746				mediaType = 'obj';
747				mediaWidth = mediaWidth || "435px";
748				mediaHeight = mediaHeight || "355px";
749				mediaSplit = URL.split('/');
750				mediaId = mediaSplit[5];
751				preload = new Swiff('http://seesmic.com/Standalone.swf?video='+mediaId, {
752					id: mediaId,
753					width: mediaWidth,
754					height: mediaHeight,
755					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
756					});
757				startEffect();
758// Tudou
759			} else if (URL.match(/tudou\.com/i)) {
760				mediaType = 'obj';
761				mediaWidth = mediaWidth || "400px";
762				mediaHeight = mediaHeight || "340px";
763				mediaSplit = URL.split('/');
764				mediaId = mediaSplit[5];
765				preload = new Swiff('http://www.tudou.com/v/'+mediaId, {
766					width: mediaWidth,
767					height: mediaHeight,
768					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
769					});
770				startEffect();
771// Twitvcam
772			} else if (URL.match(/twitcam\.com/i)) {
773				mediaType = 'obj';
774				mediaWidth = mediaWidth || "320px";
775				mediaHeight = mediaHeight || "265px";
776				mediaSplit = URL.split('/');
777				mediaId = mediaSplit[3];
778				preload = new Swiff('http://static.livestream.com/chromelessPlayer/wrappers/TwitcamPlayer.swf?hash='+mediaId, {
779					width: mediaWidth,
780					height: mediaHeight,
781					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
782					});
783				startEffect();
784// Twiturm
785			} else if (URL.match(/twiturm\.com/i)) {
786				mediaType = 'obj';
787				mediaWidth = mediaWidth || "402px";
788				mediaHeight = mediaHeight || "48px";
789				mediaSplit = URL.split('/');
790				mediaId = mediaSplit[3];
791				preload = new Swiff('http://twiturm.com/flash/twiturm_mp3.swf?playerID=0&sf='+mediaId, {
792					width: mediaWidth,
793					height: mediaHeight,
794					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
795					});
796				startEffect();
797// Twitvid
798			} else if (URL.match(/twitvid\.com/i)) {
799				mediaType = 'obj';
800				mediaWidth = mediaWidth || "600px";
801				mediaHeight = mediaHeight || "338px";
802				mediaSplit = URL.split('/');
803				mediaId = mediaSplit[3];
804				preload = new Swiff('http://www.twitvid.com/player/'+mediaId, {
805					width: mediaWidth,
806					height: mediaHeight,
807					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
808					});
809				startEffect();
810// Ustream.tv
811			} else if (URL.match(/ustream\.tv/i)) {
812				mediaType = 'obj';
813				mediaWidth = mediaWidth || "400px";
814				mediaHeight = mediaHeight || "326px";
815				preload = new Swiff(URL+'&amp;viewcount='+options.usViewers+'&amp;autoplay='+options.autoplay, {
816					width: mediaWidth,
817					height: mediaHeight,
818					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
819					});
820				startEffect();
821// YouKu
822			} else if (URL.match(/youku\.com/i)) {
823				mediaType = 'obj';
824				mediaWidth = mediaWidth || "480px";
825				mediaHeight = mediaHeight || "400px";
826				mediaSplit = URL.split('id_');
827				mediaId = mediaSplit[1];
828				preload = new Swiff('http://player.youku.com/player.php/sid/'+mediaId+'=/v.swf', {
829					width: mediaWidth,
830					height: mediaHeight,
831					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
832					});
833				startEffect();
834// YouTube Video (now includes HTML5 option)
835			} else if (URL.match(/youtube\.com\/watch/i)) {
836				mediaSplit = URL.split('v=');
837				if (options.html5) {
838					mediaType = 'url';
839					mediaWidth = mediaWidth || "640px";
840					mediaHeight = mediaHeight || "385px";
841					mediaId = "mediaId_"+new Date().getTime();	// Safari may not update iframe content with a static id.
842					preload = new Element('iframe', {
843						'src': 'http://www.youtube.com/embed/'+mediaSplit[1],
844						'id': mediaId,
845						'width': mediaWidth,
846						'height': mediaHeight,
847						'frameborder': 0
848						});
849					startEffect();
850				} else {
851					mediaType = 'obj';
852					mediaId = mediaSplit[1];
853					if (mediaId.match(/fmt=22/i)) {
854						mediaFmt = '&ap=%2526fmt%3D22';
855						mediaWidth = mediaWidth || "640px";
856						mediaHeight = mediaHeight || "385px";
857					} else if (mediaId.match(/fmt=18/i)) {
858						mediaFmt = '&ap=%2526fmt%3D18';
859						mediaWidth = mediaWidth || "560px";
860						mediaHeight = mediaHeight || "345px";
861					} else {
862						mediaFmt = options.ytQuality;
863						mediaWidth = mediaWidth || "480px";
864						mediaHeight = mediaHeight || "295px";
865					}
866					preload = new Swiff('http://www.youtube.com/v/'+mediaId+'&autoplay='+options.autoplayNum+'&fs='+options.fullscreenNum+mediaFmt+'&border='+options.ytBorder+'&color1=0x'+options.ytColor1+'&color2=0x'+options.ytColor2+'&rel='+options.ytRel+'&showinfo='+options.ytInfo+'&showsearch='+options.ytSearch, {
867						id: mediaId,
868						width: mediaWidth,
869						height: mediaHeight,
870						params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
871						});
872					startEffect();
873				}
874// YouTube Playlist
875			} else if (URL.match(/youtube\.com\/view/i)) {
876				mediaType = 'obj';
877				mediaSplit = URL.split('p=');
878				mediaId = mediaSplit[1];
879				mediaWidth = mediaWidth || "480px";
880				mediaHeight = mediaHeight || "385px";
881				preload = new Swiff('http://www.youtube.com/p/'+mediaId+'&autoplay='+options.autoplayNum+'&fs='+options.fullscreenNum+mediaFmt+'&border='+options.ytBorder+'&color1=0x'+options.ytColor1+'&color2=0x'+options.ytColor2+'&rel='+options.ytRel+'&showinfo='+options.ytInfo+'&showsearch='+options.ytSearch, {
882					id: mediaId,
883					width: mediaWidth,
884					height: mediaHeight,
885					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
886					});
887				startEffect();
888// Veoh
889			} else if (URL.match(/veoh\.com/i)) {
890				mediaType = 'obj';
891				mediaWidth = mediaWidth || "410px";
892				mediaHeight = mediaHeight || "341px";
893				URL = URL.replace('%3D','/');
894				mediaSplit = URL.split('watch/');
895				mediaId = mediaSplit[1];
896				preload = new Swiff('http://www.veoh.com/static/swf/webplayer/WebPlayer.swf?version=AFrontend.5.5.2.1001&permalinkId='+mediaId+'&player=videodetail
896sembedded&videoAutoPlay='+options.AutoplayNum+'&id=anonymous', {
897					id: mediaId,
898					width: mediaWidth,
899					height: mediaHeight,
900					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
901					});
902				startEffect();
903// Viddler
904			} else if (URL.match(/viddler\.com/i)) {
905				mediaType = 'obj';
906				mediaWidth = mediaWidth || "437px";
907				mediaHeight = mediaHeight || "370px";
908				mediaSplit = URL.split('/');
909				mediaId = mediaSplit[4];
910				preload = new Swiff(URL, {
911					id: 'viddler_'+mediaId,
912					movie: URL,
913					classid: 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000',
914					width: mediaWidth,
915					height: mediaHeight,
916					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen, id: 'viddler_'+mediaId, movie: URL}
917					});
918				startEffect();
919// Viddyou
920			} else if (URL.match(/viddyou\.com/i)) {
921				mediaType = 'obj';
922				mediaWidth = mediaWidth || "416px";
923				mediaHeight = mediaHeight || "312px";
924				mediaSplit = URL.split('=');
925				mediaId = mediaSplit[1];
926				preload = new Swiff('http://www.viddyou.com/get/v2_'+options.vuPlayer+'/'+mediaId+'.swf', {
927					id: mediaId,
928					movie: 'http://www.viddyou.com/get/v2_'+options.vuPlayer+'/'+mediaId+'.swf',
929					width: mediaWidth,
930					height: mediaHeight,
931					params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
932					});
933				startEffect();
934// Vimeo (now includes HTML5 option)
935			} else if (URL.match(/vimeo\.com/i)) {
936				mediaWidth = mediaWidth || "640px";		// site defualt: 400px
937				mediaHeight = mediaHeight || "360px";	// site defualt: 225px
938				mediaSplit = URL.split('/');
939				mediaId = mediaSplit[3];
940
941				if (options.html5) {
942					mediaType = 'url';
943					mediaId = "mediaId_"+new Date().getTime();	// Safari may not update iframe content with a static id.
944					preload = new Element('iframe', {
945						'src': 'http://player.vimeo.com/video/'+mediaSplit[3]+'?portrait='+options.vmPortrait,
946						'id': mediaId,
947						'width': mediaWidth,
948						'height': mediaHeight,
949						'frameborder': 0
950						});
951					startEffect();
952				} else {
953					mediaType = 'obj';
954					preload = new Swiff('http://www.vimeo.com/moogaloop.swf?clip_id='+mediaId+'&amp;server=www.vimeo.com&amp;fullscreen='+options.fullscreenNum+'&amp;autoplay='+options.autoplayNum+'&amp;show_title='+options.vmTitle+'&amp;show_byline='+options.vmByline+'&amp;show_portrait='+options.vmPortrait+'&amp;color='+options.vmColor, {
955						id: mediaId,
956						width: mediaWidth,
957						height: mediaHeight,
958						params: {wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
959						});
960					startEffect();
961				}
962// 12seconds
963			} else if (URL.match(/12seconds\.tv/i)) {
964				mediaType = 'obj';
965				mediaWidth = mediaWidth || "430px";
966				mediaHeight = mediaHeight || "360px";
967				mediaSplit = URL.split('/');
968				mediaId = mediaSplit[5];
969				preload = new Swiff('http://embed.12seconds.tv/players/remotePlayer.swf', {
970					id: mediaId,
971					width: mediaWidth,
972					height: mediaHeight,
973					params: {flashvars: 'vid='+mediaId+'', wmode: options.wmode, bgcolor: options.bgcolor, allowscriptaccess: options.scriptaccess, allowfullscreen: options.fullscreen}
974					});
975				startEffect();
976
977	/*	Specific Content Types	*/
978
979// HTML
980			} else {
981				mediaType = 'url';
982				mediaWidth = mediaWidth || options.defaultWidth;
983				mediaHeight = mediaHeight || options.defaultHeight;
984				mediaId = "mediaId_"+new Date().getTime();	// Safari may not update iframe content with a static id.
985				preload = new Element('iframe', {
986					'src': URL,
987					'id': mediaId,
988					'width': mediaWidth,
989					'height': mediaHeight,
990					'frameborder': 0
991					});
992				startEffect();
993			}
994		}
995		return false;
996	}
997
998	function startEffect() {
999		
1000		imgPadding = options.showFullscreen?options.imgPaddingFullscreen:options.imgPadding;
1001		
1002		if (mediaType == "img"){
1003			image.setStyles({overflow: "hidden"});			
1004			mediaWidth = preload.width;
1005			mediaHeight = preload.height;
1006			
1007			if (options.imgBackground) {
1008				image.setStyles({backgroundImage: "url("+URL+")", display: ""});
1009			} else {	// Thanks to Dusan Medlin for fixing large 16x9 image errors in a 4x3 browser
1010				if (mediaHeight >= winHeight-imgPadding && (mediaHeight / winHeight) >= (mediaWidth / winWidth)) {
1011					mediaHeight = winHeight-imgPadding;
1012					mediaWidth = preload.width = parseInt((mediaHeight/preload.height)*mediaWidth);
1013					preload.height = mediaHeight;
1014				} else if (mediaWidth >= winWidth-imgPadding && (mediaHeight / winHeight) < (mediaWidth / winWidth)) {
1015					mediaWidth = winWidth-imgPadding;
1016					mediaHeight = preload.height = parseInt((mediaWidth/preload.width)*mediaHeight);
1017					preload.width = mediaWidth;
1018				}
1019							
1020				if (Browser.ie) preload = document.id(preload);
1021				
1022				//preload.addEvent('mousedown', function(e){ e.stop(); }).addEvent('contextmenu', function(e){ e.stop(); });
1023				image.setStyles({backgroundImage: "none", display: ""});
1024
1025				preload.inject(image);
1026				
1027			}
1028		} else if (mediaType == "obj") {
1029			if (Browser.Plugins.Flash.version<8) {
1030				image.setStyles({backgroundImage: "none", display: ""});
1031				image.set('html', '<div id="mbError"><b>Error</b><br/>Adobe Flash is either not installed or not up to date, please visit <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" title="Get Flash" target="_new">Adobe.com</a> to download the free player.</div>');
1032				mediaWidth = options.DefaultWidth;
1033				mediaHeight = options.DefaultHeight;
1034			} else {
1035				image.setStyles({backgroundImage: "none", display: ""});
1036				preload.inject(image);
1037			}
1038		} else if (mediaType == "qt") {
1039			image.setStyles({backgroundImage: "none", display: ""});
1040			preload;
1041		} else if (mediaType == "inline") {
1042			if (options.overflow) image.setStyles({overflow: options.overflow});
1043			image.setStyles({backgroundImage: "none", display: ""});
1044			image.set('html', preload);
1045			if (mediaWidth>winWidth) {
1046				mediaWidth = winWidth.margin;
1047			}
1048		} else if (mediaType == "url") {
1049			image.setStyles({backgroundImage: "none", display: ""});
1050			preload.inject(image);
1051		} else {
1052			image.setStyles({backgroundImage: "none", display: ""});
1053			image.set('html', '<div id="mbError"><b>Error</b><br/>A file type error has occoured, please visit <a href="iaian7.com/webcode/mediaboxAdvanced" title="mediaboxAdvanced" target="_new">iaian7.com</a> or contact the website author for more information.</div>');
1054			mediaWidth = options.defaultWidth;	
1055			mediaHeight = options.defaultHeight;
1056		}
1057		
1058		image.setStyles({width: mediaWidth, height: mediaHeight});
1059		caption.setStyles({width: mediaWidth});
1060
1061		title.set('html', (options.showCaption) ? captionSplit[0] : "");
1062		caption.set('html', (options.showCaption && (captionSplit.length > 1)) ? captionSplit[1] : "");
1063		number.set('html', (options.showCounter && (images.length > 1)) ? options.counterText.replace(/{x}/, activeImage + 1).replace(/{y}/, images.length) : "");
1064
1065		if ((prevImage >= 0) && (images[prevImage][0].match(/\.gif|\.jpg|\.jpeg|\.png|twitpic\.com/i))) preloadPrev.src = images[prevImage][0].replace(/twitpic\.com/i, "twitpic.com/show/full");
1066		if ((nextImage >= 0) && (images[nextImage][0].match(/\.gif|\.jpg|\.jpeg|\.png|twitpic\.com/i))) preloadNext.src = images[nextImage][0].replace(/twitpic\.com/i, "twitpic.com/show/full");
1067
1068
1069		/* detect bottom height even with large text*/
1070		bottom.setStyle("width", mediaWidth);
1071		var bottomHeight = bottom.offsetHeight;
1072		bottom.setStyle("width", "auto");
1073
1074		origImageWidth = mediaWidth;
1075		origImageHeight = mediaHeight;
1076
1077		mediaWidth = image.offsetWidth;
1078		mediaHeight = image.offsetHeight+bottomHeight;		
1079
1080
1081		/* readjust the size of the lightbox*/
1082		if (options.showFullscreen) {
1083			var bottomWidth = window.getWidth()-bottom.getStyle('padding-left').toInt()-bottom.getStyle('padding-right').toInt()
1084
1085			/* detect bottom height even with large text*/
1086			if (bottomWidth	> 1024) bottomWidth = 1024;
1087			bottom.setStyle("width", bottomWidth);
1088			bottom.setStyle("margin", "auto");					
1089			caption.setStyle("width",bottomWidth);
1090
1091			var bottomHeight = bottom.offsetHeight;
1092
1093			mediaHeight = winHeight-imgPadding;
1094			
1095			if (typeof preload == 'object') {
1096				var pRatio = origImageWidth/origImageHeight;
1097				
1098				var finalHeight = origImageHeight;
1099				var finalWidth = origImageWidth;
1100								
1101				if (finalWidth>winWidth-(2*margin) || finalHeight>winHeight-bottomHeight-(2*margin) ){
1102					/* adjust the height*/
1103					finalHeight = winHeight-bottomHeight-(2*margin);				
1104					finalWidth = Math.floor(finalHeight*pRatio);
1105					
1106					/* adjust the width if the image is too width */
1107					if (finalWidth>winWidth-(2*margin)) {
1108						finalWidth = winWidth-(2*margin);				
1109						finalHeight = Math.floor(finalWidth/pRatio);
1110					}
1111				}
1112				preload.setStyles({width: finalWidth, height:finalHeight});
1113
1114				preload.setStyle("display","block");
1115				preload.setStyle("margin","auto");	
1116				var paddingTop = Math.ceil( (winHeight-bottomHeight-(finalWidth/pRatio))/2-margin );
1117				if (paddingTop>0) {
1118					preload.setStyle("padding-top", paddingTop );			
1119				}				
1120			}
1121			
1122			image.setStyle("width", "auto");
1123			image.setStyle("height", winHeight-bottomHeight-image.getStyle('padding-top').toInt()-image.getStyle('padding-top').toInt());			
1124			
1125			mediaWidth = winWidth-1-center.getStyle("padding-left").toInt()-center.getStyle("padding-right").toInt();
1126			mediaHeight = winHeight-1-center.getStyle("padding-top").toInt()-center.getStyle("padding-bottom").toInt();
1127			
1128		}
1129		else if (mediaHeight > winHeight && preload) {
1130			mediaHeight = winHeight-imgPadding;
1131			image.setStyle("height", mediaHeight-bottomHeight-(2*margin));			
1132			if (typeof preload == 'object') {
1133				var pRatio = origImageWidth/origImageHeight;
1134
1135				preload.width = ((mediaHeight-bottomHeight)*pRatio)-(2*margin);
1136				preload.setStyle("display","block");
1137				preload.setStyle("margin","auto");	
1138			}
1139			caption.setStyle("width",image.getStyle("width").toInt()-margin);
1140			title.setStyle("width", image.getStyle("width").toInt()-margin);
1141		}		
1142		
1143				
1144		if (mediaHeight >= top+top) { mTop = -top } else { mTop = -(mediaHeight/2) };
1145		if (mediaWidth >= left+left) { mLeft = -left } else { mLeft = -(mediaWidth/2) };
1146		
1147		if (options.resizeOpening) { 
1148			fx.resize.start({width: mediaWidth, height: mediaHeight, marginTop: mTop, marginLeft: mLeft});
1149		} else { 
1150			center.setStyles({width: mediaWidth, height: mediaHeight, marginTop: mTop, marginLeft: mLeft}); imageAnimate(); 
1151		}
1152	}
1153
1154	function imageAnimate() {
1155		fx.image.start(1);
1156	}
1157
1158	function captionAnimate() {
1159		center.className = "";
1160		if (prevImage >= 0) prevLink.style.display = "";
1161		if (nextImage >= 0) nextLink.style.display = "";
1162		fx.bottom.start(1);
1163	}
1164
1165	function stop() {
1166		if (preload) preload.onload = function(){};
1167		fx.resize.cancel();
1168		fx.image.cancel().set(0);
1169		fx.bottom.cancel().set(0);
1170		$$(prevLink, nextLink).setStyle("display", "none");
1171	}
1172
1173	function close() {
1174		if (activeImage >= 0) {
1175			preload.onload = function(){};
1176			image.set('html', '');
1177			for (var f in fx) fx[f].cancel();
1178			center.setStyle("display", "none");
1179			fx.overlay.chain(setup).start(0);
1180		}
1181
1182		window.removeEvent('resize', refreshCenter);
1183		window.removeEvent('scroll', refreshCenter);
1184
1185		return false;
1186	}
1187})();
1188
1189	/*	Autoload code block	*/
1190
1191Mediabox.scanPage = function() {
1192//	$$('#mb_').each(function(hide) { hide.set('display', 'none'); });
1193	var buttonElements = $$("button");
1194	var linkElements = $$("a");
1195	
1196	linkElements.combine(buttonElements);
1197	var links = linkElements.filter(function(el) {
1198		if (el.tagName == 'BUTTON' && el.getAttribute('data-rel') && el.getAttribute('data-href')) {
1199			el.setAttribute('rel',el.getAttribute('data-rel'));
1200			el.setAttribute('href',el.getAttribute('data-href'));
1201		}
1202		return el.getAttribute('rel') && el.getAttribute('rel').test(/^lightbo2/i);		
1203	});
1204		
1205	$$(links).mediabox({/* Put custom options here */}, null, function(el) {
1206		var rel0 = this.getAttribute('rel').replace(/[[]|]/gi," ");
1207		var relsize = rel0.split(" ");
1208		return (this == el) || ((this.getAttribute('rel').length > 8) && el.getAttribute('rel').match(relsize[1]));
1209	});
1210};
1211window.addEvent("domready", Mediabox.scanPage);
1212

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.