/*
* EGLV
* standard.js
*
* Date: June 2008 
* Rework: November 2009
*/

//window.onload = new Function("blurLinks();setHeight();"); //setContrastLink();

$(document).ready(function() {	
	
	$('#containerMain').css('min-height', $(window).height()-364 );
	
	$('#listIconSmall').click(function(){
		
		var $listContainer = $(this).parent().parent();
		$listContainer.removeClass('contentListExtended');
		$listContainer.find('.teaserBoxExtended').hide();

		
		if(!$(this).is(".active")){
				var newSrcSmall = $(this).attr('src').replace(".gif", "_act.gif");
				$(this).attr( 'src', newSrcSmall ).addClass("active");
				var newSrcExtended = $(this).next().attr('src').replace("_act.gif", ".gif");
				$(this).next().attr( 'src', newSrcExtended ).removeClass("active");
		}
	
		
	});
	
	$('#listIconExtended').click(function(){
		
		var $listContainer = $(this).parent().parent();
		$listContainer.addClass('contentListExtended');
		
		if(!$(this).is(".active")){
			var newSrcSmall = $(this).prev().attr('src').replace("_act.gif", ".gif");
			$(this).prev().attr( 'src', newSrcSmall ).removeClass("active");
			var newSrcExtended = $(this).attr('src').replace(".gif", "_act.gif");
			$(this).attr( 'src', newSrcExtended ).addClass("active");
		}
	});
	
	
	$('div.contentListC .teaserBox').each(function() {
	
		// Hide all with JS. People without JS can see everything.
		$(this).find('.teaserBoxExtended').hide();
		$(this).find('h2').removeClass('open');
	
		// Define H2 Hover
		$(this).find('h2').hover( 
			function() {
				$(this).addClass('hover');
			},
			function() {
				$(this).removeClass('hover');
			}
		);
		
		// Define H2 Click Function
		$(this).find('h2').click( function() {
			
			$(this).parent().parent().parent().removeClass('contentListExtended');
			
			$('div.contentListC .teaserBoxExtended').each(function() {
				$(this).hide();
			});
			$('div.contentListC .teaserBox h2').each(function() {
				$(this).removeClass('open');
			});
			
			$(this).addClass('open');
			//$(this).parent().next().show();
			$(this).parent().next().slideDown('fast', function(){
				$.scrollTo($(this).parent(),200);
			});
		});
		
	});
	

	$('div.contentListE .teaserBox').each(function() {
	
		// Hide all with JS. People without JS can see everything.
		$(this).find('.teaserBoxExtended').hide();
		$(this).find('h2').removeClass('open');
	
		// Define H2 Hover
		$(this).find('h2').hover( 
			function() {
				$(this).addClass('hover');
			},
			function() {
				$(this).removeClass('hover');
			}
		);
		
		// Define H2 Click Function
		$(this).find('h2').click( function() {
			
			$('div.contentListE .teaserBoxExtended').each(function() {
				$(this).hide();
			});
			$('div.contentListE .teaserBox h2').each(function() {
				$(this).removeClass('open');
			});
			
			$(this).addClass('open');
			//$(this).parent().next().show();
			$(this).parent().next().slideDown('fast', function(){
				$.scrollTo($(this).parent(),200);
			});
		});
		
		// Show First entry
		$('div.contentListE').each(function() {
			$(this).find('.teaserBox:first').find('.teaserBoxExtended').show();
			$(this).find('.teaserBox:first').find('h2').addClass('open');
		});
		
	});
	
	
	$('div.contentListG .teaserBox').each(function() {
	
		// Hide all with JS. People without JS can see everything.
		$(this).find('.teaserBoxExtended').hide();
		$(this).find('h2').removeClass('open');
	
		// Define H2 Hover
		$(this).find('h2').hover( 
			function() {
				$(this).addClass('hover');
			},
			function() {
				$(this).removeClass('hover');
			}
		);
		
		// Define H2 Click Function
		$(this).find('h2').click( function() {
										   
			$(this).parent().parent().parent().removeClass('contentListExtended');
			
			$('div.contentListG .teaserBoxExtended').each(function() {
				$(this).hide();
				//$(this).slideUp('fast');
			});
			$('div.contentListG .teaserBox h2').each(function() {
				$(this).removeClass('open');
			});
			
			$(this).addClass('open');
			//$(this).parent().parent().find('.teaserBoxExtended').show();
			$(this).parent().parent().find('.teaserBoxExtended').slideDown('fast', function(){
				$.scrollTo($(this).parent(),200);
			});
		});
		
	});
	
	
	
	$('.selectBox .optionBox').each(function() {
		// Define MouseOver Function on div.option
		$(this).find('.option').mouseover( function() {
			$(this).addClass('optionHover');
		});
		$(this).find('.option').mouseout( function() {
			$(this).removeClass('optionHover');
		});
	});

	$('.selectBox').hoverIntent({
		sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
		interval: 100, // number = milliseconds for onMouseOver polling interval    
		over: nothing, // function = onMouseOver callback (REQUIRED)    
		timeout: 200, // number = milliseconds delay before onMouseOut    
		out: closeSelectBox // function = onMouseOut callback (REQUIRED)    
	}).click(function(){
		$(this).toggleClass('selectBoxActive');
	}).find('.option').click( function() {
		var $thisClicked = $(this);
		var $thisOptionBox = $(this).parent();
		var $thisSelectBox = $(this).parent().parent();
		$thisSelectBox.find('.optionSelected').removeClass('optionSelected');
		$thisClicked.addClass('optionSelected');
		$thisSelectBox.find('.selected').text( $thisClicked.text() ).end()
	})
	function closeSelectBox(){
		$(this).removeClass('selectBoxActive');
	}
	function nothing(){ return true;}
	
	
	
	// Search Field Hover
	$('#searchTerm').focus(
		function() {
			if ( $(this).attr('value') == 'Suchbegriff' ) {
				$(this).attr('value','');
			}
		}
	);
	
	$('#searchTerm').blur(
		function() {
			if ( $(this).attr('value') == '' ) {
				$(this).attr('value','Suchbegriff');
			}
		}
	);
	
	
	// Pagination Button Hover
	$('.paginationBox img').hover(
		function(){
			var newSrc = $(this).attr('src').replace(".gif", "_hi.gif");
			$(this).attr( 'src', newSrc );
		},
		function(){
			var newSrc = $(this).attr('src').replace("_hi.gif", ".gif");
			$(this).attr( 'src', newSrc );
		}
	);
	
	$("a.iframe3").fancybox({
		'hideOnContentClick': false,
		'zoomOpacity' : true,
		'overlayShow' : true,
		'overlayOpacity' : 0.8,
		'padding' : 1,
		'frameWidth' : 800,
		'frameHeight' : 600
	});
	
	$("a.iframe2").fancybox({
		'hideOnContentClick': false,
		'zoomOpacity' : true,
		'overlayShow' : true,
		'overlayOpacity' : 0.8,
		'padding' : 1,
		'frameWidth' : 993,
		'frameHeight' : 590
	});
	
	$("a.iframe").fancybox({
		'hideOnContentClick': false,
		'zoomOpacity' : true,
		'overlayShow' : true,
		'overlayOpacity' : 0.8,
		'padding' : 0,
		'frameWidth' : 840,
		'frameHeight' : 600
	});

	$("a.lightbox").fancybox({
		'zoomOpacity' : true,
		'overlayShow' : true,
		'overlayOpacity' : 0.8,
		'padding' : 10,
		'zoomSpeedIn' : 500,
		'zoomSpeedOut' : 500
	});
	
	$("a.iframeextern").fancybox({
		'hideOnContentClick': false,
		'zoomOpacity' : true,
		'overlayShow' : true,
		'overlayOpacity' : 0.8,
		'padding' : 0,
		'frameWidth' : 840,
		'frameHeight' : 600
	});	
	
	
	$("a.iframepegel").fancybox({
		'hideOnContentClick': false,
		'zoomOpacity' : true,
		'overlayShow' : true,
		'overlayOpacity' : 0.8,
		'padding' : 0,
		'frameWidth' : 840,
		'frameHeight' : 1100
	});
/*
	$("#demo3 li").hoverIntent({
					sensitivity: 3, 
					interval: 200, 
					over: makeTall, 
					timeout: 500, 
					out: makeShort
				});
	*/
	
	function makeTall(){
		if ( $(this).find('ul')[0] ) {
			$(this).children('a').addClass('hover');
		}
		$(this).find('ul').show();
	}
	
	function makeShort(){
		$(this).children('a').removeClass('hover');
		$(this).find('ul').hide();
	}
	
	// Main Navigation FlyOut
	$('.navigationService').each(function(){
	
		$(this).find('li').hoverIntent({
						sensitivity: 5, 
						interval: 200, 
						over: makeTall, 
						timeout: 200, 
						out: makeShort
					})
					
					/*.mouseenter(function(){
						
						
							if ( $(this).find('ul')[0] ) {
								$(this).children('a').addClass('hover');
							}
							$(this).find('ul').show();
					});
		*/
	/*	$(this).find('li').hover(
			function(){
				if ( $(this).find('ul')[0] ) {
					$(this).children('a').addClass('hover');
				}
				$(this).find('ul').show();					   
			},
			function(){
				$(this).children('a').removeClass('hover');
				$(this).find('ul').hide();			   
			}
		);
		*/
	
	});
	
	
	$('.top p a').click(function(){
		$.scrollTo( '#container', 200 ); //, { easing:'elasout' }
		return false;
	});
	
	
	$('.contentListH a.audio').click(function(){
		$.scrollTo( '#container', 200 ); //, { easing:'elasout' }
		return false;
	});
	
	$('.contentListH a.video').click(function(){
		$.scrollTo( '#container', 200 ); //, { easing:'elasout' }
		return false;
	});
	
	$('.contentListH a.gallery').click(function(){
		$.scrollTo( '#container', 200 ); //, { easing:'elasout' }
		return false;
	});
	
	
	/*Labels*/
	/*
	$('.detailFormD fieldset input[type=text]').each(function(){
	
		var thisLabel = $(this).parent().prev().find('label').text();
		$(this).attr( 'value', thisLabel );
		
		$(this).focus(function(){
			if ( $(this).attr('value') == thisLabel ) $(this).attr('value','');
		});
		
		$(this).blur(function(){
			if ( $(this).attr('value') == '' ) $(this).attr('value', thisLabel );
		});
	
	});
	
	
	$('.detailFormD fieldset textarea').each(function(){
	
		var thisLabel = $(this).parent().prev().find('label').text();
		$(this).attr( 'value', thisLabel );
		
		$(this).focus(function(){
			if ( $(this).attr('value') == thisLabel ) $(this).attr('value','');
		});
		
		$(this).blur(function(){
			if ( $(this).attr('value') == '' ) $(this).attr('value', thisLabel );
		});
	
	});*/
	
	
});