
// default player
var playa_conf = { clip: {
					
					autoPlay: false,
					autoBuffering: true,
					baseUrl: '/resources/flowplayer/',
					scaling: 'orig'
				},
				key: '#$c31baf0a61cabb508da',
				/*logo: {
					fullscreenOnly: true,
					url: 'http://dev.acis.com/resources/flowplayer/acis_logo_transparent.png',
					linkUrl: 'http://www.acis.com' 
				},*/
				screen: {
						bottom:25        
				},
				canvas: { 
						backgroundGradient: 'none',
						backgroundColor:'#000000'
				},
				plugins: {
					controls: {
						fullscreen: true,
						backgroundColor: '#DCDDE4',
						buttonColor: '#A3A4AA',
						sliderColor: '#58585B',
						progressColor: '#58585B',
						bufferColor: '#727275',
						timeColor: '#FF0000'
					}
				} };

function getPerson(personObj)
{
	var curranchor = $(personObj).attr("href");
	var currperson = curranchor.replace(/#/, "");
	var hasVideo = true;
	//alert(currperson);
	if ($(personObj).hasClass("no_video"))
		hasVideo = false;
	return {'name': currperson, 'hasVideo': hasVideo};
}
function selectPerson(name, hasVideo)
{
	$('.team_name').hide();
	$('.team_desc').hide();
	$('#'+name+'_name').show();
	$('#'+name+'_desc').show();
	playa_conf.clip.url = 'videos/' + folder + '/' + name + "." + (flashembed.isSupported([9, 115]) ? "mp4" : "flv");
	if (hasVideo)
	{
		$('.video').show();
		$f('video', '/resources/flowplayer/flowplayer-3.1.1.swf', playa_conf);
	}
	else
		$('.video').hide();
}

$(document).ready(function() {


	var teamMap = new Object();
	
	var video_team = $('td a.team_link.random.yes_video:first-child');
	var team_total = video_team.length;
	var requestPerson;
	
	// when requesting a certain TC though anchors
	if (location.hash)
	{
		var requestName = location.hash.replace(/#/,""); // strip the #
		if (teamMap[requestName])	// if we have the old names in the list
		{
			requestPerson = $('td a.team_link:first-child[href="' + teamMap[requestName] + '"]');
		}
		else	// find if the new name exists
		{
			var team = $('td a.team_link:first-child');
			for (var i = 0; i < team.length; i++)
			{
				var ihref = $(team[i]).attr('href');
				if (ihref == location.hash)
				{
					requestPerson = $(team[i]);
				}
			}
		}
		
		if (requestPerson)	// so we've found somebody
		{
			var personAttrs = getPerson( requestPerson );
			selectPerson(personAttrs['name'], personAttrs['hasVideo']);
			$.scrollTo( '#jq_scroll_target', 500);
		}
		
	}
	if (requestPerson==undefined && team_total)
	{	// nobody was requested, so pick a random one
		var randnum = Math.floor(Math.random() * team_total);
		var luckyperson = video_team[randnum];
		var personAttrs = getPerson(luckyperson);
		selectPerson(personAttrs['name'], personAttrs['hasVideo']);
	}

	$(".team_link").click(function (e) {	// clicked on a team member
		var personAttrs = getPerson(this);

		$.scrollTo( '#jq_scroll_target', 500);
		setTimeout("$('p.extra_info:visible').addClass('hide')", 500);
		setTimeout("selectPerson('"+ personAttrs['name'] +"', "+ personAttrs['hasVideo'] +")", 1000);
	});
	
	$(".toggle_extra_info").click(function (e) {	// (don't) want more info, so (don't) show the hidden divs
		if ($(this).next(".extra_info").hasClass("hide"))
		{
			$(this).nextAll(".extra_info").removeClass('hide');
		}
		else
		{
			$(this).nextAll(".extra_info").addClass('hide');
		}
		
	});
	/*
	$("div.videos").each(function (i) {
		var currvidlink = $(this).attr("id");
		playa_conf.clip.url = 'videos/' + folder + '/' + currvidlink + "." + (flashembed.isSupported([9, 115]) ? "mp4" : "flv");
		flowplayer(currvidlink, '/resources/flowplayer/flowplayer-3.0.7.swf', playa_conf);
	});
	*/
	playa_conf.clip.autoPlay = true;
	flowplayer('div.videos', '/resources/flowplayer/flowplayer-3.1.1.swf', playa_conf);
	

});
