

$.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 
    				}, 2500, '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() ----------------------------------------------------------------------------


$(function(){

	$('div.sc_menu').mouseoverscroll();
/* 	$(document).pngFix();  */



	$('#adresses p').css({ display: 'block' }).animate({ opacity: 0 }, 0);
	$('a.standort' ).each(function(){ 
		
				var a = this;
				var tid = $(this).attr('href');
				
				
				
				$(a).hover(
/*
					function(){ $('#adresses p').css('display', 'none'); $(tid).css('display','block'); }, 
					function(){ $(tid).css('display','none'); } 
*/
					function(){ $('#adresses p').stop().animate({ opacity: 0 }, 150); $(tid).animate({ opacity: 1 },300); }, 
					function(){ $(tid).animate({ opacity: 0 }, 150); } 
					).click(function() { return false; } );
				
			});



	$('a.extern').attr('target','_blank');
	
	
	$('li', $('#main_navigation') ).each( function() { 
		var li = this;
		$(li).hover(
			function() { $('ul',li).css( 'display', 'block' ); } ,
			function() { $('ul',li).css( 'display', 'none' ); }
			);
	
	});
	
	
	
	
	/* Anti Spam */
	$('#cfDummefrage').val('2011').parents('#dummefrage_box').css('display','none');
	
	
	
	
	

});



