//Library
var i=0;
var vid;
var pos=0;

function loadVimeo(videos){
	vid=videos;
	for(i=0; i<5; i++){
		addPlayer(videos[i]);
	}
	i--;
}

function ayuda(){
	new Effect.Move('vimeo', { x: -200, y: 0, mode: 'absolute', afterFinish:function(){addPlayer(vid[i]);new Effect.Move('vimeo', {x:200, duration:0});document.getElementById('vimeo').removeChild(document.getElementById('vimeo'+pos%vid.length)); pos++;}});
	new Effect.Opacity('vimeo'+pos%vid.length, { from: 1, to: 0, duration:.5});
	i++;
	if(i>=vid.length) i=0;
}

function atras(){
	new Effect.Move('vimeo', { x: 200, y: 0, mode: 'absolute', afterFinish:function(){new Effect.Move('vimeo', {x:-200, duration:0});document.getElementById('vimeo').removeChild(document.getElementById('vimeo'+(pos+3)%vid.length)); pos--;}});
	new Effect.Opacity('vimeo'+(pos+3)%vid.length, { from: 1, to: 0, duration:.5});
	i--;
	p=i-3;
	if(i<0) i=vid.length;
	window.alert(vid.length+p)
	addPlayer(vid[p%vid.length], 1);
}

function addPlayer(data, pos){
	var player = document.createElement('div');
	player.setAttribute('id', 'vimeo'+i);
	player.setAttribute('class', 'test');
	document.getElementById("vimeo").appendChild(player); 
	
	document.getElementById('vimeo'+i).innerHTML='<object width="280" height="120">'+
	'<param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" />'+
	'<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+data.id+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00ADEF&amp;fullscreen=1" />'+
	'<embed src="http://vimeo.com/moogaloop.swf?clip_id='+data.id+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="280" height="120">'+
	'</embed></object><div class="video"><a class="video" href="http://www.vimeo.com/'+data.id+'" target="_blank">'+data.title+'</a></div>';	

}
