$(document).ready(function() {

	$(".pfp").click(function() { $("#pay-for-post").slideToggle("slow"); },function() { $("#share").slideToggle("slow"); });
	$(".shareit").click(function() { $("#share").slideToggle("slow"); },function() { $("#share").slideToggle("slow"); });
	$(".kommentieren").click(function() { $("#comments").slideToggle("slow"); },function() { $("#comments").slideToggle("slow"); });
	$(".aart .text").click(function() { $("#text").show(); $("#visuell").hide(); });
	$(".aart .bild").click(function() { $("#visuell").show(); $("#text").hide(); });

	$("#kslider").easySlider({ speed:1200, auto:true, pause:3100, continuous:true });
	
	$('.totop').click(function(){ $('html, body').animate({scrollTop:0}, 1800); return false; });
	$('.tosidebar').click(function(){ $('html, body').animate({scrollTop: $("body").attr("scrollHeight") }, 1800); return false; });
	
	$("a[rel='lightbox']").colorbox({maxWidth:"85%", maxHeight:"85%", resize:true});
	$(".lightbox").colorbox({maxWidth:"85%", maxHeight:"85%", resize:true});
	$(".gallery-icon a").colorbox({maxWidth:"85%", maxHeight:"85%", resize:true, slideshow:true, slideshowAuto:false, slideshowSpeed:2800, rel:'Galerie'});
	$("a[rel='tags']").colorbox({transition:'elastic', speed:700, width: 670, height:585});
	$("a[rel='recommendation']").colorbox({transition:'elastic', speed:700, width: 620, height:545});
	$("a[rel='suche']").colorbox({transition:'elastic', speed:700, initialWidth: 290, initialHeight:110});
	$(".youtube").colorbox({iframe:true, width:850, height:600});
	tooltip();
	
});

function tooltip()
{
  $("input.tooltip").mouseover(    
    function (event) 
    { 
      var text = this.alt;
      x = event.pageX+10;
      y = event.pageY+10;
      
      $("body").append("<div id='tooltip'>"+text+"</div>");
      $("#tooltip").css("left", x).css("top", y);
    }
  );
 
  $("input.tooltip").mouseout(
    function (event) {
      $("#tooltip").remove();
    }
  );
}

/**
* Styleswitch stylesheet switcher built on jQuery
* Under an Attribution, Share Alike License
* By Kelvin Luck ( http://www.kelvinluck.com/ )
**/
(function($)
{
	$(document).ready(function() {
		$('.styleswitch').click(function()
		{
			switchStylestyle(this.getAttribute("rel"));
			$('html, body').animate({scrollTop:0}, 1800);
			//$('html, body').animate({scrollTop: $("body").attr("scrollHeight") }, 1800);
			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);
	}
})(jQuery);

// cookie functions http://www.quirksmode.org/js/cookies.html
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);
}
// /cookie functions