$ = jQuery.noConflict();

$(function() {
	// fixed navigation	
	var toppoint = $('.site-logo').height() + 20;
	var header = $('.site-header');
	var marg = header.height() + 20;
		//console.log(toppoint);
		var scrollPosition = $(window).scrollTop();
		//console.log(scrollPosition);
	
		if ( $('body').hasClass('home') ){
			header.addClass('navbar-fixed-top');
			toppoint = 200;
		}

		if (scrollPosition > toppoint) {
			header.addClass('navbar-fixed-top');
		}
  
	$(window).scroll(function (event) {
    // what the y position of the scroll is
    var y = $(this).scrollTop();
    
    // whether that's below the form
		if (y >= toppoint) {
			// if so, ad the fixed class
			header.addClass('navbar-fixed-top');

			if ( $('body').hasClass('home') ){
				header.css('opacity', 1);
				header.css('transform', 'none');
			} else {
				$('#content').css('padding-top', marg);
			}

		} else {
			// otherwise remove it

			if ( $('body').hasClass('home') ){
				header.css('opacity', 0);
				header.css('transform', 'translateY(-100%) translateZ(0)');
			} else {
				header.removeClass('navbar-fixed-top');
				$('#content').removeAttr('style');
			}

		}
	});
	// end scroll and fixed navigation


	// particle effect
	particlesJS("particle-container", {
		"particles": {
			"number": {
				"value": 200,
				"density": {
					"enable": true,
					"value_area": 900
				}
			},
			"color": {
				"value": "#acd4f4"
			},
			"shape": {
				"type": "circle",
				"stroke": {
					"width": 0,
					"color": "#000000"
				},
				"polygon": {
					"nb_sides": 5
				},
				"image": {
					"src": "img/github.svg",
					"width": 100,
					"height": 100
				}
			},
			"opacity": {
				"value": 1.0,
				"random": false,
				"anim": {
					"enable": false,
					"speed": 1,
					"opacity_min": 0.5,
					"sync": false
				}
			},
			"size": {
				"value": 3,
				"random": true,
				"anim": {
					"enable": false,
					"speed": 40,
					"size_min": 0.1,
					"sync": false
				}
			},
			"line_linked": {
				"enable": false,
				"distance": 150,
				"color": "#ffffff",
				"opacity": 0.4,
				"width": 1
			},
			"move": {
				"enable": true,
				"speed": 1,
				"direction": "none",
				"random": false,
				"straight": false,
				"out_mode": "out",
				"bounce": false,
				"attract": {
					"enable": false,
					"rotateX": 600,
					"rotateY": 1200
				}
			}
		},
		"interactivity": {
			"detect_on": "canvas",
			"events": {
				"onhover": {
					"enable": false,
					"mode": "repulse"
				},
				"onclick": {
					"enable": false,
					"mode": "push"
				},
				"resize": true
			},
			"modes": {
				"grab": {
					"distance": 400,
					"line_linked": {
						"opacity": 1
					}
				},
				"bubble": {
					"distance": 400,
					"size": 40,
					"duration": 2,
					"opacity": 8,
					"speed": 3
				},
				"repulse": {
					"distance": 200,
					"duration": 0.4
				},
				"push": {
					"particles_nb": 4
				},
				"remove": {
					"particles_nb": 2
				}
			}
		},
		"retina_detect": true
	});

	// form input effect
	var inputs_effect = '.input-effect';
	$( '<span class="focus-border"></span>' ).insertAfter( $( inputs_effect ).find('.effect-1:first') );
	$( inputs_effect ).find('.effect-1:first').focus(function(){
		$(this).closest( inputs_effect ).addClass('input-focused');
	}).blur(function(){
		if ( $(this).val() == '' ){
			$(this).closest( inputs_effect ).removeClass('input-focused');
		} else {
			$(this).closest( inputs_effect ).addClass('input-focused');
		}
	});
	
});