﻿function checkBrowserName(name){  
	var agent = navigator.userAgent.toLowerCase();  
	if (agent.indexOf(name.toLowerCase())>-1) {  
		return true;  
	}  
	return false;  
}  

function animateLayer(status){
	
	if (status == "on"){
		var contentheight = jQuery('#content').outerHeight();
		var footer = jQuery('#footer').outerHeight();
		var hauptnavigation = 24;
		
		var fullheight = hauptnavigation + contentheight - footer;
		jQuery('#layer_menu_hover').show();
		jQuery('#layer_menu_hover').height(fullheight);
	}
	if (status == "off"){
		var fullheight = 0;
		jQuery('#layer_menu_hover').hide();
		jQuery('#layer_menu_hover').height(fullheight);
	}
	return false;
} 

function gotoHash ( hash ) {
	var anchor = jQuery('h4[id="' + hash.replace(/#/g, '') + '"]');
	var realAnchor = jQuery('a[name="' + hash.replace(/#/g, '') + '"]');
	if (realAnchor.length > 0) {
		anchor = realAnchor;
	}
	if (anchor.length > 0) {
		var check = anchor.parents('div.accordion_content');
		if (check.length > 0) {
			var accordion = check.prev('h3.accordion_header');
			if (!accordion.hasClass('accordion_active')) {
				accordion.addClass('accordion_active');
				accordion.next('div.accordion_content').show();
			}
			
			var targetOffset = anchor.offset().top;
			jQuery('html,body').animate({scrollTop: targetOffset}, 0);
		}
	} else {
		var anchor = jQuery('h3[id="' + hash.replace(/#/g, '') + '"]');
		var check = anchor.next('div.accordion_content');
		if (check.length > 0) {
			if (!anchor.hasClass('accordion_active')) {
				anchor.addClass('accordion_active');
				anchor.next('div.accordion_content').show();
			}
			
			var targetOffset = anchor.offset().top;
			jQuery('html,body').animate({scrollTop: targetOffset}, 0);
		}
	}
}


jQuery.noConflict();

jQuery(document).ready(function () { 
	
	/*Navigation JavaScript*/
	
	jQuery('ul#menu_links').superfish({
	   	speed		: 'slow',
	   	delay		: 0,
	   	autoArrows	: false,
		dropShadows : false,
		animation:   {opacity:'show',height:'show'},
		onBeforeShow : function () {
			jQuery("li.level_0:not('.sfHover')").addClass('layer_inactive');
		},
		onHide : function () {			
			
		}
	});
	/*
	jQuery('ul#menu_links').superfish({
	   	speed		: 'normal',
	   	delay		: 500,
	   	autoArrows	: false,
		dropShadows : false,
		animation:   {opacity:'show',height:'show'}
	});
	*/
 
	/*Navigations animation mit Layer*/
	jQuery("li.level_0").hover(function() {	
		
		var status = "on";
		var contentheight = jQuery('#content').outerHeight();
		var footer = jQuery('#footer').outerHeight();
		var hauptnavigation = 24;
		var fullheight = hauptnavigation + contentheight - footer;
		
		//animateLayer(status);
		jQuery('#layer_menu_hover').show();
		jQuery('#layer_menu_hover').height(fullheight);
		jQuery("li.level_0:not('.sfHover')").addClass('layer_inactive');
	}, function(){
		
		var status = "off";
		//animateLayer(status);
		
		var fullheight = 0;
		jQuery('#layer_menu_hover').hide();
		jQuery('#layer_menu_hover').height(fullheight);
		jQuery("li.level_0:not('.sfHover')").removeClass('layer_inactive');
	});
	
	/*Navigation Border submenu_level1*/
	jQuery('div.subcol:eq(1)').addClass('subcolborder');
	jQuery('div.subcol:eq(4)').addClass('subcolborder');
	
	/*Accordion*/
	jQuery('div.accordion_content').hide();
	jQuery('div.accordionblock h3.accordion_header:first-child').addClass('accordion_first');
	jQuery('div.accordionblock h3.accordion_header:last').addClass('accordion_border_last');
	
	jQuery('h3.accordion_first').next('div.accordion_content').show();
	
	jQuery('div.accordionblock > h3').click(function (){
		jQuery(this).next('div.accordion_content').slideToggle('slow');
		
		if (jQuery(this).hasClass('accordion_active')){
			//alert('ist schon active');
			jQuery(this).removeClass('accordion_active');
		} else if (jQuery(this).hasClass('accordion_first')){
			//alert('ist die erste');
			jQuery(this).removeClass('accordion_first');
			jQuery(this).removeClass('accordion_active');
		}else{
			jQuery(this).addClass('accordion_active');
		}
		
		return false;
	});
	
	if (location.href.match(/search/i)) {
		jQuery('h3.accordion_header').click();
	}
	
	jQuery('a[href^="#"]').click(function() {
		gotoHash(jQuery(this).attr("hash"));
	});
	
	if (location.hash != '') {
		gotoHash(location.hash);
	}
	
	/*Suche*/
	jQuery('#searchTag').click(function (){
		jQuery("#search_quickfinder").show('slow');
		
		var searchTagColor = jQuery('#searchTag').attr('class');
		
		if (searchTagColor == 'searchTag_blue'){
			jQuery('#searchTag').addClass('searchTag_blue_active');
		}
		
		if (searchTagColor == 'searchTag_red'){
			jQuery('#searchTag').addClass('searchTag_red_active');
		}
		
		
		jQuery("#search_quickfinder").addClass('search_quickfinder_aktiv');
	});
	
	/*Print*/
	
	if (window.location.search == '?printReport=1'){
		jQuery('div.accordion_content').each(function (){
			jQuery('div.accordion_content').show();
			jQuery('h3.accordion_header').addClass('accordion_active');
		});
		
	}
	
	/* Links IE7 */
	jQuery('.link-line').hover(
		function() {jQuery(this).next('a').css('color', '#0291d5')},
		function() {jQuery(this).next('a').css('color', '')}
	);
	
	jQuery('.link-line').click(function() {
		window.location.href = jQuery(this).next('a').attr('href');
	});
});
	

