// Change this to your username to load in your clips
var vimeoUserName = 'chrisadams4';

// Tell Vimeo what function to call
var userInfoCallback = 'userInfo';
var clipsCallback = 'showThumbs';
var numberOfThumbnails = 4; //clips.length;

// Set up the URLs
var userInfoUrl = 'http://www.vimeo.com/api/' + vimeoUserName + '/user_info.json?callback=' + userInfoCallback;
var clipsUrl = 'http://www.vimeo.com/api/' + vimeoUserName + '/clips.json?callback=' + clipsCallback;

// This function goes through the clips and puts them on the page
function showThumbs(clips) {
	var thumbs = document.getElementById('vimeo_feed');
	thumbs.innerHTML = '';
	
	var ul = document.createElement('ul');
	thumbs.appendChild(ul);
	
	for (var i = 0; i < numberOfThumbnails; i++) {
		var thumb = document.createElement('img');
		thumb.setAttribute('src', clips[i].thumbnail_medium);
		thumb.setAttribute('alt', clips[i].title);
		thumb.setAttribute('title', clips[i].title);
		
		var a = document.createElement('a');
		a.setAttribute('href', clips[i].url);
		a.setAttribute('target', clips[i], '_blank');
		a.appendChild(thumb);
		
		var li = document.createElement('li');
		li.appendChild(a);
		ul.appendChild(li);
	}
}

// This function loads the data from Vimeo
function init_vimeo() {
	var head = document.getElementsByTagName('head').item(0);
	
	var userJs = document.createElement('script');
	userJs.setAttribute('type', 'text/javascript');
	// userJs.setAttribute('src', userInfoUrl);
	head.appendChild(userJs);
	
	var clipsJs = document.createElement('script');
	clipsJs.setAttribute('type', 'text/javascript');
	clipsJs.setAttribute('src', clipsUrl);
	head.appendChild(clipsJs);
}
