// (c) 2010 by Franky 4 RedBowl Oelde
// www.franky.ws

jQuery(document).ready(function() {
	//jQuery(document).pngFix(); 
	
	if(jQuery.browser.msie && jQuery.browser.version.substr(0,1) == 6) {
		// IE6
		jQuery("#leftmenu li a").css({'padding': 0, 'margin': 0});
		jQuery("div.postcontent").prepend('<p style="border:3px solid #f00;padding:7px;background-color:#222">Wichtig: Sie benutzen den veralteten Internet Explorer 6 von 2001! Daher kann es zu Darstellungsfehlern kommen. Bitte aktualisieren Sie kostenlos via Windows Update mindestens auf Version 7 oder steigen Sie z.B. auf die <a href="http://www.mozilla-europe.org/de/firefox/">kostenlose Alternative <b>Firefox</b></a> um.</p>');
	}else{
		// alle ausser ie6
		jQuery(document).pngFix();
	}
	
	
	jQuery("#topmenu li.nichtaktiv").css({
		opacity: 0.2
	}).hover(function(){
		jQuery(this).animate({ opacity: 0.5 }, "slow");
	}, function(){
		jQuery(this).animate({ opacity: 0.2 }, "slow");
	});
	
	jQuery("table.partner td").css({
		opacity: 0.2
	}).hover(function(){
		jQuery(this).animate({ opacity: 1 }, "fast");
	}, function(){
		jQuery(this).animate({ opacity: 0.2 }, "fast");
	});
	
	jQuery("ul.galerie span.datum").hide();
	jQuery("ul.galerie li").css({
		opacity: 0.6,
		backgroundColor: '#2F322C'
	}).hover(function(){
		jQuery(this).find('span.datum').slideDown('fast');
		jQuery(this).animate({ opacity: 1, backgroundColor: '#222222' }, "fast");
	}, function(){
		jQuery(this).find('span.datum').slideUp('fast');
		jQuery(this).animate({ opacity: 0.6, backgroundColor: '#2F322C' }, "fast");
	});
	
	jQuery("#topmenu li.aktiv").css({
		opacity: 1
	});
	
	jQuery("ul#leftmenu li").hover(function(){
		jQuery(this).animate({ marginLeft: "10px" }, "fast");
	}, function(){
		jQuery(this).animate({ marginLeft: 0 }, "fast");
	});
	
	jQuery("#main h1").css({
		opacity: 0.8
	}).hover(function(){
		jQuery(this).animate({ opacity: 1 }, "slow");
	}, function(){
		jQuery(this).animate({ opacity: 0.8 }, "slow");
	});
	
	jQuery('#beamusbacklink').click(function(){
		jQuery('html, body').animate({scrollTop: '0px'}, "slow");
		return false;
	});
	
	jQuery('.gallery-icon a').fancybox({
		'overlayShow': true, 
		'hideOnContentClick': true, 
		'overlayOpacity': 0.3,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'easingIn': 'easeOutBack',
		'easingOut': 'easeInBack',
		'zoomSpeedIn': 600,
		'zoomSpeedOut': 500
	});

	jQuery('#content img.size-thumbnail, #content img.size-full, #content img.size-medium').closest('a').fancybox({
		'overlayShow': true, 
		'hideOnContentClick': true, 
		'overlayOpacity': 0.3,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'easingIn': 'easeOutBack',
		'easingOut': 'easeInBack',
		'zoomSpeedIn': 600,
		'zoomSpeedOut': 500
	});
	
	jQuery('#content input[type=text], #content textarea').focus(function(){
		jQuery(this).animate({ backgroundColor: "#555555", color: '#ffffff' }, "slow");
	});
	
	jQuery('#content input[type=text], #content textarea').blur(function(){
		jQuery(this).animate({ backgroundColor: '#444444', color: '#bbbbbb' }, "fast");
	});
	
	jQuery('#content img.aligncenter').closest('p').css('text-align', 'center');
	
	// Kalendar
	jQuery.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: 'DD, d. MM yy', firstDay: 1,
			isRTL: false};
	jQuery.datepicker.setDefaults(jQuery.datepicker.regional['de']);
	
	jQuery('input.formdatum').datepicker({
		minDate: new Date(),
		showMonthAfterYear: false,
		changeMonth: true
	});
	
	jQuery('form .autosaveinput').autosave({ cookieExpiryLength: 30 * 12 });

	
	// Effects yes / no 
	// (c) 2010 by Franky
	var cookieeffects = 'effectcookie';
	if(jQuery.cookie(cookieeffects) == 'effectsno'){
		var textstring = 'Effekte einschalten';
		jQuery.fx.off = true;
	}else{
		var textstring = 'Effekte ausschalten';
		jQuery.fx.off = false;
	}
	jQuery('div#beamusback span').prepend('<a href="#" style="color:#888" id="togglejquery">' + textstring + '</a> &bull; ');
	
	jQuery('#togglejquery').click(function(){
		var date = new Date();
		date.setTime(date.getTime() + (3 * 24 * 60 * 60 * 1000));
		
		if(!jQuery.fx.off){
			jQuery.cookie(cookieeffects, 'effectsno', { path: '/', expires: date });
			jQuery(this).html('Effekte einschalten');
			jQuery.fx.off = true;
		}else{
			jQuery.cookie(cookieeffects, 'effectsyes', { path: '/', expires: date });
			jQuery(this).html('Effekte ausschalten');
			jQuery.fx.off = false;
		}
		
		return false;
	});

	jQuery.getScript('http://www.google-analytics.com/ga.js', function() {
		// ("if(_gat_)" weil IE6 _gat_ nicht findet..)
		var pageTracker = _gat._getTracker('UA-727174-31');
		pageTracker._trackPageview();
	});			
});