Lightbox.addMethods ({
    start: function(elementLink) {	

		hideSelectBoxes();		
		hideFlash();
		
		// stretch overlay to fill page and fade in
		var arrayPageSize = getPageSize();
		Element.setWidth('overlay', arrayPageSize[0]);
		Element.setHeight('overlay', arrayPageSize[1]);
		
		// Again, if the user is on a Mac and has a Mozilla flavor browser, we can't use dynamically generated opacity or you will experience problems with the Flash movies.
		if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1 || userAgent.indexOf('camino')!=-1) {
			Element.show('overlay');
		}else{ // Non-Mac, carry on as usual.
			new Effect.Appear('overlay', { duration: overlayDuration, from: 0.0, to: overlayOpacity });
		}

		elementArray = [];
		elementNum = 0;		

		if (!document.getElementsByTagName){ return; }
		var anchors = document.getElementsByTagName(elementLink.tagName);
		
				
		// If the image or SWF is not a part of the set...
		if((elementLink.getAttribute('rel') == 'lightbox')){
			// Add single image or SWF to elementArray
			if(elementLink.getAttribute('href').endsWith('swf')) { // SWF
				elementArray.push(new Array(elementLink.getAttribute('href'), elementLink.getAttribute('title'), elementLink.getAttribute('width'), elementLink.getAttribute('height'), elementLink.getAttribute('rev'), elementLink.getAttribute('target')));
			} else { // Image
				elementArray.push(new Array(elementLink.getAttribute('href'), elementLink.getAttribute('title')));
			}				
		} else {
		// Image or SWF is not part of a set...
				
			// Loop through anchors, find other images/SWF's in the set, and add them to elementArray
			for (var i=0; i<anchors.length; i++){
				var anchor = anchors[i];
				if (anchor.getAttribute('href') && (anchor.getAttribute('rel') == elementLink.getAttribute('rel'))){
					if(anchor.getAttribute('href').endsWith('swf')) { // SWF
						elementArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title'), anchor.getAttribute('width'), anchor.getAttribute('height')));
					} else {
						elementArray.push(new Array(anchor.getAttribute('href'), anchor.getAttribute('title')));
					}
				}
			}
			elementArray.removeDuplicates();
			while(elementArray[elementNum][0] != elementLink.getAttribute('href')) { elementNum++;}
		}

		// Calculate top and left offset for the lightbox 
		var arrayPageScroll = getPageScroll();
		var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
		var lightboxLeft = arrayPageScroll[0];
		Element.setTop('lightbox', lightboxTop);
		Element.setLeft('lightbox', lightboxLeft);
		
		Element.show('lightbox');
		
		this.changeElement(elementNum);
	},
        
        showElement: function(){
		Element.hide('loading');
		
		if(elementArray[activeElement][0].endsWith('swf')) { // SWF
			// Since the activeElement is a SWF, hide the image element.
			$('lightboximage').style.display = 'none';
			
			
			// Setup the proper object and embed tags in the SWF div.  The following is a basic set of object and embed tags, edit as you see fit.
			var obj = $('lightboxswf');
			obj.innerHTML =
				
				//this would be the proper flash object tag by: http://www.alistapart.com/articles/flashsatay ATTENTION:it doesnt check for version! flash is version9 most spread!
				//'<object type="application/x-shockwave-flash" data="'+elementArray[activeElement][0]+"?rev="+elementArray[activeElement][4]+"&target="+elementArray[activeElement][5]+'" width="'+elementArray[activeElement][2]+'" height="'+elementArray[activeElement][3]+'"><param name="movie" value="'+elementArray[activeElement][0]+"?rev="+elementArray[activeElement][4]+"&target="+elementArray[activeElement][5]+'" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" />"</object>'	


				//traditional flash object and embed tag
				"<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\" width=\""+elementArray[activeElement][2]+"\" height=\""+elementArray[activeElement][3]+"\">" +
				"<param name=\"movie\" value=\""+elementArray[activeElement][0]+"?rev="+elementArray[activeElement][4]+"&target="+elementArray[activeElement][5]+"\"/>" +
				"<param name=\"allowFullScreen\" value=\"true\" />" +
				"<param name=\"quality\" value=\"high\" />" +
				"<param name=\"allowscriptaccess\" value=\"always\" />" +
                                "<param name=\"bgcolor\" value=\"#ffffff\" />" +
				"<embed allowFullScreen=\"true\" allowscriptaccess=\"always\" bgcolor=\"#ffffff\" src=\""+elementArray[activeElement][0]+"?rev="+elementArray[activeElement][4]+"&target="+elementArray[activeElement][5]+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+elementArray[activeElement][2]+"\" height=\""+elementArray[activeElement][3]+"\">" +
				"</embed>" +
				"</object>"
				
			new Effect.Appear('lightboxswf', {  duration: resizeDuration, queue: 'end', from: 0.0, to: 100, afterFinish: function(){ myLightbox.updateDetails(); } });
		} else { // Image
			// Since the activeElement is an image, hide the SWF element.
			$('lightboxswf').style.display = 'none';
			new Effect.Appear('lightboximage', { duration: resizeDuration, queue: 'end', afterFinish: function(){ myLightbox.updateDetails(); } });
			this.preloadNeighborImages();
		}
	}
});