jQuery.noConflict();

jQuery(document).ready(function($){

	
	/* Scrollpane */
	
	//jQuery('#inhalt').jScrollPane({showArrows: true});
	
	
	/* Hauptnavigation */
	
	// array fuer die originalen Hintergrundbilder
	var original_bg = new Array();
	
	// zweite navigationsebene verstecken
	jQuery('#accordion').find('div.navi_element').find('ul.second').hide();
	
	// wenn das navi-element aktiv ist, dann die zweit Ebene anzeigen
	jQuery('#accordion').find('div.navi_active').find('ul.second').show();
	
	// wenn man mit der Mouse ueber eine Navi-Zeile faehrt
	jQuery('#accordion').find('div.navi_element').mouseover(function(){
	
		var nav = jQuery(this);
	
		show_second(nav, 'show');
			
	});
	
	// wenn man mit der Mosue die Navi-Zeile verlaesst
	jQuery('#accordion').find('div.navi_element').mouseout(function(){
	
		var nav = jQuery(this);
	
		show_second(nav, 'hide');
			
	});
	
	
	jQuery('#accordion').find('div.navi_element').find('ul').find('li.no').find('a').mouseover(function(){
	
		var a = jQuery(this);
	
		var punkt = a.find('span.text').html();
	
		punkt = punkt.toLowerCase().replace(' ', '_');
		punkt = punkt.replace('&amp;', '');
	
		
		//src = a.find('span.no').find('img').attr('src');
		// das bild austauschen
		//a.find('span.no').find('img').attr('src', 'fileadmin/template/insight_out/images/nav_' + punkt + '_a.png');
		
		a.find('span.act').css('display', 'block');
		a.find('span.no').css('display', 'none');
		
	
	}); 
	
	
	jQuery('#accordion').find('div.navi_element').find('ul').find('li.no').find('a').mouseout(function(){
	
		var a = jQuery(this);
	
		var punkt = a.find('span.text').html();
	
		punkt = punkt.toLowerCase().replace(' ', '_');
		punkt = punkt.replace('&amp;', '');
		// das bild austauschen
		//a.find('span.no').find('img').attr('src', 'fileadmin/template/insight_out/images/nav_' + punkt + '.png');
	
		a.find('span.act').css('display', 'none');
		a.find('span.no').css('display', 'block');
		
		
		
	
	}); 
	
	
	
	function show_second (nav, action) {
	
		var ori_bg = nav.css('background-image');
		var nav_id = nav.attr('id');
		
		//if (ori_bg.indexOf('mouseover_navi.png') == -1)
		if (action == 'show')
		{
			//alert(ori_bg);
		
			if(!nav.hasClass('navi_active'))
			{
				/*
				var tmp = ori_bg.split( '/' );
				tmp.pop();
				*/
				
				element = nav_id + ':' + ori_bg;
			
				//alert(element);
			
				original_bg.push(element);
								
				//nav.css('background-image', tmp.join( '/' ) + '/mouseover_navi.png")');
				nav.css('background-image', 'url("fileadmin/template/insight_out/images/mouseover_navi.png")');
			
				nav.find('img.navi_image').attr('src', nav.find('img.navi_image').attr('src').replace('.png', '_a.png'));
					
				nav.find('ul.second').show();
			}
		}
		
		if (action == 'hide')
		{
			// wenn die Navi-Zeile aktiv ist (die zweite Ebene nicht ausblenden beim verlassen und nicht den Hintergrund tauschen)
			if(!nav.hasClass('navi_active'))
			{
				var background = '';
			
				for (i = 0; i < original_bg.length; i++)
				{
					if (original_bg[i].indexOf(nav_id) != -1)
					{
						background = original_bg[i].replace(nav_id + ':', '');
						original_bg[i] = '';
					}
				}
			
				nav.css('background-image', background);
				nav.find('img.navi_image').attr('src', nav.find('img.navi_image').attr('src').replace('_a.png', '.png'));
			
				nav.find('ul.second').hide();
			}
			
		}
	
	}
	
	
	/* Pressenavigation */
	
	jQuery('#pressnavigation').css({display: 'none', left: 'auto'});
	
	jQuery('#press_link').click(function(){
	
		var pl = jQuery(this);
	
		var img_src = pl.find('img').attr('src');
		
		if (img_src.indexOf('nav_top_press_a') == -1)
		{
			pl.find('img').attr('src', img_src.replace('.gif', '_a.gif'));
			jQuery('#pressnavigation').slideDown();
		}
		else
		{
			pl.find('img').attr('src', img_src.replace('_a.gif', '.gif'));
			jQuery('#pressnavigation').slideUp();
		}
		
	
		return false;
		
	});

});