





$.fn.accordeon_menu = function() {

	this.find(".accordeon_item").each( function(index) {
	
		var item = $(this);
		
		item.content = $(".accordeon_content", item);
		//item.content_o1 = $(".accordeon_content", item).not( ".accordeon_content:first", item );
		item.content.height = Math.max( item.content.outerHeight(), ( $(".accordeon_foto", item).height() || 0 ) );
		item.content.css({ overflow: 'hidden', height: '0' });
		
/* 		alert(index); */
		if(index=='0') {
		item.addClass("open");
		item.content.animate({ height: item.content.height }, 400);
		}
		
		item.link = $("a.accordeon_title", item);
		item.link = $("a.accordeon_title", item);
		
		item.link.bind("click", function() {
			
						if(item.hasClass("open")) {
							item.content.animate({ height: 0 }, 400);
							item.removeClass("open");
						} else {	
							$(".open").find(".accordeon_content").animate({ height: 0 }, 400);
							$(".open").removeClass("open");
							item.content.animate({ height: item.content.height }, 400);
							item.addClass("open");
						}
							return false;
							
					});
			
		
		});
	
	
	
	return this;
	
	}
	
	
	
	
	
	
	
	$.fn.mouseoverscroll = function() { // -----------------------------------------------------------------

	
			return this.each(function() {
		    
		    //Get our elements for faster access and set overlay width
		    var div = $(this),
		    	ul = $('ul.sc_menu', this),
		    	ulPadding = 15;
		    
		    //Get menu width
		    var divWidth = div.width();
		
		    //Find last image container
		    lastLi = div.find('li:last-child');
			var anz = div.find('li').length;
			var ulWidth = /* lastLi[0].offsetLeft +  */ anz * lastLi.outerWidth() + ulPadding;

		    ul.css({ width: ulWidth });
			
			//alert(ulWidth);

		    //Remove scrollbars
		    div.css({overflow: 'hidden'});
		    
			var aktuellePos = 0;
		
		    //When user move mouse over menu
		    div.mousemove(function(e){
		    	
		    	//As images are loaded ul width increases,
		    	//so we recalculate it each time
		    	
		    	var posleft = (e.pageX - $(this).offset().left) * (ulWidth - divWidth) / divWidth - 5 - aktuellePos/2;
		    	$(this).scrollLeft(posleft);
		    	
		    	//ul.animate({ left: -ulWidth }, 0);
		    })
		    //div.mouseenter( function(e) { div.stop(); /* aktuellePos = $(this).scrollLeft() + e.pageX; */ } ).mouseleave(function() { autoscroll() } );
		
			 
			 
			 function autoscroll() {
			 	if( div.scrollLeft() > 63 ) div.scrollLeft(0);
			 	div.animate({ 
        			scrollLeft : 63 // +ulWidth 
    				}, 4500, 'linear', function() {
    										var firstlist = $('li:first-child',div)
    										firstlist.klon = firstlist.clone();
    										firstlist.remove();
    										div.animate({ scrollLeft: 0 },0);
    										$('ul',div).append(firstlist.klon);
    										delete firstlist;
    										//autoscroll();
    										
    										//firstlist.clone().prependTo('ul',div);
    										//firstlist.;
    									});
				

			    }
			
			
			//autoscroll();
			
			}); // return

} // END mouseoverscroll() ----------------------------------------------------------------------------




$.fn.ieffembedfix = function() {
		
		// CONFIGURE THE PATH TO YOUR 1BY1 PNG HERE, RELATIVE TO THE LOCATION OF THIS JS FILE.
		
		var pngimgurl = "http://eurorscglife.de/assets/site/templates/js/hIEfix.png";
		
    return this.each(function() {
        //check for IE7/8
        if ($.browser.msie/* jQuery.support.objectAll == false */) {
        	//alert("go");
            $(this).css({
						
						filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + pngimgurl + ",sizingMethod=crop',
						zoom: '1'
						});
        }
        });
    }






$(function() {

	$(document).pngFix(); 
	
	$('#voodoo_visual, .extern_link').attr("target","_blank");

	
	var searchdefaultvalue = $('#search').val();
	$('#search')
		.bind('focus', function() { $(this).val(''); })
		.bind('blur', function() { if( $(this).val() == '') $(this).val(searchdefaultvalue); });
	

	$('#bird')
		.attr("target","_blank")
		.css({ opacity: 0.7 })
		.hover(	function() { $(this).stop().animate({ opacity: 1 },300); },
				function() { $(this).stop().animate({ opacity: 0.7 },500); }
				);
	
/*
	$('#main_menu').find('a')
		.hover(	function() { $(this).animate({ backgroundColor: '#f62a2b' },500 ); },
				function() { $(this).animate({ backgroundColor: 'transparent' },500 ); }
				);
*/
	
	$('#main_menu a')
	.not('#main_menu li.active a')
	.css( {backgroundPosition: "-200px 0"} )
	.mouseover(function(){
		$(this).stop().animate(
			{backgroundPosition:"(0 0)"}, 
			{duration:600})
		})
	.mouseout(function(){
		$(this).stop().animate(
			{backgroundPosition:"(-200px 0)"}, 
			{duration:450})
		});
		
		
		
	function formatTitle(title, currentArray, currentIndex, currentOpts) {
    	return  '<div class="lightbox_paging">' + title + 'Seite ' + (currentIndex + 1) + ' von ' + currentArray.length + '</div>';
		}	
		
		
	$("a.arbeitsprobe_show").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200,
		'overlayOpacity':	0.8,
		'overlayColor'	:	'#000',
		'titleShow'		:	'true',
		'titlePosition' :	'outside',
		'titleFormat'	: 	formatTitle
		
	});
		
		
		
		
	$('.mouseoverscroll').mouseoverscroll();
	
	
	$('#newsteaser_startseite').jqFancyTransitions({
	
		width: 920, // wave, zipper, curtain
		height: 540, // wave, zipper, curtain
		effect: 'curtain', // wave, zipper, curtain
		strips: 20, // number of strips
		delay: 5000, // delay between images in ms
		stripDelay: 50, // delay beetwen strips in ms
		titleOpacity: 1, // opacity of title
		titleSpeed: 1000, // speed of title appereance in ms
		position: 'alternate', // top, bottom, alternate, curtain
		direction: 'alternate', // left, right, alternate, random, fountain, fountainAlternate
		navigation: true, // prev and next navigation buttons
		links: true // show images as links

		});
	
	
	
	
     $("#accordeon_menu").accordeon_menu();
     
     
     
/*      $('#copytext, h1,h2,h3,p').ieffembedfix(); */



// AJax loading ------------------------------------------------------------------
     
if(! ($.browser.msie /* && jQuery.browser.version.substr(0,3)=="6.0"  */) ){
     
     /*
$('.mitarbeiter')
     	.bind('click', function(event) {
     		
     		event.preventDefault();
     		
     		var href = $(event.target).attr('href');
     		
     		$('#copytext').css("overflow","hidden").animate({ height: '0' }, 300 );
     		
       		//var temp_obj = document.createElement("div");
     		
     		$('#mitarbeiter_box').css("overflow","hidden").animate({ height: 0 })
     		$(temp_obj).load(href+"?" + Math.random()*99999, function() { 
     							//alert( $(temp_obj).find('#mitarbeiter').html()     );
     							$('#mitarbeiter_box').html( $(temp_obj).find('#mitarbeiter') ).animate({ height: '246px' },300 );
     							 });    		
     		     		
     		return false;
     		
     	});
*/
     
     $('.mitarbeiter')
     	.bind('click', function(event) {
     		
     		//event.preventDefault();
     		
     		var href = $(event.target).attr('href');
     		
     		$('#copytext').css({ overflow: "hidden"}).animate({ height: 0 }, 300, function() { $('#copytext').css({ display: "none"}); } );
     		
     		/*  */
     		//var temp_obj = document.createElement("div");
     		
     		$('#mitarbeiter_box')
     			.css({ overflow: 'hidden' })
     			.animate({ height: 0, opacity: 0 }, 200)
     			
     			.load( href+ "?" + Math.random()*99999   + ' #mitarbeiter'  , function() { 
     							$('#mitarbeiter_box').animate({ height: '246px', opacity: 1 } ,200 );
     							 });    		
     		     		
     		return false;
     		
     	});





     
     
     
     $('a', $('.cases_kunde') )
     	.bind('click', function(event) {
     		
     		var el = $('a', $(event.target).parents('.cases_kunde') );
     		var href = el.attr('href');
     		
     		//$('body').append(href);
       		
     		$('#cases_brand')
     			.animate({ opacity: 0  })
     			.load(href + " #c_brands", function() { 
     									$('#cases_brand').animate({ opacity: 1 }) 
										$('a.active', $('#cases_kunden_brands')).removeClass('active');
										$(el).addClass('active');
     									});    		
     		
     		return false;
     	
     		
	});     	
     
}      // END OF Ajax loading
     


/*
	if( $('#team').length != 1) 
		
*/
/*
	$('#mitarbeiter').wrap('<div id="mitarbeiter_box"></div>')
	
		.ajaxify({
		onStart:function() { $('#copytext').wrap('<div id="mitarbeiter_box"></div>').animate({ opacity: 0 },300 );
							 $('#mitarbeiter_box').animate({ height: '246px' },300 ); },
		target:'#mitarbeiter',
        tagToload:'#mitarbeiter',
        animateOut:{ opacity: '0' },
        animateOutSpeed:100,
        animateIn:{opacity:'1'},
        animateInSpeed:150,
        loading_img:'/assets/site/templates/img/ajax_loader.gif'
	});
	
	
	
	$('a', $('.cases_kunde') ).ajaxify({
		target:'#cases_brand',
        tagToload:'#cases_brand',
        animateOut:{ opacity: '0' },
        animateOutSpeed:100,
        animateIn:{opacity:'1'},
        animateInSpeed:150,
        loading_img:'/assets/site/templates/img/ajax_loader.gif',
		onSuccess: function(current) { 
					//alert( $(current.object).html() );
					$('a.active', $('#cases_kunden_brands')).removeClass('active');
					$(current.object).addClass('active');
					}
		});
*/
	

	
});




















/*
$(document).ready(function(){ 
        
        
		
        $('#navigation li').hover(function(){
               $(this).addClass('over');
        }, function() {
               $(this).removeClass('over');
		});
		
		
		
		
    });
*/
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

