	/*dynamic css for flexbox*/
    $(document).ready(function(){
    	$('#contentLinks').hide();
      var boxes = $('.flexbox');
      $(boxes[0]).css("padding-left", "0px");
      $(boxes[2]).css("padding-right", "0px");
    });
    /*dynamic css for photos*/
    $(document).ready(function(){
      $('div[class|="csc-textpic-imagewrap"]').css("width", "290px");
      $('div[class|="csc-textpic-imagerow"]').css("width", "290px");
      
      if($('#produktinfo-photos img').size() == 1){
    	  $('dl[class="csc-textpic-image csc-textpic-firstcol csc-textpic-lastcol"]').css("border", "none");
      }
    });
    /*dynamic css for slogan*/
    $(document).ready(function(){
    	var height = $('#content').height();
    	var h = $('#content-rechts').height();
    	var newHeight = height-h-40;

        $('#produktinfo-photos').css("height", newHeight+"px");
      });
	/*dynamic css for content box blue 2*/
	$(document).ready(function(){
		if(document.getElementById('blueboxContent2RightBoxHeader')){
			$('#content-links').width(451);
			$('#content-links').css("padding-right", "20px");
			
			$('#blueboxContent2RightBoxHeader').children(":nth-child(4)").css("margin-left", "-18px");
			
			$('#blueboxContent2RightBoxHeader').children(":first").css("margin-left", "0px");
			$('#blueboxContent2RightBoxHeader').children(":first").css("background-image", "url('/fileadmin/templates/koenen/images/blue-box-content-header-active.png')");
			
			$('#blueboxContent2RightContent2').hide();
			$('#blueboxContent2RightContent3').hide();
			
			$('#blueboxContent2RightBoxHeader').children(":nth-child(1)").click(function(){
				$('#blueboxContent2RightContent1').show();
				$('#blueboxContent2RightBoxHeader').children(":nth-child(1)").css("background-image", "url('/fileadmin/templates/koenen/images/blue-box-content-header-active.png')");
				$('#blueboxContent2RightContent2').hide();
				$('#blueboxContent2RightBoxHeader').children(":nth-child(2)").css("background-image", "url('/fileadmin/templates/koenen/images/blue-box-content-header-inactive2.png')");
				$('#blueboxContent2RightContent3').hide();
				$('#blueboxContent2RightBoxHeader').children(":nth-child(3)").css("background-image", "url('/fileadmin/templates/koenen/images/blue-box-content-header-inactive2.png')");
			});
			$('#blueboxContent2RightBoxHeader').children(":nth-child(2)").click(function(){
				$('#blueboxContent2RightContent1').hide();
				$('#blueboxContent2RightBoxHeader').children(":nth-child(1)").css("background-image", "url('/fileadmin/templates/koenen/images/blue-box-content-header-inactive.png')");
				$('#blueboxContent2RightContent2').show();
				$('#blueboxContent2RightBoxHeader').children(":nth-child(2)").css("background-image", "url('/fileadmin/templates/koenen/images/blue-box-content-header-active2.png')");
				$('#blueboxContent2RightContent3').hide();
				$('#blueboxContent2RightBoxHeader').children(":nth-child(3)").css("background-image", "url('/fileadmin/templates/koenen/images/blue-box-content-header-inactive2.png')");
			});
			$('#blueboxContent2RightBoxHeader').children(":nth-child(3)").click(function(){
				$('#blueboxContent2RightContent1').hide();
				$('#blueboxContent2RightBoxHeader').children(":nth-child(1)").css("background-image", "url('/fileadmin/templates/koenen/images/blue-box-content-header-inactive.png')");
				$('#blueboxContent2RightContent2').hide();
				$('#blueboxContent2RightBoxHeader').children(":nth-child(2)").css("background-image", "url('/fileadmin/templates/koenen/images/blue-box-content-header-inactive2.png')");
				$('#blueboxContent2RightContent3').show();
				$('#blueboxContent2RightBoxHeader').children(":nth-child(3)").css("background-image", "url('/fileadmin/templates/koenen/images/blue-box-content-header-active2.png')");
			});
		}
	});
	/*dynamic css for suche*/
	$(document).ready(function(){
		if(document.URL.indexOf("suche.html") > 1){
			$('#content-flex-box').hide();
		}
	});
	/*dynamic css for contentContainer*/
	$(document).ready(function(){
		//var height = $(document).height();
		//height = height - 750 + $('#content').height();
		var height = $('#bg').height();
		height += $('#spacer').height();
		height += $('#content').height();
		height += $('#content-flex-box').height();
		height += $('#footer').height();
		height += 30;
		$('#contentContainer').css("height", height+"px");
		$('#contentContainer').css("overflow", "hidden");
		
	});
       
      
    /*black and white pictures*/
    function desaturate(img) {
      var img2 = Pixastic.revert(img);
    img.onmouseout = function() {
      Pixastic.process(this, "desaturate");
    }
    }
    
    $(document).ready(function(){
    	var photos = $('#produktinfo-photos img');
    	if($(photos[0]).width() < 70){
    		initBlackAndWhite();
    	}
    	else{
    		$('#produktinfo-photos').css("height", $(photos[0]).height());
    	}
      initPicHover();
    });
    
    function initBlackAndWhite(){
      var photos = $('#produktinfo-photos img');        
        for(var i=0; i<photos.length; i++){
         var img = Pixastic.process(photos[i], "desaturate");
          $(img).mouseover(function(){
            var img = Pixastic.revert(this);
            $('#produktinfo-photos img').unbind();
            $('#produktinfo-photos img').mouseout(function(){
              initBlackAndWhite();
            });
          });
        }
    }
    function changeText(){
    	if((window.location.pathname == "/") || (window.location.pathname == "/en.html")){
    		window.currentText++;
	    	if(window.currentText > window.numberOfPhotos.length){
	    		window.currentText = 1;
	    	}
	    	var newText = $('#photo-text-'+window.currentText).html();
	    	
	 	   if(newText != null){
	 		   var height = $('#content-links').height();
	 		  
	 		   $('#content-links').html(newText);
	 		   $('#content-links').height(height);
	 	   }
	 	  
	 	  var photos = $('#produktinfo-photos img');
	 	  
	 	  for(var i=0; i<photos.length; i++){
 			var img = Pixastic.process(photos[i], "desaturate");
	 	  }
	 	 //alert("1");
/*	 	 var photos = $('#produktinfo-photos canvas');
	 	 /*IE*/
	 	//alert(photos.length);
/*	 	if($(photos).size()==0){
	 		var photos = $('#produktinfo-photos img');
	 	}
	 	if($(photos).size()<window.numberOfPhotos.length){*/
	 		var photos = $('#produktinfo-photos canvas');
	 		//alert("canvas" +photos.length);
	 		var photos = $('#produktinfo-photos img');
	 		//alert("img"+photos.length);
	 		var photosLI = $('#produktinfo-photos li');
	 		//alert("li"+photosLI.length);
	 		var photos = new Array();
	 		for(var i=0;i<photosLI.length;i++){
	 			var children = $(photosLI[i]).children();
	 			photos.push(children[0]);
	 			//alert("p"+$(photosLI[i]).children().size());
	 		}
//	 	}
	 	
	 	photos[window.currentText-1] = Pixastic.revert(photos[window.currentText-1]);
    	}
    	
    }

    
    //init timer
    $(document).ready(function(){
    	if((window.location.pathname == "/") || (window.location.pathname == "/en.html")){
		    window.timer = window.setInterval("changeText()", 8000);
		    window.currentText = 1;
		    window.numberOfPhotos = $('#produktinfo-photos canvas');
		    /*IE*/
		    if(window.numberOfPhotos.length==0){
		    	window.numberOfPhotos = $('#produktinfo-photos img');
		    }
		    
		   // var photos = $('#produktinfo-photos canvas');
		 	//photos[window.currentText-1] = Pixastic.revert(photos[window.currentText-1]);
		 	
	      //init first
		  window.isFirst = true;
	      window.currentText = 0;
	      
	      window.setTimeout("changeText()", 200);
	      window.setTimeout("$('contentLinks').show()", 200);

    	}
    });
    
    /*change text on pic hover*/
    function initPicHover(){
    	var originalHTML = $('#content-links').children(":first-child").children(":first-child").html();
    	 window.savedText = originalHTML;
      var photos = $('#produktinfo-photos canvas');
	    /*IE*/
	    if($(photos).size()==0){
	    	var photos = $('#produktinfo-photos img');
	    }
      for(var i=0; i<photos.length; i++){
       $(photos[i]).parent().attr("id", i+1);
       $(photos[i]).parent().mouseenter(function(){
    	   //clear interval
    	   window.clearInterval(window.timer);
    	   /*var newText = $('#photo-text-'+$(this).attr("id")).children(":first-child").children(":first-child").html();
    	   if(newText != null){
    		   var height = $('#content-links').height();
    		  
    		   $('#content-links').children(":first-child").children(":first-child").html(newText);
    		   $('#content-links').height(height);
    	   }*/
    	   window.currentText = $(this).attr("id");
    	   window.currentText--;
    	   changeText();
       });
       $(photos[i]).parent().mouseleave(function(){
    	   //reset interval
    	   //window.timer = window.setInterval("changeText()", 8000);
    	   //changeText();
    	   
    	   //$('#content-links').children(":first-child").children(":first-child").html(window.savedText);
       });
      }
    }
    
    
    
    Pixastic.Actions.desaturateCustom = {

    		process : function(params) {
    			var useAverage = !!(params.options.average && params.options.average != "false");

    			if (Pixastic.Client.hasCanvasImageData()) {
    				var data = Pixastic.prepareData(params);
    				var rect = params.options.rect;
    				var w = rect.width;
    				var h = rect.height;

    				var p = w*h;
    				var pix = p*4, pix1, pix2;

    				if (useAverage) {
    					while (p--) 
    						data[pix-=4] = data[pix1=pix+1] = data[pix2=pix+2] = (data[pix]+data[pix1]+data[pix2])/3
    				} else {
    					while (p--)
    						data[pix-=4] = data[pix1=pix+1] = data[pix2=pix+2] = (data[pix]*0.3 + data[pix1]*0.59 + data[pix2]*0.11);
    				}
    				return true;
    			} else if (Pixastic.Client.isIE()) {
    				params.image.style.filter += " gray";
    				return true;
    			}
    		},
    		checkSupport : function() {
    			return (Pixastic.Client.hasCanvasImageData() || Pixastic.Client.isIE());
    		}
    	}
