function loadVideo(flv, thumb, description) {
	$('#videoplayer').css({
		float: 'left',
		width: '400px'
	}).find('h1, object').remove();
	
	var str = '<object height="315" name="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="player" width="400">';
        str += '<param value="/fileadmin/user_upload/innotrans/player.swf" name="movie" />';
        str += '	<param value="true" name="allowfullscreen" />';
        str += '	<param value="always" name="allowscriptaccess" />';
        str += '	<param name="flashvars" value="file=' + flv + '&amp;image=' + thumb + '" />';
        str += '<embed flashvars="file=' + flv + '&amp;image=' + thumb + '" allowfullscreen="true" allowscriptaccess="always" src="/fileadmin/user_upload/innotrans/player.swf" name="player2" id="player2" type="application/x-shockwave-flash" height="315" width="400">';
        str += '</object>';
        
        $('#videomsg').before(str);
        $('#videomsg').find('cite').html(description);	
}
$(document).ready(function() {
	var url = "/fileadmin/user_upload/innotrans/videotest.xml";
	$.get(url, { dataType: 'xml' }, videocallback, 'xml');
	
	function videocallback(data) {
		$('#playlist').css({
			width: '300px',
			float: 'left',
			height: '315px',
			margin: '0 0 0 10px'
		});
		
		$('#right_panel').hide();
		$('#content, #middle_panel').css('width', 'auto');
		var firstFLV = '';
		var firstIMG = '';
		var firstDesc = '';
		var executed = false;
		var flippedVideos = new Array();
		
		$.each($(data).children().children(), function(i,n) {
			if($(n).attr('lang') != 'de') {
        			return;
        		}        	
			flippedVideos.push($(n));
		});
		
		flippedVideos.reverse();
		
		
		$.each($(flippedVideos), function(i,n) {
        		var previewDiv = document.createElement('div');
        		var previewTitle = document.createElement('h4');
        		var previewImage = document.createElement('img');
        		var myNode = n;
        	
        		if(executed == false) {
        			executed = true;
        			firstFLV = $(n).attr('url');
        			firstIMG = $(n).attr('img1');
        			firstDesc = $(n).attr('title');
        		}
        		
        		$(previewImage).click(function(event) {
        			loadVideo($(myNode).attr('url'), $(myNode).attr('img1'), $(myNode).attr('title'));
        		})
        		.attr('src', $(n).attr('img1'))
        		.attr('width', 100)
        		.attr('height', 75)
        		.attr('alt', $(n).attr('title'))
        		.attr('title', $(n).attr('title'))
        		.attr('border', 0)
        		.css({
        			float: 'left',
        			margin: '0 5px 0 0',
        			cursor: 'pointer'
        		})
        		.appendTo(previewDiv);
        		
        		$(previewTitle).css({
        			fontSize: '12px'
        		})
        		.html($(n).attr('title'))
        		.appendTo(previewDiv);
        		
        		$(previewDiv).css({
        			overflow: 'hidden',
        			margin: '0 0 5px 0'
        		}).appendTo($('#playlist'));
        	});
		
        	
        	loadVideo(firstFLV, firstIMG, firstDesc);
	}

});
