var openedPlayer = '';
var openedV = '';
function changeVideo(v, target, autoplay)
{
	//fake default value since we can't do function foo(a='bar'){}
	target = typeof(target) != 'undefined' ? target : 'video';
	autoplay = typeof(autoplay) != 'undefined' ? autoplay : false; 
	
	//if multiple players on one page we'll unload the active one so two or more videos aren't buffering at once
	if(openedPlayer != '' && openedPlayer != target)
	{
		//document.getElementById(openedPlayer).innerHTML = '';
		document.getElementById(openedPlayer).innerHTML = "<a href='#"+openedPlayer+"' onclick='changeVideo(\""+openedV+"\", \""+openedPlayer+"\", true); return false;'><img src='/images/clickToPlay.gif' alt='Click to Play' /></a>";
	}
	openedPlayer = target;
	openedV = v;
	 
	var sa = new SWFObject('/swf/player.swf','mpl','470','300','9');
	sa.addParam('allowfullscreen','true');
	sa.addVariable('file','http://www.throughtheeyes.org/files/videos/'+v);
	//sa.addVariable("image","/images/clickToPlay.gif");	
	if(autoplay)
	{
		sa.addVariable("autostart","true");
	}
	sa.write(target);
	return false;
}
/*
	var s1 = new SWFObject('/swf/player.swf','mpl','470','300','9');
		s1.addParam("allowfullscreen","true");
		s1.addVariable("file",videoName);
		s1.addVariable("image","clickToPlay.gif");	
		if(autoPlay)
			s1.addVariable("autostart","true");
		s1.write(elem);
		return false;
		
		*/
