$(function(){
		$.getScript('http://s7.addthis.com/js/250/addthis_widget.js?pub=xa-4a27d72a6abe5c91', function() {
			$('#shareLink').show();
			$('#shareLinkLoader').hide();
			$('#shareLink').hover(function() {
				return addthis_open(this, '', '[URL]', '[TITLE]');
			}, function() {
				addthis_close();
			});
			$('#shareLink').click(function() {
				return addthis_sendto()
			});
		});
		
 });

$(document).ready(function() {
	var klappen = $('.klappen');
	$.each(klappen, function() {
		var id = $(this).parent().attr('id');
		var temp = $.cookie(id);
		var state = temp;
		if(temp == "closed") {
			$(this).next().hide();
			$(this).addClass("closed");			
		} else {
			$(this).next().show();
		}
	});
});

$(document).ready(function() {
	$('.klappen').click(function() {
		$(this).next().slideToggle('normal',function(){
			var id = $(this).parent().attr('id');
			if ($(this).is(':hidden')) {
				if(id == 'eventBox') {
					$('#eventCal').hide();
				}
				if(id.indexOf('videoBox') >= 0) {
					$(this).find('#flash_element').hide();
				}
				$(this).prev().addClass("closed");
				var state = "closed";		    
			} else {
				if(id == 'eventBox') {
					$('#eventCal').show();
				}
				if(id.indexOf('videoBox') >= 0) {
					$(this).find('#flash_element').show();
				}
				$(this).prev().removeClass("closed");                 
				var state = "open";
			}
			$.cookie(id, state);
			
		});
		return false;
	});

	
});

$(document).ready(function() {
	$('.styleswitch').click(function() {
		switchStylestyle(this.getAttribute("rel"));
		return false;
	});
	var c = readCookie('style');
	if (c) switchStylestyle(c);
});

function switchStylestyle(styleName) {
	$('link[@rel*=style][title]').each(function(i) {
		this.disabled = true;
		if (this.getAttribute('title') == styleName) this.disabled = false;
	});
	createCookie('style', styleName, 365);
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name) {
	createCookie(name,"",-1);
}
