
		var mediaImages = new Array();
		var mediaImageIndex = 0;
		var mediaVideos = new Array();
		var mediaVideoIndex = 0;
		var innerHTML = '';
		
		function initMediaElements()
		{
			for(i = 0; document.getElementById('mediaImage' + i); i++)
			{
				registerImage(document.getElementById('mediaImage' + i).value);
			}
			for(i = 0; document.getElementById('mediaVideo' + i); i++)
			{
				registerVideo(document.getElementById('mediaVideo' + i).value);
			}				
		}		
		
		function registerImage(src)
		{
			mediaImages[mediaImages.length] = src;
		}
		
		function registerVideo(src)
		{
			mediaVideos[mediaVideos.length] = src;
		}
		
		function activateLightBoxShade()
		{
			document.getElementById('LightBoxShade').id='LightBoxShadeActive';																						
		}
		
		function deactivateLightBoxShade()
		{			
			document.getElementById('LightBoxShadeActive').id='LightBoxShade';						
		}
		
		function activateMediaBox(startIndex, isImage)
		{
			innerHTML = document.body.innerHTML;
			document.body.innerHTML = '<div style="width:99%; height:100%; margin:0px; padding:0px; position:fixed; overflow:hidden;">' + innerHTML + '</div>';
			
			activateLightBoxShade();
			document.getElementById('MediaBox').id='MediaBoxActive';
			if(isImage)
			{
				showImage(startIndex);
				document.getElementById('MediaBoxMediaControls').innerHTML = '<table width="100%"><tr><td align="left"><input type="image" src="images/left.gif" alt="previous image" onClick="mediaBoxPreviousImage();" /></td><td align="center">Use left and right arrows to browse images</td><td align="right"><input type="image" src="images/right.gif" alt="next image" onClick="mediaBoxNextImage();" /></td></tr></table>';
			}
			else
			{
				showVideo(startIndex);
				document.getElementById('MediaBoxMediaControls').innerHTML = '<table width="100%"><tr><td align="left"><input type="image" src="images/left.gif" alt="previous video" onClick="mediaBoxPreviousVideo();" /></td><td align="center">Use left and right arrows to browse videos</td><td align="right"><input type="image" src="images/right.gif" alt="next video" onClick="mediaBoxNextVideo();" /></td></tr></table>';		
			}
		}
		
		function showImage(startIndex)
		{
			document.getElementById('MediaBoxMediaHolder').innerHTML = '<img src="'+mediaImages[startIndex]+'" alt="Image '+(startIndex+1)+'" />';
			document.getElementById('mediaTitle').innerHTML = 'Image ' + (startIndex + 1);
			mediaImageIndex = startIndex;
		}
		
		function mediaBoxPreviousImage()
		{
			var prev = 0;
			if(mediaImageIndex == 0)
			{
				prev = mediaImages.length-1;
			}
			else
			{
				prev = mediaImageIndex-1;
			}
			showImage(prev);
		}
		
		function mediaBoxNextImage()
		{
			var nxt = 0;
			if(mediaImageIndex == (mediaImages.length-1))
			{
				nxt = 0;
			}
			else
			{
				nxt = mediaImageIndex+1;
			}
			showImage(nxt);	
		}
		
		function showVideo(startIndex)
		{																
			var arrVal = mediaVideos[startIndex].split("#");	
			var videoPath = arrVal[0];	
			var title = arrVal[1];
			var description = arrVal[2];
			document.getElementById('MediaBoxMediaHolder').innerHTML = '<div id="ufoVideo">The video will display shortly, please wait...</div><div style="width:320px; text-align:left;">' + description + '</div>';
			var contents = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" WIDTH="400" HEIGHT="266" id="ObjHigh">';
			contents += '<PARAM NAME=movie VALUE="videoPlayer.swf">';
			contents += '<PARAM NAME=quality VALUE=high>';
			contents += '<PARAM NAME=bgcolor VALUE=#FFFFFF>';
			contents += '<PARAM NAME=flashvars VALUE=videoURL='+videoPath+'&title=' + escape(title) + '>';
			contents += '<EMBED src="videoPlayer.swf" quality=high bgcolor=#FFFFFF WIDTH="400" HEIGHT="266" FLASHVARS="videoURL='+videoPath+'&title=' + escape(title) + '" NAME="myMovieName" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>';
			contents += '</OBJECT>';
			document.getElementById('ufoVideo').innerHTML = contents;	
			document.getElementById('mediaTitle').innerHTML = title;
			mediaVideoIndex = startIndex;
		}
		
		function mediaBoxPreviousVideo()
		{
			var prev = 0;
			if(mediaVideoIndex == 0)
			{
				prev = mediaVideos.length-1;
			}
			else
			{
				prev = mediaVideoIndex-1;
			}
			showVideo(prev);
		}
		
		function mediaBoxNextVideo()
		{
			var nxt = 0;
			if(mediaVideoIndex == (mediaVideos.length-1))
			{
				nxt = 0;
			}
			else
			{
				nxt = mediaVideoIndex+1;
			}
			showVideo(nxt);	
		}
		
		function deactivateMediaBox()
		{
			deactivateLightBoxShade();			
			document.getElementById('MediaBoxMediaHolder').innerHTML = '';
			document.getElementById('mediaTitle').innerHTML = '';
			document.getElementById('MediaBoxMediaControls').innerHTML = '';
			document.getElementById('MediaBoxActive').id='MediaBox';
			document.body.innerHTML = innerHTML;
		}