var viewer = new function()
{
	this.pictures = [];
	this.videos = [];
	this.path = {
		'pictures' : null,
		'videos' : null,
		'separator' : '/'
	};
	
	this.goScreenshots = function(itemId)
	{
		if (itemId in this.pictures)
		{
			// fix pictures list - add path
			var _pictures = [];
			for (i in this.pictures[itemId])
			{
				var _pic = this.path.pictures + this.path.separator + this.pictures[itemId][i];
				_pictures.push(_pic);
			}
			// show lightbox
			$.prettyPhoto.open(_pictures.sort());
		}
		
		// stop link function
		return false;
	};
	
	this.goVideos = function(itemId)
	{
		if (itemId in this.videos)
		{			
			// fix videos list
			var _videos = [];
			for (i in this.videos[itemId])
			{
				var _vid = this.videos[itemId][i];
				var _new = null;
				
				// figure file extension: either FLV, SWF, MOV.
				var _ext = _vid.match(/\.([a-z0-9]{3,4})$/i);
				if (null != _ext && 1 in _ext)
					_ext = _ext[1];
				
				if (_ext == 'flv' || _ext == 'wmv')
				{
					// flv or wmv; use proxy page for player
					_new = '/page/video/file/' + _vid + '?iframe=true';
					_new+= '&width=460&height=370';
				}
				else if (_ext == 'swf')
				{
					// flash; add dimensions to GET
					_new = this.path.videos + this.path.separator + _vid;
					
					_new+= (_vid.indexOf('?') < 0) ? '?' : '&';
					_new+= 'width=460&height=370';
				}
				else if (_ext == 'mov')
				{
					// quicktime; add dimensions to GET
					_new = this.path.videos + this.path.separator + _vid;
					_new+= '?width=460&height=370';
				}
				
				if (null != _new)
				{
					_videos.push(_new);
				}
			}
			
			// show lightbox
			if (_videos.length)
			{
				$.prettyPhoto.open(_videos.sort());
			}
		}
		// stop link function
		return false;
	};
};

$(document).ready(function()
{
	// init prettyPhoto API (pretty stupid, right?)
	$('NONE').prettyPhoto();
});