$(document).ready(function(){		
		
	$('#navimap-image').data('zsEntwicklungshilfe','Zukunftsstiftung Entwicklungshilfe');
	$('#navimap-image').data('zsLandwirtschaft','Zukunftsstiftung Landwirtschaft');
	$('#navimap-image').data('zsBildung','Zukunftsstiftung Bildung');
	$('#navimap-image').data('zsSozialesLeben','Zukunftsstiftung Soziales Leben');	
	$('#navimap-image').data('zsGesundheit','Zukunftsstiftung Gesundheit');

	$('#navimap-image').data('dachstiftung','Dachstiftung für individuelles Schenken');
	$('#navimap-image').data('studienfoerderung','Studienförderung');
	$('#navimap-image').data('sNeueEnergie','Stiftung<br />Neue Energie');
	$('#navimap-image').data('foerderfondsDirekt','Förderfonds Direkt');
		
	if($('#kooperationskreis').length) { // only on page with container #kooperationsImage
	
	    function hideHoverLayer (){
			$('#kooperationskreis area').each(function() { 
				currentId = $(this).attr('id'); 
				$('#hover-'+currentId).fadeOut('fast');
			
			});
		}
		function hideKooperationText () {
			$('#c1529').parent('div').hide();
			$('#c1530').parent('div').hide();
			$('#c1531').parent('div').hide();
		}
		hideKooperationText();

		$('#page').append('<div id="kooperationDynText" style="display:none;"></div>');
		
		/*
		 * kooperationsImageMap Über uns/Kooperationen
		 * dynamic hover images and texts 
		 */		 
		 function hoverIntOver(){
			// * hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
			
			// Do not show an earlier layer! Hide all of them here and not on hoverIntOut
			// So there is no timeout needed!
			hideHoverLayer();
			// Hide and remove kooperationDynText (and not on HoverInt)
			if($('#kooperationDynText').html()){
				// console.log('HTML');
				$('#kooperationDynText').fadeOut('fast');
				$('#kooperationDynText').empty();
			}			
			var currentHref = $(this).attr('href'); 
			var currentId = $(this).attr('id');
			if (currentHref.match(/#/)) {
        		var url    = currentHref.split('#')[0];		
        		var currentAnchor = currentHref.replace(url,'');
			}
			var currentContainer = $(currentAnchor).parent('div');
			// console.log(currentId, currentAnchor);
			$('#hover-'+currentId).fadeIn('fast');
			
			var dynText = currentContainer.html();
			// console.log(dynText);
			$('#kooperationDynText').append(dynText).attr({class: currentId});
			$('#kooperationDynText').fadeIn('fast');
            // console.log($(this).attr('hoverIntent_s'),'Attr_s');
		 }
		 function hoverIntOut() {
			 
			/* var currentId = $(this).attr('id'); 
			$('#hover-'+currentId).fadeOut('fast');
			
			if($('#kooperationDynText').html()){
				$('#kooperationDynText').fadeOut('fast');
				$('#kooperationDynText').empty();
			}*/	
		}		 
		 var hoverIntConfig = {    
			 sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
			 interval: 50, // number = milliseconds for onMouseOver polling interval    
			 over: hoverIntOver, // function = onMouseOver callback (REQUIRED)    
			 timeout: 0, // number = milliseconds delay before onMouseOut    
			 out: hoverIntOut // function = onMouseOut callback (REQUIRED)    
		};	
			
		 
		$('#kooperationsImage').removeAttr( 'usemap' );
		var imgPath = 'layout/gls-treuhand/img/';
		var image_trans = '<img src="'+imgPath+'kooperation_trans.gif" usemap="#kooperationsImageMap" id="kooperationsImage-translayer" />';	
		var hi = ''; //hover-images
		$('#kooperationskreis area').each(function() { 
			var currentId = $(this).attr('id'); 
			hi += '<img style="display: none;" src="'+imgPath+currentId+'_on.gif" id="hover-'+currentId+'" />';				   
		});
		// layers: first #navimap-image, than hover-image-containers, than #navimap-translayer
		var dynamicmap_elements = hi+image_trans;
		$('#kooperationsImage').after(dynamicmap_elements);		
		
		 // NO hover effect!, because if fadeIn is ready, it is a mouseoute effect!!!	 
		 $('#kooperationskreis area').hoverIntent(hoverIntConfig);
		 
		$('#kooperationDynText').hover(
			function(){
				/*
				var currentPartId = $(this).attr('class');				
				
				// clearTimout to see allways the active area
				clearTimeout($('#'+currentPartId).attr('hoverIntent_t'));
				$('#'+currentPartId).removeAttr('hoverIntent_t');
				$('#'+currentPartId).removeAttr('hoverIntent_s');
				$('#hover-'+currentPartId).show();
				// setTimeout("$('#hover-"+currentPartId+"').show()", 100);
			    // hoverTimeout = setTimeout("$('#hover-"+currentPartId+"').show()", 200);#
				*/
			},
			function(){	
				var currentPartId = $(this).attr('class');				
				//console.log(currentPartId);		
			    $('#hover-'+currentPartId).fadeOut('fast');
				$('#kooperationDynText').fadeOut('fast');
			});
	
	} // only on page with #kooperationskreis container	
	
	
	if($('#themen-navigation').length) { // only on page with container #navimap-image
	
		/*
		 * navimap Themen und Zukunftsstiftungen
		 * dynamic hover images and texts 
		 */		 
		 function hoverIntOver(){
			var currentId = $(this).attr('id'); 
			//alert(currentId);
			$('#hover-'+currentId).fadeIn('fast');	
			$('#htext').hide();
			// $('#htext').fadeOut('fast');	
			$('#htext').attr('class',currentId);	
			$('.'+currentId).html($('#navimap-image').data(currentId));
			 $('.'+currentId).fadeIn();
			 //$('.'+currentId).show();
		 }
		 function hoverIntOut() {
			var currentId = $(this).attr('id'); 
			//alert(currentId);
			$('#hover-'+currentId).fadeOut('fast');
			// $('.'+currentId).fadeOut('fast');
			 $('.'+currentId).hide();
		}
		 
		 var hoverIntConfig = {    
			 sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
			 interval: 50, // number = milliseconds for onMouseOver polling interval    
			 over: hoverIntOver, // function = onMouseOver callback (REQUIRED)    
			 timeout: 50, // number = milliseconds delay before onMouseOut    
			 out: hoverIntOut // function = onMouseOut callback (REQUIRED)    
		};
	
		 
		$('#navimap-image').removeAttr( 'usemap' );
		var imgPath = 'layout/gls-treuhand/img/';
		
		var image_trans = '<img src="'+imgPath+'themenkreis_trans.gif" usemap="#navimap" id="navimap-translayer" />';	
		var hi = ''; //hover-images
		$('#themen-navigation area').each(function() { 
			var currentId = $(this).attr('id'); 
			hi += '<img style="display: none;" src="'+imgPath+currentId+'_on.jpg" id="hover-'+currentId+'" />';				   
		});
		// layers: first #navimap-image, than hover-image-containers, than #navimap-translayer
		var dynamicmap_elements = hi+image_trans;
		$('#navimap-image').after(dynamicmap_elements);		
		
		$('#themen-navigation').append('<div id="htext"></div>');
		$('#htext').hide();
		//no $('#themen-navigation .hc').attr('id','hc');
		 // NO hover effect!, because if fadeIn is ready, it is a mouseoute effect!!!	 
		 $('#themen-navigation area').hoverIntent(hoverIntConfig);
	
	} // only on page with #themen-navigation container
						
});