
	jQuery(document).ready( function() {
	
		var divparent = jQuery(".slider")
        var liitem = jQuery(".slider ul li");
        var i = 0;

        jQuery(".slider ul li").css("display", "none");
        jQuery(".slider ul li span").css("display", "none");
        jQuery(".slider ul li:first").css("display", "block");
        jQuery(".slider ul li span:first").css("display", "block");
        jQuery(".archive .post .entry .mehr").remove();
		

        //create pgings
        liitem.each(function(){
            jQuery('.slider_navi').append("<a href='#' rel='"+i+"' class='pagins'></a>");
            i++;
        });
        
        jQuery(".slider a.pagins:first").addClass("active");
        jQuery(".post:last").addClass("last");
        jQuery(".videopost:last").addClass("last");
        jQuery(".wpcf7-submit").attr("value","");
        
        jQuery("a.pagins").click(function(){ paginhclick(jQuery(this)) });
        
        function paginhclick(el){
            jQuery("a.pagins").removeClass("active");
            el.addClass("active");
            var currel = el.attr("rel");
            liitem.find("span").slideUp(function(){})
			// fade speed
            liitem.fadeOut(300);
            jQuery(liitem[currel]).fadeIn(300,function(){
                jQuery(liitem[currel]).find("span").slideDown();
            });
        }
        
		// slide interval
        setInterval(function(){
            anim()
        }, 5500)
        
        function anim(){
			var links = jQuery("a.pagins");
            var curlink = jQuery("a.pagins.active");
            var currel = parseInt(curlink.attr("rel"));
            jQuery("a.pagins").removeClass("active");
			
			if(currel >= links.length-1){
                currel = -1;
            }else{  }
			
			jQuery(links[currel+1]).addClass("active");
            liitem.find("span").slideUp(function(){})
            liitem.fadeOut(600);
            jQuery(liitem[currel+1]).fadeIn(600,function(){
                jQuery(liitem[currel+1]).find("span").slideDown();
            });
			
        }
		
		jQuery('.news:last').addClass('last');
		
		//Caption Sliding (Partially Hidden to Visible)
		jQuery('.boxes .widget_sp_image').hover(function(){
			jQuery(".caption", this).stop().animate({bottom:'0px'},{queue:false,duration:160});
		}, function() {
			jQuery(".caption", this).stop().animate({bottom:'-20px'},{queue:false,duration:160});
		});
		
		jQuery('.lehrkrafte .person .more a').attr('href','javascript:;').addClass('mehr');
		
		jQuery('.lehrkrafte .person .teaser .mehr').live("click",function() {   
			jQuery(this).parent().parent().parent('.teaser').hide('slow');
			jQuery(this).parent().parent().parent('.teaser').next('.full').show('slow');            
			jQuery(this).parent().parent().parent('.teaser').next('.full').find('p:last').find('.mehr').remove();
			jQuery(this).parent().parent().parent('.teaser').next('.full').find('p:last').append('... <a class="mehr" href="javascript:;">weniger</a>');
		});
		
		jQuery('.lehrkrafte .person .full .mehr').live("click",function() {   
			jQuery(this).parent().parent().hide('slow');
			jQuery(this).parent().parent().prev('.teaser').show('slow'); 
		});
	});
	
	function toTop() {
		jQuery('html, body').animate( { scrollTop: 0 }, 'slow' );
	}

