jQuery().ready(function(){

	// Eventlinks im neuen Fenster
	$('.event_links a.ext').attr('target', '_blank');

	/*
	 Font-size vom body ändern, wenn zu klein
	 Minimum: 10.5(6)px (Schtriftgröße Browser 16px bei 66%)
	*/
	var bodysizeString = $('body').css('font-size');
	var bodysize = bodysizeString.replace(/px/g, "");
	var minBodysize = 10.5;

	if(bodysize < minBodysize){
		var newBodysize = 66/bodysize*minBodysize; // 66% aus css
		$('body').css( 'font-size', newBodysize + '%');
	}

	$('#toggle-inst-list, #inst-list-close').bind('click', function() {
		$('#inst-list').slideToggle('fast');
		$('#coop-list').hide();
		return false;
	});

	$('#toggle-coop-list, #coop-list-close').bind('click', function() {
		$('#coop-list').slideToggle('fast');
		$('#inst-list').hide();
		return false;
	});

	$('#inst-list, #coop-list').bind('click', function(e) {
		e.stopPropagation();
		return true;
	});

	$('body').bind('click', function() {
		$('#inst-list, #coop-list').slideUp('fast');
		return true;
	});

	// Nur im IE 6 + 7
  if(jQuery.browser.msie==true && jQuery.browser.version.substr(0,1) < 8){

		$("a.extern-link-new-window").attr("class","js-extern-link-new-window").append("<span class=\"icon\"></span>");
		$("a.extern").attr("class","js-extern").append("<span class=\"icon\"></span>");
		$("a.pdf").attr("class","js-pdf").append("<span class=\"icon\"></span>");
		$("a.rss").attr("class","js-rss").append("<span class=\"icon\"></span>");
		$("a.rss_events").attr("class","js-rss_events").append("<span class=\"icon\"></span>");
		$("a.email").attr("class","js-email").append("<span class=\"icon\"></span>");
		$("a.file-download").attr("class","js-file-download").append("<span class=\"icon\"></span>");
		$("a.top").attr("class","js-top").append("<span class=\"icon\"></span>");
		$("a.back").attr("class","js-back").append("<span class=\"icon\"></span>");
		$("a.video").attr("class","js-video").append("<span class=\"icon\"></span>");
		$("a.sound").attr("class","js-sound").append("<span class=\"icon\"></span>");
		$("a.zoom").attr("class","js-zoom").append("<span class=\"icon\"></span>");

	}

	// Tabs
	if ($("ul.tabs").length > 0) {
		$("ul.tabs").tabs("div.panes > div.tab");
		$('#tab_events a').bind('click', function() {
			//alert($(this).attr('href'));
			window.location.href = $(this).attr('href');
		});
	}

/*
	$("#news_cols").children().css('margin-right','1em');
	$("#news_cols").children(":last-child").css('margin-right','0');
*/

	// Manipulation Shortcuts auf der Startseite
	$("#news_cols").children(":last-child").addClass('last');

	// Manipulation rechte Spalte
	$("#sidebar-right .box .contentbox").children(":last-child").addClass('last');
	$("#sidebar-right .box .contentbox .csc-textpic .csc-textpic-text").children(":last-child").addClass('last');

	// Slider
	if($('#slideshow').length) {

		$('#slideshow').cycle({
			fx: 'fade',
			/* speed:0	// Kein Überblendungseffekt */
			speed:1000
		});

	}

	// Fancybox Mail-a-friend
	if($('.mailafriend').length) {
		$('.mailafriend').fancybox({
			'width':600,
			'height':370,
			'autoScale':false,
			'transitionIn':'none', // elastic
			'transitionOut':'none',
			'overlayOpacity' : 0.4,
			'overlayColor' : '#d1d1d1',
			'type':'iframe'
		});

	}

	// Veranstaltungsarchiv
	if($('.mailafriend').length) {
		// Wenn Archiv noch nicht gewählt wurde, dann verstecken
		archiveresult = document.URL.match(/tx_ttnews\[year\]/g);
		if (!archiveresult){
			$('#event-archive-items').hide();
		}
	}
	$('#event-archive-head').click(function() {
		$('#event-archive-items').toggle('slow');
		return false;
	});

	if($('#jobs-frame').length) {
		jobFrame = $('#jobs-frame');
		jobFrameOnload = function() {
			jobFrame = $('#jobs-frame');

			if($.browser.msie) {
				jobFrameHeight	= jobFrame.contents().find('body').height();
				cheight 				= '1%';
			} else {
				jobFrameHeight	= jobFrame.contents().find('html').height();
				cheight 				= $('#contentwrapper').height() + jobFrameHeight;
			}

			if(jobFrameHeight !== undefined && typeof(jobFrameHeight) === 'number' && jobFrameHeight !== 0) {
				jobFrame.height(jobFrameHeight);
				jobFrame.attr('scrolling', 'no');

				$('#contentwrapper').height(cheight);
			} else {
				jobFrame.attr('scrolling', 'auto');
			}
		};

		if($.browser.msie) {
			jobFrame.ready(jobFrameOnload);
		} else {
			jobFrame.ready(function() {
				setTimeout(jobFrameOnload, 750);
			});
		}
	}

	 $('.tx-cqfeedread-pi1-archive h3').click(function() {
			$(this).next().toggle();
			return false;
	 }).not('.active').next().hide();

});

