﻿/*
Luther Seminary - Thad Dahlberg 2009
FUNCTION: viewVideoRequirements: JQuery, JQuery UI, SwfObject
FORMAT: viewVideo(title, lecturetitle, speaker, speakerattr, path, previewIMG )
	title: 			Title of the popup dialog
	lecturetitle: 	Title of the lecture or event
	speaker: 		Speaker Name
	speakerattr: 	Speaker titles/honorariums
	path:			Path to the actual video on the internet
	previewIMG:		Poster frame preview image (will default to generic image if not set)
LINK EXAMPLE:
	<a href="javascript:;" 
	onclick="viewVideo('2009  Andrew S. Burgess Lecture in Global Mission',
	'Account for the Hope: Mission At Home With Pluralism',
	'Dr. S. Mark Heim','Samuel Abbot Professor of Christian Theology, Andover Newton Theological School Samuel', 
	'http://download.luthersem.edu/media/burgess/20091014BurgessLectureSMarkHeim.mp4')">
	View video</a>
COMMENTS: Notice the javascript:; as the link above. Keeps the page from sliding to the top.
*/
$(function() {	
	$("body").append('<div id="vdialog" ><div style="diplay:block; height:290px; "><div id="videoplayer"></div></div><div id="videoTitle"></div></div>');
	$("#vdialog").dialog({ autoOpen: false, width: 505, height: 'auto', modal: true});
});
function viewVideo(title, lecturetitle, speaker, speakerattr, path, previewIMG ) {
	var videoTitle;
	videoTitle = "<br/>";
	if (lecturetitle) {videoTitle = videoTitle + "<h5 style='margin-top:0px;'><em>&ldquo;" + lecturetitle + "&rdquo;</em></h5>";}
	if (speaker) {videoTitle = videoTitle + "<strong>" + speaker + "</strong>";}
	if (speakerattr) {videoTitle = videoTitle + "<br/>" + speakerattr + "<br/><br/>";}
	if (!previewIMG) {previewIMG = "/computer_services/fplayer/PosterFrame480x340.jpg";}
	$("#videoTitle").html(videoTitle);
	//init jwplayer
	var flashvars = {} ; var params = {}; var attributes = {};
	flashvars.file = path;
	flashvars.image = previewIMG;
	params.allowfullscreen = "true";
	params.allowscriptaccess = "always";
	params.wmode = "opaque";
	swfobject.embedSWF("/assets/utils/flvplayer.swf", "videoplayer", "480", "290", "9.0.0", "/computer_services/fplayer/flvplayer.swf/expressInstall.swf", flashvars, params, attributes);
	//open the dialog
	$('#vdialog').dialog('option', 'title', title);
	$('#vdialog').dialog('open');
	$(".ui-widget-overlay").click( function() { $('#vdialog').dialog('close'); } );
}
