// This is the oEmbed endpoint for Vimeo (we're using JSON)
// (Vimeo also supports oEmbed discovery. See the PHP example.)
var endpoint = 'http://www.vimeo.com/api/oembed.json';

// Tell Vimeo what function to call
var callback = 'embedVideo';

var videoEmbedCode = '';

// This function puts the video on the page
function embedVideo(video) {
	videoEmbedCode = video.html;
	document.getElementById('playerID1').innerHTML = unescape(video.html);
}

// This function loads the data from Vimeo
function init(clipUrl) {
	// Put together the URL
	var url = endpoint + '?url=' + encodeURIComponent(clipUrl) + '&width=480&title=false&callback=' + callback;	
	
	var js = document.createElement('script');
	js.setAttribute('type', 'text/javascript');
	js.setAttribute('src', url);
	document.getElementsByTagName('head').item(0).appendChild(js);
}