



		var apiEndpoint = 'http://www.vimeo.com/api/v2/';
		var oEmbedEndpoint = 'http://www.vimeo.com/api/oembed.json'
		var oEmbedCallback = 'switchVideo';
		var videosCallback = 'setupGallery';
		var vimeoUsername = 'chicagofakty';
		
		// Get the user's videos
		$(document).ready(function() {
			$.getScript(apiEndpoint + vimeoUsername + '/videos.json?q=sd&callback=' + videosCallback);
		});
		
		function getVideo(url) {
			$.getScript(oEmbedEndpoint + '?url=' + url + '&width=700&q=sd&callback=' + oEmbedCallback);
		}
		
		function setupGallery(videos) {
			
			// Set the user's thumbnail and the page title
			//$('#stats').prepend('<img id="portrait" src="' + videos[0].user_portrait_medium + '" />');
			//$('#stats h2').text(videos[0].user_name + "'s Videos");
			
			// Load the first video
			getVideo(videos[0].url);
			
			// Add the videos to the gallery
			var html = '<ul>';
			for (var i = 0; i < videos.length; i++) {
				html += '<li><a href="' + videos[i].url + '"><img src="' + videos[i].thumbnail_medium + '" class="thumb" />';
				html += '<p>' + videos[i].title + '</p></a></li>';
			}
				html +='</ul>';
			$('#thumbs').html(html);			
			
			// Switch to the video when a thumbnail is clicked
			$('#thumbs a').click(function(event) {
				event.preventDefault();
				getVideo(this.href);
				return false;
			});

			if(typeof(jQuery.url.param("v"))!='undefined'){
				$("a[href=http://vimeo.com/"+jQuery.url.param("v")+"]").trigger('click');
			}	
			
		}
		
		function switchVideo(video) {
			$('#video').html(unescape(video.html.replace(/height="(\d+)"/, 'height="400"')));
		}
		



