/* ---------------------------*/
/* ready -------------*/
/* ---------------------------*/
		var current = 0;	
		 var maxi;
		 var interval;

$(document).ready(function () {
							
 //-----------------//
 //akkordeon -------//
 //-----------------//
 
 if(  $(".karriere_akkordeon").length > 1 ){
	
	$(".karriere_akkordeon").each(function(i){
			   
		var shorttext = trim( $(this).children('.karriere_container').children('.karriere_longtext').children('.karriere_longtext_content').children('p').text().substring(0, 300) );
		if( shorttext.length != 0 ){ shorttext +=' ...   <img src="_img/news/mehr_infos.jpg" alt="mehr Infos" class="karriere_float_right_news"/>'; }
		// insert shortext into the specific html-tag
		$(this).children('.karriere_container').children('.karriere_shorttext').children('.karriere_paragraph').html( shorttext );
	
	 });
	 $(".karriere_akkordeon").click(function(){
		 if (interval)
		 { window.clearInterval(interval);
		 current = 0;}
		 
		 if( $(this).hasClass('karriere_active_akkordeon') ){			
				var shorttextheight = $(this).children('.karriere_container').children('.karriere_shorttext').height();					
				
				if (BrowserDetect.browser == 'Explorer'){ 
                    $(this).children('.karriere_container').children('.karriere_longtext').hide();
				}else {
					$(this).children('.karriere_container').children('.karriere_longtext').fadeOut(300);
                }
					
			$(this).children('.karriere_container').animate({
						height: shorttextheight + 'px'
						 }, 1000, 'swing', function() {
                         
                         
                         if (BrowserDetect.browser == 'Explorer'){ 
                    $(this).children('.karriere_shorttext').show();
                 }else{
                   $(this).children('.karriere_shorttext').fadeIn( 500 );
                 }

						//$(this).children('.karriere_shorttext').fadeIn( 500 );
						$('.karriere_active_akkordeon').removeClass('karriere_active_akkordeon');
		
			});				
				//$(this).children('.karriere_container').children('.karriere_longtext').css('opacity', '0');
	
				//$(this).removeClass('active_akkordeon');
				
		 }else{		 
					 
			 if( $('.karriere_active_akkordeon').length > -1 ){
				//aktive Akkordeon-Box schlie&szlig;en
				 var shorttextheight = $('.karriere_active_akkordeon').children('.karriere_container').children('.karriere_shorttext').height();
				 
				 
                if (BrowserDetect.browser == 'Explorer'){ 
				$('.karriere_active_akkordeon').children('.karriere_container').children('.karriere_longtext').hide();	
				
				}else {
                $('.karriere_active_akkordeon').children('.karriere_container').children('.karriere_longtext').fadeOut(300);	
					}

				$('.karriere_active_akkordeon').children('.karriere_container').animate({
					height: shorttextheight + 'px'
					 },1000, 'swing', function() {		
                if (BrowserDetect.browser == 'Explorer'){ 
                    $(this).children('.karriere_shorttext').show();
                 }else{
                   $(this).children('.karriere_shorttext').fadeIn( 500 );
                 }

                                        					
					
					$('.karriere_active_akkordeon').removeClass('karriere_active_akkordeon');
						
			 });	
				//$('.karriere_active_akkordeon').children('.karriere_container').children('.karriere_longtext').css('opacity', '0');
			
				
				
			 }
			 
			 
			  //neue Akkordeon-Box &ouml;ffnen	
			 $(this).children('.karriere_container').children('.karriere_longtext').css('display', 'block');
			 var textheight = $(this).children('.karriere_container').children('.karriere_longtext').height();
			 $(this).children('.karriere_container').children('.karriere_longtext').css('display', 'none');	
			
			maxi = $('.karriere_slides').length;
			
			if (maxi > 1){
			interval = window.setInterval("slidephotos()", 4000);
			 }
             
             if (BrowserDetect.browser == 'Explorer'){ 
                    $(this).children('.karriere_container').children('.karriere_shorttext').hide();
				 $(this).addClass('karriere_active_akkordeon');

             }else {
					$(this).children('.karriere_container').children('.karriere_shorttext').fadeOut(300, function(){
				 $(this).parent().parent().addClass('karriere_active_akkordeon');
			 });
                }
			 	
			
			
			 $(this).children('.karriere_container').animate({
				 height: textheight+'px'//100 ... padding oder margin im content-bereich
			 },1000, 'swing', function(){			 
				                 
                 if (BrowserDetect.browser == 'Explorer'){ 
                    $(this).children('.karriere_longtext').show();
                 }else{
                    $(this).children('.karriere_longtext').fadeIn( 500 );
                 }
                 $(this).css('height', 'auto');
			
			 });
	 	}
	});
	 
 }else{
	//	alert('only one akkordeon');
	$('.karriere_akkordeon').addClass('karriere_active_akkordeon');
	$('.karriere_akkordeon').children('.karriere_container').children('.karriere_shorttext').css('display','none'); 
	$('.karriere_akkordeon').children('.karriere_container').children('.karriere_longtext').css('display','block'); 

 }
	
});
function trim(s)
{
	var l=0; var r=s.length -1;
	while(l < s.length && s[l] == ' ')
	{	l++; }
	while(r > l && s[r] == ' ')
	{	r-=1;	}
	return s.substring(l, r+1);
}


function slidephotos()
{
	
	if (current == maxi-1)
			 { 
			 
			$("#bild"+current).removeClass('karriere_float_news');
			$("#bild"+current).addClass('karriere_display_none');
			$("#bild0").removeClass('karriere_display_none');
			$("#bild0").addClass('karriere_float_news');
            current =0;
			 }
    else{ 
			$("#bild"+current).removeClass('karriere_float_news');
			$("#bild"+current).addClass('karriere_display_none');
			$("#bild"+(current+1)).removeClass('karriere_display_none');
			$("#bild"+(current+1)).addClass('karriere_float_news');
			current++;
    }
}

