function initWorkarounds() {
	/*
	// workaround for XION-7, XION-8
	// resolve issue XION-9 on deletion
	// remove h1 around all news content elements
	// same for sitemap
	jQuery('div.csc-default div.news, div.csc-default div.csc-sitemap').each(function(){
		jQuery(this).parents('.csc-default').children('h1').remove();
	});
	*/
	
	// workaround for XION-10
	// search currently active news by headline and mark with CSS
	var currentHeadline=jQuery('div.news-single-item div.news-header h1').text();
	jQuery('div.news-list-container li a').each(function(){
		var jThis = jQuery(this);
		if (jThis.text() == currentHeadline) {
			jThis.addClass('Active');
		}
	});
	
	// workaround for XION-11
	// QUESTION: keep as default functionality in case we have invalid id?
	// automatically follow first available news item
	/*
	var items = jQuery('.news-list-container li');
	var single = jQuery('.news-single-item');
	if (single.length == 0) {
		// no news item displayed, go to top-most
		if (items.length > 0) {
			var url = items.first().find('a').attr('href');
			window.location.href = url;
		}
	}
	*/
	
	// workaround for XION-27
	// remove all to-be-hidden parts of events
	jQuery('.event-hide-if-empty').each(function(){
		var jThis = jQuery(this);
		var jValue = jThis.find('.event-hide-value');
		
		// check for emptiness
		var empty = '';
		if (!jValue.hasClass('date')) {
			empty = jValue.text().match(/^\s*$/);
		} else {
			empty = (jValue.text() == '01.01.1970');
		}
		
		// remove if empty
		if (empty) {
			jThis.remove();
		}
	});
	
	// workaround for XION-28
	// NOTE: run after workaround for XION-27
	jQuery('.event-date').each(function(){
		var jThis = jQuery(this);
		
		if (jThis.find('.date-to').length > 0) {
			// event has an end date
			var jFrom = jThis.find('.date-from');
			jFrom.text(jFrom.text().replace(/(\d*\.\d*.)\d*/g, '$1'));
		}
	});
}

function initSuperFish() {
	jQuery('.sf-menu').supersubs({
		minWidth: 5,
		maxWidth: 15
	}).superfish();
}

function initMain() {
	//initSuperFish();
	
	// make search clickable in main menu
	jQuery('.head .search a.submitter').click(function(){
		jQuery('.head .search form').submit();
		return false;
	});
	
	initWorkarounds();
}

jQuery(document).ready(initMain);
