;(function($) {
$.fn.anchorAnimate = function(settings) {
    settings = jQuery.extend({
        speed : 1100,
        offset : 0
    }, settings);
    return this.each(function(){
        var caller = this;
        jQuery(caller).click(function (event) {
            event.preventDefault();
            var locationHref = window.location.href;
            var elementClick = jQuery(caller).attr("href").replace('#','');
			if(jQuery('#'+elementClick).length > 0){ // Make sure there's a destination to go to
	            var destination = jQuery('*[name="'+elementClick+'"],*[id="'+elementClick+'"]').offset().top;
	            jQuery("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination+settings.offset}, settings.speed, 'easeOutQuad', function() {
	                window.location.hash = elementClick;
	            });
	            return false;
	        }
        })
    })
}
})(jQuery);

$(document).ready(function(){
	if(location.hash && $(location.hash).length>0) // Abide by hash rather than scrolling to top
		$('html:not(:animated),body:not(:animated)').animate({scrollTop:$(location.hash).offset().top},1000,'easeOutQuad'); // Animate scroll to anchor
	else
		$('html:not(:animated),body:not(:animated)').animate({scrollTop:0},100); // Conceal address bar on mobile devices
	$('body').animate({backgroundPositionY:'0'},1000);
	$('header h1').fadeIn(2000);
	$('#com').delay(1400).fadeIn(800);
	$('#networks').delay(1600).fadeIn(800);

	$('header h1 a').hover(function(){
		$('#com').stop().animate({opacity:0.1},200);
	},function(){
		$('#com').stop().animate({opacity:1},500);
	});

	 // Animated anchor scrolling
	jQuery('a[href^="#"]').anchorAnimate();
});
