function loadScript(url, callback){
    var script = document.createElement("script");
    script.type = "text/javascript";
    if (script.readyState){  //IE
        script.onreadystatechange = function(){
            if (script.readyState == "loaded" ||
                    script.readyState == "complete"){
                script.onreadystatechange = null;
                callback();
            }
        };
    } else {  //Others
        script.onload = function(){
            callback();
        };
    }
    script.src = url;
    document.getElementsByTagName("head")[0].appendChild(script);
}

function clearField (thisfield, placeholder) {
	if (thisfield.value == placeholder) {
		thisfield.value = '';
//		thisfield.css('color','#000');
	}
}

function labelField(tfield,placeholder) {
	if (tfield.value == '') {
		tfield.value = placeholder;
//		tfield.css('color','#C6C7C8');
	}
}



var activeFlash = null;
function toggleFlashPlay(prevActiveFlash,currentFlash){
	if(prevActiveFlash!=null){
	 	prevActiveFlash.flash( function() { this.StopPlay();this.GotoFrame(0); } );
	}
	if(currentFlash != null){
		activeFlash = currentFlash.parent();
		window.setTimeout('activeFlash.flash( function() { this.Play(); } )', 500);
	}
}


function getRandom( min, max ) {
	if( min > max ) {
	return( -1 );
	}
	if( min == max ) {
	return( min );
	}
	return min + parseInt( Math.random() * ( max-min+1 ));
}


function initPage (devurl,projektfilter){


	$("div.scriptonly").removeClass("none");
	
	$("a.info").each(function(){
	    var iLink = $(this);
	    var iLayer = iLink.parent().siblings("div.info_layer");
	    iLayer.wrap('<div style="position:relative;">');
	    iLink.bind("mouseover",function(e){
	        iLayer.show();
		});
		iLink.bind("mouseout",function(){
	        iLayer.hide();
		});

	});

	if(location.hash != "" ){
		$('[name=' + location.hash.slice(1) +']').next().children("a.news_title").toggleClass("opened").next().toggle();
			
	}

	var imgGroupList = $(".moving_images").find(".img_group");

	if(imgGroupList.length!=0){
		//noch position john doe auslesen. aktuell letztes Bild im imgSet. Wenn imperia-modul fertig noch überarbeiten.
		var currentImgGroup1 = 0;
		var currentImgGroup2 = 3;
		var currentImgGroup3 = 5;
		var randInterval1 = 3000;
		var randInterval2 = 5000;
		var randInterval3 = 7000;
		var imgSet = $("div.img_set").children("img");
		//var activeImages = new Array();
		//var activeImages = new Array(3,5,9,13,16,17);
		var activeImages = new Array(3,5,9,13,16,23);

		var imgInfo = new Array();
		imgInfo['team'] = new Array();
		var imgSetCounter = 0;
		imgSet.each(function(){
		    var imgInfoText = $(this).attr("alt").split("|");
		    var imgSrc = $(this).attr("src");
		    imgInfo['team'][imgSetCounter] = new Array();
			imgInfo['team'][imgSetCounter]['name'] = imgInfoText[0];
			imgInfo['team'][imgSetCounter]['info'] = imgInfoText[1];
			imgInfo['team'][imgSetCounter]['src'] = imgSrc;
			imgSetCounter++;
		});
		var imgsMaxRandom = imgInfo['team'].length - 1;
		
		var rotate1 = window.setInterval(function(){rotateImgs(imgGroupList,1)}, randInterval1);
		var rotate2 = window.setInterval(function(){rotateImgs(imgGroupList,2)}, randInterval2);
		var rotate3 = window.setInterval(function(){rotateImgs(imgGroupList,3)}, randInterval3);
	}
	
	function rotateImgs(imgGroups,funcIndex){
		var toMoveImgGroup=2;
		while(currentImgGroup1 == toMoveImgGroup || currentImgGroup2 == toMoveImgGroup || currentImgGroup3 == toMoveImgGroup){
			toMoveImgGroup = getRandom (0,5);
		}
		
		if(funcIndex == 1) {
			currentImgGroup1 = toMoveImgGroup;
			randInterval1 = getRandom (3000,7000);
  		    window.clearInterval(rotate1);
  		    rotate1 = window.setInterval(function(){rotateImgs(imgGroupList,1)}, randInterval1);
		}
		if(funcIndex == 2) {
		    currentImgGroup2 = toMoveImgGroup;
			randInterval2 = getRandom (3000,7000);
			window.clearInterval(rotate2);
  		    rotate2 = window.setInterval(function(){rotateImgs(imgGroupList,2)}, randInterval2);
		}
		if(funcIndex == 3) {
			currentImgGroup3 = toMoveImgGroup;
			randInterval3 = getRandom (3000,7000);
			window.clearInterval(rotate3);
  		    rotate3 = window.setInterval(function(){rotateImgs(imgGroupList,3)}, randInterval3);
		}
		
		imgGroups.eq(toMoveImgGroup).each(function() {
		    var imgCon = $(this).children(".img_con");
			var img = imgCon.children("img:visible");
			var name = $(this).children("strong");
			var info = $(this).children("span");
			var nextImg = img.siblings("img:hidden");
			var nextImgSrc = "";
			var imgSetIndex = 0;
			while(jQuery.inArray(imgSetIndex, activeImages)!=-1){
				imgSetIndex = getRandom (0,imgsMaxRandom);
			}
			
			activeImages[toMoveImgGroup] = imgSetIndex;
			//nextImgSrc = imgSet.eq(imgSetIndex).attr("src");
			nextImgSrc = imgInfo['team'][imgSetIndex]['src'];
			nextImg.attr("src",nextImgSrc);
			var directionChoose = getRandom(0,100);
			name.html("");
			info.html("");
			
			if(directionChoose < 50) {
				imgCon.removeClass("cursor");
				img.animate({
				    marginLeft: "-=280"
					  }, "slow", function() {
					  $(this).hide();
					  $(this).css("margin-left","0");
					  nextImg.css("margin-left","280px");
					  nextImg.css("display","block");

        			  nextImg.animate({
						  marginLeft: "-=280"
							  }, "slow", function() {
							  	name.html(imgInfo['team'][imgSetIndex]['name']);
								info.html(imgInfo['team'][imgSetIndex]['info']);
								if(imgSetIndex==23){
									imgCon.addClass("cursor");
								}
					 });
				});
			} else {
				imgCon.removeClass("cursor");
				img.animate({
				    marginLeft: "+=280"
					  }, "slow", function() {
					  $(this).hide();
					  $(this).css("margin-left","0");
					  nextImg.css("margin-left","-280px");
					  nextImg.css("display","block");

				      nextImg.animate({
					     marginLeft: "+=280"
					 	   }, "slow", function() {
						   name.html(imgInfo['team'][imgSetIndex]['name']);
						   info.html(imgInfo['team'][imgSetIndex]['info']);
						   if(imgSetIndex==23){
						  	 imgCon.addClass("cursor");
						   }
					  });
				});
			}
		});
	}
	

	$('a[href*=#]').click(function() {
	    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
	    && location.hostname == this.hostname) {
	      var $target = $(this.hash);
	      $target = $target.length && $target
	      || $('[name=' + this.hash.slice(1) +']');
	      if ($target.length) {
	        var targetOffset = $target.offset().top;
	        $('html,body')
	        .animate({scrollTop: targetOffset}, 1500);
	       return false;
	      }
	    }
	});


	$("div.img_toggle").each(function() {
	    var imgCon = $(this);
	    var firstImg = imgCon.find("img:eq(0)");
	    var secondImg = imgCon.find("img:eq(1)");
	    var link = $(this).children("a");
	    
		imgCon.bind("mouseover",function() {
		    if(!imgCon.hasClass("selected")){
			    imgCon.removeClass("opacity")
	    		firstImg.hide();
	    		secondImg.show();
    		}
    	});
    	
    	imgCon.bind("mouseout",function() {
    		if(!imgCon.hasClass("selected")){
    			secondImg.hide();
    			firstImg.show();
    		}
			if(imgCon.siblings().hasClass("selected")){
				imgCon.addClass("opacity")
			}
    	});
    	
    	imgCon.bind("click",function() {
    		var box = $(this).parent();
    	
    		if(link.length != 0){ document.location = $(this).find("a").attr("href"); }

    		var siblings = imgCon.siblings(".img_toggle");
    		
    		if (!box.find("div.details").is(':animated')) {
	    		siblings.find("img:eq(0)").show();
	    		siblings.find("img:eq(1)").hide();
	    		siblings.addClass("opacity");
	    		siblings.removeClass("selected");
	    		imgCon.addClass("selected");

	  			if(box.find("div.details:visible").length==0){
					box.find("div.details:eq("+box.find(".img_toggle").index(imgCon)+")").slideDown("normal");

				} else {
					box.find("div.details").hide();
					box.find("div.details:eq("+box.find(".img_toggle").index(imgCon)+")").show();
				}
			}
    	});
    	
	});

	$("div.details").each(function() {
	    var details = $(this);
		details.find("a.close").bind("click",function() {
			details.slideUp("normal");
			var selected = details.parent().find("div.img_toggle.selected");
			selected.find("img:eq(1)").hide();
			selected.find("img:eq(0)").show();
			details.parent().find("div.img_toggle").removeClass("selected opacity");
		});
	});


	$("#sub_nav").find("a.close").bind("click",function() {
	    var aClose = $(this);
	  	aClose.hide();
		$("#sub_nav").children(".sub_nav_content:visible").slideUp("normal",function(){
        	aClose.show();
      	});
	});


	$("#main_nav").children("a").each(function() {
	    var link = $(this);
		var sub_nav = $("#sub_"+$(this).attr("id"));
		var aClose = $("#sub_nav").find("a.close");
      	link.bind("click",function() {
       		//toggleFlashPlay(activeFlash,null); evtl. flash stoppen wenn hauptnavi aufgeklappt wird. Aber klären wie die Animation dann nue gestartet werden kann
           	link.siblings("a").removeClass("active");
           	link.addClass("active");
			var speed = "normal";
			aClose.hide();
			$("#sub_nav").children(".sub_nav_content:visible").not("#sub_"+$(this).attr("id")).slideUp(speed,function(){
        		aClose.show();
      		});
      		sub_nav.slideToggle(speed,function(){
        		aClose.show();
      		});
		});
	});
	

	$("#sub_nav").children("div.sub_nav_content").each(function() {
		var sub_nav_content = $(this);
	    var links = $(this).find("a.button");
	    var content = $(this).find("div.sub_nav_content_details");
	    
		links.bind("click",function() {
			
			var href=$(this).attr("href");
    		if(href!="javascript://"){
 				document.location = href;
				return false;
			}
			
		    var next = content.eq(links.index($(this)));
		    
		    if($(this).hasClass("selected") || next.html()== null ){
				return false;
			}
		    
		    links.removeClass("selected");
		    $(this).addClass("selected");
		    next.css("margin-left","1000px");
		    
		    var current = next.siblings(".sub_nav_content_details:visible");
	          
	        current.animate({
			    marginLeft: "-=1000"
				  }, "normal", function() {
				  $(this).hide();
				  $(this).css("margin-left","1000px");
				  next.css("display","block");

			    next.animate({
				    marginLeft: "-=1000"
					  }, "normal", function() {
				});
			});
			
		});
		
		links.parent().bind("mouseenter",function() {
		    var subEntries = $(this).children("a.button").next();
		    if(subEntries.html()!= null){
				$(this).addClass("button_hover");
				//$(this).children("a.button").removeClass("down");
				//$(this).children("a.button").addClass("goto");
				$(this).children("a.button").next().show();
			}
		});
		links.parent().bind("mouseleave",function() {
		 	var subEntries = $(this).children("a.button").next();
		    if(subEntries.html()!= null){
				$(this).removeClass("button_hover");
				//$(this).children("a.button").removeClass("goto");
				//$(this).children("a.button").addClass("down");
				$(this).children("a.button").next().hide();
			}
		});
		
	});

	


	$("#page").find("div.move_box").each(function() {

		var moveBoxContent = $(this).find("div.move_box_content");
		
		activeFlash = moveBoxContent.eq(0).find("object");
		
		var newsBox = false;
		var projectBox = false;
		var projectExcludeId = 0;

		var topNav = $(this).find("div.move_box_top_nav").children("a");
	    var boxCount = moveBoxContent.size();
	    var boxWidth = moveBoxContent.width();
	    var maskWidth = $(this).find('div.move_box_mask').width();
	    var containerWidth = boxCount*maskWidth;
	    var moveBoxContainer = $(this).find("div.move_box_content_container");
	    moveBoxContainer.css("width",containerWidth+"px");
	    var m = containerWidth / boxCount;
    	var mcalc = boxCount - 1;
    	var mv = false;

    	var buttonPrev =  $(this).find("a.prev");
    	var buttonNext =  $(this).find("a.next");
    	
    	 if($(this).parent().hasClass("news_box")){
	    	newsBox = true;
 	    	initMoveBoxContent(moveBoxContent);
       		if(boxCount>1) buttonNext.show();
		}
		
		if($(this).hasClass("projekt_box")){
	    	projectBox = true;
	    	var eID = $("#project_id").attr("class");
			projectExcludeId = eID.substr(1);
		}

    	buttonPrev.click(function() {
    		var href=$(this).attr("href");
    		if(href!="javascript://"){
 				document.location = href;
				return false;
			}

	        var cm = parseInt(moveBoxContainer.css('margin-left'));
	        if (isNaN(cm)) cm = 0;
	        
	        var canMove = false;
			for (var i = 0; i < boxCount; i++){
				if (cm == 0 - m * i){
					canMove = true;
				}
			}
			if(!canMove) return false;
	        
	        //if ((cm != 0 - m * 0) && (cm != 0 - m * 1) && (cm != 0 - m * 2) && (cm != 0 - m * 3) && (cm != 0 - m * 4) && (cm != 0 - m * 5)) return false;

	        topNav.removeClass("active");
	        if (cm < 0) {
	            moveBoxContainer.animate({
	                marginLeft: cm + m
	            },
	            'normal',function(){
                        if(parseInt(moveBoxContainer.css('margin-left'))== 0 && newsBox){
							buttonPrev.hide();
						}
						if(newsBox) {buttonNext.show();}
						toggleFlashPlay(activeFlash,moveBoxContent.eq(cm/m * -1 -1).find("object"));
                    });
                    
                var topNavIndex = cm/m * -1 -1;
	            topNav.eq(topNavIndex).addClass("active");

	            if(projectBox && moveBoxContent.eq(topNavIndex).html()== ""){
     				$.ajax({
	  					url: devurl+"/ajax/projects.php?page="+(topNavIndex+1)+"&f="+projektfilter+"&e="+projectExcludeId,
  						cache: false,
  						success: function(html){
		       				 moveBoxContent.eq(topNavIndex).append(html);
		       				initProjectMoveBoxContent(moveBoxContent);
	  					}
					});
				}
	          
	            
	        } else {
	            moveBoxContainer.animate({
	                marginLeft: 0 - m * mcalc
	            },
	            'slow',
				function(){
				toggleFlashPlay(activeFlash,moveBoxContent.eq(boxCount -1).find("object"));
				});
				
	            var topNavIndex = boxCount -1;
	            topNav.eq(topNavIndex).addClass("active");
	            
	          	if(projectBox && moveBoxContent.eq(topNavIndex).html()== ""){
     				$.ajax({
	  					url: devurl+"/ajax/projects.php?page="+(topNavIndex+1)+"&f="+projektfilter+"&e="+projectExcludeId,
  						cache: false,
  						success: function(html){
		       				 moveBoxContent.eq(topNavIndex).append(html);
		       				initProjectMoveBoxContent(moveBoxContent);
	  					}
					});
				}
                
	        }
	        
	        if(newsBox){
				moveBoxContent.find("div.news_text").hide();
     			moveBoxContent.find("a.news_title").removeClass("opened");
     		}
	        
    	});
    	
    	buttonNext.click(function() {
    	
    		var href=$(this).attr("href");
    		if(href!="javascript://"){
 				document.location = href;
				return false;
			}
			
	        var cm = parseInt(moveBoxContainer.css('margin-left'));
	        if (isNaN(cm)) cm = 0;


			var canMove = false;
			for (var i = 0; i < boxCount; i++){
				if (cm == 0 - m * i){
					canMove = true;
				}
			}
			if(!canMove) return false;
			
	        //if ((cm != 0 - m * 0) && (cm != 0 - m * 1) && (cm != 0 - m * 2) && (cm != 0 - m * 3) && (cm != 0 - m * 4) && (cm != 0 - m * 5)) return false;
			
		 	topNav.removeClass("active");
		    if (cm > 0 - m * mcalc) {
	            moveBoxContainer.animate({
	                marginLeft: cm - m
	            },
	            'normal',function(){
						if( (containerWidth-boxWidth) == (parseInt(moveBoxContainer.css('margin-left'))*-1) && newsBox){
							buttonNext.hide();
						}
						if(newsBox) {buttonPrev.show();}
						
						toggleFlashPlay(activeFlash,moveBoxContent.eq(cm/m * -1 + 1).find("object"));
					});
	            
				 var topNavIndex = cm/m * -1 + 1;
	             topNav.eq(topNavIndex).addClass("active");
	             
	             
	             if(newsBox && moveBoxContent.eq(topNavIndex).html()== ""){
     				$.ajax({
	  					url: devurl+"/ajax/news.php?page="+(topNavIndex+1),
  						cache: false,
  						success: function(html){
		       				 moveBoxContent.eq(topNavIndex).append(html);
		       				 initMoveBoxContent(moveBoxContent.eq(topNavIndex));
	  					}
					});
				}
				
			   if(projectBox && moveBoxContent.eq(topNavIndex).html()== ""){
     				$.ajax({
	  					url: devurl+"/ajax/projects.php?page="+(topNavIndex+1)+"&f="+projektfilter+"&e="+projectExcludeId,
  						cache: false,
  						success: function(html){
		       				moveBoxContent.eq(topNavIndex).append(html);
		       				initProjectMoveBoxContent(moveBoxContent);
	  					}
					});
				}
				
	        } else {
	            moveBoxContainer.animate({
	                marginLeft: 0
	            },
	            'slow',
					function(){
					toggleFlashPlay(activeFlash,moveBoxContent.eq(0).find("object"));
					}
				);
	            topNav.eq(0).addClass("active");
		    }
		    
		    if(newsBox){
				moveBoxContent.find("div.news_text").hide();
     			moveBoxContent.find("a.news_title").removeClass("opened");
     		}
	        
    	});
    	
    	topNav.bind("click",function() {
    	
    		var link = $(this);
    		var linkIndex = link.index();
    	
    	    if(newsBox){
				moveBoxContent.find("div.news_text").hide();
     			moveBoxContent.find("a.news_title").removeClass("opened");
     			if(linkIndex+1 == boxCount){ buttonNext.hide(); }
			    if(linkIndex == 0){ buttonPrev.hide(); }
			    if(linkIndex > 0 ){ buttonPrev.show(); }
			    if(linkIndex+1 < boxCount){ buttonNext.show(); }
			    
     			if(moveBoxContent.eq(linkIndex).html()== ""){
     				$.ajax({
	  					url: devurl+"/ajax/news.php?page="+(linkIndex+1),
  						cache: false,
  						success: function(html){
		       				 moveBoxContent.eq(linkIndex).append(html);
		       				 initMoveBoxContent(moveBoxContent.eq(linkIndex));
	  					}
					});
				}
			}
    	    
    	    topNav.removeClass("active");
    	    link.addClass("active");
    	    moveBoxContainer.animate({
	        		marginLeft:  -m * link.index()
	            },
    	        'normal',
				function(){
						toggleFlashPlay(activeFlash,moveBoxContent.eq(linkIndex).find("object"));
				}
			);
		});
	});


	$(".screens_nav").each(function() {
	    var screens = $(this).siblings(".screens").children("img");
	    var screenLinks = $(this).children("a");
		screenLinks.bind("click",function() {
		    var link = $(this);
			screenLinks.removeClass("active");
			link.addClass("active");
			screens.hide();
			screens.eq(link.index()).show();
		});
	});

	$(".imgmap_box").each(function(){
	    var imgs = $(this).children("img").not(":eq(0)");
	    var maps = $(this).find("area");
		maps.bind("mouseover",function(){
			imgs.hide();
			imgs.eq($(this).index()).show();
		});
		maps.bind("mouseout",function(){
			imgs.hide();
		});
	});


	$(".toggle_entry").each(function(){
     	var title = $(this).children("a.toggle_title");
     	var text = $(this).children("div.toggle_text");
	   
	   	title.bind("click",function(){
        	var link = $(this);
        	link.next().toggle();
        	link.toggleClass("opened");
  	  	});
	});


	//block löschen wenn anpassungen an move_box Funktion getestet
 	$(".lalala").each(function(){
 	
 	    var moveBoxContent = $(this).find(".move_box_content");
 	
 	    initMoveBoxContent(moveBoxContent);
 	    
 	    /* in funktion initMoveBoxContent ausgelagert
        var newsList = $(this).find(".news_entry");
     	var newsTitle = newsList.children("a.news_title");
     	var newsText = newsList.children("div.news_text");

    	newsTitle.bind("click",function(){
        	var link = $(this);
        	newsText.not(link.next()).hide();
        	newsTitle.not($(this)).removeClass("opened");
        	link.next().toggle();
        	link.toggleClass("opened");
     	});
     	*/
     	
     	$(this).find("a.next,a.prev,.move_box_top_nav a").click(function(){
     	
     		moveBoxContent.find("div.news_text").hide();
     		moveBoxContent.find("a.news_title").removeClass("opened");
			
	        $.ajax({
  				url: devurl+"/ajax/news.php?page=2",
  				cache: false,
  				success: function(html){
  					
	       			if(moveBoxContent.eq("1").html()== ""){
	       			      //alert("geladen");
	       				  moveBoxContent.eq("1").append(html);
	       				 initMoveBoxContent(moveBoxContent.eq("1")); //index noch mit angeben?
	       			}
	  			}
			});
		});
     	
     });

	jQuery.fn.supersleight = function(settings) {
		settings = jQuery.extend({
			imgs: true,
			backgrounds: true,
			shim: '/cnm10/img/trans.gif',
			apply_positioning: true
		}, settings);

		return this.each(function(){
			if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 && parseInt(jQuery.browser.version, 10) > 4) {
				jQuery(this).find('*').andSelf().each(function(i,obj) {
					var self = jQuery(obj);
					// background pngs
					if (settings.backgrounds && self.css('background-image').match(/\.png/i) !== null) {
						var bg = self.css('background-image');
						var src = bg.substring(5,bg.length-2);
						var mode = (self.css('background-repeat') == 'no-repeat' ? 'crop' : 'scale');
						var styles = {
							'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')",
							'background-image': 'url('+settings.shim+')'
						};
						self.css(styles);
					};
					// image elements
					if (settings.imgs && self.is('img[src$=png]')){
						var styles = {
							'width': self.width() + 'px',
							'height': self.height() + 'px',
							'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + self.attr('src') + "', sizingMethod='scale')"
						};
						self.css(styles).attr('src', settings.shim);
					};
					// apply position to 'active' elements
					if (settings.apply_positioning && self.is('a, input') && (self.css('position') === '' || self.css('position') == 'static')){
						self.css('position', 'relative');
					};
				});
			};
		});
	};
	
 	$('#buehne').find("div.screens").supersleight();
 	$('#buehne').find("img.png24").supersleight();
 	
 	
 	$('#buehne').find("div.calendar_sheet").bind("mouseover mouseout",function(){
			$(this).toggleClass("calendar_sheet_hover");
		}
	);

 	
 	$("#rueckruf").colorbox({opacity:"0.5",inline:true, href:"#rueckruf_form_box",onLoad:function(){  $("#cboxContent").css("display","none");} },
	 	function(){
	 	    var offset =$("#rueckruf").offset();
			$("#colorbox").css("left",(offset.left-48)+"px");
			$("#colorbox").css("top",(offset.top-150)+"px");
	 	    $("#cboxContent").css("display","block");
		}
	);
 			

	$("#project_info").colorbox({
		 opacity:"0.5",
		 inline:true,
		 href:"#project_info_form_box",
		 onLoad:function(){
		 	$("#cboxContent").css("display","none");
			$("#cboxContent").addClass("project_info_bg");
		 },
		 onClosed:function(){
			$("#cboxContent").removeClass("project_info_bg");
		 }},
	 	function(){
	 	    $("#cboxContent").css("display","block");
		}
	);
	
	$('#project_info_submit').click(function(){
		if ($('#pi_vorname').val() == 'Bitte Vornamen eingeben ...') $('#pi_vorname').val('');
		if ($('#pi_nachname').val() == 'Bitte Nachnamen eingeben ...') $('#pi_nachname').val('');
		if ($('#pi_firma').val() == 'Bitte Firma eingeben ...') $('#pi_firma').val('');
		if ($('#pi_email').val() == 'Bitte E-Mail-Adresse eingeben ...') $('#pi_email').val('');
		if ($('#pi_fon').val() == 'Bitte Telefonnummer eingeben ...') $('#pi_fon').val('');
		if ($('#pi_nachricht').val() == 'Bitte Nachricht eingeben ...') $('#pi_nachricht').val('');

		$('#project_info_form').find('.error').toggleClass('error');

		$('#project_info_error').hide();
		$('#project_info_form').ajaxSubmit({
			url:$('#project_info_form').attr('action'),
			dataType:'xml',
			success:function (xml) {
				var err = $(xml).find('err').attr('value');
				var msg = $('msg',xml).text().replace(/\n/,"<br />");
				if (err == "1") {
					if ($('#pi_vorname').val() == '') $('#pi_vorname').val('Bitte Vornamen eingeben ...');
					if ($('#pi_nachname').val() == '') $('#pi_nachname').val('Bitte Nachnamen eingeben ...');
					if ($('#pi_firma').val() == '') $('#pi_firma').val('Bitte Firma eingeben ...');
					if ($('#pi_email').val() == '') $('#pi_email').val('Bitte E-Mail-Adresse eingeben ...');
					if ($('#pi_fon').val() == '') $('#pi_fon').val('Bitte Telefonnummer eingeben ...');
					if ($('#pi_nachricht').val() == '') $('#pi_nachricht').val('Bitte Nachricht eingeben ...');
					$('#project_info_error').children('p').html(msg);
					$('#project_info_error').show();
					$(xml).find('err').children().each(function() {
						var id = $(this).attr('id');
						$('#'+id).toggleClass('error');
					});
				} else {
					$('#project_info_success').html(msg);
					$('#project_info_form_container').hide();
					$('#project_info_submit').hide();
					$('#project_info_success').show();
				}
			}
		});
	});
	
	$('#seminar_submit').click(function(){
		if ($('#seminar_vorname').val() == 'Bitte Vornamen eingeben ...') $('#seminar_vorname').val('');
		if ($('#seminar_nachname').val() == 'Bitte Nachnamen eingeben ...') $('#seminar_nachname').val('');
		if ($('#seminar_firma').val() == 'Bitte Firma eingeben ...') $('#seminar_firma').val('');
		if ($('#seminar_email').val() == 'Bitte E-Mail-Adresse eingeben ...') $('#seminar_email').val('');
		if ($('#seminar_strasse').val() == 'Bitte Straße eingeben ...') $('#seminar_strasse').val('');
		if ($('#seminar_plz_ort').val() == 'Bitte PLZ und Ort eingeben ...') $('#seminar_plz_ort').val('');
		
		$('#seminar_form').find('.error').toggleClass('error');

		$('#seminar_error').hide();
		$('#seminar_form').ajaxSubmit({
			url:$('#seminar_form').attr('action'),
			dataType:'xml',
			success:function (xml) {
				var err = $(xml).find('err').attr('value');
				var msg = $('msg',xml).text().replace(/\n/,"<br />");
				if (err == "1") {
					if ($('#seminar_vorname').val() == '') $('#seminar_vorname').val('Bitte Vornamen eingeben ...');
					if ($('#seminar_nachname').val() == '') $('#seminar_nachname').val('Bitte Nachnamen eingeben ...');
					if ($('#seminar_firma').val() == '') $('#seminar_firma').val('Bitte Firma eingeben ...');
					if ($('#seminar_email').val() == '') $('#seminar_email').val('Bitte E-Mail-Adresse eingeben ...');
					
					if ($('#seminar_strasse').val() == '') $('#seminar_strasse').val('Bitte Straße eingeben ...');
					if ($('#seminar_plz_ort').val() == '') $('#seminar_plz_ort').val('Bitte PLZ und Ort eingeben ...');
					
					$('#seminar_error').children('p').html(msg);
					$('#seminar_error').show();
					$(xml).find('err').children().each(function() {
						var id = $(this).attr('id');
						$('#'+id).toggleClass('error');
					});
				} else {
					$('#seminar_success').html(msg);
					$('#seminar_form_container').hide();
					$('#seminar_submit').hide();
					$('#seminar_success').show();
				}
			}
		});
	});

	$('#contact_submit').click(function(){
		if ($('#contact_vorname').val() == 'Bitte Vornamen eingeben ...') $('#contact_vorname').val('');
		if ($('#contact_nachname').val() == 'Bitte Nachnamen eingeben ...') $('#contact_nachname').val('');
		if ($('#contact_firma').val() == 'Bitte Firma eingeben ...') $('#contact_firma').val('');
		if ($('#contact_email').val() == 'Bitte E-Mail-Adresse eingeben ...') $('#contact_email').val('');
		if ($('#contact_nachricht').val() == 'Bitte Nachricht eingeben ...') $('#contact_nachricht').val('');

		$('#contact_form').find('.error').toggleClass('error');

		$('#contact_error').hide();
		$('#contact_form').ajaxSubmit({
			url:$('#contact_form').attr('action'),
			dataType:'xml', 
			success:function (xml) {
				var err = $(xml).find('err').attr('value');
				var msg = $('msg',xml).text().replace(/\n/,"<br />");
				if (err == "1") {
					if ($('#contact_vorname').val() == '') $('#contact_vorname').val('Bitte Vornamen eingeben ...');
					if ($('#contact_nachname').val() == '') $('#contact_nachname').val('Bitte Nachnamen eingeben ...');
					if ($('#contact_firma').val() == '') $('#contact_firma').val('Bitte Firma eingeben ...');
					if ($('#contact_email').val() == '') $('#contact_email').val('Bitte E-Mail-Adresse eingeben ...');
					if ($('#contact_nachricht').val() == '') $('#contact_nachricht').val('Bitte Nachricht eingeben ...');
					$('#contact_error').children('p').html(msg);
					$('#contact_error').show();
					$(xml).find('err').children().each(function() {
						var id = $(this).attr('id');
						$('#'+id).toggleClass('error');
					});
				} else {
					$('#contact_success').html(msg);
					$('#contact_form_container').hide();
					$('#contact_submit').hide();
					$('#contact_success').show();
				}
			}
		});
	});

	$('#rueckruf_submit').click(function(){
		if ($('#rr_firma').val() == 'Bitte Firma eingeben') $('#rr_firma').val('');
		if ($('#rr_name').val() == 'Bitte Namen eingeben') $('#rr_name').val('');
		if ($('#rr_fon').val() == 'Bitte Telefonnummer eingeben') $('#rr_fon').val('');
		if ($('#rr_email').val() == 'Bitte E-Mail-Adresse eingeben') $('#rr_email').val('');

		$('#rueckruf_form').find('.error').toggleClass('error');

		$('#rueckruf_success').hide();
		$('#rueckruf_form').ajaxSubmit({
			url:$('#rueckruf_form').attr('action'),
			dataType:'xml', 
			success:function (xml) {
				var err = $(xml).find('err').attr('value');
				var msg = $('msg',xml).text().replace(/\n/,"<br />");
				if (err == "1") {
					if ($('#rr_firma').val() == '') $('#rr_firma').val('Bitte Firma eingeben');
					if ($('#rr_name').val() == '') $('#rr_name').val('Bitte Namen eingeben');
					if ($('#rr_fon').val() == '') $('#rr_fon').val('Bitte Telefonnummer eingeben');
					if ($('#rr_email').val() == '') $('#rr_email').val('Bitte E-Mail-Adresse eingeben');
					$('#rueckruf_success').children('p').html(msg);
					$('#rueckruf_form_container').hide();
					$('#rueckruf_submit').hide();
					$('#rueckruf_success').show();
					$(xml).find('err').children().each(function() {
						var id = $(this).attr('id');
						$('#'+id).toggleClass('error');
					});
				} else {
					$('#rueckruf_success').html(msg);
					$('#rueckruf_form_container').hide();
					$('#rueckruf_submit').hide();
					$('#rueckruf_success').show();
				}
			}
		});
	});
	$('#rueckruf_back').click(function(){
		$('#rueckruf_form_container').show();
		$('#rueckruf_submit').show();
		$('#rueckruf_success').hide();
	});

	$('#newsletter_add_submit').click(function(){
		if ($('#newsletter_add_vorname').val() == 'Bitte Vornamen eingeben ...') $('#newsletter_add_vorname').val('');
		if ($('#newsletter_add_nachname').val() == 'Bitte Nachnamen eingeben ...') $('#newsletter_add_nachname').val('');
		if ($('#newsletter_add_firma').val() == 'Bitte Firma eingeben ...') $('#newsletter_add_firma').val('');
		if ($('#newsletter_add_email').val() == 'Bitte E-Mail-Adresse eingeben ...') $('#newsletter_add_email').val('');

		$('#newsletter_add_form').find('.error').toggleClass('error');

		$('#newsletter_add_error').hide();
		$('#newsletter_add_form').ajaxSubmit({
			url:$('#newsletter_add_form').attr('action'),
			dataType:'xml', 
			success:function (xml) {
				var err = $(xml).find('err').attr('value');
				var msg = $('msg',xml).text().replace(/\n/,"<br />");
				if (err == "1") {
					if ($('#newsletter_add_vorname').val() == '') $('#newsletter_add_vorname').val('Bitte Vornamen eingeben ...');
					if ($('#newsletter_add_nachname').val() == '') $('#newsletter_add_nachname').val('Bitte Nachnamen eingeben ...');
					if ($('#newsletter_add_firma').val() == '') $('#newsletter_add_firma').val('Bitte Firma eingeben ...');
					if ($('#newsletter_add_email').val() == '') $('#newsletter_add_email').val('Bitte E-Mail-Adresse eingeben ...');
					$('#newsletter_add_error').children('p').html(msg);
					$('#newsletter_add_error').show();
					$(xml).find('err').children().each(function() {
						var id = $(this).attr('id');
						$('#'+id).toggleClass('error');
					});
				} else {
					$('#newsletter_add_success').html(msg);
					$('#newsletter_add_form_container').hide();
					$('#newsletter_add_submit').hide();
					$('#newsletter_add_success').show();
				}
			}
		});
	});

	$('#newsletter_remove_submit').click(function(){
		if ($('#newsletter_remove_email').val() == 'Bitte E-Mail-Adresse eingeben ...') $('#newsletter_remove_email').val('');

		$('#newsletter_remove_form').find('.error').toggleClass('error');

		$('#newsletter_remove_error').hide();
		$('#newsletter_remove_form').ajaxSubmit({
			url:$('#newsletter_remove_form').attr('action'),
			dataType:'xml', 
			success:function (xml) {
				var err = $(xml).find('err').attr('value');
				var msg = $('msg',xml).text().replace(/\n/,"<br />");
				if (err == "1") {
					if ($('#newsletter_remove_email').val() == '') $('#newsletter_remove_email').val('Bitte E-Mail-Adresse eingeben ...');
					$('#newsletter_remove_error').children('p').html(msg);
					$('#newsletter_remove_error').show();
					$(xml).find('err').children().each(function() {
						var id = $(this).attr('id');
						$('#'+id).toggleClass('error');
					});
				} else {
					$('#newsletter_remove_success').html(msg);
					$('#newsletter_remove_form_container').hide();
					$('#newsletter_remove_submit').hide();
					$('#newsletter_remove_success').show();
				}
			}
		});
	});

	$('body').bind("click",function(e){
		$('div.select_box_entries').each(function(){
			if (!$(this).hasClass('none')) {
				if (!$(this).siblings('input.select_value').val()) $(this).siblings('div.select_box_button').children('a.select').text($(this).siblings('input.select_default').val());
				else $(this).siblings('div.select_box_button').children('a.select').text($(this).siblings('input.select_value').val());
				$(this).toggleClass('none');
			}
		});
	});

	$('a.select').each(function(){
		$(this).bind("click",function(e){
			e.stopPropagation();
			if ($(this).parent().siblings('div.select_box_entries').hasClass('none')) {
				if ($(this).text() != $(this).parent().siblings('input.select_default').val()) $(this).text($(this).parent().siblings('input.select_default').val());
			}
			$(this).parent().siblings('div.select_box_entries').toggleClass('none');
		})
	});
	$('a.select_entry').each(function(){
		$(this).bind("click",function(e){
			e.stopPropagation();
			$(this).parent().siblings('input.select_value').val($(this).text());
			$(this).parent().siblings('div.select_box_button').children('a.select').text($(this).text());
			$(this).parent().toggleClass('none');
		})
	});
}


function initMoveBoxContent(content){
	var newsList = content.find(".news_entry");
 	var newsTitle = newsList.children("a.news_title");
 	var newsText = newsList.children("div.news_text");

	newsTitle.bind("click",function(){
    	var link = $(this);
    	newsText.not(link.next()).hide();
    	newsTitle.not($(this)).removeClass("opened");
    	link.next().toggle();
    	link.toggleClass("opened");
 	});
}


function initProjectMoveBoxContent(content){
	content.find("div.img_toggle").each(function() {
	    var imgCon = $(this);
	    var firstImg = imgCon.find("img:eq(0)");
	    var secondImg = imgCon.find("img:eq(1)");
	    var link = $(this).children("a");

		imgCon.bind("mouseover",function() {
		    if(!imgCon.hasClass("selected")){
			    imgCon.removeClass("opacity")
	    		firstImg.hide();
	    		secondImg.show();
    		}
    	});

    	imgCon.bind("mouseout",function() {
    		if(!imgCon.hasClass("selected")){
    			secondImg.hide();
    			firstImg.show();
    		}
			if(imgCon.siblings().hasClass("selected")){
				imgCon.addClass("opacity")
			}
    	});

    	imgCon.bind("click",function() {
    		if(link.length != 0){ document.location = $(this).find("a").attr("href"); return false;}
    	});

	});
}


function loadFlash(el) {
	var swf = el['swf'];
	for (var i = 0; i < swf.length; i++) {
	    //var flashCon =$('#'+el['swf'][i]['id']);
		$('#'+el['swf'][i]['id']).flash({
			swf: el['swf'][i]['src'],
			wmode: 'transparent',
			width:el['swf'][i]['width'],
			height:el['swf'][i]['height'],
			play:el['swf'][i]['play'],
			flashvars: el['swf'][i]['flashvars']
			//callbackFn: playthis()
			}
		);
		//flashCon.flash( function() { this.GotoFrame(0);this.Play(); } );
	}
}

/*
function playthis() {
	var movie = $('#flash_185375797');
	movie.Play();

}
*/


