/* * Moving Boxes script by Chris Coyier * http://css-tricks.com/moving-boxes/ */
/* Script wurde von bildbau verändert und entspricht nicht mehr dem Original */
	(function(c){
		c.movingBoxes=function(d,f){
			var a=this;
			a.$el=c(d);
			a.el=d;
			a.$el.data("movingBoxes",a);
			
			a.init=function(){
			var newActive;
			if(!newActive){
				//newActive=a.options.startPanel;
			}
				a.options=c.extend({},c.movingBoxes.defaultOptions,f);
				var newActive;
					if(!newActive){
						newActive=a.options.startPanel-1;
						jQuery('#image_view_'+newActive).attr('src',jQuery("#image_sharp_"+newActive).attr("src"));
				}
				var b=a.$el.find(".panel");
				
				a.options.totalPanels=b.length;
				a.options.regWidth=b.css("width");
				a.options.regImgWidth=b.find("img.slide").css("width");
				a.options.regTitleSize=b.find("h2").css("font-size");
				a.options.regParSize=b.find("p").css("font-size");
				b.css({"float":"left",position:"relative"});
				a.$el.data("currentlyMoving",false);
				a.$el.find(".scrollContainer").css("width",a.$el.find(".panel")[0].offsetWidth*a.$el.find(".panel").length+129);
				a.$el.find(".scroll").css("overflow","hidden");
				a.$el.data("currentPanel",-1);
				a.change(a.options.startPanel);
				curPanel=a.options.startPanel;
				a.$el.find(".right").click(function(){
					a.change(a.$el.data("currentPanel")+1)
				}).end().find(".left").click(function(){a.change(a.$el.data("currentPanel")-4)});
				
				
				
				if(jQuery('#dsds'+newActive+' h2').height()==null){
					jQuery('#dsds'+newActive+' h2').height(15);	
				}
				
				if(48-jQuery('#dsds'+newActive+' h2').height() < 1){ 
					var paddingh2 = 0;
				}else{
					var paddingh2 = (48-jQuery('#dsds'+newActive+' h2').height());
				}
				//alert(paddingh2);
				jQuery('#dsds'+newActive+' h2').css({'padding-top':paddingh2+'px'});
				
			b.click(function(){
				
			
				jQuery('#image_view_'+newActive).attr('src',jQuery("#image_blur_"+newActive).attr("src"));
				newActive = b.index(c(this));
				jQuery('#image_view_'+newActive).attr('src',jQuery("#image_sharp_"+newActive).attr("src"));
				//alert(newActive);
				//alert(jQuery('#dsds'+newActive+' h2').height());
				if(48-jQuery('#dsds'+newActive+' h2').height() < 1){
					var paddingh2 = 0;
				}else{
					var paddingh2 = (48-jQuery('#dsds'+newActive+' h2').height());
				}
				
				jQuery('#dsds'+newActive+' h2').css({'padding-top':paddingh2+'px'});
				
				a.change(b.index(c(this))+1);
			})
			jQuery('.sliderbuttonright').click(function(){
				var wholeWidth = jQuery('body').width();
				var amountOfPanels = Math.round(wholeWidth/129);
				//alert(amountOfPanels);
				
				jQuery('#image_view_'+newActive).attr('src',jQuery("#image_blur_"+newActive).attr("src"));
				//alert("scv"+newActive);
				newActive = newActive+amountOfPanels-2;
				if(newActive > b.length){newActive= (b.length - 1)}
				//alert(b.length);
				jQuery('#image_view_'+newActive).attr('src',jQuery("#image_sharp_"+newActive).attr("src"));
				if(48-jQuery('#dsds'+newActive+' h2').height() < 1){
					var paddingh2 = 0;
				}else{
					var paddingh2 = (48-jQuery('#dsds'+newActive+' h2').height());
				}
				
				jQuery('#dsds'+newActive+' h2').css({'padding-top':paddingh2+'px'});
				a.change(newActive+1);
			});
			
			jQuery('.sliderbuttonleft').click(function(){
				var wholeWidth = jQuery('body').width();
				var amountOfPanels = Math.round(wholeWidth/129);
				//alert(amountOfPanels);
				
				jQuery('#image_view_'+newActive).attr('src',jQuery("#image_blur_"+newActive).attr("src"));
				
				newActive = newActive-amountOfPanels+1;
				if(newActive<0){newActive=0}
				//alert(newActive);
				jQuery('#image_view_'+newActive).attr('src',jQuery("#image_sharp_"+newActive).attr("src"));
				
				
				
				if(48-jQuery('#dsds'+newActive+' h2').height() < 1){
					var paddingh2 = 0;
				}else{
					var paddingh2 = (48-jQuery('#dsds'+newActive+' h2').height());
				}
				
				jQuery('#dsds'+newActive+' h2').css({'padding-top':paddingh2+'px'});
				a.change(newActive+1);
			});
			
			};
			
			
			
			a.returnToNormal=function(b){
				
				a.$el.find(".panel").not(":eq("+(b-1)+")").animate({
					width:a.options.regWidth
				},
					a.options.speed).find("img.slide").removeClass('big').animate({
						width:a.options.regImgWidth},
						a.options.speed).end().find("h2").animate({
							fontSize:a.options.regTitleSize},
							a.options.speed).css({'visibility': 'hidden'}).end().find("p").animate({
								fontSize:a.options.regParSize},
								a.options.speed).css({'visibility': 'hidden'})
			};
			a.growBigger=function(b){
				var urlwert = jQuery('#'+a.$el.find(".panel").eq(b-1).attr('id')+' .more a').attr('info');
				//alert(urlwert);
				
				a.$el.find(".panel").eq(b-1).animate({width:a.options.curWidth},a.options.speed).find("img.slide").animate({width:a.options.curImgWidth},a.options.speed).wrap('<a href="'+urlwert+'" />').addClass('big').end().find("h2").animate({'fontSize':a.options.curTitleSize},a.options.speed).css({'visibility':'visible'}).end().find("p").animate({fontSize:a.options.curParSize},a.options.speed).css({'visibility':'visible'})};
			
			a.change=function(b){
				var e=a.$el.find(".panel");
				if(b<1||a.$el.data("currentPanel")==b||b>e.length)return false;
				if(!a.$el.data("currentlyMoving")){
					a.$el.data("currentPanel",b);
					a.$el.data("currentlyMoving",true);
			
					//e=a.$el.find(".scroll").innerWidth()/4-e.eq(b-1).outerWidth()/4-a.options.movingDistance*(b-1);
					var element = jQuery('.top-contentbox');
					var position = element.position();
					var okoili = position.left; //position des striches
					var screenWidth = document.width;
			
					e=okoili-a.options.movingDistance*(b-1);
	
					a.$el.find(".scrollContainer").stop().animate({left:e},a.options.speed,function(){a.$el.data("currentlyMoving",false)});
					a.returnToNormal(b);
					a.growBigger(b)
				}
			};
			a.currentPanel=function(b){typeof b!=="undefined"&&a.change(parseInt(b,10));
			return a.$el.data("currentPanel")};
			
			a.init()};
			c.movingBoxes.defaultOptions={startPanel:1,movingDistance:129,curWidth:166,curImgWidth:166,curTitleSize:"11px",curParSize:"11px",speed:1000};
			c.fn.movingBoxes=function(d){return this.each(function(){new c.movingBoxes(this,d)})};
			c.fn.getmovingBoxes=function(){this.data("movingBoxes")}})(jQuery);
/* 			kr */
