/**
 * controls behaviour of various insite authoring tools
 *
 * @author Andreas Nebiker (andreas.nebiker@infocentricresearch.com)
 */

$(document).ready(function()
{
	$('.controls h2.trigger').click(function()
	{
		if ($('.controls form').css('display') == 'block') {
			$('.controls form').css('display', 'none');
		} else {
			$('.controls form').css('display', 'block');
		}
	});
});


/**
 * Modules / Applications
 */
 
/**
 * Movieplayer
 *
 * @author Andreas Nebiker (andreas.nebiker@infocentricresearch.com)
 */

function initMovie(filename, target, height, autostart)
{
	if (!autostart) {
		autostart = false
	}
	
	height = parseInt(height)
	//alert("height: " + height)
		
	var mp = new SWFObject("/static/app/movieplayer/videoplayer.swf", "Player", "100%", "100%", "8", "#000000");

	// src path of the flv file relatively to videoplayer.swf
	//mp.addVariable("flvsrc", "./video/" + filename);
	mp.addVariable("flvsrc", filename);

	// width and height of the flv file (without the additional height for the control bar of the video player)
	mp.addVariable("flvwidth", "315");
	//mp.addVariable("flvheight", height + "px");
	mp.addVariable("flvheight", height);

	// buffer time in seconds
	mp.addVariable("bufferT", "3");

	// autostart?
	//mp.addVariable("autostart", "false");
	mp.addVariable("autostart", autostart);

	// color code f&#252;r time display, play button, pause button and progress bar
	mp.addVariable("fontcolor", "0xFFFFFF");

	//mp.addParam("scale", "noscale");

	// change height of containing div
	$('#' + target).css('height', (height+40) + "px");

	mp.write(target);
}

$(document).ready(function()
{
	var movie;
	var height;
	var current;
	
	$('#movieplayer').each(function()
	{
		current = $(this);
		movie	= current.attr('className') || '';
		height	= current.css('height') || '236';
		height	= parseInt(height);
		initMovie(movie, current.attr('id'), height);
	});
});