

function ani_back(ele, from, to, r, g, b) {
    from += from > to ? -1 : 1;
    if(!$.support.opacity){
        if(from != to){
            var opStr = (Math.round(from * 25.5)).toString(16);
            ele.css({background:'transparent',filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#" + opStr + "00c2ed, endColorstr=#" + opStr + "00c2ed)"});   
        }else{
            ele.css({background:'transparent',filter:"none"});   
        }
    }else{
        ele.css("backgroundColor", "rgba(" + r + " , " + g + "," + b + " , " + (from) / 10 + ")"); 
    }

    if(from != to)  
        setTimeout(function() { ani_back(ele, from, to, 0,194,237) }, 50);
	}

function changeCurrentMenu(number) {
	var i = 0;
	$('#menu ul li').each(function() {
    	if (i == (number - 1)) {
    		$(this).addClass('current_page');
    	} else {
    		$(this).removeClass('current_page');
    	}
    	i += 1;
	});

}



function sticky_nav() {
  var window_top = $(window).scrollTop();
  var div_top = $('#content').scrollTop();
  //alert(window_top);
  if (window_top > 230) {
  	//alert('hallo');
  	$('#post_navigation').removeClass('in_post_navigation');
    $('#post_navigation').addClass('in_post_navigation_stick');
    
  } else {
    $('#post_navigation').removeClass('in_post_navigation_stick');
    $('#post_navigation').addClass('in_post_navigation');
    }
  }

	
$(document).ready(function(){



	$(window).scroll(sticky_nav);
  	sticky_nav();



	
	if ($('.tlb').length > 0) {
		$('#lightbox_toggle').fadeIn('slow');
		$('#lightbox_toggle').animate({
			color: '#00a0c2'
		}, 600, function() {
				$('#lightbox_toggle').animate({color: '#ccc'}, 600);
			});
		
		
	}
	

	/*$(window).scroll(function () {
		
		if ($(window).scrollTop() > 100) {
			$('#conn_nav').animate({opacity: '0.5'}, 200);
		} else {
			$('#conn_nav').animate({opacity: '1.0'}, 200);
		}
	}); 
*/
	$('#header_toggle').click(function() {
		$('#head_info').slideToggle("slow").toggleClass('open');
		if ($('#head_info').hasClass('open')) {
			$('#header_toggle').animate({top: '+=200'},"slow");
			$('#header_toggle').html('Schlie§e MenŸ');
			$('#header').animate({height: '+=185'}, 200);
		} else {
			$('#header_toggle').animate({top: '-=200'},"slow");
			$('#header_toggle').html('…ffne MenŸ');
			$('#header').animate({height: '-=185'}, "slow");
		}
	});
	
	
	 
	
	
	/*
	$("#work_mosaic_blog").vgrid({
		easeing: "easeOutQuint",
		time: 800,
		delay: 60,
		forceAnim: 1,
		fadeIn: {
			time: 700,
			delay: 100
		}
	});*/
	
	
	
	
	$(window).load(function(e){
		setTimeout(function(){
		$("#work_mosaic").css("paddingTop", "0px");
		}, 1000);
	});
	

	 $("#tclick").click(function() {changeCurrentMenu(1);});
	
	//HOVER STUFF - MOSTLY FADE FX
	$("h1").hover(
  		function() {return ani_back($(this), 8, 10, 0,194,237)},
    	function() {return ani_back($(this), 10, 8, 0,194,237)}
	);
	
	$(".footerw ul li").hover(
  		function() {$('.footerw ul li div').fadeIn(100)},
  		function() {$('.footerw ul li div').fadeOut(100)}
	);
/*	
	$("#menu li").hover(function(){

		$(this).animate({
			backgroundColor: "#ccc"
		}, 310); 
		$(this).children().animate({
			color: '#fff'
		}, 310);
		},
		function() {
			if($(this).hasClass("current_page") != true) {
				$(this).animate({
					backgroundColor: "#fff"
				}, 310);
				$(this).children().animate({color: '#959595'}, 310);

			}
	});
*/	
	
	
	$("#sumbit").hover(function() {
		$(this).animate({
			opacity: '0.7'
		}, 300);
	},
	function() {
		$(this).animate({
			opacity: '1.0'
		}, 300);
	}
	);
	
	
	$(".comment").hover(function() {
			$('.reply', $(this)).fadeIn('fast');
		},
		function() {
			$('.reply', $(this)).fadeOut('fast');
		
	});
	
	
	$(".teaser").hover(
	function() {
		$(this).children("a").stop().fadeTo("fast", .5);
		$(this).children("h1").animate({top: '5px'}, 100);
		ani_back($(this).children("h1"), 3, 7, 0,194,237);
	},
	function() {
		$(this).children("a").stop().fadeTo("fast", 1);
		$(this).children("h1").animate({top: '120px'}, 100);
		ani_back($(this).children("h1"), 10, 3, 0,194,237);
	});
	
	$(".port_links_article").hover(
	function() {
		jQuery(this).stop().fadeTo("fast", .5);
	},
	function() {
		jQuery(this).stop().fadeTo("fast", 1);
	}); 
	
	$("#port_links a").hover(
	function() {
		jQuery(this).stop().fadeTo("fast", .5);
	},
	function() {
		jQuery(this).stop().fadeTo("fast", 1);
	}); 
	
	$("#lightbox_toggle").hover(
	function() {
		jQuery(this).stop().fadeTo("fast", .5);
	},
	function() {
		jQuery(this).stop().fadeTo("fast", 1);
	}); 
/*	$(".abo_conn").hover(
	function() {
		jQuery(this).children('a').children('span').stop().animate({color: '#00a0c2'}, 200);
	},
	function() {
		jQuery(this).children('a').children('span').stop().animate({color: '#cccccc'}, 200);
	}); 
*/	
	
	//END HOOVER STUFF
	
	
	
	
	/*
	THE MAIN PAGE SLIDER

	$('#slider').nivoSlider({
        effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
        slices:15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed:500, // Slide transition speed
        pauseTime:3000, // How long each slide will show
        startSlide:0, // Set starting Slide (0 index)
        directionNav:false, // Next & Prev navigation
        directionNavHide:true, // Only show on hover
        controlNav:false, // 1,2,3... navigation
        controlNavThumbs:false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        keyboardNav:false, // Use left & right arrows
        pauseOnHover:true, // Stop animation while hovering
        manualAdvance:false, // Force manual transitions
        captionOpacity:0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
    });
    	*/
    
    
    /*
    THE LIGHTBOX - all images "tlb"-class will be lightboxed and shown
    */   
	$("#lightbox_toggle").click(function() {
	
	var image_array = $(".tlb").map(function() {
	  return $(this).attr("src");
	}).get();
	
	$.fancybox(image_array, {
		'padding' : 0,
		'transitionIn' : 'elastic',
		'transitionOut' : 'none',
		'type' : 'image',
		'changeFade' : 300,
		'overlayOpacity' : 1,
		'overlayColor' : '#272727',
		'hideOnOverlayClick' : false
	});
	}); 


	if ($.browser.msie && $.browser.version.substr(0,1)<9) {
		$(".sidelink a").corner('30px');
	}
	
	

});


