	var ie6Preload;
	var ieVersion = window.details.ieVersion();
	var isIE = ieVersion > -1;
	var isOpera = navigator.appName.toLowerCase().contains('opera');
	var isIE6 = ieVersion > -1 && ieVersion < 7;
	var isMacSafari = (navigator.appVersion.indexOf("Mac")!=-1&&navigator.appVersion.indexOf("Safari")!=-1);
	var isMacFF = (navigator.appVersion.indexOf("Mac")!=-1&&navigator.appVersion.indexOf("Safari")==-1);
	
	var viewBoxPaddingTop = 0;
	var viewBoxPaddingBottom = (isIE)?40:32;
	var viewBoxPaddingRight = 32;
	var viewBoxMaxHeight = 625;
	var viewBoxLoadLatency = 300;

	var tmrExpand;
	var itemDimensions;
	var intThumbnails = 0;
	var currentItemArgs;

	// IE RENDERS THINGS DIFFERENTLY.
	if(isIE){
		viewBoxPaddingRight += 8;
	}

	function viewItem(args,basePath){
		
		if(basePath) args.url = basePath + args.url;		
		
		itemDimensions = [];
		var viewBox = $('viewBox');
		var viewBoxDescription = $('viewBoxDescription');

		// RESET VIEWBOX
		if(!viewBox) return;
		viewBox.innerHTML = '';

		if(args.height>viewBoxMaxHeight) args.height = viewBoxMaxHeight;

			var width = args.width || 500;
			var height = args.height || 280;
			itemDimensions = [width,height];

			// PREPARE VIEWBOX CONTENTS
			viewBox.innerHTML = '<div id="viewBoxInner"><div id="viewBoxItem"><img src="../images/spacer.gif" style="width:'+width+'px;height:'+height+'px" /></div></div>';
			var fileExtension = args.url.getExtension();
			var fileName = args.url.getFileName();
			var imgUrl = '/portfolio/thumbnails/vid_' + fileName.replace(fileExtension,'jpg');
			writeVideoObject('viewBoxItem',imgUrl,args.url,width,height);
			window.setTimeout(sizeViewBoxToFit,viewBoxLoadLatency);
			currentItemArgs = args;
			
			$('viewBoxDescriptionTitle').innerHTML = args.name;
			$('viewBoxDescriptionCaption').innerHTML = args.caption;
			
			// COREMETRICS
			if(args.pageid){
				cm_pageview(args.pageid);
			}
	}
	
	function image_loaded(srcElement){
		$('viewBoxInner').style.display = 'block';
		itemDimensions = [srcElement.clientWidth,srcElement.clientHeight-viewBoxPaddingTop];
		sizeViewBoxToFit();
	}
	
	function sizeViewBoxToFit(){
		$('viewBoxInner').style.display = 'block';

		var viewBox = $('viewBox');
		showViewBox();

		// TEMPORARILY SET TO FULL DIMENSIONS
		var fullWidth = itemDimensions[0] + viewBoxPaddingRight;
		var fullHeight = itemDimensions[1] + viewBoxPaddingBottom + viewBoxPaddingTop;
		viewBox.style.visibility = 'hidden';
		viewBox.style.height = fullHeight + 'px';
		viewBox.style.width = fullWidth + 'px';
		viewBox.style.backgroundImage = 'none';
		showViewBoxDescription();

		// SET VIEWBOX LOCATION
		resizeDarkScreen(true);

		// RESIZE BACK DOWN
		viewBox.style.width = '50px';
		viewBox.style.height = '50px';
		viewBox.style.visibility = 'visible';

		// SHOW ITEM
		$('viewBoxInner').style.visibility = 'visible';

		// BEGIN TO EXPAND VIEWBOX
		window.setTimeout(
			function(){
				tmrExpand = window.setInterval(expandViewBox,10);
			}
		,100);
	}

	function expandViewBox(){
		var increment = 48;
		
		// DETERMINE DIMENSIONS
		var viewBox = $('viewBox');
		var fullWidth = itemDimensions[0] + viewBoxPaddingRight;
		var fullHeight = itemDimensions[1] + viewBoxPaddingBottom + viewBoxPaddingTop;
		var currentWidth = viewBox.clientWidth;
		var currentHeight = viewBox.clientHeight;

		if(currentWidth+increment<fullWidth||currentHeight+increment<fullHeight){
			if(currentWidth+increment<fullWidth){
				viewBox.style.width = (currentWidth+increment) + 'px';				
			}
			
			if(currentHeight+increment<fullHeight){
				viewBox.style.height = (currentHeight+increment) + 'px';
			}
		}else{
			// FULL SIZE REACHED; STOP EXPANDING
			viewBox.style.width = fullWidth + 'px';
			viewBox.style.height = fullHeight + 'px';
			window.clearInterval(tmrExpand);
			$('viewBoxCloseAnchor').style.display = "block";
			resizeDarkScreen(true);
			showViewBoxDescription();
		}
	}

	function showViewBoxDescription(){
		var viewBox = $('viewBox');
		var viewBoxDescription = $('viewBoxDescription');
		var viewBoxDescriptionTitle = $('viewBoxDescriptionTitle');
		var viewBoxDescriptionCaption = $('viewBoxDescriptionCaption');

		var title = viewBoxDescriptionTitle.innerHTML;
		var description = viewBoxDescriptionCaption.innerHTML;

		// HIDE OR SHOW TITLE DIV
		if(title){
			viewBoxDescriptionTitle.innerHTML = title;
			viewBoxDescriptionTitle.style.display = 'block';
		}else{
			viewBoxDescriptionTitle.style.display = 'none';
		}
		
		// HIDE OR SHOW DESCRIPTION DIV
		if(description){
			viewBoxDescriptionCaption.innerHTML = description;
			viewBoxDescriptionCaption.style.display = 'block';
		}else{
			viewBoxDescriptionCaption.style.display = 'none';
		}
		
		// SHOW AND POSITION INFO DIV IF INFO TO SHOW
		if(title||description){
			viewBoxDescription.style.display = 'block';
		}else{
			viewBoxDescription.style.display = 'none';
		}
		resizeDarkScreen(true);
	}

	function showViewBox(){
		$('viewBox').style.display = "block";
		$('dark_screen').style.display = "block";
		resizeDarkScreen(true);
		return void(0);
	}

	function closeViewBox(){
		$('dark_screen').style.display = 'none';
		$('viewBox').style.display = 'none';
		$('viewBoxCloseAnchor').style.display = 'none';
		$('viewBoxDescription').style.display = 'none';
		$('viewBoxDescriptionTitle').style.display = 'none';
		$('viewBoxDescriptionCaption').style.display = 'none';
		$('viewBox').innerHTML = '';
		$('viewBoxDescription').style.visibility = 'hidden';

		window.clearInterval(tmrExpand);
	}

	function fixEntities(txt){
		if(!txt) return '';
		txt = txt.replaceAll('&amp;39;','&#39;');
		txt = txt.replaceAll('&amp;34;','&#34;');
		txt = txt.replaceAll('&39;','&#39;');
		txt = txt.replaceAll('&34;','&#34;');
		return txt;
	}

	function resizeDarkScreen(){
		var dark_screen_top, dark_screen_left;
		var dark_screen = $('dark_screen');
		var viewBox = document.getElementById('viewBox');
		var viewBoxCloseAnchor = $('viewBoxCloseAnchor');
		var viewBoxDescription = $('viewBoxDescription');

		// IF DARK SCREEN ISN'T VISIBLE, BAIL OUT
		if(!dark_screen||dark_screen.style.display!='block') return;

		with (dark_screen) {
			var visibleHeight = window.details.innerHeight();
			var visibleWidth = window.details.innerWidth();
			
			dark_screen_left = (document.body.scrollLeft||document.documentElement.scrollLeft);
			dark_screen_top = (document.body.scrollTop||document.documentElement.scrollTop);
			
			if(isIE){
				style.position = 'absolute';
				style.left = dark_screen_left + 'px';
				style.top = dark_screen_top + 'px';
			}

			style.width = visibleWidth + "px";
			style.height = visibleHeight + "px";
			
			var viewBoxCoords;

			viewBoxCoords = [(((dark_screen.clientWidth - viewBox.clientWidth) / 2) + dark_screen_left),(((dark_screen.clientHeight - viewBox.clientHeight) / 2) + dark_screen_top)];
		
			viewBox.style.left = viewBoxCoords[0] + "px";
			viewBox.style.top = viewBoxCoords[1] + "px";
			

			viewBoxCloseAnchor.style.top = (parseInt(viewBox.style.top) - viewBoxCloseAnchor.clientHeight - 2) + 'px';
			viewBoxCloseAnchor.style.left = (parseInt(viewBox.style.left) + viewBox.clientWidth - viewBoxCloseAnchor.clientWidth) + 'px';
			viewBoxDescription.style.left = viewBoxCoords[0] + 'px';
			viewBoxDescription.style.top = (viewBoxCoords[1]+viewBox.clientHeight+8) + 'px';
		}
	}

	function $(elt){
		return document.getElementById(elt);
	}
	
	window.onscroll = resizeDarkScreen;
	window.onresize = resizeDarkScreen;
