$(document).ready(function () {
    //einzelansicht exkludieren
		//home-page mit jquery slide
		/*if(	$('body').hasClass('home')){
			$galcycle = $('#content_row2 .blogeintrag');
			
			$galcycle.cycle({ 
				fx:    'scrollHorz', 
	    	speed: 'fast',
	    	slideExpr: 'div.post_home', 
	    	timeout: 0,
	    	next:   '#blog_next',
		    prev:   '#blog_prev',
		    nowrap: false
		  });
		}*/
		
		
		/*FACEBOOK BADGE*/
		$('#facebook_badge').hover(function(){
				//$(this).css('marginBottom','0px');
				$(this).stop().animate({marginBottom: '0px'},50);
			},function(){
				//$(this).css('marginBottom','-61px');
				//$(this).stop().animate({marginBottom: '-61px'},300);
				hideBadge();
			}
		);
		function hideBadge(){
			$('#facebook_badge').stop().animate({marginBottom: '-61px'},300);
		}
		
		window.setTimeout(hideBadge,5000);
				
		/*/FACEBOOK BADGE*/
		
		/* LIGHTBOX */
		//$("a[href$='jpg']:not([rel^='prettyPhoto']):not([rel^='keine_box'])").attr('rel',function () {return "prettyPhoto["+$(this).parents('div.Post').attr('id')+"]";});
		$("a[href$='jpg']:not([rel^='prettyPhoto']):not([rel^='keine_box'])").attr('rel',function () {return "prettyPhoto["+$(this).parents('div.contentbox').attr('id')+"]";});
		$("a[href$='jpeg']:not([rel^='prettyPhoto']):not([rel^='keine_box'])").attr('rel',function () {return "prettyPhoto["+$(this).parents('div.contentbox').attr('id')+"]";});
		$("a[href$='gif']:not([rel^='prettyPhoto']):not([rel^='keine_box'])").attr('rel',function () {return "prettyPhoto["+$(this).parents('div.contentbox').attr('id')+"]";});
		$("a[href$='png']:not([rel^='prettyPhoto']):not([rel^='keine_box'])").attr('rel',function () {return "prettyPhoto["+$(this).parents('div.contentbox').attr('id')+"]";});
		
		$tmp = $("a[rel^='prettyPhoto']");
		//$tmp.prettyPhoto({theme: 'light_square',showTitle: true,});
		//$tmp.prettyPhoto({showTitle: true,});
		$tmp.prettyPhoto({showTitle: false,});
		
		
		
		//MOVING BOXES
		
		var totalPanels			= $(".scrollContainer").children().size();
		
		var regWidth			= $(".panel").css("width");
		//var regWidth			= 600;
		var regImgWidth			= $(".panel img").css("width");
		var regTitleSize		= $(".panel h2").css("font-size");
		var regParSize			= $(".panel p").css("font-size");
		
		//var movingDistance	    = 300;
		//var movingDistance	    = 391;
		var movingDistance	    = 591;
		
		//var curWidth			= 350;
		var curWidth			= 576;
		var curImgWidth			= 326;
		var curTitleSize		= "20px";
		var curParSize			= "15px";
	
		var $panels				= $('#slider .scrollContainer > div');
		var $container			= $('#slider .scrollContainer');
	
		$panels.css({'float' : 'left','position' : 'relative'});
	    
		$("#slider").data("currentlyMoving", false);
	
		$container
			.css('width', ($panels[0].offsetWidth * $panels.length) + 100 )
			.css('left', "100px"); //.css('left', "-580px"); //.css('left', "-350px");
	
		var scroll = $('#slider .scroll').css('overflow', 'hidden');
	
		function returnToNormal(element) {
			$(element)
				.animate({ width: regWidth })
				.find("img")
				.animate({ width: regImgWidth })
			    .end()
				.find("h2")
				.animate({ fontSize: regTitleSize })
				.end()
				.find("p")
				.animate({ fontSize: regParSize })
				.css('color', "#CCCCCC");;
		};
		
		function growBigger(element) {
			$(element)
				.animate({ width: curWidth })
				.find("img")
				.animate({ width: curImgWidth })
			    .end()
				.find("h2")
				.animate({ fontSize: curTitleSize })
				.end()
				.find("p")
				.animate({ fontSize: curParSize })
				.css('color', "#333333");
		}
		
		//direction true = right, false = left
		function change(direction) {
		   
		    //if not at the first or last panel
			if((direction && !(curPanel < totalPanels)) || (!direction && (curPanel <= 1))) { return false; }	
	        
	        //if not currently moving
	        if (($("#slider").data("currentlyMoving") == false)) {
	            
				$("#slider").data("currentlyMoving", true);
				
				var next         = direction ? curPanel + 1 : curPanel - 1;
				var leftValue    = $(".scrollContainer").css("left");
				var movement	 = direction ? parseFloat(leftValue, 10) - movingDistance : parseFloat(leftValue, 10) + movingDistance;
			
				$(".scrollContainer")
					.stop()
					.animate({
						"left": movement
					}, function() {
						$("#slider").data("currentlyMoving", false);
					});
				
				returnToNormal("#panel_"+curPanel);
				growBigger("#panel_"+next);
				
				curPanel = next;
				
				//remove all previous bound functions
				$("#panel_"+(curPanel+1)).unbind();	
				
				//go forward
				$("#panel_"+(curPanel+1)).click(function(){ change(true); });
				
	            //remove all previous bound functions															
				$("#panel_"+(curPanel-1)).unbind();
				
				//go back
				$("#panel_"+(curPanel-1)).click(function(){ change(false); }); 
				
				//remove all previous bound functions
				$("#panel_"+curPanel).unbind();
			}
		}
		
		// Set up "Current" panel and next and prev
		//growBigger("#panel_3");	
		//var curPanel = 3;
		growBigger("#panel_1");	
		var curPanel = 1;
		
		$("#panel_"+(curPanel+1)).click(function(){ change(true); });
		//$("#panel_"+(curPanel-1)).click(function(){ change(false); });
		
		//when the left/right arrows are clicked
		$(".scrright").click(function(){ change(true); });	
		$(".scrleft").click(function(){ change(false); });
		
		$(window).keydown(function(event){
		  switch (event.keyCode) {
				case 13: //enter
					$(".scrright").click();
					break;
				case 32: //space
					$(".scrright").click();
					break;
		    case 37: //left arrow
					$(".scrleft").click();
					break;
				case 39: //right arrow
					$(".scrright").click();
					break;
		  }
		});
		
		
			
														
		

});


var addthis_config =
{
   // ... members go here
   services_exclude: "facebook,twitter",
   ui_click: true,
   ui_language: "de",
   ui_offset_top:-25,
   ui_hover_direction:1,
   ui_header_color:"#fff",
   ui_header_background:"#000",
   //ui_cobrand:"einfach besser!"
}
