// 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="280"');
	document.getElementById('embed').innerHTML = unescape(videoEmbedCode);
}

// Load in the first video
if (loadFirst) {
	loadScript(oEmbedUrl + '?width=504&callback=' + oEmbedCallback);
}

// 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);
}

