/*
	id
	title
	description
	url
	upload_date
	thumbnails_small
	thumbnails_medium
	thumbnails_large
	user_name
	user_url
	user_portraits_small
	user_portraits_medium
	user_portraits_large
	user_portraits_huge
	stats_number_of_likes
	stats_number_of_plays
	stats_number_of_comments
	duration
	width
	height
	tags
*/
// Change this to your username to load in your clips
var vimeoUserName='bueroamstrand';

// Tell Vimeo what function to call
var videoCallback='latestVideo';
var oEmbedCallback='embedVideo';

// Set up the URLs
var videosUrl='http://www.vimeo.com/api/v2/'+vimeoUserName+'/videos.json?callback='+videoCallback;
var oEmbedUrl='http://www.vimeo.com/api/oembed.json';

// This function puts the video on the page
function embedVideo(video){
	videoEmbedCode=video.html;
	document.getElementById('vimeoembed').innerHTML=unescape(video.html);
}

// This function uses oEmbed to get the last clip
function latestVideo(videos){
	var videoUrl=videos[0].url;

	// Get the oEmbed stuff
	loadScript(oEmbedUrl+'?url='+encodeURIComponent(videoUrl)+'&width=299&height=189&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);
}