var playobj;

    function changemovie(var_id, var_file, var_image, var_link, var_title, var_hits, var_showing, var_contest){
		$.cookie(city_id + '_id', var_id);
		$.cookie(city_id + '_file', var_file);
		$.cookie(city_id + '_image', var_image);
		$.cookie(city_id + '_link', var_link);
		$.cookie(city_id + '_title', var_title);
		$.cookie(city_id + '_hits', var_hits);
		$.cookie(city_id + '_showing', var_showing);
		$.cookie(city_id + '_contest', var_contest);
		playobj = new SWFObject("/_img/player.swf","flvlayer","320","214","9",'#000000');
		playobj.addParam("allowfullscreen","true");
		playobj.addParam("allowscriptaccess","always");
		playobj.addParam("wmode","opaque");
		playobj.addVariable('type', 'video');
		playobj.addVariable("file",var_file);
		playobj.addVariable("image",var_image);
		playobj.addVariable("link", var_link);
		playobj.addVariable("backcolor","0x1A4A78");
		playobj.addVariable("frontcolor","0xFFFFFF");
		playobj.addVariable("lightcolor","0xC31900");
		playobj.addVariable("screencolor","0x000000");
		playobj.addVariable("controlbar","over");
		playobj.addVariable("height","214");
		playobj.addVariable("width","320");
		playobj.addVariable("abouttext","powered by Cineplex Deutschland GmbH & Co. KG");
		playobj.addVariable("autostart","false");
		playobj.addVariable("linktarget","_top");
		$("#movie_footer").fadeOut("slow",function(){
			$("#titel").html("<p>"+var_title+"</p><div class='fadeOut2'></div>");
			$("#hits").html(var_hits);
			var html='<a id="filmimfos" href="'+var_link+'"></a>'
			if(var_showing!=null && var_showing!="" && city_id != 0){
				html += '<a id="showing" href="' + var_showing + '"></a>';
			}
			if(var_contest!=null && var_contest!=""){
				html += '<a id="contest" href="' + var_contest + '"></a>';
			}
			$("#imagelinks").html(html);
			$("#movie_footer").fadeIn("fast");
		});
		$("#flashplayer").fadeOut("slow",function(){
			$("#flvplayercontainer").hide();
			$("#flashplayer").css("background", "url("+var_image+") no-repeat center");
			$("#flashplayer").fadeIn("slow");
			playobj.write("flvplayercontainer");
			$("#flvplayercontainer").show();
		});
	}
	function playlist(var_liste){
	    $('#liste').html('<div id="liste-scroll"></div>');
	    
		var count = 0;
		var filmInList = false;
		$.get(var_liste, function(d){
			$(d).find('track').each(function() {
				var $movie = $(this); 
				var tmpTitle = $movie.find('title').text();
				var title = tmpTitle.replace(/'/g, '�');
				var subtitle = $movie.find('subtitle').text();
				var imageurl = $movie.find('image').text();
				var thumbimageurl = $movie.find('thumbimage').text();
				var showing = $movie.find('showing').text();
				var location = $movie.find('location').text();
				var info = $movie.find('info').text();
				var hits = $movie.find('hits').text();
				var contest = $movie.find('contest').text();
				var var_active = "";
				var identifier = "id"+$movie.find('identifier').text();
				if($.cookie(city_id + '_id')==identifier){
					var_active = "active";
				}
				if (count == 0) {
    				if($.cookie(city_id + '_id')==null) {
        			    var_active = "active";
        			    changemovie(identifier, location, imageurl, info, title, hits, showing, contest);
        			}
        		}
				var html = '<div id="'+identifier+'"><a class="movie '+var_active+'" href="#" onclick="changemovie(\'' + identifier + '\',\'' + location + '\',\'' + imageurl + '\',\'' + info + '\',\'' + title + '\',\'' + hits + '\',\'' + showing + '\',\'' + contest + '\');"><div class="fadeOut"></div><div class="plakat"><img class="bookImage" alt="" width="50" src="' + thumbimageurl + '" /></div>';
				html += '<p class="title"><strong>' + title + '</strong></p>';
				html += '<p class="subtitle">' + subtitle + '</p>';
				html += '</a>';
				if(showing!=""){
					html += '<a class="showing" href="' + showing + '"><img src="/_img/spielzeiten.gif" /></a>';
				}
				html += '</div>';
				$('#liste-scroll').append($(html));
    			count++;
			});
			
			$('#liste-scroll').jScrollPane();
			//$('#liste-scroll').css("overflow-x","hidden");
			
			$(".movie").click( function() {
				$(".movie").removeClass("active");
				$(this).addClass("active");
			});

		});
		
	}
	$(function()
	{
	    
		if($.cookie(city_id + '_liste')!=""){
			$(".kategorien a."+$.cookie(city_id + '_liste')).addClass("active");
		}
		
		/* Der Making Of Link: */
		$(".makingOfLink a").click( function() {		    		
			$(this).addClass("active");
			$(".kategorien a").removeClass("active");			
			$("#trailerShowHolder").hide();
    		$("#movieBoxHolder").show();
    		if((document.all) && (navigator.appName == "Microsoft Internet Explorer")) {
    			$("#movieBoxHolder div.original").remove();
    			$("#movieBoxHolder").append('<div id="moviebox"></div>');
    			flvlayer.sendEvent('STOP');
    			_moviebox.init({customerid:'2342',boxtype:'makingof',width:553,height:328});
    		}
		});
		
		$(".kategorien a").click( function() {
			if((document.all) && (navigator.appName == "Microsoft Internet Explorer")) {
				if ($(".makingOfLink a").hasClass("active")) { _moviebox.shutdown(); }
			}
			$(".makingOfLink a").removeClass("active");
			$(".kategorien a").removeClass("active");
			$("#movieBoxHolder").hide();
			$("#trailerShowHolder").show();			
			$.cookie(city_id + '_liste', $(this).attr('class'));
			$.cookie(city_id + '_playlist', $(this).attr('rel'));
			$(this).addClass("active");
			playlist($(this).attr('rel'));
			//$('#liste-scroll').jScrollPane();
		});
		if($.cookie(city_id + '_playlist')!=null){
			playlist($.cookie(city_id + '_playlist'));
		} else {
		    playlist($('div.kategorien a:first').attr('rel'));
		}
		
		if($.cookie(city_id + '_id')!=null){
			changemovie($.cookie(city_id + '_id'), $.cookie(city_id + '_file'), $.cookie(city_id + '_image'), $.cookie(city_id + '_link'), $.cookie(city_id + '_title'), $.cookie(city_id + '_hits'), $.cookie(city_id + '_showing'), $.cookie(city_id + '_contest'));
		}
		if($.cookie(city_id + '_playlist')==null) {
		    $('div.kategorien a:first').addClass('active');
		}
		
		
		
	});
