$(document).ready( function() {
	// Flashmessages ausblenden
	window.setTimeout(function() {
		$('#flashMessage').slideUp('normal');
	}, 1500);
	
	// Laufband
	$('div.scroller').css({
		'position':'relative',
		'display':'block',
		'overflow':'hidden'
	});
	
	$('div#scroller .scrollingtext').css({
		'position':'absolute',
		'white-space':'nowrap'
	}).	bind('marquee', function() {
		var ob = $(this);
		var tw = ob.width();
		var ww = ob.parent().width();
		ob.css({left: tw});
		ob.animate({left:-ww}, 20000, 'linear', function() {
			ob.trigger('marquee');
		});
	}).trigger('marquee');
	
	// TinyMCE dynamisch laden
	if( $('textarea.tinyMCE').length > 0 ) {
		$.ajax({
			type:		'GET',
			dataType:	'script',
			url:		CAKE_ROOT+'js/tiny_mce/jquery.tinymce.js',
			success:	function(data, textStatus) {
				$('textarea.tinyMCE')
					.attr('rows',12)
					.tinymce({
						// Location of TinyMCE script
						script_url: CAKE_ROOT+'js/tiny_mce/tiny_mce.js',
						
						// General options
						theme: 'advanced',
						plugins: 'layer,table,media,searchreplace,print,contextmenu,paste',
						
						// Theme options
						theme_advanced_buttons1: 'bold,italic,underline,strikethroug,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect',
						theme_advanced_buttons2: 'cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,media,cleanup,help,code',
						theme_advanced_buttons3: ' tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,print',
						theme_advanced_toolbar_location: "top",
						theme_advanced_toolbar_align: "center",
						theme_advanced_statusbar_location: "bottom",
						theme_advanced_resizing: true,
						theme_advanced_resize_horizontal: false,
						
						// Example content CSS (should be your site CSS)
						content_css: CAKE_ROOT+'/css/tinymce.css'
					});
			}
		});
	}
});
