function showCaptions() {
	$('#videoCaptions').show();
	$('#videoCaptions p').eq(0).show();
	$('#videoCaptions').data('currentCaption', 0);
}
function hideCaptions() {
	$('#videoCaptions').hide();
}

function changeCaption(p_params)
{
	params = eval('('+p_params+')');	// Required
	$("#videoCaptions p").hide();
	$("#videoCaptions p").eq(params.parameters.caption).show();
}

$(function() {
	$('#videoCaptions p').hide(); //hide all captions at first

	$("ul.tabs li a").click(
		function (event)
		{
			try
			{
				//console.log("Load " + "/profiles-playlist-" + $(this).parent("li").attr("class"));
				sendMessage("replaceVideo", "loadJSON", "/profiles-playlist-" + $(this).parent("li").attr("class"));
				//sendMessage("replaceVideo", "skip", $(this).parent("li").attr("class"));
			}
			catch(err)
			{
				//console.log("err.description: " + err.description);
			}
			return false;
		}
	);
	
	$('.showVideoPopup').bind('click', function() {
		$('#videoPopupTabbed .tabs li a').removeClass('selected');
		$('#videoPopupTabbed .tabs li.'+$(this).attr("rel")+' a').addClass('selected');
		
		showBlackout();
		if ($('#homeReplaceVideo').length) {
			sendMessage("homeReplaceVideo", "pauseVideo", "");
		}
		
		centerElement('videoPopupTabbed');
		$('#profileTabs').show();
		$('#headOfficeTourTabs').hide();
		$('#videoPopupTabbed').show();
		swfobject.embedSWF("/flash/profiles/ProfileVideoPlayer.swf", "replaceVideo", "640", "360", "9.0.0","expressInstall.swf", {meta: "/profiles-playlist-" + $(this).attr("rel")}, {allowscriptaccess: 'sameDomain', allowfullscreen: 'true'}, {id: "replaceVideo", name: "replaceVideo"});
		return false;
	});
	$('#closeVideoBox').bind('click', function() {
		if ($('#homeReplaceVideo').length) {
			sendMessage("homeReplaceVideo", "resumeVideo", "");
		}
		sendMessage("replaceVideo", "stopVideo", "");
	    $('#videoPopupTabbed').hide();
	    removeBlackout();
	});
	$('#videoPopupTabbed .tabs a').bind('click', function() {
		$('a.selected', $('#videoPopupTabbed')).removeClass('selected');
		$(this).addClass('selected');
	});
	
	$('.showTourPopup').bind('click', function() {
		showBlackout();
		centerElement('videoPopupTabbed');
		$('#profileTabs').hide();
		$('#headOfficeTourTabs').show();
		$('#videoPopupTabbed').show();
		swfobject.embedSWF("/flash/profiles/ProfileVideoPlayer.swf", "replaceVideo", "640", "360", "9.0.0","expressInstall.swf", {meta: "/playlist-head-office-tour"}, {allowscriptaccess: 'sameDomain', allowfullscreen: 'true'}, {id: "replaceVideo", name: "replaceVideo"});
		return false;
	});
});