$(document).ready(function() {
	
	//GLEICHE GROSSE - SIDEBAR UND INHALT (MAIN)
	if($(".column-sidebar").length) {
		

		$(".column-sidebar").each( function(){
			
			//variablen
			var curRel	= $(".column-content",this).attr("rel");
			var item	= $(".column-content",this);
			
			
			//prueft auf rel. attr.
			if(curRel == true) {
				var actContentHeight 	= $('.column-mainRight .column-content[rel="'+curRel+'"]').height();
				var actSidebarHeight	= $('.column-sidebar .column-content[rel="'+curRel+'"]').height();
				
				if(actSidebarHeight < actContentHeight) 
				{
					$(".column-content",this).css({"height": actContentHeight+"px"});
				} else {
					$('.column-mainRight .column-content[rel="'+curRel+'"]').css({"height": actSidebarHeight+"px"});
				}
				
			}
			
			
		});		
	}//END GLEICHE GROESSE
	
	//ALL OTHER SLIDER AS CLASS (SAME FUNCTIONS)
	if($(".slider").length)
	{
		$(".slider").each( function()
		{
			var slider 		= $(this);
			var count 		= 1;
			var dots		= "";
			
			$(".item", slider).each( 
			function()
			{	
				$(this)
					.attr("rel","sliderPage-"+count)
					.css({'z-Index': count, 'opacity': 0});
					
				dots = dots+'<a href="#SliderPage'+count+'" rel="sliderPage-'+count+'">a</a>';
				count++;
			});
			
			//IF ONE ITEM
			if(count > 2 && dots != false) 
			{
				$(".slider-nav .dots", slider).append(dots);
			}
			
			//setup the slider for a great work 
			$(".slider-nav .dots", slider).css({width: (count*43)+"px"});
			$(".item:last", slider).css({"opacity": 1}).addClass("active");
			$(".slider-nav .dots a:last", slider).addClass("active");
		
			$(".slider-nav .dots a", slider)
				.each( function()
				{
					var sliderPage = $(this).attr("rel"); // Which Button was clicked
					
					$(this).click( function(){	
						
						var currentSliderPage	= $(".item.active", slider); // get active Slider page				
						var sliderValueActive	= $(".item.active", slider).attr("rel"); // get the active page value		
	
						if(sliderPage !== sliderValueActive) // if the current button ist not linked to the active slider page
						{
							$(".slider-nav .dots a", slider).removeClass("active");
							$(this).addClass("active");
							currentSliderPage.removeClass("active").css({'z-Index':39});
							$('.item[rel="'+sliderPage+'"]', slider)
								.animate({opacity: 1}, 300, function(){ currentSliderPage.css({'z-Index':0,opacity:0}) })
								.css({'z-Index':40}).addClass("active");
						}	
					});
				});
				
			});//EACH BANNER SLIDER
	}

	$(".galthumb a").fancybox({
		'titleShow'		: false
	});	

	$(".video a").click(function() {
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});
		return false;
	});
	
	
}); // END DOCUMEND READY
