jQuery(document).ready(function() {
	$('.slideshow_items').cycle({
		cleartype: true, 
		cleartypeNoBg: true,
		timeout: 6800,
		delay: -800,
		speed:  800,
		pager: '.slideshow_pager'
	}).css('visibility','visible');
	
	var l = $('.two_games').length;
	if(l < 3 ){
		$('.game_slider_control, .two_games .separator_right').hide();
	}
	if(l >= 1){
		$('.game_slider').cycle({
			cleartype: true, 
			cleartypeNoBg: true,
			fx: 'scrollHorz',
			timeout: 8000,
			delay: -800,
			speed:  800,
			next: "#game_next",
			prev: "#game_prev"
		}).css('visibility','visible');
	}
	
	var s = $('.sponsor_item').length;
	if(s < 1 ){
		$('.sponsoren_headline, .all_sponsors').hide();
	}else{
		$('.all_sponsors').cycle({
			cleartype: true, 
			cleartypeNoBg: true,
			timeout: 13600,
			delay: -800,
			speed:  800
		}).css('visibility','visible');
	}
	
	$("#login_link").click(function(event){
		$(".login_box").stop(true, true).fadeIn(400);
		event.preventDefault();
	});
		
	$(".login_wrapper").mouseleave(function(){
		$(".login_box").stop(true, true).delay(2000).fadeOut(400);
	});
	$('#filter_link').click(function(event){
		$("#cat_filter_list").stop(true, true).slideDown(400).mouseleave(function(){
			$(this).stop(true, true).delay(3000).slideUp(400);
		});
		event.preventDefault();
	});
	
	$.datepicker.regional['de'] = {
		closeText: 'schließen',
		prevText: '&#x3c; zurück',
		nextText: 'vor &#x3e;',
		currentText: 'heute',
		monthNames: ['Januar','Februar','März','April','Mai','Juni',
		'Juli','August','September','Oktober','November','Dezember'],
		monthNamesShort: ['Jan','Feb','Mär','Apr','Mai','Jun',
		'Jul','Aug','Sep','Okt','Nov','Dez'],
		dayNames: ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],
		dayNamesShort: ['So','Mo','Di','Mi','Do','Fr','Sa'],
		dayNamesMin: ['So','Mo','Di','Mi','Do','Fr','Sa'],
		dateFormat: 'yy-mm-dd',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: '',
		showButtonPanel: true
	};
	$.datepicker.setDefaults($.datepicker.regional['de']);
	$('#event_datetime').datetimepicker({
		timeFormat: 'hh:mm',
		separator: ' '
	});

	$("#cloneit").click(function(event){
		$('.cloneable').before($('.cloneable').clone().attr("class","notcloneable"));
		event.preventDefault();
	});
	
	$('.toggle_info').toggle(
		function(){
			$(this).find('img.toggle_icon').attr("src","img/icons/down.png");
			$(this).parent().find('div.game_info').slideDown(400);
		},
		function(){
			$(this).find('img.toggle_icon').attr("src","img/icons/right.png");
			$(this).parent().find('div.game_info').slideUp(400);
		});
	$('.toggle_info').toggle(
		function(){
			$(this).find('img.toggle_icon').attr("src","img/icons/down.png");
			$(this).parent().find('div.res_info').slideDown(400);
		},
		function(){
			$(this).find('img.toggle_icon').attr("src","img/icons/right.png");
			$(this).parent().find('div.res_info').slideUp(400);
		});
	
	$('.genDownloadLink').hide();
	$('.getDownLink').toggle(function(){
		$(this).next('.genDownloadLink').fadeIn();
	}, function(){
		$(this).next('.genDownloadLink').fadeOut();
	});

	jQuery('#iforum').iframeAutoHeight();
		
	
	$('#addimg').fancybox({
		'type' : 'ajax'
	});
	var path = window.location.pathname.split("/");
	if(path.length >= 3){
		tinyMCE.init({
			// General options
			mode : "textareas",
			theme : "advanced",
			plugins : "style,layer,table,advhr,advimage,advlink,insertdatetime,preview,searchreplace,print,contextmenu,paste,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras",
			elements : 'relurls',
			relative_urls : true,
			extended_valid_elements: "div[id|dir|class|align|style],span[class|align|style]",
			// Theme options
			theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
			theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,code,|,insertdate,inserttime,preview,",
			theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,media,advhr,nonbreaking,|,print,fullscreen",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
			theme_advanced_resizing : true
		});
	}

});

