		
		// Tell Vimeo what function to call
		var oEmbedCallback = 'embedVideo';
		
		// Set up the URL
		var oEmbedUrl = 'http://www.vimeo.com/api/oembed.json';
		
		// Load the first one in automatically?
		var loadFirst = true;
		
		// This function puts the video on the page
		function embedVideo(video) {
			var videoEmbedCode = video.html;
			videoEmbedCode = videoEmbedCode.replace(/height="(\d+)"/, 'height="523"');
			videoEmbedCode = videoEmbedCode.replace('</object>', '<param name="scale" value="showAll" /><param name="wmode" value="transparent" /></object>');
			document.getElementById('embed').innerHTML = unescape(videoEmbedCode);
	
		}
		
		// This function runs when the page loads and adds click events to the links
		function init() {
			var links = document.getElementById('thumbs').getElementsByTagName('a');

			
			// Load in the first video
			if (loadFirst) {
				loadScript(oEmbedUrl + '?url=' + links[0].href + '&width=930&callback=' + oEmbedCallback);
			}
		}


		function show_video (link, lid) {
			loadScript(oEmbedUrl + '?url=' + link + '&width=930&callback=' + oEmbedCallback);						
			$jQ('a.lid').addClass('bgred');
			$jQ('a.lid').removeClass('bgred_selected');
			$jQ('#'+lid).addClass('bgred_selected');			
		}
		
		
		
		
		// This function loads the data from Vimeo
		function loadScript(url) {
			var js = document.createElement('script');
			js.setAttribute('type', 'text/javascript');
			js.setAttribute('src', url);
			document.getElementsByTagName('head').item(0).appendChild(js);
		}
		
		// Call our init function when the page loads
		window.onload = init;