/**
 * WVG SPLENDID - jQuery Splendid Plugin
 * Copyright (C) 2010 portrix.net GmbH
 * j.scheurer and b.bartels
 **/
var imnotcachable = "2012-02-23 00:34:59";

$.fn.LoadMiniNews = function(){
	// Check what News are Required
	if(language == 'nl'){
		// if we are in the netherlands just show the exisitng ones
		jQuery('.mininewsNL').show();
		jQuery('.ajax_news .elm').show();
		jQuery('.ajax_news .elm a').attr('href','#');

	}else{
		// if we are in germany remove the existing ones and smuggle the mininews inside
		jQuery('.mininewsNL').remove();
		
		// distracting the custom controls
		jQuery(this).html('<img src="/ceemes/webfile/show/2140" alt="loading" style="width:32px;height:32px;display:block;margin:60px auto;"/>');

		// getting date when to smuggle
		var myDate = new Date();
		var urlMonth = getURLMonth(myDate.getMonth());
		
		var prevMonth = 0;
		if(myDate.getMonth() > 0)
			prevMonth=myDate.getMonth()-1;
		else
			prevMonth = 11;
		var prevURLMonth = getURLMonth(prevMonth);

		// store calling element
		var handler = jQuery(this);
		// smuggelin
		jQuery.post("http://www.splendid-film.nl/ceemes/page/show/splendid_news_"+urlMonth+myDate.getFullYear()+":mininews",function(data){
			var newsData = jQuery(data).not(':not(.mininews)');
			jQuery(handler).html(newsData);
			//jQuery(handler).append('<a class="small more" href="http://www.splendid-film.nl/ceemes/page/show/splendid_news_'+urlMonth+myDate.getFullYear()+'">Mehr ..</a>');
			//DaySort(jQuery('.mininews'));
			
			

			jQuery.post("http://www.splendid-film.nl/ceemes/page/show/splendid_news_"+prevURLMonth+myDate.getFullYear()+":mininews",function(data){
				var newsData = jQuery(data).not(':not(.mininews)');
				jQuery(handler).append(newsData);
				jQuery(handler).append('<a class="small more" href="http://www.splendid-film.nl/ceemes/page/show/splendid_news_'+urlMonth+myDate.getFullYear()+'">Mehr ..</a>');
				DaySort(jQuery('.mininews'));
				// if we're on contact just equal 
				if(jQuery('a.set').text() == "Kontakt")
					EqualContainers();
			});
		});
		
	}
};

function numsort(a,b){
   return a-b;
}

function DaySort(jq_objects){
   var dates = new Array();
   var elements = new Array();
   var counter = 0;
   // Collect and sort elements
   jQuery('.datesort').each(function(){
      var str_date = jQuery(this).text().split(".");
      var date = parseInt(str_date[2]+str_date[1]+str_date[0]);
      dates.push(date);
      if (typeof elements[date+"_"] == 'undefined')
        elements[date+"_"] = jQuery("<span></span>");
      elements[date+"_"] = jQuery(elements[date+"_"]).after(jQuery(jQuery(jq_objects)[counter]).clone());
      counter++;
   });
   dates.sort(numsort);
   // resort elements
   dates.reverse();
   elements.reverse();

   // reinsert
   var handle = jQuery(jq_objects).parent();
   jQuery(handle).html('');

   for(i=0;i<dates.length;i++)
      jQuery(handle).append(elements[dates[i]+"_"]);

}

$.fn.ArticlePreview = function(url, is_available){
    	var context = jQuery(this);
    	jQuery.post(url,function(html){
		var $temp_html = jQuery(jQuery(html).not(':not(div)')[0]);
    		$temp_html.find('.niceDate').each(function(){
    			jQuery(this).text(GetNiceDate(jQuery(this).text()));
    		});
    		
    		var m = '';
    		var m_prev = '';
		var i = 0;
		var final_html = [];
    		$temp_html.find('li').each(function(index) {
    			if(typeof final_html[i] == 'undefined') {
    				final_html[i] = '';
    			}
    			m = jQuery(this).find('.niceDate').text().split('.')[1];
    			if(m != m_prev) {
    				
    				if(index > 0) {
    					final_html[i] = '</ul>' + final_html[i];
    				}
    				i++;
    				final_html[i] = '<h3>' + getMonth(m) + '</h3><ul style="display: none;">';  				
    			}
    			if(is_available) {
    				final_html[i] += '<li><a href="' + jQuery(this).find('a').attr('href') + '">' + jQuery(this).find('a').html() + '</a></li>'; 				
    			}
			else {
    				final_html[i] += '<li>' + jQuery(this).html() + '</li>';
    			}
    			
    			m_prev = m;
    		});
    		final_html[i] += '</ul>';
    		for(var i=0; i < final_html.length; i++) {
    			jQuery(context).append(final_html[i]);
    		}		
    		jQuery(context).find('ul').show();
    		
    		// Content loaded completely, add equal class...
    		jQuery(context).parent().addClass('equal');
    		
    		// ...and equal the Height...
    		//equalHeight(jQuery('.equal'));
    		
    		//...da real way sir
    		EqualContainers();
    	});
    
};

$.fn.Slider4Col = function(url) {
    	var context=jQuery(this);
    	jQuery(this).find('.holder').html('<img src="/ceemes/webfile/show/2140" alt="loading" style="width:32px;height:32px;display:block;margin:60px auto;"/>');
        jQuery.post(url,function(html){
        	jQuery(context).find('div.buffer').html(jQuery(html).not(':not(.elm)'));
        	jQuery(context).find('.holder').html('<div class="content"></div>');
        	jQuery(context).slider();
        	FixSteelbooks();
        	//jQuery('body').css('visibility','visible');
	},"html");
};
    
$.fn.Slider5Col = function(url) {
        var context=jQuery(this);
        jQuery(this).find('.holder').html('<img src="/ceemes/webfile/show/2140" alt="loading" style="width:32px;height:32px;display:block;margin:60px auto;"/>');
        jQuery.get(url,function(html){
        	var prefix=jQuery(context).find('h3').text();
        	prefix = prefix.split(' ');
        	html=html.replace(/##REPLACE##/g,prefix[0]);
        	jQuery(context).find('div.buffer').html(jQuery(html).not(':not(.elm)'));
        	jQuery(context).find('.holder').html('<div class="content"></div>');
        	jQuery(context).slider2();
        	FixSteelbooks();
	});
};


$.fn.Pager5Col = function(url) { 
    	var context = jQuery(this);
	jQuery(this).html('<img src="/ceemes/webfile/show/2140" alt="loading" style="width:32px;height:32px;display:block;margin:60px auto;"/>');
        jQuery.get(url,function(html){
    		var isTrailerPage=jQuery('div.trailer').length && jQuery('.pagename').text()=='splendid_trailer';
    		
    		jQuery(context).html(' ');
    		jQuery(context).html(jQuery(html).not(':not(.elm.rnd)'));
    		
    		// Manipulate buttons and functions on trailerpage 
    		if(isTrailerPage){
    			jQuery(context).find('.elm.rnd').each(function(){
    				var ean = jQuery(this).find('.ean').text();
    				var title = jQuery(this).find('.title').text();
    				var inhalt = jQuery(this).find('.inhalt_kurz').text();
    				var keyframe_url = ""+jQuery(this).find('.trailer_keyframe').text();
    				if(keyframe_url == "")
    					keyframe_url="/img/trailer_kf/"+ean+"_KF_0_00_06.jpg";
    				var movie_url = jQuery(this).find('a.btn').attr('href');
    				jQuery(this).find('a.btn span').text('Jetzt ansehen');
    				
    				jQuery(this).find('a.btn,a.img').click(function(){
    					jQuery('.teaser.info.float h1').text(title);
    					jQuery('.teaser.info.float p').text(inhalt);
    					jQuery('.teaser.info.float p').css('overflow','hidden');
    					jQuery('.float p').height(jQuery('.teaser.info.float').height()-jQuery('.teaser.info.float h1').height()-60);
    					if(!jQuery('.teaser.info.float .more').length)
    						jQuery('.teaser.info.float p').after('<span class="more">...<br/></span>');
    					jQuery('.teaser a.moreinfo').attr('href', jQuery(this).attr('href'));
    					jQuery('#sendmail input[name="notes"]').val(movie_url);
    					
    					jQuery('#trailer div.mov.flv').remove();
    					jQuery('#trailer').html('<a href="/trailer_web/'+ean+'.flv" title="'+keyframe_url+'">trailer here</a>');
    					InitTrailerplayer();
    					return false;
    				});
    			});
    			// Show message when user already send an email
    			var message = window.location+"";
    			message = message.split('#');
    			if(message.length == 2)
    				jQuery('div.trailer div.float #sendmail').after(unescape(message[1]));
    		}
    		
    		jQuery(context).find('.elm.rnd:eq(4)').after('<br style="clear:both"/>');
  		jQuery(context).parent('div div.trailer-over').after(jQuery(html).not(':not(div.nav-page)'));
  		if(jQuery('div.nav-page').length>1)
  			jQuery('div.nav-page:last').remove();
    			
    		jQuery('div.nav-page a[href!=#]').each(function(){
    			var lnk_url = jQuery(this).attr('href');
    			jQuery(this).click(function(){
    				jQuery('.5ColPager').Pager5Col(lnk_url);
    				return false;
    			});
    			jQuery(this).attr('href','#');
    		});
    		
    		jQuery('div.nav-page span.currentPage').html('<a class="set">'+jQuery('div.nav-page span.currentPage').text()+'</a>');
    		if(!isTrailerPage){
    			if(jQuery('#search_result_info').length)
    				jQuery('#search_result_info').remove();
    			jQuery('#search-more').after(jQuery(html).not(':not(#search_result_info)'));
    			if(!jQuery('.nav-alpha a.set').length)
    				jQuery('#search_result_info').prepend('<h3 class="no-border">Titel met de eerste letter: Neuerscheinungen</h3>')
    			else
    				jQuery('#search_result_info').prepend('<h3 class="no-border">Titel met de eerste letter: '+jQuery('.nav-alpha a.set').text()+'</h3>')
    			jQuery('.nav-page.rnd div a.btn').css('margin-top','2px');    			
    			jQuery('.nav-page.rnd div').clone(true).prependTo('#search_result_info');

    		}
    		if(!jQuery(context).find('div.elm.rnd').length){
    			jQuery(context).html('<span>Leider erzielte Ihre Suche keine Ergebnisse.</span>');
    			jQuery('div.nav-page').html(' ');
    		}else if(jQuery('div.nav-page a').length>20)
    			for(var x = 1; x < jQuery('div.nav-page a').length/20;x++)
    				jQuery(jQuery('div.nav-page a')[(x*20)-1]).after('<br/>');

    	    	FixSteelbooks();
    	});
};

$.fn.TopSlider = function(url) { 
    	var context=jQuery(this);
    	//jQuery(this).find('.content').html('<img src="/ceemes/webfile/show/2140" alt="loading" style="width:32px;height:32px;display:block;margin:60px auto;"/>');
    	jQuery.get(url,function(html){
    		jQuery(context).find('.content ul').append(jQuery(html).not(':not(.MovieSlide)'));
    		jQuery(context).find('.content').easySlider({
			auto: true,
			continuous: true,
			numeric: true,
			speed: 600,
			pause: 8000
		});
    	});
};
function ModifyArticle(){
var usdate=jQuery('.date').text();
		var x = usdate.split(' ');
		var d = x[0].split('-');
		jQuery('.date').text(d[2]+"."+d[1]+"."+d[0]);
		
		if(jQuery('#trailer').attr('title') == "")
			jQuery('#trailer').attr('title','/img/trailer_kf/'+jQuery(jQuery('.block.lft dl.info.clearfix dd')[1]).text()+'_KF_0_00_06.jpg');
		if(jQuery('#trailer_exists').text() == "200")
			InitTrailerplayer();
		else
			jQuery('#trailer').remove();

		// ExtendedSearch: Genre Dropdown
		if(jQuery('select[name="category[1]"]').length > 0)
			jQuery('select[name="category[1]"]').loadAllGenres();

		if(jQuery('.gal a.state200 img,.col.lft img.pic').length > 0) {
			jQuery('.gal a.state200 img,.col.lft img.pic').load(function(){
				images_loaded++;
				if(images_loaded == jQuery('.gal a.state200 img,.col.lft img.pic').length){
					jQuery('.gal a.state200 img').each(function(){
						if(jQuery(this).width()<jQuery(this).height()){
							jQuery(this).css('margin','0 24px');
							jQuery(this).siblings('p').css('right','24px');
						}
					});
					// Fix heights of the containers
					EqualContainers();
				}
			});
		} else {
			EqualContainers();
		}
			// Fixup fsk searchvalues
		jQuery('select[name="fsk"] option').each(function(){
			if(jQuery(this).attr('value') != "")
				jQuery(this).attr('value',"\""+jQuery(this).attr('value')+"\"");
		});
		if(language=="nl"){
			jQuery('select[name="fsk"]').html(fsk_benelux);
			jQuery('select[name="genre_1"]').html(genre_benelux);
			// Override german gerne with benelux one
			if("console" in window)
				console.log(jQuery(jQuery('.block.col.rgt dd')[2]).text(),jQuery('select[name="genre_1"] option[value="'+jQuery(jQuery('.block.col.rgt dd')[2]).text()+'"]'));
			jQuery(jQuery('.block.col.rgt dd')[2]).text(jQuery('select[name="genre_1"] option[value="'+jQuery(jQuery('.block.col.rgt dd')[2]).text()+'"]').text());
			
			jQuery('form').each(function(){
				jQuery(this).prepend('<input type="hidden" name="ex_bbenelux" value="1"/>');
			});
			jQuery('span.de').hide();
			jQuery('span.nl').show();

			jQuery('#main-bot ul.nav li.par:first a.l.set').css('border','none');
			jQuery('#main-bot ul.nav li.par:last').hide();
		}
		jQuery('a.thickbox').each(function(){ jQuery(this).append('<p />');}); // zoom icon
		InitColorboxes();
		Search2SlideEffect();
		// Facebook implementation
		if(jQuery('#post_facebook').length) {
		  	jQuery('#post_facebook').click(function() {
		  		var article_id = jQuery.url.param('article');
		  		var article_ean = jQuery('#cnt-media .block.col.lft.rnd .info.clearfix dd:eq(1)').text();
		  		var format = jQuery('#cnt-media .head.rnd.no-bot h3:first').text();
		  		var startdate = jQuery('#cnt-media .block.col.lft.rnd .info.clearfix dd:eq(2)').text();;
		  		var fullurl = window.document.URL;
		  		
				fb_connect_stream_publish(article_id, article_ean, format, startdate, fullurl);
		  	
			  	return false;
		  	});
		}
		
		// Twitter implementation
		if(jQuery('#post_twitter').length){
			jQuery('#post_twitter').click(function() {
				var url = window.location+"";
				// url = escape(url);
				// url = url.replace(/\//g,'%3F');
				var article_name = jQuery('#cnt-media .block.col.lft.rnd dd:eq(0)').text().replace(/ /g,'+');
				// article_name = article_name.replace(/\r/g,'').replace(/\n/g,'').replace(/ /g,'+');
				//console.log(article_name);
				window.open('http://www.twitter.com/share?url='+url+'&text='+article_name+'&via=dvdliebhaber','twitter-popup','width=590,height=200,scrollbars=yes,toolbar=no,status=no,resizable=yes,menubar=no,location=no,directories=no,top=100,left=100');
			});
			if(language == 'nl')
				jQuery('#post_twitter').hide();
		}
		getVersions((location+"").match(/[0-9]+/)[0]);
		EqualContainers();
}    
var images_loaded=0;    
$.fn.LoadArticle = function(article_id) {
	var context = jQuery(this);
	var aid = parseInt(article_id);
	var url = (typeof user_loggedin == "undefined") ? "/ceemes/?article/show/"+aid+"/layout=splendid_article_detail_view" : "/ceemes/?article/show/"+aid+"/layout=splendid_article_detail_view_press";
	var target_html = '';
	var target_obj = null;
	
	// Show loader
	jQuery('.MainArea').html('<img id="loading_image" src="/ceemes/webfile/show/2140" alt="loading" style="width:32px;height:32px;display:block;margin:60px auto;"/>');
	
	// Get
	jQuery.get(url, function(html) {
		target_html = jQuery(html).find('#cnt-media').outerHTML();
		
		jQuery('#loading_image').remove();
		
		jQuery('.MainArea').html(target_html);
		
                /*setTimeout("equalHeight(jQuery('.equal'))", 333);*/
		
		var usdate=jQuery('.date').text();
		var x = usdate.split(' ');
		var d = x[0].split('-');
		jQuery('.date').text(d[2]+"."+d[1]+"."+d[0]);
		
		if(jQuery('#trailer').attr('title') == "")
			jQuery('#trailer').attr('title','/img/trailer_kf/'+jQuery(jQuery('.block.lft dl.info.clearfix dd')[1]).text()+'_KF_0_00_06.jpg');
		if(jQuery('#trailer_exists').text() == "200")
			InitTrailerplayer();
		else
			jQuery('#trailer').remove();

		// ExtendedSearch: Genre Dropdown
		if(jQuery('select[name="category[1]"]').length > 0)
			jQuery('select[name="category[1]"]').loadAllGenres();

		if(jQuery('.gal a.state200 img,.col.lft img.pic').length > 0) {
			jQuery('.gal a.state200 img,.col.lft img.pic').load(function(){
				images_loaded++;
				if(images_loaded == jQuery('.gal a.state200 img,.col.lft img.pic').length){
					jQuery('.gal a.state200 img').each(function(){
						if(jQuery(this).width()<jQuery(this).height()){
							jQuery(this).css('margin','0 24px');
							jQuery(this).siblings('p').css('right','24px');
						}
					});
					// Fix heights of the containers
					EqualContainers();
				}
			});
		} else {
			EqualContainers();
		}
			// Fixup fsk searchvalues
		jQuery('select[name="fsk"] option').each(function(){
			if(jQuery(this).attr('value') != "")
				jQuery(this).attr('value',"\""+jQuery(this).attr('value')+"\"");
		});
		if(language=="nl"){
			jQuery('select[name="fsk"]').html(fsk_benelux);
			jQuery('select[name="genre_1"]').html(genre_benelux);
			// Override german gerne with benelux one
			if("console" in window)
				console.log(jQuery(jQuery('.block.col.rgt dd')[2]).text(),jQuery('select[name="genre_1"] option[value="'+jQuery(jQuery('.block.col.rgt dd')[2]).text()+'"]'));
			jQuery(jQuery('.block.col.rgt dd')[2]).text(jQuery('select[name="genre_1"] option[value="'+jQuery(jQuery('.block.col.rgt dd')[2]).text()+'"]').text());
			
			jQuery('form').each(function(){
				jQuery(this).prepend('<input type="hidden" name="ex_bbenelux" value="1"/>');
			});
			jQuery('span.de').hide();
			jQuery('span.nl').show();

			jQuery('#main-bot ul.nav li.par:first a.l.set').css('border','none');
			jQuery('#main-bot ul.nav li.par:last').hide();
		}
		jQuery('a.thickbox').each(function(){ jQuery(this).append('<p />');}); // zoom icon
		InitColorboxes();
		Search2SlideEffect();
		// Facebook implementation
		if(jQuery('#post_facebook').length) {
		  	jQuery('#post_facebook').click(function() {
		  		var article_id = jQuery.url.param('article');
		  		var article_ean = jQuery('#cnt-media .block.col.lft.rnd .info.clearfix dd:eq(1)').text();
		  		var format = jQuery('#cnt-media .head.rnd.no-bot h3:first').text();
		  		var startdate = jQuery('#cnt-media .block.col.lft.rnd .info.clearfix dd:eq(2)').text();;
		  		var fullurl = window.document.URL;
		  		
				fb_connect_stream_publish(article_id, article_ean, format, startdate, fullurl);
		  	
			  	return false;
		  	});
		}
		
		// Twitter implementation
		if(jQuery('#post_twitter').length){
			jQuery('#post_twitter').click(function() {
				var url = window.location+"";
				// url = escape(url);
				// url = url.replace(/\//g,'%3F');
				var article_name = jQuery('#cnt-media .block.col.lft.rnd dd:eq(0)').text().replace(/ /g,'+');
				// article_name = article_name.replace(/\r/g,'').replace(/\n/g,'').replace(/ /g,'+');
				//console.log(article_name);
				window.open('http://www.twitter.com/share?url='+url+'&text='+article_name+'&via=dvdliebhaber','twitter-popup','width=590,height=200,scrollbars=yes,toolbar=no,status=no,resizable=yes,menubar=no,location=no,directories=no,top=100,left=100');
			});
			if(language == 'nl')
				jQuery('#post_twitter').hide();
		}
	}).complete(function() {
		getVersions(jQuery.url.param("article"));
EqualContainers();
	});
};

function LoadPressArticles(url,dateobj){
	jQuery.get(url,function(html){
		jQuery('#press_articlepreview .search_result_list').html('');
		jQuery('#press_articlepreview .search_result_list').append(jQuery(html).filter('.elm'));
		jQuery('#press_articlepreview .search_result_list').prepend('<h3 style="text-transform: capitalize;">'+getURLMonth(dateobj.getMonth())+'</h3>');
		if(jQuery('#press_articlepreview .search_result_list .elm').length){
			jQuery('#press_articlepreview .search_result_list .elm .date').each(function(){
				jQuery(this).text(GetNiceDate(jQuery(this).text()));
				jQuery(this).css('font-weight','bold');
				jQuery(this).show();
			});
		}else{
			jQuery('#press_articlepreview .search_result_list').append('<span>In diesem Monat sind keine Artikel erschienen.</span>');
		}
		FixSteelbooks();
		EqualContainers();
	});
}
/* ##### Gets the names of all subcategories and puts them into the genre dropdown ##### */
$.fn.loadAllGenres = function() {
	// DropDown Variable
	var DropDown = jQuery(this);

	// Fire the ajax
	jQuery.get('/ceemes/articlecategory/xmllist/', function(data) {
		// Shall contain the sub categories of '/DVD/'
		var categories_objs = new Array(); 
		// Shall contain the sub categories of '/DVD/*/'
		var subcategories_objs = new Array(); 
		// Shall contain the final sub categories-names of '/DVD/*/'
		var subcategories = new Array(); 
		
		/* ### Get all categories_objs ### */
		// First off, we have to fetch all parent-elements
		var parents = jQuery(data).find('parent');
		
		// Now iterate the parent-elements and check for children of the category '123' which is '/DVD/'
		parents.each(function() {
			if(jQuery(this).text() == 123)
				categories_objs.unshift(jQuery(this).parent());
		});
		
		/* ### Get all subcategories_objs of the categories_objs fetched above ### */
		// Hold the cat_id of a main-category
		var cat_id = -1;
		
		// Iterate the categories_objs from above
		jQuery.each(categories_objs, function() {
			// Get the idx of the current category
			cat_id = parseInt(jQuery(this).find('idx').text());
			
			// Iterate the parents
			jQuery.each(parents,function() {
				// Compare the current parent-id with the current category-id
				if(parseInt(jQuery(this).text()) == cat_id) {
					// IDX and Parent-ID matches, this is a subcategory like '/DVD/Spielfilm/Erotik'
					var subcategory = jQuery(this).parent();
					
					// Add it to the subcategories_objs collection
					subcategories_objs.unshift(subcategory);
				}
			});
		});
	
		/* ### MAIN ### */
		jQuery.each(subcategories_objs, function() {
			// A name like '/DVD/Spielfilm/Erotik/'
			var subcat_name = jQuery(this).find('name').text();
			
			// Split the name by '/'
			var subcat_name_parts = subcat_name.split('/');
			
			// Determinate the subcategory name
			var final_subcat_name = subcat_name_parts[subcat_name_parts.length-2];
			
			// Add it to the subcategories
			subcategories.unshift(final_subcat_name);
		});
		
		// Sort the subcategories
		subcategories.sort();
		
		// Unique the subcategories
		subcategories.unique();
		
		// Lets prepare the genre dropdown by iterating the subcategories and adding an option for each of them
		jQuery(DropDown).html('');
		jQuery(DropDown).append('<option value="">Alle Genre</option>');
		jQuery.each(subcategories, function() {
			var name = this;
			jQuery(DropDown).append('<option value="'+name+'">'+name+'</option>');
		});
	});
};

/*################################ PLUGIN END ################################*/
function GetRandom( min, max ) {
	if( min > max ) {
		return( -1 );
	}
	if( min == max ) {
		return( min );
	}
 
        return( min + parseInt( Math.random() * ( max-min+1 ) ) );
}
function GetNiceDate(date){
	var x = date.split(' ');
	var d = x[0].split('-');
	return d[2]+"."+d[1]+"."+d[0];
};

function InitColorboxes() {
	// Initialise the colorboxes
	jQuery('a.thickbox').colorbox({
 		transition:'elastic',
 		opacity:0.85,
 		slideshow:true,
 		slideshowAuto:false,
 		current: '{current} von {total}',
 		maxWidth:'100%',
 		maxHeight:'100%'
	});
};
function Search2SlideEffect(){
	jQuery('#search-more2-toggleBTN').toggle(function(){
			if(jQuery('#main-bot .block.dbl').length)
				jQuery('#main-bot .block.dbl .inner:last').height(parseInt(jQuery('#main-bot .block.dbl .inner:last').height())+347);
			else{
				jQuery('#main-bot .block.mid .inner:last').height(parseInt(jQuery('#main-bot .block.mid .inner:last').height())+347);
				jQuery('#main-bot .block.lft .inner:last').height(parseInt(jQuery('#main-bot .block.lft .inner:last').height())+347);
			}
			
			jQuery('#search-more2').slideDown();
			return false;
		},
		function(){
			jQuery('#search-more2').slideUp(400,function(){
				if(jQuery('#main-bot .block.dbl').length)
					jQuery('#main-bot .block.dbl .inner:last').height(parseInt(jQuery('#main-bot .block.dbl .inner:last').height())-347);
				else{
					jQuery('#main-bot .block.mid .inner:last').height(parseInt(jQuery('#main-bot .block.mid .inner:last').height())-347);
					jQuery('#main-bot .block.lft .inner:last').height(parseInt(jQuery('#main-bot .block.lft .inner:last').height())-347);
				}	
			});
			return false;
	});
}
function InitTrailerplayer(){
	var baseurl = "http://www.splendid-film.nl/ceemes/".replace('/ceemes/','');
	jQuery.fn.media.defaults.flvPlayer = baseurl + '/trailer_web/nonverblaster.swf';

	jQuery('a[href$="flv"], a[href$="mov"], a[href$="mp4"], a[href*="youtube.com/v/"]').each(function(){
		var mov = jQuery(this).attr('href');
		var keyframe = jQuery('#trailer span.previewpic').text().replace(/\s/g,'').replace(baseurl,'');
		if (keyframe == '')
			keyframe = 'none';

		var add = 'qkt';
		var trailerheight = 300;
		if(jQuery('body').hasClass('kino_neuheiten_detail'))
			trailerheight = 284;

		var options = {
			preferMeta: false,
			width: 468,
			height: trailerheight,
			autoplay: false,
			bgColor: '#000000',
			caption: false,
			attrs: {allowfullscreen:'true', wmode:'transparent'},
			params: {allowfullscreen:'true'}
		};
		if (mov.search(/youtube/)>0){
			options = jQuery.extend(options,{
				src: mov+'&fs=1&fmt=6', // fmt: 18=mp4, 6=flv
				type: 'swf'
			});
			add = 'you';
		}
		if (mov.search(/\.flv/)>0){
			options = jQuery.extend(options,{
				flashvars: {
					videoURL: mov,
					teaserURL: keyframe,
					controlColor: '0xffffff',
					controlBackColor: '0x000000'
				}
			});
			add = 'flv';
		}
		if (jQuery('.col.mid').length){
			options = jQuery.extend(options,{
				width: 394,
				height: 246
			});
		}
		jQuery(this).addClass('mov '+add).media(options);
	});
}

function getURLMonth(m){
	var MonthArray = Array("januar","februar","maerz","april","mai","juni","juli","august","september","oktober","november","dezember");
	return MonthArray[m];
}

function getMonth(m) {
	switch(m) {
		case '01': return 'Januar';
		case '02': return 'Februar';
		case '03': return 'März';
		case '04': return 'April';
		case '05': return 'Mai';
		case '06': return 'Juni';
		case '07': return 'Juli';
		case '08': return 'August';
		case '09': return 'September';
		case '10': return 'Oktober';
		case '11': return 'November';
		case '12': return 'Dezember';
		default: return '';
	}
}


function EqualContainers(){
		var sidebarHeight=0;
		
		jQuery('#main-bot .rgt:visible').each(function(){
			sidebarHeight+=parseInt(jQuery(this).css('height').replace(' px',''));
		});
		if(jQuery('#main-bot .block.dbl.news').length){
			var mainHeight = parseInt(jQuery('#main-bot .block.dbl').css('height').replace(' px',''));
			jQuery('#main-bot .rgt:visible:last .inner').css('height',parseInt(jQuery('#main-bot .rgt:visible:last .inner').css('height'))-117);
		}else if(jQuery('#main-bot .block.dbl.press_new').length){
			var mainHeight = parseInt(jQuery('#main-bot .block.dbl').css('height').replace(' px',''));
			jQuery('#main-bot .rgt:visible:last .inner').css('height',mainHeight-237);
		}else if(jQuery('#main-bot .MainArea .block.mid').length){
			if(jQuery('#main-bot .rgt:visible').length==3)
				sidebarHeight=sidebarHeight+10;

				
			var mainHeight = parseInt(jQuery('#main-bot .MainArea .block.mid').height());
			var leftHeight = parseInt(jQuery('#main-bot .MainArea .block.lft').height());
			if(sidebarHeight>mainHeight && sidebarHeight>leftHeight){
				jQuery('#main-bot .MainArea .block.mid .inner').css('height',parseInt(jQuery('#main-bot .MainArea .block.mid .inner').css('height').replace(' px',''))+(sidebarHeight-mainHeight));
				jQuery('#main-bot .MainArea .block.lft .inner').css('height',(parseInt(jQuery('#main-bot .MainArea .block.lft .inner').css('height').replace(' px','')))+(sidebarHeight-leftHeight));
			}else if(mainHeight>sidebarHeight && mainHeight>leftHeight){
				jQuery('#main-bot .MainArea .block.lft .inner').css('height',(parseInt(jQuery('#main-bot .MainArea .block.lft .inner').css('height').replace(' px','')))+(mainHeight-leftHeight));
				jQuery('#main-bot .MainArea .rgt.block:visible .inner').css('height',(parseInt(jQuery('#main-bot .MainArea .rgt.block:visible .inner').css('height').replace(' px',''))-10)+(mainHeight-sidebarHeight));
			}else if(leftHeight>mainHeight && leftHeight>sidebarHeight){
				jQuery('#main-bot .MainArea .block.mid .inner').css('height',parseInt(jQuery('#main-bot .MainArea .block.mid .inner').css('height').replace(' px',''))+(leftHeight-mainHeight));
				jQuery('#main-bot .MainArea .rgt.block:visible .inner').css('height',(parseInt(jQuery('#main-bot .MainArea .rgt.block:visible .inner').css('height').replace(' px',''))-10)+(leftHeight-sidebarHeight));
			}
		}else{
			if(jQuery('#main-bot .block.dbl').length){
				var mainHeight = parseInt(jQuery('#main-bot .block.dbl').css('height').replace(' px',''));
		
				if(sidebarHeight>mainHeight){
					jQuery('#main-bot .block.dbl .inner').css('height',parseInt(jQuery('#main-bot .block.dbl .inner').css('height').replace(' px',''))+10+(sidebarHeight-mainHeight));
				}else{
					jQuery('#main-bot .rgt:visible:last .inner').css('height',(parseInt(jQuery('#main-bot .rgt:last .inner').css('height').replace(' px',''))-10)+(mainHeight-sidebarHeight));
				}
			}
		}
}

/*    
    $.fn.Splendid.News = function(o) { };
    
    $.fn.Splendid.MiniNews = function(o) { };
*/

/* ########## FACEBOOK APP INITIALISATION, Domain Related AppIDs -_- ########## */
function InitFacebook(){
var facebook_appid_wwwde = 'f1d8f5d81b761fbbad6c2e3764e8ebbb';
var facebook_appid_wwwcom = '6c06631a17774caad0242439fac3de67';
var facebook_appid_de = 'd3f88f8d789e2a0d128349cb17a74fcb';
var facebook_appid_com = '98d8904b9f04579751db982bc7378425';
if(typeof(FB) !== "undefined") {
	// On the www-subdomain
	if(document.URL.search(/www./) != -1) {
		if(document.URL.indexOf(".de") != -1)
			FB.init(facebook_appid_wwwde);
		else
			FB.init(facebook_appid_wwwcom);
		
	} 		
	// Not on the www-subdomain
	else {
		if(document.URL.indexOf(".de") != -1)
			FB.init(facebook_appid_de);
		else
			FB.init(facebook_appid_com);
	}
}
}
/* Facebook Post Function - Splendid related! See AmasiaJS for Amasia related version */
function fb_connect_stream_publish(article_id, article_ean, format, startdate, fullurl) {

	content_short = jQuery('#cnt-media .block.col.mid.rnd .inhalt_kurz').text();
	article_name = jQuery('#cnt-media .block.col.lft.rnd dd:eq(0)').text();
	
	var message = 'Neue ' + format + ' ' + article_name + ' jetzt bei Splendid Film!'; 

	var attachment = { 
	    'name': article_name, 
	    'href': fullurl + '/article/show/' + article_id, 
	    'caption': format + ' ab ' +startdate+' im Handel!', 
	    'description': content_short, 
	    'media': [{ 'type': 'image', 'src': 'http://www.wvg.com/img/dvd_th/' + article_ean + '.jpg', 'href': fullurl + '/article/show/' + article_id}]
	}; 
	var action_links = [{ 'text': 'Jetzt anschauen!', href: fullurl + '/article/show/' + article_id }];
	var user_message_prompt = 'Neue ' + format + ' ' + article_name + ' jetzt bei Splendid Film';
	return FB.Connect.streamPublish(message, attachment, action_links, null, user_message_prompt);
}

function getVersions(articleID) {
	if (jQuery('#versionnav').length < 1)
		return;
	jQuery.get('/ceemes/wvg/getotherversions/0/articleid=' + articleID,
		function(html) {
			jQuery('#versionnav').html(html);
		}
	);
}

function FixSteelbooks(){
	jQuery('.frame_color_no-border img').each(function(){
		jQuery(this).attr('src',jQuery(this).attr('src').replace('splendid_th','dvd_th'));
		jQuery(this).parents('.Blu-ray').removeClass('Blu-ray').addClass('DVD');
	});
	jQuery('.3D').each(function(){
		jQuery(this).find('img[src*=dvd_th]').each(function(){
			jQuery(this).attr('src',jQuery(this).attr('src').replace("dvd_th","splendid_th"));
		});
	})
}

// ############################ MAIN START : DOCUMENT READY BELOW
var language = "NL";
var fsk_benelux = '<option value="">alle leeftijden</option><option value="o.A. bzw. 0">o.A. bzw. 0</option><option value="6">6</option><option value="12">12</option><option value="16">16</option><option value="k.J. bzw. ab 18">k.J. bzw. ab 18</option>';
var genre_benelux = '<option></option><option value="Abenteuer">Aventuur</option><option value="Action">Actie</option><option value="Action/Thriller">Actie/Thriller</option><option value="Animation">Animatie</option><option value="Anime">Anime</option><option value="Dokumentation">Documentatie</option><option value="Drama">Drama</option><option value="Erotik">Erotiek</option><option value="Fantasy">Fantasy</option><option value="Horror">Horror</option><option value="Kinder">Kinderen</option><option value="Komödie">Komedie</option><option value="Liebesfilm">Liefdesfilm</option><option value="Martial Arts">Martial Arts</option><option value="Musik">Muziek</option><option value="Romance">Romantiek</option><option value="Science Fiction">Science Fiction</option><option value="Spielfilm">Speelfilm</option><option value="Splatter">Splatter</option><option value="Thriller">Thriller</option><option value="TragiKomödie">TragiKomedie</option><option value="Zeichentrick">Tekenfilm</option>';	
jQuery(function(){
	var loadingArticlePreview = 0;
		
	//#######################################
	// Welcome to the Netherlands
	//#######################################
	if(language=="nl")
	{
		// Remove menu entries
		for(i=0;i<3;i++){
			// Top menu
			jQuery('#navx>ul>li:last').remove();
			// Bottom menu
			jQuery(jQuery('.nav-foot>ul>li')[6]).remove();
		}
		jQuery(jQuery('#navx>ul>li')[2]).remove();
		jQuery(jQuery('.nav-foot>ul>li')[2]).remove();
		jQuery('li#3dmenu').remove();
		
		// Remove standard banners
		jQuery('.bullet').each(function(){
			if(!jQuery(this).hasClass('benelux'))
				jQuery(this).remove();
		});
		// Setting menu searchlinks
		jQuery('#navx>ul li a[href*="action=search"],#footer .nav-foot a[href*="action=search"]').each(function(){
			jQuery(this).attr('href',jQuery(this).attr('href').replace('&rental','&ex_bbenelux=1&rental'));
		});

		// Setting cinema menulink to nl 
		jQuery(jQuery('#navx>ul>li>a')[1]).attr('href',jQuery(jQuery('#navx>ul>li>a')[1]).attr('href')+"_nl");

		// Redirecting trailers to youtube ...
		jQuery(jQuery('#navx>ul>li>a')[5]).attr('href','http://www.youtube.com/user/SplendidFilmBenelux');
		jQuery(jQuery('#navx>ul>li>a')[5]).attr('target','_blank');
		
		// Redirecting youtube icon to nl youtube page
		jQuery('.socials .ico.you').attr('href','http://www.youtube.com/user/SplendidFilmBenelux');

		// Setting impress link nl 
		jQuery('#footer .nav-foot ul:first li a:last').attr('href',jQuery('#footer .nav-foot ul:first li a:last').attr('href')+"_nl");

		// Removing contact link
		jQuery(jQuery('#footer .nav-foot ul:first li')[5]).remove();


		// Adding brochure entry
		jQuery('#navx>ul').append('<li><a href="http://splendid.digitalebrochure.com/">Brochure</a></li>');
		jQuery(jQuery('.nav-foot>ul>li')[5]).before('<li><a href="http://splendid.digitalebrochure.com/">Brochure</a></li>');
		
		// remove social icons and show another one
		jQuery('.socials .twr').remove();
		jQuery('.socials .fbk').attr('href','http://www.facebook.com/splendidfilmbnl');
		jQuery('.socials .hyv').show();
		
		// transform ajax searches 
		jQuery('.ajaxurl').each(function(){
			jQuery(this).text(jQuery(this).text().replace("&label","&ex_bbenelux=1&label"));
		});
		
		// alter searchforms to find benelux articles
		jQuery('form input[value=article]').after('<input type="hidden" name="ex_bbenelux" value="1"/>');
		
		if(jQuery('#teaser').length){
			// remove splendid germany slide
			jQuery('#teaser .content .splendid').remove();
			
			// replace slider ajax page with splendid nl page
			jQuery('#teaser').attr('lang',jQuery('#teaser').attr('lang').replace('349','431')); 
		}
		
		// showing brochure pagelet
		if(jQuery('#brochure').length){
			jQuery('#brochure').show();
			
			// fixing style
			jQuery('#main-bot .col.rgt.rnd').css('background-color','#000');
			
			// fixing height of news container
			jQuery('.inner.rnd-bot.newsbar.clearfix').css({'overflow':'hidden',
									'min-height':'0px',
									'height':'260px'});	
		}
		// fix fsk values
		if(jQuery('select[name="fsk"]').length)		
			jQuery('select[name="fsk"]').html(fsk_benelux);
		// fix genre languages in searches
		if(jQuery('select[name="genre_1"]').length)
			jQuery('select[name="genre_1"]').html(genre_benelux);
		// fix mininews
		if(jQuery('.ajax_news').length){
			jQuery('.ajax_news .elm a.img').attr('href','#');
			jQuery('.ajax_news .elm *').not('.adminbar').find('a').attr('href','#');
			jQuery('.ajax_news div.elm').show();
		}
		
	}else{
		// remove splendid netherlands slide
		jQuery('#teaser .content .splendid_nl').remove();
		
		// remove benelux banners
		if(jQuery('.bullet.benelux').length){
			jQuery('.bullet.benelux').remove();
		}
		// load mininews
		if(jQuery('.ajax_news').length){		
			jQuery('.ajax_news').LoadMiniNews();
			var hdl = jQuery('.ajax_news').prev('div').find('h3');
			jQuery(hdl).css('cursor','pointer');
			jQuery(hdl).click(function(){
				location = jQuery(jQuery('#navx>ul>li')[6]).find('a').attr('href');
			});
		}

	}
	//#######################################
	// You are leaving the Netherlands now
	//#######################################
	
	// navigation new and soon releases links	
	var nr_date_from = new Date();
	var nr_date_to = new Date();
	var sr_date_from = new Date();
	var sr_date_to = new Date();

	nr_date_from.setDate(nr_date_from.getDate()-70);
	
	jQuery('.new_releases').each(function(){
		if(!jQuery(this).hasClass('ajaxurl')){
		jQuery(this).attr('href',jQuery(this).attr('href').replace("startdate[0]","startdate[0]="+nr_date_from.getDate()+"."+(nr_date_from.getMonth()+1)+"."+nr_date_from.getFullYear()));
		jQuery(this).attr('href',jQuery(this).attr('href').replace("startdate[2]","startdate[2]="+nr_date_to.getDate()+"."+(nr_date_to.getMonth()+1)+"."+nr_date_to.getFullYear()));
		}else{
		jQuery(this).text(jQuery(this).text().replace("startdate[0]","startdate[0]="+nr_date_from.getDate()+"."+(nr_date_from.getMonth()+1)+"."+nr_date_from.getFullYear()));
		jQuery(this).text(jQuery(this).text().replace("startdate[2]","startdate[2]="+nr_date_to.getDate()+"."+(nr_date_to.getMonth()+1)+"."+nr_date_to.getFullYear()));
		}
	});
	
	sr_date_from.setDate(sr_date_from.getDate()+1);

	jQuery('.soon_releases').each(function(){
		jQuery(this).attr('href',jQuery(this).attr('href').replace("startdate[0]","startdate[0]="+sr_date_from.getDate()+"."+(sr_date_from.getMonth()+1)+"."+sr_date_from.getFullYear()));
		jQuery(this).attr('href',jQuery(this).attr('href').replace("startdate[2]","startdate[2]=31.12.2030"));
	});
	
	jQuery('.ajaxurl.ajax_soon').each(function(index){ 
		jQuery(this).text(jQuery(this).text().replace("startdate[0]","startdate[0]="+sr_date_from.getDate()+"."+(sr_date_from.getMonth()+1)+"."+sr_date_from.getFullYear()));
		jQuery(this).text(jQuery(this).text().replace("startdate[2]","startdate[2]=31.12.2030"));
	});
	
	jQuery('.ajaxurl.ajax_available').each(function(index){ 
		jQuery(this).text(jQuery(this).text().replace("startdate[0]","startdate[0]="+nr_date_from.getDate()+"."+(nr_date_from.getMonth()+1)+"."+nr_date_from.getFullYear()));
		jQuery(this).text(jQuery(this).text().replace("startdate[2]","startdate[2]="+nr_date_to.getDate()+"."+(nr_date_to.getMonth()+1)+"."+nr_date_to.getFullYear()));
	});
	
	jQuery('.ajaxurl.new_press_releases').each(function(){
		jQuery(this).text(jQuery(this).text().replace("startdate[0]","startdate[0]=01."+(nr_date_to.getMonth()+1)+"."+nr_date_to.getFullYear()));
		var press_release_to_month = nr_date_to.getMonth()+2;
		var press_release_to_year = nr_date_to.getFullYear();
		if(press_release_to_month == 13) {
			press_release_to_month = 1;
			press_release_to_year += 1;
		}
		jQuery(this).text(jQuery(this).text().replace("startdate[2]","startdate[2]=01."+press_release_to_month+"."+press_release_to_year));
	});
	
	
	// Choose an ad to display
	if(jQuery('.bullet').length>1){
		var ad_index = GetRandom(0,jQuery('.bullet').length-1);
		jQuery(jQuery('.bullet')[ad_index]).show();
	}
	// convert searchresult dates
	if(jQuery('.with_date').length){
		jQuery('.with_date .date').each(function(){
			jQuery(this).text(GetNiceDate(jQuery(this).text()));
			jQuery(this).show();
		});
	}
	
	// Teaser preparation: Remove the amasia element
	if(jQuery('#teaser .content .amasia').length) {
		jQuery('#teaser .content .amasia').remove();
	}
	
	// Apply Splendid functions to elements
	if(jQuery('#teaser').length)
		if(jQuery('#teaser').attr('lang')!='/ceemes/')
			jQuery('#teaser').TopSlider(jQuery('#teaser').attr('lang'));
			
	if(jQuery('.preview').length){
		jQuery('.preview').each(function(){
			if(jQuery(this).find('span.ajaxurl').text()!='/ceemes/'){
				loadingArticlePreview = 1;
				jQuery(this).ArticlePreview(jQuery(this).find('span.ajaxurl').text(), jQuery(this).find('.ajax_available').length);
			}
		});	
		jQuery('div.nav-page span.currentPage').html('<a class="set">'+jQuery('div.nav-page span.currentPage').text()+'</a>');
	}
		
	if(jQuery('.4ColSlider').length){
		jQuery('.4ColSlider').each(function(){
			if(jQuery(this).find('span.ajaxurl').text()!='/ceemes/')
				jQuery(this).Slider4Col(jQuery(this).find('span.ajaxurl').text());
		});
	}
	if(jQuery('.5ColSlider').length){
		jQuery('.5ColSlider').each(function(){
			if(jQuery(this).attr('lang')!='/ceemes/')
				jQuery(this).Slider5Col(jQuery(this).attr('lang'));
		});
	}
	if(jQuery('.5ColPager').length){
		if(jQuery('.5ColPager').find('span.ajaxurl').text()!='/ceemes/'){
			jQuery('.5ColPager').Pager5Col(jQuery('.5ColPager').find('span.ajaxurl').text());
		}
	}
	
	// Search functions		
	if(jQuery('.nav-alpha').length && jQuery('.5ColPager').length) {
		jQuery('.nav-alpha a').each(function(){
				jQuery(this).click(function(){
					var search_url = jQuery('.nav-alpha .ajaxurl').text();
					if(!jQuery(this).hasClass('all') && !jQuery(this).hasClass('digit'))
						search_url= search_url+"&starts_with="+jQuery(this).text();
					else if(jQuery(this).hasClass('digit'))
						search_url= search_url+"&starts_with=digit";
					jQuery('.nav-alpha a').removeClass('set');
					jQuery(this).addClass('set');
					jQuery('.5ColPager').Pager5Col(search_url);
					return false;
				})
			});
	}

	// Kino Neuheit Presse addons
	if(jQuery('body').hasClass('kino_neuheiten_detail') && press)
	{
		jQuery('.btn-o,.press').show();
		jQuery('.trailer .inner').height(jQuery('.trailer .inner').height()+14);
	}


	if(jQuery('#search-more').length && jQuery('.5ColPager').length){
		jQuery('#search-more input[type="submit"]').remove();
		jQuery('#search-more a.btn').click(function(){
			if(jQuery('.nav-alpha').length)
				var searchmore_str = jQuery('.nav-alpha .ajaxurl').text();
			else
				var searchmore_str = "";
			jQuery('#search-more select,#search-more input').each(function(){
				searchmore_str= searchmore_str + "&" + jQuery(this).attr('name') + "=" + jQuery(this).val();
			});
			jQuery('.5ColPager').Pager5Col(searchmore_str);
		});
		jQuery('#search input[type="submit"]').remove();
		jQuery('#search a.search-btn').click(function() {
			var search_str = "";
			jQuery('#search input').each(function() {
				search_str= search_str + "&" + jQuery(this).attr('name') + "=" + jQuery(this).val();
			});
			jQuery('.5ColPager').Pager5Col(search_str);
		});
		// Prevent form from beeing submitted natively by pressing return
		jQuery('form#search').submit(function(){
			jQuery('#search a.search-btn').click();
			return false;
		});
	}
	if(jQuery('.search_result_list').length) {
		if(jQuery('.search_result_list .elm').length) {
			for(var x = 1;x<jQuery('.search_result_list .elm').length/4;x++)
				jQuery(jQuery('.search_result_list .elm')[x*4-1]).after('<br style="clear:both"/>');
		} else if(jQuery.url.param("action")&&!jQuery('.review_article').length) {
			jQuery('.search_result_list').html('<span style="line-height:0px">Leider erzielte Ihre Suche keine Ergebnisse.</span>');
		}
	}

if(jQuery('div.nav-alpha').length && navigator.userAgent.indexOf("Firefox") != -1 && navigator.userAgent.indexOf("Macintosh") != -1){
jQuery('div.nav-alpha a.btn-ico').eq(26).css('margin-right','0px');
jQuery('div.nav-alpha a.btn-ico').eq(0).css('width','25px');
}

	// Fixup fsk searchvalues
	jQuery('select[name="fsk"] option').each(function(){
		if(jQuery(this).attr('value')!="")
			jQuery(this).attr('value',"\""+jQuery(this).attr('value')+"\"");
	});
	if(jQuery('.news').length){
		DaySort(jQuery('.news>.col.rnd'));

		jQuery('.news>.col.rnd .head.rnd.no-bot').hide();		
		jQuery('.news>.col.rnd .head.rnd.no-bot:first').show();		
	}
	
	if(jQuery('div.news').length&&jQuery('div.archiv.equal').length){
		jQuery('div.archiv.equal').height(jQuery('div.rnd.news').height()-76);
		jQuery('.archiv a').each(function(){
		    var news_loc = window.location+"";
		    if(news_loc.search(jQuery(this).attr('href')) != -1)
		        jQuery(this).addClass('set');
		});
	}
	// article detail view function
	if(jQuery.url.param("article") !== undefined) {
		jQuery('#main-bot').LoadArticle(jQuery.url.param("article"));
	}
	
	// navigation highlightning
	jQuery('#navx li a[href$='+jQuery('.pagename').text()+'],#footer .nav-foot ul li a[href$='+jQuery('.pagename').text()+']').addClass('set');
	if(!jQuery('#navx li a.set').length){
		var loc = window.location+"";
		var headline;
		loc= loc.replace(">","%3E");
		loc= loc.replace("<","%3C");
		headline = loc.split('#');
		jQuery('#navx ul li a,#footer .nav-foot ul li a').each(function(){
			if(jQuery(this).attr('href')==loc)
				jQuery(this).addClass('set');
		});
		if(headline.length == 2)
			jQuery('.noslider_2col div h3').text(decodeURI(headline[1]));
		
	}
	if(jQuery('#navx .set').parents('ul.nav-sub').length){
		var parentnode = jQuery('#navx .set').parents('ul.nav-sub').siblings('a');
		jQuery(parentnode).addClass('set');
		jQuery('#footer .nav-foot ul li a').each(function(){
			if(jQuery(this).attr('href')==jQuery(parentnode).attr('href'))
				jQuery(this).addClass('set');
		});
	}
	if(!(typeof user_loggedin == "undefined"))
		jQuery('#navx ul li a[href$=splendid_press]').attr('href','/ceemes//page/show/splendid_press_loggedin_new');
	// create nice dates again
	jQuery('.review_article .date').each(function(){
    			jQuery(this).text(GetNiceDate(jQuery(this).text()));
    			jQuery(this).show();
    		});
	// remove images that are not set
	if(jQuery('div.stills').length)
		jQuery('div.stills img[src*="blank.gif"]').parents('a').remove();
	else
		InitFacebook();

	// setup colorboxes	
	InitColorboxes();
	
	// setup trailer if needed
	if(jQuery('#trailer').length)
		InitTrailerplayer();
	
	if((jQuery('#navx a.set').text() == "Trailer"|| jQuery('#navx a.set').text() == "IN DE BIOSCOOP") && language == "nl"){
		jQuery('#sendmail').remove();
		var infotext = jQuery('.teaser.info.float').html();
		jQuery('.teaser.info.float').remove();
		if(jQuery('#navx a.set').text() == "IN DE BIOSCOOP"){
			jQuery('#trailer').after('<div style="width:380px;float:left;padding-left:20px">'+infotext+'</div>');
		}else{
			jQuery('form#search').after('<div style="width:380px">'+infotext+'</div>');
			jQuery('form#search').css('width','auto');
			jQuery('form#search input').css('width','100%');
		}
	}
	
	// ExtendedSearch: Genre Dropdown
	/*if(jQuery('select[name="category[1]"]').length > 0)
		jQuery('select[name="category[1]"]').loadAllGenres();
	*/
	// Fix heights on pages with search2 container
	if(jQuery('.search2').length>0 && loadingArticlePreview != 1){
		EqualContainers();
	}
	
	// Adding toggle event to search2 containers
	if(jQuery('.search2').length>0)
		Search2SlideEffect();
	
	
	// hide search navigation bar if no search is done
	if(escape(jQuery('.nav-page.bar.space.rnd').html()) == '%0A%09%0A')
		jQuery('.nav-page.bar.space.rnd').hide();

	
	// VERY NEW PRESS AREA
	var press_date = new Date();
	var press_date_from_fullYear = press_date.getFullYear();
	var press_date_to_fullYear = press_date.getFullYear();
	if(jQuery('#press_articlepreview').length){
		jQuery('#navx>ul>li:last a').addClass('set');
		var monthcounter = press_date.getMonth();
		for(var i = press_date.getMonth(); i>press_date.getMonth()-5;i--){
			if(press_date_from_fullYear != press_date_to_fullYear) {
				press_date_to_fullYear = press_date_from_fullYear;
			}
			if(monthcounter<0) {
				monthcounter = 11;
				press_date_from_fullYear -= 1;
			}
			
			jQuery('.press_new .nav-foot').append('<div class="freebtn"><div class="left">&nbsp;</div><span>'+getURLMonth(monthcounter).replace('ae','ä')+'</span><div class="right"></div></div>');
			jQuery('.press_new .nav-foot .freebtn:last').data('monthid',monthcounter);
			jQuery('.press_new .nav-foot .freebtn:last').data('fromyear',press_date_from_fullYear);
			jQuery('.press_new .nav-foot .freebtn:last').data('toyear',press_date_to_fullYear);
			jQuery('.press_new .nav-foot .freebtn:last').click(function(){
				var url = "/ceemes//?__type__=article&action=search&__boolop__=AND&__sortby__=startdate&__sortdir__=DESC&startdate[0]&startdate[1]=%3E=&startdate[2]&startdate[3]=%3C=&rental=0&label=Splendid I-ON Fortune Star&destination=splendid_4col_press_pager_ajax:articles";
				press_date.setMonth(jQuery(this).data('monthid'));
				url = url.replace('startdate[0]','startdate[0]=01.'+(press_date.getMonth()+1)+"."+jQuery(this).data('fromyear'));
				to_month = press_date.getMonth()+2;
				if(to_month == 13)
					to_month = 1;
				url = url.replace('startdate[2]','startdate[2]=01.'+to_month+"."+jQuery(this).data('toyear'));
				LoadPressArticles(url,press_date);
			});
			monthcounter--;
		}
		
		LoadPressArticles(jQuery('#press_articlepreview .ajaxurl').text(),nr_date_to);
	}

	// PREVENT DELETING OF PAGELETS
	if(jQuery('.adminbar').length){
		jQuery('.adminbar').each(function(){

			jQuery(jQuery(this).find('a')[5]).click(function(){
				return confirm("Wollen Sie dieses Element wirklich Löschen?");
			});
		});
	}
	jQuery('#download-high-cover-t').click(function() {
		return confirm("Das Frontcover für diesen Artikel ist nur vorläufig, Änderungen sind möglich. Möchten Sie die Bilddatei trotzdem laden?");
	});

	if(jQuery('.articledetailview').length)
		ModifyArticle();

FixSteelbooks();
});
