function globalfunctions(){
	// Variable, die angibt, ob der Internet-Explorer 6 benutzt wird
	var ie6 = (jQuery.browser.version < 7 && jQuery.browser.msie);
	//alert(jQuery.browser.msie);
	// wird auf jeder Seite ausgeführt
	//alert("Globale Funktionen");
	//Ausblenden bzw. Einblenden der Elemente in Abhängigkeit von Javascript
	
	jQuery('.explodemainpoint').removeClass('explodemainpointscriptless');
	jQuery('.explodemainpoint').removeClass('explodeactivescriptless');
	// Sicherstellen, dass realBody eingeblendet wird nachdem er auf Seiten ausgeblendet wurde
	jQuery('#realBody').fadeIn(5200,function(){});
	jQuery('.logobox').wrap('<a href="index.php"></a>');
	jQuery('a.mainnavielement, a.explodenavielement').each(function(){
		if(jQuery(this).attr('target')!='_blank' && jQuery(this).attr('target')!='_parent' && !jQuery(this).hasClass("linksOk")){
			var temp = jQuery(this).attr('href');
			jQuery(this).addClass("linksOk");
				jQuery(this).click(function(){
					//alert('dd');
					jQuery('#realBody').fadeOut(1000,function(){
					jQuery('.top-sec').fadeOut(1000);
					jQuery('.mid-sec').fadeOut(1000);
					jQuery('.bot-sec').fadeOut(1000);
//					jQuery('.top-sec').animate({'width':'0px'},1000,function(){

						jQuery('#bgimage-target').fadeOut(1000,function(){
							//alert(temp);
							location.href= temp;
							//location.replace(temp);
							//window.location = temp;
						});
				});
			});
		}
		jQuery(this).removeAttr('href');
	});
}

function buildLinks(targetID){
	jQuery(targetID+' a').each(function(){
		
		jQuery(this).css("cursor", "pointer");
		// Linkmanipulation soll nur angewendet werden, wenn es ein interner Link ist	
		if(jQuery(this).attr('target')!='_blank' && jQuery(this).attr('target')!='_parent' && !jQuery(this).hasClass("linksOk")){
			var temp = jQuery(this).attr('href');
			jQuery(this).addClass("linksOk");
			
			jQuery(this).click(function(){
				jQuery('.scroll').css({'margin-left':'1px'});
				jQuery('.scroll').animate({'width':'0px'},1000,function(){
					jQuery('#realBody').fadeOut('fast',function(){
				
						jQuery('#bgimage-target').fadeOut(1000,function(){
							//alert(temp);
							location.href= temp;
							//location.replace(temp);
							//window.location = temp;
						});
					});

				});
			});
			jQuery(this).removeAttr('href');
		}
		
	});
	
}

function buildIndexSiteLinks(targetID){
	jQuery(targetID+' a').each(function(){
		
		jQuery(this).css("cursor", "pointer");
		// Linkmanipulation soll nur angewendet werden, wenn es ein interner Link ist	
		if(jQuery(this).attr('target')!='_blank' && jQuery(this).attr('target')!='_parent' && !jQuery(this).hasClass("linksOk")){
			var temp = jQuery(this).attr('href');
			jQuery(this).addClass("linksOk");
			
			jQuery(this).click(function(){
				var clickedId = jQuery(this).parent().attr('id');
				//jQuery(this).parent().offset().top;
				//setTeaserPosFixed('.explodeindexmainpoint');
				var leftPos = 0;
				var animationSpeed = 1000;
				var reduceSpeed = 90;
				for(var i = 1; i<5 ; i++){
					if(clickedId != 'explodeindexelement'+i){
						
						jQuery('#explodeindexelement'+i).animate({'left':'-'+leftPos+'px'},animationSpeed);
						jQuery('#explodeindexelement'+i+' a').hide();
						leftPos = leftPos + 14;	
						animationSpeed = animationSpeed - reduceSpeed;
					}else{
						jQuery('#explodeindexelement'+i).animate({'left':'-42px'},animationSpeed);
						jQuery('#explodeindexelement'+i).addClass('explodeindexmainpointactive');
						animationSpeed = animationSpeed - reduceSpeed;
						//alert('clicked: '+i);
					}
					
					
					
				}
				
				jQuery('.explodenaviindexwrapper').animate({'top':'0px'},1000);
					jQuery('.explodeindexmainpoint').animate({'top':'0px'},1000,function(){
						jQuery('#realBody').fadeOut('fast',function(){				
							jQuery('#bgimage-target').fadeOut(1000,function(){
								//alert(temp);
								location.href= temp;
								//location.replace(temp);
								//window.location = temp;
							});
						});
					});
								
				

				
					
			});
			jQuery(this).removeAttr('href');
		}
		
	});
	
}


function backLinkToReferenzPreview(targetID){
	jQuery(targetID+' a').each(function(){
		
		jQuery(this).css("cursor", "pointer");
		// Linkmanipulation soll nur angewendet werden, wenn es ein interner Link ist	
		if(jQuery(this).attr('target')!='_blank' && jQuery(this).attr('target')!='_parent' && !jQuery(this).hasClass("linksOk")){
			//alert(jQuery(this).attr('target'));
			var temp = jQuery(this).attr('href');
			jQuery(this).addClass("linksOk");
			
			jQuery(this).click(function(){
				jQuery('.projektdetailsTextBox').animate({'width':'0px'},1000,function(){
					jQuery('#realBody').fadeOut('fast',function(){
				
						jQuery('#bgimage-target').fadeOut(1000,function(){
							//alert(temp);
							location.href= temp;
							//location.replace(temp);
							//window.location = temp;
						});
					});

				});
			});
			jQuery(this).removeAttr('href');
		}
		
	});
}

function replacelinktext(text){
	var newtext = text.replace(/\//g,"-");
	var newtext = newtext.replace(/ /g,"_");	
	//alert(newtext);
	return newtext;
}
function sliderLinkAction(targetID){
	jQuery(targetID+' a').each(function(){
		jQuery(this).css("cursor", "pointer");
		jQuery(this).mouseup(function(){
			//alert('projektdetails.php?bildbau-projekt='+jQuery('#handle_speed').attr('aria-valuetext')+'/'+jQuery('#handle_speed').attr('aria-valuenow'));
			//alert();
			var temp = 'projektdetails.php?bildbau-projekt='+replacelinktext(jQuery('#handle_speed').attr('aria-valuetext'))+'/bildbau/'+jQuery('#listidentifier_'+jQuery('#handle_speed').attr('aria-valuenow')).attr('value');
			jQuery('.projektdetailsTextBox').animate({'width':'0px'},1000,function(){
					jQuery('#realBody').fadeOut('fast',function(){
				
						jQuery('#bgimage-target').fadeOut(1000,function(){
							//alert(temp);
							location.href= temp;
							//location.replace(temp);
							//window.location = temp;
						});
					});

				});
			
			
		});
		
		jQuery(this).removeAttr('href');
	});
}

function handPosition(){
	jQuery('#hand').css({
		'left':window.event.x-118,
		'top':window.event.y-36
	})
}

function showHand(){

	handPosition();
	//jQuery('#hand').fadeIn(200,function(){
	//	jQuery('#hand').fadeOut(200);
	//});
	jQuery('#hand').show();
	jQuery('#hand').animate({
		'width':'269px',
		'height':'599px'
	},100,function(){
		jQuery('#hand').animate({
			'width':'200px',
			'height':'450px'
		},100,function(){
			jQuery('#hand').hide(100);
		})
	});
	
}

function resizeActionSmall(){
	$(window).resize(function() {
  		jQuery('#values-target').html(jQuery('#currentFile').html());
  		if(jQuery(window).height()>450){
			jQuery('#values-target').html('zuklein');
			location.href= '../'+jQuery('#currentFile').html();
		}

	});

}


function resizeAction(){
	$(window).resize(function() {
  		jQuery('#values-target').html(jQuery('#currentFile').html() );
  		if(jQuery(window).height()<450){
			jQuery('#values-target').html('zuklein');
			location.href= 'small/index.php?redi='+jQuery('#currentFile').html();
		}
  		setSectionDimensions();
  		setsliderposition();
  		setkontaktbackgroundposition()
	});

}

function resizeActionIndex(){
	$(window).resize(function() {
  		//setSectionDimensionsIndex();
  		setTransLayerHeight();
	});

}

function setSectionDimensions(){
	setTopSectionHeight();
  	setMidSectionHeight();
  	//alert(jQuery('#currentFile').html());
  	if(jQuery('#currentFile').html()!="projektdetails.php"){
  		setBotSectionHeight();
  	}
  	
  	setkontaktbackgroundposition()
}

function setSectionDimensionsIndex(){
	setTopSectionHeightIndex();
  	setMidSectionHeightIndex();
  	setBotSectionHeightIndex();
}

function setTopSectionHeight(){
	var topSecHeight = jQuery(window).height()/100*25;
	var topSecPosTop = 0;
	jQuery('.top-sec').css({
		'height':topSecHeight+'px',
		'top':topSecPosTop+'px'
	});
}

function setMidSectionHeight(){
	var midSecHeight = jQuery(window).height()/100*55;
	var midSecPosTop = jQuery(window).height()/100*25;
	jQuery('.mid-sec').css({
		'height':midSecHeight+'px',
		'top':midSecPosTop+'px'
	});
}


function setTransLayerHeight(){
	var midcontentheight = jQuery('.mid-contentbox').height();
	var windowheight = jQuery(window).height();
	var percentval = ((midcontentheight+41)*100)/windowheight;
	jQuery('.transparent').css({'height':percentval+'%'});
}

function setBotSectionHeight(){
	var botSecHeight = jQuery(window).height()/100*20;
	var botSecPosTop = jQuery(window).height()/100*80;
	jQuery('.bot-sec').css({
		'height':botSecHeight+'px',
		'top':botSecPosTop+'px'
	});
}

/* Resize für Startseite */
function setTopSectionHeightIndex(){
	var topSecHeightIndex = jQuery(window).height()/100*20;
	var topSecPosTopIndex = 0;
	jQuery('.top-sec').css({
		'height':topSecHeightIndex+'px',
		'top':topSecPosTopIndex+'px'
	});
}

function setMidSectionHeightIndex(){
	var midSecHeightIndex = jQuery(window).height()/100*60;
	var midSecPosTopIndex = jQuery(window).height()/100*20;
	jQuery('.mid-sec').css({
		'height':midSecHeightIndex+'px',
		'top':midSecPosTopIndex+'px'
	});
}

function setBotSectionHeightIndex(){
	var botSecHeightIndex = jQuery(window).height()/100*10;
	var botSecPosTopIndex = jQuery(window).height()/100*90;
	jQuery('.bot-sec').css({
		'height':botSecHeightIndex+'px',
		'top':botSecPosTopIndex+'px'
	});
}

function setsliderposition(){
	var midSecHeight = jQuery('.mid-sec').height();
	var sliderHeight = jQuery('#slider-one').height()
 	var marginTop = ((midSecHeight-sliderHeight)/2);
	var topSecHeightIndex = jQuery(window).height()/100*60;
	var midSecPosTopIndex = jQuery(window).height()/100*20;
	jQuery('#wrapper').css({
		'border':'0px solid green',
		'top': marginTop+'px'
	});
}

function setkontaktbackgroundposition(){
	var topSecHeightIndex = jQuery(window).height()*0.25;
	var topSecWidth = jQuery('.top-sec').width();
	var posBreakLine = topSecWidth*0.3;
	
	//alert(topSecHeight);
	//jQuery('#values-target').html(topSecHeightIndex);
	var marginTop = (topSecHeightIndex-150);
	//var topSecHeightIndex = jQuery(window).height()/100*60;
	//var midSecPosTopIndex = jQuery(window).height()/100*20;
	jQuery('.kontaktbackground').css({
		'border':'0px solid green',
		'top': marginTop+'px',
		'left':(posBreakLine-325)+'px'
	});
}

function activateSubnavButton(idelement){
	//alert(jQuery('.subnaviactive').length);
	if (jQuery('.subnaviactive').length > 0 ){
			jQuery('.subnaviactive').animate({'margin-top':'25px'},function(){
				jQuery('.subnaviactive').removeClass('subnaviactive');
				jQuery('#'+idelement).addClass('subnaviactive');
				jQuery('#'+idelement).animate({'margin-top':'10px','height':'30px'});

		})
	}else{
		jQuery('#'+idelement).addClass('subnaviactive');
		jQuery('#'+idelement).animate({'margin-top':'10px','height':'30px'});
	}

	
}


function checkBackgroundImageKontakt(status){
	if(status=="anfahrt"){
		jQuery('#kontaktactivebox').animate({
			'top':'19px',
			'left':'213px'
		});
	}else if(status=="bewerbung"){
		jQuery('#kontaktactivebox').animate({
			'top':'27px',
			'left':'113px'
		});
	}else if(status=="formular"){
		jQuery('#kontaktactivebox').animate({
			'top':'37px',
			'left':'2px'
		});
	}	


	/* jQuery('#kontaktbackground').html('<img src="images/kontakt/bb_back_'+status+'.png" alt="bb_kontakt_beige" width="878" height="689" />'); */
}




function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


