
var playerPath = '../typo3conf/ext/kf_mediaarchive/flash/mediaplayer.swf';
var uploadPath = '/uploads/tx_kfmediaarchive/';
var expressInstallPath = '../typo3conf/ext/kf_mediaarchive/flash/expressInstall.swf';
var skinPath = '../typo3conf/ext/kf_mediaarchive/flash/ClearExternalPlaySeekMute.swf';
var movieSizeX = 560;
var movieSizeY = 339;
var requiredFlashVersion = 7;

var flashStageLayer = 'media';
var informationLayer = 'mediainformation';
var informationSrcLayer = 'medialist-information-';
var movieItemLayer = 'medialist-item-';

var activeItem = 0;


function showMediaitem(moviename, movieid)
{
	// show information text
	document.getElementById(informationLayer).innerHTML = document.getElementById(informationSrcLayer+movieid).innerHTML;

	// unhilight old active item
	if (activeItem != 0)
	{
		classname = activeItem.className;
		activeItem.className = classname.replace(/medialist-activeitem/g, '');
	}
	
	// highlight choosen movie in list
	activeItem = document.getElementById(movieItemLayer+movieid);	
	classname = document.getElementById(movieItemLayer+movieid).className;
	document.getElementById(movieItemLayer+movieid).className = classname+' medialist-activeitem';

	
	flashVars = 'media='+uploadPath+moviename+'&skin='+skinPath+'&valid=true';	
	// should look like this later: swfobject.embedSWF('../typo3conf/ext/kf_mediaarchive/flash/mediaplayer.swf', 'media', '560', '339', '7', '../typo3conf/ext/kf_mediaarchive/flash/expressInstall.swf', false, {flashvars: 'media=/uploads/tx_kfmediaarchive/L1030859.flv&skin=../typo3conf/ext/kf_mediaarchive/flash/ClearExternalPlaySeekMute.swf&valid=true'});	
	swfobject.embedSWF(playerPath, flashStageLayer, ''+movieSizeX+'', ''+movieSizeY+'', ''+requiredFlashVersion+'', expressInstallPath, false, {flashvars: flashVars});
}

function hoverMediaitem(objekt)
{
	classname = objekt.className;
	objekt.className = classname+' medialist-hoveritem';	
}

function dishoverMediaitem(objekt)
{
	classname = objekt.className;
	objekt.className = classname.replace(/medialist-hoveritem/g, '');
}

function checkUrlParams()
{
	url = window.location.href;
	urlparts = url.split("#");
	if (urlparts.length > 1)
	{
		movieurl = urlparts[1];
		movieparts = movieurl.split("/");
		if (movieparts.length > 1)
		{
			showMediaitem(movieparts[0], movieparts[1]);
		}
		else
		{
			startFirstMovie();
		}
	}
	else
	{
		startFirstMovie();
	}
}

function startFirstMovie()
{
	$(".medialist-item").first().click();
}

$(document).ready(function() 
		{
	checkUrlParams();
		});
