var player = null;
function playerReady(thePlayer) {
	player = window.document[thePlayer.id];
}

$(document).ready(function(){
	
	$(".dialog li:even").addClass("highlight");
	$("#video").append('<div id="caption"></div>');
	
	$(".time").click(function(){
		
		//convert time to jw friendly seconds
		var splitTime = $(this).attr('href').replace('#', '').split(':', 3);	
		var jHour = parseFloat(splitTime[0] * 3600);
		var jMin = parseFloat(splitTime[1] * 60);
		var jSecs = parseFloat(splitTime[2]);
		var jwTime = jHour + jMin + jSecs;
		
		//send to jw player
		if (jwTime > 0) {
			player.sendEvent('SEEK', jwTime);
			player.sendEvent('PLAY');
		}
		
		//get question html
		var $question = $(this).next().html();
		
		//set question over player
		$("#caption").contents($question);
		$("#caption").fadeIn().delay(20000).fadeOut(function(){
			$(this).empty();
		});
		
		
		//scroll up to player
	}).smoothScroll({scrollTarget: '#video'}, 1000);
	

});

	//if the url already has a time specified, seek that!
//	var pathname = window.location.pathname;
//	var pathTime = $(pathname).split('#', 2);
//	console.log(pathname);
