/*
function setScrollUp(richtung)
{
	if(richtung == "up"){
		
		if(parseInt(jQuery("#news_content_scroll_content").css("top").replace("px", "")) < 0){
			jQuery("#news_content_scroll_content").css({"top" : (parseInt(jQuery("#news_content_scroll_content").css("top").replace("px", ""))+10) +"px" });
		}
	}else{
		//jQuery("#debug").html((jQuery("#news_content_scroll_content").height()-jQuery("#news_content_scroll").height())*(-1));
		test1 = (jQuery("#news_content_scroll_content").height()-jQuery("#news_content_scroll").height())*(-1);
		test2 = parseInt(jQuery("#news_content_scroll_content").css("top").replace("px", ""));
		//
		jQuery("#debug").html(test1+" - "+test2);
		
		 
		if( test1 <= test2){
			jQuery("#news_content_scroll_content").css({"top" : (parseInt(jQuery("#news_content_scroll_content").css("top").replace("px", ""))-10) +"px" });
		}
		
	}
}

function mouseclicker(){
	
	$('#news_content_scroller_down').mousedown(function(){
		//alert($("#news_content_scroll_content").css("top").replace("px", ""));
		Timeout = window.setInterval("setScrollUp('down')", 100);
	});
	$('#news_content_scroller_down').mouseup(function(){
		window.clearInterval(Timeout);
		//alert($("#news_content_scroll_content").css("top").replace("px", ""));
	});
	
	$('#news_content_scroller_up').mousedown(function(){
		//alert($("#news_content_scroll_content").css("top").replace("px", ""));
		Timeout = window.setInterval("setScrollUp('up')", 100);
	}).mouseup(function(){
		window.clearInterval(Timeout);
	});
}
*/



//---------------------------------------------------------------------------------------------
//		Scrollfunktion		------------------------------------------------------------------
//---------------------------------------------------------------------------------------------

function scroll(direction, obj)
{
	////console.log(obj);
	var container = obj.children('.scroll_container');																	// umschließender Container mit fester Höhe
	var scrollable = obj.children('.scroll_container').children('.scrollable_content');			// scrollbare Container mit dynamischer Höhe
	
	var containerHeight = container.height();
	var scrollableHeight = scrollable.height();
	
	//alert(scrollable);
	
	if(scrollableHeight > containerHeight)
	{	
		var currentPos = parseInt(scrollable.css('top'));
		switch(direction)
		{
			case 'up':																// Nach oben scrollen
				if(currentPos < 0)
				{	
					scrollable.css({
						'top' : (currentPos + 10) + 'px'
					});
				} else {
					scrollable.css({
						'top' : 0 + 'px'
					});
				}
			break;
			case 'down':													// Nach unten scrollen
				if(currentPos > (containerHeight - scrollableHeight))
				scrollable.css({
					'top' : (currentPos - 10) + 'px'
				});
			break;
		}
	}
}

//-----------------------------------------------------------------------------------------
//		Tab Reset 		-------------------------------------------------------------------
//-----------------------------------------------------------------------------------------

function reset() {
	jQuery('.item').fadeOut();
	jQuery('.tabs1').tabs().resetTabs();
    jQuery('.tabs2').tabs().resetTabs();
    swapMiddleImage('color');
}



//(function ($){
//$.noConflict();
	//alert('sdfs');




function imgresize (){

		// ------------------------------------------------------------------------------------------------------------------
		// 	Gesamtlayout 		---------------------------------------------------------------------------------------
		// ------------------------------------------------------------------------------------------------------------------
		
		// Browsergrößen auslesen
		var browserWidth			= $(window).width();
		var browserHeight		= $(window).height();
		var browserMinWidth	= 640;									// Mindestbreite des Browsers für Resize
		var browserMinHeight= 420;								// Mindeshöhe des Browsers für Resize
		
		var contentVerhaeltnis = 1000/ 518																									// Seitenverhaeltnis des Contentberiches		
		var browserVerhaeltnis = browserWidth/browserHeight															// Seitenverhältnis des Browsers
						
		// feste Größen auslesen
		//var pageHead 	= $('#main_head').height() + $('#content_head').height();			//	Höhe Kopf
		//var pageFoot 		= $('#main_footer').height() + $('#content_footer').height();	//	Höhe Footer
		
		
		// Browserdetection
		
		var browser
		
		jQuery.each(jQuery.browser, function(i, val) {
	   	
	   			//alert(jQuery.browser.msie);
	   			//alert(jQuery.browser.version);
	   			if(jQuery.browser.msie == 'true') {
	   				browser = 'ie';
	   			} else {
	   				browser = 'undefined';
	   			}
	   			
	   		
 		});
		
		
		
		if(browserWidth < browserMinWidth)
		{
			browserWidth = browserMinWidth;
			$('#content').css({'width' : browserMinWidth + 'px'});
			//$('#content_head').css({'width' : browserMinWidth + 'px'});
			//$('#content_footer').css({'width' : browserMinWidth + 'px'});
			jQuery('html').css({'overflow-x' : 'scroll'});
		} else {
			jQuery('html').css({'overflow-x' : 'hidden'});
		}
		
		if(browserHeight < browserMinHeight)
		{
			browserHeight = browserMinHeight;
			jQuery('html').css({'overflow-y' : 'scroll'});
		} else {
			jQuery('html').css({'overflow-y' : 'hidden'});
		}		
		
		// maximale Größen für Content-Bereich
		var maxContentWidth = browserWidth * 0.81;
		var maxContentHeight = browserHeight * 0.7;
		
		// festlegen der Minimalen Größe
		
		//Größenanpassung für den Contentbereich
		var tmpHeight = (maxContentWidth/contentVerhaeltnis) + browserHeight * 0.3			// Vorrausberechnung der Höhe des kompletten Layouts
		var spacerWidth = browserWidth * 0.01;																							// Vorrausberechnung der Spacerbreite
		
		// Prüfen ob bei maximaler Breite die Höhe in den Browser passt
		var contentWidth = 0;	// Endgültige berechnete Breite des Contentbereiches
		var contentHeight = 0;	// Endgültige berechnete Höhe des Contentbereiches
		
		if(tmpHeight > browserHeight) 
		{
			contentHeight = maxContentHeight;
			contentWidth = maxContentHeight*contentVerhaeltnis;
		}
		else
		{
			contentHeight = tmpHeight - browserHeight * 0.3 // maximal Höhe des Layouts - Header & Footer
			contentWidth = maxContentWidth;
		}
		
		// Prüfen ob Contentwidth eine gerade Zahl ist
		
		if ((Math.round(contentWidth) % 2) !== 0) {
			contentWidth = Math.round(contentWidth) + 1;
			// alert('ungerade breite: ' + contentWidth);
		}
		
		
		var contentHeaderHeight = Math.round(contentHeight * 0.115);
		var logoHeight = Math.round(contentHeaderHeight * 0.5);
		var logoPadding = Math.round(contentHeaderHeight * 0.25);
		var grundlinie = logoPadding + logoHeight;
		var headerHeight = Math.round((browserHeight - (contentHeight + (contentHeaderHeight * 2))) / 2);
		var naviPadding = grundlinie - 15;
		var naviBottomPadding = naviPadding;
		var loadingPadding = contentHeaderHeight * 0.1;
		
		
		// Berechnung der restlichen Elemente		
		var imgLeftWidth = 0;
		var imgRightWidth = 0;
		
		imgLeftWidth = imgRightWidth =  (browserWidth - contentWidth - (spacerWidth*2)) / 2;
		
		// Gesamtbreite aller Elemente berechenen
		var gesamtWidth = 2*(Math.round(imgLeftWidth) + Math.round(spacerWidth)) + Math.round(contentWidth);
		if(gesamtWidth > browserWidth)
		{
			imgLeftWidth = imgLeftWidth-(gesamtWidth-browserWidth);
		} 
		
		// Übergabe der berechneten Größen an die Elemente (Content)
		
			// Headerwerte
			$('#content_head').css({'height' : contentHeaderHeight + 'px'});	
			$('#main_head').css({'height' : headerHeight + 'px'});			
			$('#logo_image').css({'height' : logoHeight + 'px', 'margin-top' : logoPadding + 'px'});
			$('#navi').css({'padding-top' : naviPadding  + 'px'});
			
			//Footerwerte
			$('#main_footer').css({'height' : headerHeight + 'px'});
			$('#content_footer').css({'height' : contentHeaderHeight + 'px'});
			$('#loading').css({'height' : contentHeaderHeight / 2.5});
			$('#navi_bottom').css({'margin-top' : naviBottomPadding + 'px'});
			$('#content_footer_left').css({'height' : contentHeaderHeight + 'px'});
			$('#content_footer_right').css({'height' : contentHeaderHeight + 'px'});
			$('#content_footer_middle').css({'height' : contentHeaderHeight + 'px'});
			$('#loading').css({'top' : loadingPadding + 'px'});


			$('#main_head').css({'width':browserWidth+'px'});
			$('#content').css({'width':browserWidth+'px'});
			$('#main_footer').css({'width':browserWidth+'px'});
			
			$('#middle').css({'width': Math.round(contentWidth) + 'px'});
			$('#middle').css({'height': Math.round(contentHeight) + 'px'});
			$('#content').css({'height': Math.round(contentHeight) + 'px'});
			
			$('#middle').css({'left': Math.round(imgLeftWidth)+ Math.round(spacerWidth) + 'px'});	
			
			
			$('#content_head').css({'width' : browserWidth + 'px'});
			$('#content_footer').css({'width' : browserWidth + 'px'});
			
			$('.hintergrundbild').css({'width': Math.round(contentWidth) + 'px'});
			$('#middle_image').css({'width': Math.round(contentWidth) + 'px'});
			$('#raster').css({'width': Math.round(contentWidth) + 'px', 'height' : Math.round(contentHeight) + 'px'});
			$('#middle_image_grey').css({'width': Math.round(contentWidth) + 'px'});
			$('#content_head_middle, #content_footer_middle').css({'width': Math.round(contentWidth) + 'px'});
			
			$(".content_spacer").css("width", Math.round(spacerWidth) +"px");
			
			$('#left').css({'width': Math.round(imgLeftWidth) + 'px', 'height' : contentHeight + 'px'});
			$('#content_head_left, #content_footer_left').css({'width': Math.round(imgLeftWidth) + 'px'});
			$('#right').css({'width': Math.round(imgRightWidth) + 'px', 'height' : contentHeight + 'px'});
			$('#content_head_right, #content_footer_right').css({'width': Math.round(imgLeftWidth) + 'px'});
			
		//--------------------------------------------------------------------------------------------------------------
		//		Resize Newsbereich		-----------------------------------------------------------------------------
		//--------------------------------------------------------------------------------------------------------------	
		
		// Auslesen der festen Größen im Newsberich
			var scrollerWidth = $('#news_content_scroller').width(); 						// Breite der Scrollbar
			var newsContentHeadHeight = $('#news_content_head').height();	// Höhe des Content Headers (News)
			var newsContentNaviHeight = $('#news_content_navi').height();		// Höhe der Navigation im News Content
			var newsContentArrowWidth = $('.news_content_arrow').width();	// Breite der Markierungspfleile einer News
			var newsContentPadding = parseInt($('#news_content_scroll').css('padding-left'));	// left-padding des News Content
			
			var scrollerTopPadding = (contentHeight - 72 - 47 - 47) / 2
			
			
		// Berechnungen der Größen
			var newsContentWidth = contentWidth/2; 															// Breite der Newsübersicht
			var newsScrollableContentWidth = newsContentWidth - scrollerWidth - newsContentPadding;		// Breite des scrollbaren Containers
			var newsScrollableContentHeight = 	contentHeight 											// Höhe des scrollbaren Containers
																					- newsContentHeadHeight
																					- newsContentNaviHeight;
																					
			var newsContentItemWidth = newsScrollableContentWidth							// Breite einer News in Übersicht
																		- newsContentArrowWidth;
																					
		// Übergabe der berechneten Größen an die Elemente (News)
			$('#news_content').css({'width': newsContentWidth + 'px'});
			$('#news_content_scroll_content').css({'width': newsScrollableContentWidth + 'px'});
			$('#news_content').css({'height': contentHeight});
			$('#news_content_text').css({'height': newsScrollableContentHeight});
			//$('#news_content_scroll').css({'height' : newsScrollableContentHeight + 'px'});
			//$('#news_content_scroller').css({'padding-top' : scrollerTopPadding - 36 + 'px'});
			$('#news_main_content_text').children('.content_scroller').css({'padding-top' : scrollerTopPadding + 'px'});
			$('.news_container').children('.content_scroller').css({'padding-top' : scrollerTopPadding + 'px'});
			
		//--------------------------------------------------------------------------------------------------------------
		//		Resize Klienten Übersicht ------------------------------------------------------------------------
		//--------------------------------------------------------------------------------------------------------------
		
		// Berechnung der Spaltenbreite
			var naviHeight = $('#uebersicht_navi').height();	 		// NaviHöhe
			var columnWidth = Math.round(contentWidth/3)		// 3 Spalten pro Seite a 6 Klienten
			var rowHeight = Math.round((contentHeight - naviHeight )/2)		// 2 Zeilen pro Spalte a 3 Klienten
			
			
		// Berechnung der Bildergröße
			var containerHorizontalHeight = (rowHeight/2) - 1;														// Horizontal Höhe - 1px Border
			var containerVerticalWidth =  containerHorizontalHeight;										// Vertikale Breite - 1px Border
			var containerHorizontalWidth = columnWidth - containerVerticalWidth - 2;		// Horizontal Breite - 1px Border  
			var containerVerticalHeight = rowHeight - 1;																	// Verikal Höhe - 1px Border
			
			
		// Übergabe der Werte
			$('#uebersicht_container').css({'height' : rowHeight*2 + 'px'});
			$('.container_six').css({'width' : columnWidth + 'px'});
			$('.container_six').css({'height' : rowHeight*2 + 'px'});
			$('.container_three').css({'height' : rowHeight + 'px'});
			
			$('.container_left_horizontal').css({'width' : containerHorizontalWidth + 'px', 'height' : containerHorizontalHeight + 'px'});
			$('.container_right_horizontal').css({'width' : containerHorizontalWidth + 'px', 'height' : containerHorizontalHeight + 'px'});
			$('.container_left_vertical').css({'width' : containerVerticalWidth + 'px', 'height' : containerVerticalHeight + 'px'});
			$('.container_right_vertical').css({'width' : containerVerticalWidth + 'px', 'height' : containerVerticalHeight + 'px'});
			
			$('.clientHor').css({'width' : containerHorizontalWidth + 'px', 'height' : containerHorizontalHeight + 'px'});
			$('.clientVert').css({'width' : containerVerticalWidth + 'px', 'height' : containerVerticalHeight + 'px'});
			
		// Absolute Positionierung des Sliders anhand pageIndex des Sliders
			var index = $('#scrollIndex').val();	
			var leftPos = contentWidth * (parseInt(index)+1);
			$('.items').css({'left' : - (leftPos) + 'px'});
			
		// Positionierung Prev- & Next-Button
			var buttonHeight = $('.prevPage').height();
			var topPos = (contentHeight/2) - naviHeight + (buttonHeight/2);
			
			$('.prevPage').css({'top': -(topPos)+2 + 'px'});
			$('.nextPage').css({'top': -(topPos) + 'px'});
			
		//--------------------------------------------------------------------------------------------------------------
		//		Klient Detailseite		--------------------------------------------------------------------------------
		//--------------------------------------------------------------------------------------------------------------
		
		// Auslesen der festen Größen
		var naviHeight = $('.client_navi').height();
		//var scrollContainerPaddingTop = $('.scroll_container').css('padding-top');
		//var scrollContainerPaddingBottom = $('.scroll_container').css('padding-bottom');
		
		//alert(scrollContainerPaddingTop + "\n" + scrollContainerPaddingBottom);
		//alert(naviHeight);
		var tabMaxHeight = contentHeight - naviHeight;
		var tabContentWidth = contentWidth / 2 - 80;
		
		var previewImageScaleFactor = 0.2;
		var previewImageWidth = Math.floor(contentWidth * previewImageScaleFactor);
		var previewImageHeight = contentHeight * previewImageScaleFactor;
		var countImgs = $('.image').length;

		/*if(typeof(console) !=  'undefined')
		{
			//console.log(countImgs);
		}*/

		var maxImgPerRow = 4;
		var previewContainerWidth = 0;
		var previewContainerHeight = 0;
		
		var downloadContainerWidth = 320
		var downloadContainerHeight = 200;

		
		if(countImgs <= maxImgPerRow)
		{
			previewContainerWidth = (previewImageWidth * countImgs) + (5*(countImgs-1)) + 1;
			previewContainerHeight = previewImageHeight;
		} else {
			previewContainerWidth = (previewImageWidth * 4) + (5*3);
			previewContainerHeight = previewImageHeight * (Math.ceil(countImgs/maxImgPerRow));
		}
		
		var previewContainerX = (contentWidth - previewContainerWidth)/2;
		var previewContainerY = (contentHeight - previewContainerHeight)/2 - (previewContainerHeight/2);
		
		var downloadContainerX = (contentWidth - downloadContainerWidth) / 2;
		var downloadContainerY = (contentHeight - downloadContainerHeight) / 2;
		
		imageContainerLightbox = previewContainerWidth-4;
		if(countImgs==2)
			dShadowWidth = imageContainerLightbox+1;
		else
			dShadowWidth = imageContainerLightbox;
		
		$('.image_container').css({'width' : imageContainerLightbox + 'px', 'height' : previewContainerHeight + 'px', 'top' : previewContainerY + 'px', 'left' : previewContainerX + 'px'});
		$('.d-shadow').css({'width' : dShadowWidth + 'px'});
		$('.image > img').css({'width' : previewImageWidth + 'px'});
		$('.image').css({'width': previewImageWidth + 'px', 'height' : previewImageHeight + 'px'});
		
		$('.download_container').css({'left': downloadContainerX + 'px','top': downloadContainerY + 'px' });
		
		$('.news_content_text').css({'height': tabMaxHeight + 'px', 'width' : tabContentWidth + 'px'});
		
		$('.scroll_container').each(function()
									{ 
										if( $(this).hasClass('detail_vita_pane') )
										{
											$(this).css('height', (tabMaxHeight-25-8)+'px');
											$(this).css('width',  tabContentWidth+'px');
										}else
										{
											$(this).css('max-height', (tabMaxHeight)+'px');
											$(this).css('width', tabContentWidth + 'px');
										}
									});		
		


		$('.layer_bg').css({'width':contentWidth + 'px', 'height':contentHeight + 'px'});
		
		// --------------------------------------------------------------------------------------------------------------
		// 	Fotovergleich 	--------------------------------------------------------------------------------------
		// --------------------------------------------------------------------------------------------------------------
		
		$('#auswahl_links').css({'width' : contentWidth / 2 - 2 + 'px', 'height' : contentHeight + 'px'});
		$('#auswahl_rechts').css({'width' : contentWidth / 2 + 'px', 'height' : contentHeight + 'px'});
		$('#bild_links_color').css({'width' : contentWidth / 2 - 2 + 'px', 'height' : contentHeight + 'px'});
		$('#bild_rechts_color').css({'width' : contentWidth / 2 + 'px', 'height' : contentHeight + 'px'});
		$('#bild_links_grey').css({'width' : contentWidth / 2 - 2 + 'px', 'height' : contentHeight + 'px'});
		$('#bild_rechts_grey').css({'width' : contentWidth / 2 + 'px', 'height' : contentHeight + 'px'});
		
		var scaleFactorSmall = 0.2;
		var previewImageSmallWidth = Math.round(contentWidth/2 * scaleFactorSmall);
		var previewImageSmallHeight = Math.round(contentHeight * scaleFactorSmall);
		
		var countImages = $('.imagesmall').length;
		
		var maxImagesPerRow = 4;
		
		if(countImages <= maxImagesPerRow)
		{
			galleryContainerWidth = (previewImageSmallWidth * countImages) + (3*(countImages) - 2);
			galleryContainerHeight = previewImageSmallHeight;
		} else {
			galleryContainerWidth = (previewImageSmallWidth * 4) + (4*3) - 2;
			galleryContainerHeight = previewImageSmallHeight * (Math.ceil(countImages/maxImagesPerRow)) + (Math.ceil(countImages/maxImagesPerRow)*3)-3;
		}

		
		var galleryContainerX = (contentWidth - galleryContainerWidth) / 2;
		var galleryContainerY = (contentHeight - galleryContainerHeight) / 2;
		
		$('.layer_bg').css({'width' : contentWidth + 'px', 'height' : contentHeight + 'px'});
		
		$('.gallerycontainer').css({
				'width' : galleryContainerWidth + 'px',
				/*'height' : galleryContainerHeight + 'px',*/
				'top' : galleryContainerY - galleryContainerHeight / 2 + 'px',
				'left' : galleryContainerX + 'px'
		});
		$('.gallerycontainer').children('.d-shadow').css({'width' : (galleryContainerWidth) + 'px'});
		$('.imagesmall > a > img').css({'width' : previewImageSmallWidth + 'px', 'height' : previewImageSmallHeight + 'px'});
		$('.imagesmall').css({'width': previewImageSmallWidth + 'px', 'height' : previewImageSmallHeight + 'px'});
		
		/*-----------------------------------------------------------*/
		
		var scaleFactorSmallFV = 0.15;
		var previewImageSmallWidthFV = contentWidth/2 * scaleFactorSmallFV;
		var previewImageSmallHeightFV = contentHeight * scaleFactorSmallFV;
		
		var countImagesFV_L = $('#auswahl_links').children('.gallery').children('.bildauswahlcontainer').children('.d-shadow').children('.d-shadow-wrap').children('.imagesmallFV').length;
		var countImagesFV_R = $('#auswahl_rechts').children('.gallery').children('.bildauswahlcontainer').children('.d-shadow').children('.d-shadow-wrap').children('.imagesmallFV').length;
		
		/* resize linke Seite ----------------------------------------------- */
		
		if(countImagesFV_L <= maxImagesPerRow)
		{
			galleryContainerWidthFV = (previewImageSmallWidthFV * countImagesFV_L) + (5*(countImagesFV_L-1));
			galleryContainerHeightFV = previewImageSmallHeightFV;
		} else {
			galleryContainerWidthFV = (previewImageSmallWidthFV * 4) + (5*3);
			galleryContainerHeightFV = previewImageSmallHeightFV * (Math.ceil(countImagesFV_L/maxImagesPerRow));
		}
		
		var galleryContainerXFV = ((contentWidth/2) - galleryContainerWidthFV) / 2;
		var galleryContainerYFV = (contentHeight - galleryContainerHeightFV) / 2;
		
		$('#auswahl_links').children('.gallery').children('.bildauswahlcontainer').css({
				'width' : galleryContainerWidthFV + 'px',
				'height' : galleryContainerHeightFV + 'px',
				'top' : galleryContainerYFV - galleryContainerHeightFV / 2 + 'px',
				'left' : galleryContainerXFV + 'px'
		});
		$('#auswahl_links').children('.gallery').children('.bildauswahlcontainer').children('.d-shadow').css({'width' : galleryContainerWidthFV + 'px'});
		
		/*if(typeof(console) != 'undefined')
		{
			//console.log(contentWidth);
			//console.log(galleryContainerWidthFV);
		}*/
				
		/* resize rechte seite --------------------------------------------------------*/
		if(countImagesFV_R <= maxImagesPerRow)
		{
			galleryContainerWidthFV = (previewImageSmallWidthFV * countImagesFV_R) + (5*(countImagesFV_R-1));
			galleryContainerHeightFV = previewImageSmallHeightFV;
		} else {
			galleryContainerWidthFV = (previewImageSmallWidthFV * 4) + (5*3);
			galleryContainerHeightFV = previewImageSmallHeightFV * (Math.ceil(countImagesFV_R/maxImagesPerRow));
		}
		
		var galleryContainerXFV = ((contentWidth/2) - galleryContainerWidthFV) / 2;
		var galleryContainerYFV = (contentHeight - galleryContainerHeightFV) / 2;
		
		$('#auswahl_rechts').children('.gallery').children('.bildauswahlcontainer').css({
				'width' : galleryContainerWidthFV + 'px',
				'height' : galleryContainerHeightFV + 'px',
				'top' : galleryContainerYFV - galleryContainerHeightFV / 2 + 'px',
				'left' : galleryContainerXFV + 'px'
		});
		$('#auswahl_rechts').children('.gallery').children('.bildauswahlcontainer').children('.d-shadow').css({'width' : galleryContainerWidthFV + 'px'});
		
		$('.imagesmallFV  > img').css({'width' : previewImageSmallWidthFV + 'px', 'height' : previewImageSmallHeightFV + 'px'});
		$('.imagesmallFV').css({'width': previewImageSmallWidthFV + 'px', 'height' : previewImageSmallHeightFV + 'px'});
		
		$('#right_image_container').css({'width' : contentWidth + 2 + 'px'});
		$('#left_image_container').css({'width' : contentWidth + 2 + 'px'});
		
		$('#left_image_left').css({'width' : contentWidth/2 + 'px', 'height' : contentHeight + 'px'});
		$('#left_image_right').css({'width' : contentWidth/2 + 'px', 'height' : contentHeight + 'px'});
		$('#right_image_left').css({'width' : contentWidth/2 + 'px', 'height' : contentHeight + 'px'});
		$('#right_image_right').css({'width' : contentWidth/2 + 'px', 'height' : contentHeight + 'px'});
		
		/*if(typeof(console) != 'undefined')
		{
			//console.log(galleryContainerWidthFV);
		}*/
		
		//--------------------------------------------------------------------------------------------------------------
		//		PDF Overlay -----------------------------------------------------------------------------------------
		//--------------------------------------------------------------------------------------------------------------
		
		/*var overlayWidth = browserWidth*0.5;
		var overlayHeight = browserHeight * 0.7;
		*/
		
		var iFrameHeight = 0.8 * browserHeight;
		var iFrameWidth = iFrameHeight * (210/297) + 20;
		
		var overlayWidth = iFrameWidth + 300;
		var overlayHeight = iFrameHeight;
		
		var iFrameContentWidth = overlayWidth - iFrameWidth -24;
		
		var overlayPosX = (browserWidth - overlayWidth) / 2;
		var overlayPosY = (browserHeight - overlayHeight) / 2;		
		
		/*if(iFrameHeight > overlayHeight) {
			iFrameHeight = overlayHeight;
			iFrameWidth = iFrameHeight * (210/297);
		}*/
		
		$('.layer_complete').css({
			'width' : browserWidth + 'px',
			'height' : browserHeight + 'px'
		});
		$('.pdf_overlay').css({
			'width' : overlayWidth + 'px',
			'height' : overlayHeight + 'px',
			'top' : overlayPosY + 'px',
			'left' : overlayPosX + 'px'
		});
		
		$('.pdf_overlay').children('.d-shadow').css({
			'width' : overlayWidth + 'px'
		});
		
		$('#pdf_vorschau').css({
			'width' : iFrameWidth + 'px',
			'height' : iFrameHeight + 'px'
		});
		
		$('#pdf_vorschau_content').css({
			'width' : iFrameContentWidth + 'px'
		});
		
		$('.d-sh-tl').css({'height' : iFrameHeight + 300 + 'px'});
		$('.d-sh-tr').css({'height' : iFrameHeight +300 + 'px'});

		//---------------------------------------------------------------------------------------------------------------
		//		Debug und Werteausgabe		--------------------------------------------------------------------
		//---------------------------------------------------------------------------------------------------------------
		
		/*if(typeof(console) != 'undefined')
		{
			//console.log('Browser Breite ' + browserWidth);
			//console.log('Browser Hoehe ' + browserHeight);
			//console.log('Content: maximale Breite ' + maxContentWidth);
			//console.log('Content: maximale Hoehe ' + maxContentHeight);
			//console.log('Content: Seitenverhaeltnis ' + contentVerhaeltnis);
			//console.log('Content: berechnete Hoehe ' + tmpHeight);
			//console.log('Content: breite ' + contentWidth);
			//console.log('Content: hoehe ' + contentHeight);
			//console.log('spacer: breite ' + spacerWidth);
			//console.log('newsContentPadding: ' + newsContentPadding);
			//console.log(gesamtWidth);
			//console.log(browserVerhaeltnis);
			//console.log(parseInt(index)+1);
			//console.log('-----------------------------');
		}*/
		
		//var tTabHeight = (tabMaxHeight <= 0)?(tabMaxHeight/2):(tabMaxHeight-40);
		//$('.detail_vita_pane').css({'height': tabMaxHeight + 'px', 'width' : tabContentWidth + 'px'});
		
		//$('.details_tab').animate({'height': tabMaxHeight},500,'linear',closeLoader);
		//console.log('imgresize');
		checkHeightMetanaviPages();
	}
		
	
	function registerScrollEvents()
	{
		$('.scroll_up').mousedown(function()
								{
									if(typeof(timeOut) != 'undefined')
										clearTimeout(timeOut);
									
									var container = '.item.current';
									
									if( $(this).parent().parent().hasClass('news_container') )
										container = '.news_container';
									
									timeOut = setInterval("scroll('up', jQuery('"+container+"'))", 100);
									//scroll('up', $('.item.current'));
								});
		
		$('.scroll_up').mouseup(function(){	clearTimeout(timeOut);});
	
		$('.scroll_down').mousedown(function()
									{
										if(typeof(timeOut) != 'undefined')
										{
											clearTimeout(timeOut);
										}
										var container = '.item.current';
										
										if($(this).parent().parent().hasClass('news_container'))
											container = '.news_container';		
										
										timeOut = setInterval("scroll('down', jQuery('"+container+"'))", 100);
										//scroll('up', $('.item.current'));
									});
		
		$('.scroll_down').mouseup(function(){
			clearTimeout(timeOut);
		});
	}
	
	function initMouseOver() 
	{
	/*
		   jQuery('.preview').mouseenter(function(){ jQuery(this).children('.grey').fadeOut(); $('#clientname').html( $(this).attr('title') ); });
		   
		   jQuery('.preview').mouseenter(function(){ jQuery(this).children().children('.grey').fadeOut(); });
		   
		   jQuery('.preview').mouseleave(function() { jQuery(this).children('.grey').fadeIn(); });
		   
		   jQuery('.preview').mouseleave(function() { jQuery(this).children().children('.grey').fadeIn(); $('#clientname').html(''); });
	*/
		
			jQuery('.preview img').mouseover(function() {
			
				if(jQuery(this).parent().hasClass('regie')) {
			 		
			 		jQuery(this).parent().children('.overlayImg').fadeTo('fast', 0);
			 		jQuery(this).parent().children('.active').fadeTo('fast', 1);
			 			
				
				} else {
				
					if(jQuery(this).hasClass('active')) {
						jQuery(this).stop().fadeTo('fast', 1);
						jQuery('#clientname').html( $(this).parent().attr('title') );
					} else if(jQuery(this).hasClass('overlayImg')) {
						jQuery(this).stop().fadeTo('fast', 0);
						jQuery('.active').stop().fadeTo(0, 1);
						jQuery('#clientname').html( $(this).parent().attr('title') );
					}
				
				}
			});
			jQuery('.preview').mouseenter(function(){ 
				if(jQuery(this).hasClass('active')) {
					jQuery(this).children('.grey').fadeOut();
					$('#clientname').html( $(this).attr('title') );
				}
			});
			jQuery('.preview').mouseleave(function() { 
				if(jQuery(this).hasClass('active')) {
					jQuery(this).children().children('.grey').fadeIn();
					 
				}
			});
			jQuery('.preview img').mouseout(function() {
			
				if(jQuery(this).parent().hasClass('regie')) {
			
					jQuery(this).parent().children('.overlayImg').fadeTo('fast', 0.7);
			 		jQuery(this).parent().children('.active').fadeTo('fast', 0);
					
				} else {
				
					if(jQuery(this).hasClass('active')) {
						jQuery(this).stop().fadeTo('fast', 0.7)
						jQuery('#clientname').html('');
					} else if(jQuery(this).hasClass('overlayImg')) {
						jQuery(this).stop().fadeTo('fast', 1);
						jQuery('#clientname').html('');
					}
					
				}
			});
	
	}
	
	
	$(document).ready(function()
		{
		imgresize();
		//mouseclicker();
		initMouseOver();
		var timeOut = "";
		
		jQuery('.preview img').fadeTo(0, 0.7);
		jQuery('.preview.regie img.active').fadeTo(0, 0);
		
		$('span#contactform_link').mouseover(function() 
                                                 { 
                                                      $(this).children('img').attr('src','/ccds_tpl_img/arrow_grey.png'); 
                                                      $(this).children('b').addClass('Kontakt_Text_Label'); 
                                                 });      
         $('span#contactform_link').mouseout(function() 
                   { 
                        $(this).children('img').attr('src','/ccds_tpl_img/arrow.png'); 
                        $(this).children('b').removeClass('Kontakt_Text_Label'); 
                   }); 
                   
                   
        /*$('.tabs1 > img').click(function() {
        	if($(this).hasClass('current'))
        	{
        		reset();
        	}
        });*/

		
		/*function initShowBtn()
		{
			jQuery('.showMale').click(function() {
				showClient('male');
				//alert('test');
			});
			jQuery('.showFemale').click(function() {
				showClient('male');
				//alert('test');
			});
		}*/
		
	jQuery('.btn_hidemale').click(function() {	
		if(jQuery(this).hasClass('active'))
		{
			showClient('female');
			jQuery(this).removeClass('active');

		} else {
			hideClient('male');
			jQuery(this).addClass('active');
			jQuery('.btn_hidefemale').removeClass('active');

		}
	});
	
	jQuery('.btn_hidefemale').click(function() {
		if(jQuery(this).hasClass('active'))
		{
			showClient('male');
			jQuery(this).removeClass('active');
		} else {
			hideClient('female');
			jQuery(this).addClass('active');
			jQuery('.btn_hidemale').removeClass('active');
		}
	});
		
		$('a').click(function() {
				if($(this).attr('target') == '_blank')
				{
					//
				} else {
					$('#loading').fadeIn('fast');
				}
		});
		
		
		$('#loading').fadeOut('fast');
		//alert('yeah');
	
		$('.text').click(function()
						{
							$(this).siblings('.text').removeClass('active');
							$(this).addClass('active');
						});
		
		$('form#contact_form').submit(function()
									{
										var nameObj = $(this).find("input#name");
										var telObj  = $(this).find("input#telefon");
										var isValid = true;
										
										if($(nameObj).val() == "")
										{
											$(nameObj).siblings('label').css('color',"#FF0000");
											isValid = false;
										}else
											$(nameObj).siblings('label').css('color',"#FFF");

										
										if($(telObj).val() == "")
										{
											$(telObj).siblings('label').css('color',"#FF0000");
											isValid = false;
										}else
											$(telObj).siblings('label').css('color',"#FFF");
										
										if(!isValid) 
											$('fieldset.error_msg').show();
										
										return isValid;
									});
		
		$('span#contactform_link').click(function()
										{
											$(this).children('img').attr('src','/ccds_tpl_img/arrow_grey.png');
											$(this).children('b').addClass('Kontakt_Text_Label');
											//$('#contact_detail_content').show();
										});	
		$('input#contact_send').mouseover(function()  {	$(this).attr('src','/ccds_tpl_img/btn_senden_.png'); });      
         $('input#contact_send').mouseout(function()  { $(this).attr('src','/ccds_tpl_img/btn_senden.png');  }); 
		
		/***************** registers scroll events *********************/
		
		registerScrollEvents();
		

		

		/* BUGFIX
		$('.preview').mouseleave(function() {
			var element = this;
			$(element).children('.grey').fadeIn('fast');
		});

		jQuery('.preview').mouseenter(function() {
			var element = this;
			jQuery(this).children('.grey').fadeOut('fast');
			$('#clientname').html($(element).attr('title'));
		});


		*/	
		jQuery('.dd_current').click(function() {
			jQuery(this).parent().children('.dd_list').slideToggle();
		});
		
		$(function() {
		if(typeof(timeOut) != 'undefined')
		{
			$('.content_scroller').mouseout(function(){
				clearTimeout(timeOut);
			});			
		}
		})
		
		/***************** END / registers scroll events *********************/
		

				
		//$('#news_content_text').jScrollPane({showArrows:true});
		
		
		//-----------------------------------------------------------------------------------------
		//		Inline-Links Hover		-----------------------------------------------------------
		//-----------------------------------------------------------------------------------------
		
		$('.inline_text a').mouseover(function() {
			$('.text').addClass('white');
		});
		
		$('.inline_text a').mouseout(function() {
			$('.text').removeClass('white');
		});
		
			
	});

	$(window).resize(function(){

			imgresize();
			setVideoSize();
	
	});

//})(jQuery);

	function hideClient(gender)
	{
		if(gender == 'female')
		{
		
			jQuery('.male').fadeTo("slow", 0.05);
			jQuery('.male').removeClass('active');
			jQuery('.male').parent().parent().removeClass('image_exist');
			
			jQuery('.female').fadeTo("slow", 0.7);
			jQuery('.female').addClass('active');
			jQuery('.female').parent().parent().addClass('image_exist');

		} 
		else	
		{
		
			jQuery('.male').fadeTo("slow", 0.7);
			jQuery('.male').addClass('active');
			jQuery('.male').parent().parent().addClass('image_exist');
			
			jQuery('.female').fadeTo("slow", 0.05);
			jQuery('.female').removeClass('active');			
			jQuery('.female').parent().parent().removeClass('image_exist');
			
			
		}
	}
	
	function showClient(gender)
	{
		if(gender == 'female')
		{		
			jQuery('.female').fadeTo("slow", 0.7);
			jQuery('.female').parent().parent().addClass('image_exist');
			if(!jQuery('.female').hasClass('active'))
			{
				jQuery('.female').addClass('active');
			}
		} 
		else 
		{
			jQuery('.male').fadeTo("slow", 0.7);
			jQuery('.male').parent().parent().addClass('image_exist');
			if(!jQuery('.male').hasClass('active'))
			{
				jQuery('.male').addClass('active');
			}
		}
	}
		
	function swapName(name)
	{
		jQuery('#clientname').html(name);
	}
	
	function swapImageIn(obj) {
		jQuery(obj).fadeOut(500,openLoader);
	}
	
	function swapImageOut(obj) {
		jQuery(obj).fadeIn(500,closeLoader);
	}

	function checkHeight(obj)
	{
		var contentHeight 			= jQuery('#middle').height();
		var itemHeight 				= obj.parent().parent().height();
		var scrollableHeight 		= obj.find('.scrollable_content').height();
		var scrollContainerHeight 	= obj.find('.scroll_container').height();
		
		if(scrollableHeight > scrollContainerHeight) 
		{
			obj.siblings('.content_scroller').css({'padding-top' : (obj.height()-72) / 2 + 'px'});
			obj.siblings('.content_scroller').show();
			obj.find('.scroll_container').css({'height': obj.find('.scroll_container').height() + 'px', 'position' : 'relative'});
			obj.find('.scrollable_content').css({'position' : 'absolute'});
		}
		else
		{
			obj.siblings('.content_scroller').hide();
			//obj.children().css({'height': '', 'position' : ''});
			//obj.children().children().css({'position' : ''});
		}

	}	
	/*
	function checkHeight(obj)
	{	    
		var contentHeight = jQuery('#middle').height();
		var itemHeight = obj.parent().parent().height();
		var scrollableHeight = obj.find('.scrollable_content').height();
		
		if(itemHeight >= obj.height()) {

		} else
		{
			//obj.animate({'height':itemHeight-30},1000,'linear');
			obj.parent().parent().css('height',itemHeight-30);
		}
		
		//console.log(obj.height()+" >= "+contentHeight);
		
		if(obj.height() >= contentHeight)
		{
			jQuery('#client_left').height(contentHeight);
			jQuery('.content_scroller').show();
			jQuery('.content_scroller').css({'padding-top' : (obj.height()-72) / 2 + 'px'});
			obj.children('.scroll_container').css({'height': obj.height() + 'px', 'position' : 'relative'});
			obj.children().children().css({'position' : 'absolute'});
		}else
		{
			jQuery('.content_scroller').hide();
			//jQuery('.content_scroller').css({'padding-top' : (obj.height()-72) / 2 + 'px'});
		}
	}
*/
	function checkHeightMetanaviPages()
	{
		var obj = $(".c_content");
		
		$(obj).each(function()
					{
						/*//console.log(this);*/
						var contentHeight 	= $('#middle').height();
						var scrollableHeight= $(obj).find(".scroll_container").height();
						
						if($(".news_container").hasClass("news_container"))
						{
							/*//console.log("news_container");*/
							scrollableHeight = contentHeight - $('.news_content_head').height()-$('.news_content_navi').height()-20;
							$(".news_container .scroll_container").height(scrollableHeight);
							
							if($(".news_container .scrollable_content").height()  >= $(".news_container .scroll_container").height())
								$('.news_container .content_scroller').show();
							else 
								$('.news_container .content_scroller').hide();
						}
						
						if($(this).attr('id')=="news_main_content_text")
						{
							scrollableHeight = contentHeight - $('.news_content_head').height()-33;
							content_scrollerPadding = (scrollableHeight-72) / 2;
							
							$(this).find(".scroll_container").height(scrollableHeight);
							$(this).find(".content_scroller").css("padding-top",content_scrollerPadding);
							
							if($(this).find(".scrollable_content").height()  >= $(this).find(".scroll_container").height())
								$(this).children(".content_scroller").show();
							else 
								$(this).children(".content_scroller").hide();
						}
					});
	}
	
	function setVideoSize() {
		var browserWidth = jQuery(window).width();
		var browserHeight = jQuery(window).height();
		
		var containerHeight = Math.round(browserHeight * 0.8); //510;   //feste maße von 640*480 beibehalten
		var playerHeight = Math.round(containerHeight - 30);
		var playerVerhaeltnis = 4/3;		
		var playerWidth = Math.round(playerHeight * playerVerhaeltnis);
		var containerWidth = playerWidth;
		playerHeight = playerHeight+18;
		
		var leftPos = (browserWidth-containerWidth) / 2;
		var topPos = (browserHeight - containerHeight) / 2;
		
		jQuery('.layer_bg').css({'width' :browserWidth + 'px', 'height' : browserHeight + 'px'});
		jQuery('.movie_container').css({'width':containerWidth + 'px', 'height': containerHeight + 'px', 'left' : leftPos + 'px', 'top': topPos + 'px'});
		jQuery('#movieplayer').css({'width':playerWidth + 'px', 'height': playerHeight + 'px'});
		jQuery('.movie_container').children('.d-shadow').css({'width' : containerWidth + 'px'});
		jQuery('#quicktime').attr('width', playerWidth);
		jQuery('#quicktime').attr('height', playerHeight);
		$('.d-sh-tl').css({'height' : playerHeight + 300 + 'px'});
		$('.d-sh-tr').css({'height' : playerHeight +300 + 'px'});
	}
	
	/*function swapMiddleImage(color) {
		if(color == 'grey')
		{
			jQuery('#middle_image').fadeOut();	
			jQuery('#raster').fadeIn();	
		}
		else
		{
			jQuery('#middle_image').fadeIn();
			jQuery('#raster').fadeOut();	
		}
		
	}*/
	
	function swapMiddleImage(color) {
	
		if(color == 'grey')
		{
			jQuery('#middle_image').fadeTo('fast', 0.3);	
			jQuery('#raster').fadeIn();	
		}
		else
		{
			jQuery('#middle_image').fadeTo('fast', 1);
			jQuery('#raster').fadeOut();	
		}
	
	}
	
	function showRaster() {
		jQuery('#raster').fadeIn();
		jQuery('#middle_image').fadeTo('fast', 1);
	}
	
	function preloadIMGs()
	{
	    if (document.images)
	    {
	      preload_image_object = new Image();
	      // set image url
	      image_url = new Array();
	      image_url[0] = "/ccds_tpl_img/auswahl_2.png";
	      image_url[1] = "/ccds_tpl_img/arrow_grey.png";
	      image_url[2] = "/ccds_tpl_img/dropdown_grey_btn.png";
	      image_url[3] = "/ccds_tpl_img/sanduhr.gif";
	      image_url[4] = "/ccds_tpl_img/btn_senden_trans.png";
	      
	       var i = 0;
	       for(i=0; i<=image_url.length; i++) 
	         preload_image_object.src = image_url[i];
	    }
	}
	
	$(function() 
	{
		
	
		var active;
		preloadIMGs();
		
		checkHeightMetanaviPages();
		
		$('.showGallery').click(function() {
			/*$(this).parent().fadeOut('slow');*/
			$(this).parent().parent().children('.img_color').fadeOut();
			$(this).parent().parent().children('.gallery').fadeIn('slow', function() {
				$('#loading').fadeOut('fast');
			});
		});
	
		$('.auswahl').mouseenter(function() {
			$(this).children('.options').fadeIn('slow');
		});
		
		$('.auswahl').mouseleave(function() {
			$(this).children('.options').fadeOut('slow');
		});
		
		$('#auswahlsymbol').click(function() {
			if($(this).attr('src') == '/ccds_tpl_img/auswahl_1.png')
			{
				$(this).attr('src','/ccds_tpl_img/auswahl_2.png');
				$('#bildnum').val('2');
				$('#auswahltext').text('rechtes Bild wählen : ');
			} else {
				$(this).attr('src', '/ccds_tpl_img/auswahl_1.png');
				$('#auswahltext').text('linkes Bild wählen : ');
				$('#bildnum').val('1');
			}
		});
		
		$('.bglayer').click(function() {
			$(this).parent('.gallery').hide();
			$(this).parent().parent().children('.img_color').fadeIn();
			active = 1;
		});
		
	})
	
	function closeLoader()
	{
		$("#loading").fadeOut();
	}
	
	function openLoader()
	{
		$("#loading").fadeIn();
	}	
	
	/* INIT SLIDER */
	function closeDetailsTab()
	{
		$('.details_tab').animate({'top': $("#middle").css('height')},500,'linear',closeLoader);
	}
	
	function closeMainTab()
	{
		$('.main_tab').animate({ 'top': $("#middle").css('height')},500,'linear',closeLoader);
	}
	
	function slideDetailsTab()
	{
		$('.details_tab').animate({'top': 0},500,'linear',closeLoader);
		checkHeightMetanaviPages();
	}
	
	function slideMainTab()
	{
		$('.main_tab').animate({ 'top': 0},500,'linear',closeLoader);
		checkHeightMetanaviPages();
	}
	
	function calcDetailsTabHeight()
	{
		$('.main_tab').css('top',$("#middle").css('height'));
		$('.details_tab').css('top',$("#middle").css('height'));
	}
	
	function resetMetaPageTabs()
	{
		$("#middle").css('overflow','hidden');
		closeMainTab();
		closeDetailsTab();
	}
	
	function checkDDbg()
	{
		if($(this).css('display') == 'block')
			$(this).siblings('.dd_current').css('background','url(/ccds_tpl_img/dropdown_btn.png) right no-repeat');
		else
			$(this).siblings('.dd_current').css('background','url(/ccds_tpl_img/dropdown_grey_btn.png) right no-repeat');
	}

	
	$(document).ready(function()
						{	
							firstCatContent 			= $("#firstCat").html();
							dd_current_inner_content 	= $('.dd_current_inner').html();
							 
							if(dd_current_inner_content!=null)
							{
								if(firstCatContent!="" && (dd_current_inner_content=="" || dd_current_inner_content==" - ") )
									$('.dd_current_inner').html(firstCatContent);
							
								var dropdownleave = function()
													{ 
														$(this).slideUp('500',checkDDbg);
														$('#middle').css('overflow','hidden');
													};

								$(".dropdown").mouseleave(function()
														{
															$('.dd_list').live("mouseleave", dropdownleave);
														});

								$('.dd_current').hover(function()
													{ 
														$('#middle').css('overflow','visible');
														$(this).css('background','url(/ccds_tpl_img/dropdown_btn.png) right no-repeat');
													});
							}

							if($('.main_tab').hasClass('main_tab'))
							{
								calcDetailsTabHeight();
								slideMainTab();
								
								$('#content_footer_middle a,#content_head_middle a,.dropdown a,a.content_head_button').click(resetMetaPageTabs);
							}
							
						});
	