/* =Main INIT Functions

-------------------------------------------------------------- */

function initializeVisia() {



	"use strict";



	//IE9 RECOGNITION

	if (jQuery.browser.msie && jQuery.browser.version == 9) {



		jQuery('html').addClass('ie9');

	}



	//NAVIGATION CUSTOM FUNCTION

	jQuery(document).aetherNavigation();



	//LOCAL SCROLL

	jQuery('.navigation, .call-to-action').localScroll({

		offset: -50

	});



	jQuery("#top").click(function () {

		e.preventDefault();

		/*return*/

		jQuery("body,html").stop().animate({

			scrollTop: 0

		}, 800, "easeOutCubic"), !1;

	});



	//RESPONSIVE HEADINGS

	jQuery("h1").fitText(1.8, { minFontSize: '30px', maxFontSize: '52px' });

	jQuery("h2").fitText(1.5, { minFontSize: '20px', maxFontSize: '36px' });

	





	//HERO DIMENSTION AND CENTER

	(function() {

	    function heroInit(){

	       var hero = jQuery('.hero'),

				ww = jQuery(window).width(),

				wh = jQuery(window).height(),

				heroHeight = wh;



			hero.css({

				height: heroHeight+"px",

			});



			var heroContent = jQuery('.hero .content'),

				contentHeight = heroContent.height(),

				parentHeight = hero.height(),

				topMargin = (parentHeight - contentHeight) / 2;



			heroContent.css({

				"margin-top" : topMargin+"px"

			});

	    }



	    jQuery(window).on("resize", heroInit);

	    jQuery(document).on("ready", heroInit);

	})();



	//HERO TICKER

	var current = 1; 

	var height = jQuery('.ticker').height(); 

	var numberDivs = jQuery('.ticker').children().length; 

	var first = jQuery('.ticker h1:nth-child(1)'); 

	setInterval(function() {

	    var number = current * -height;

	    first.css('margin-top', number + 'px');

	    if (current === numberDivs) {

	        first.css('margin-top', '0px');

	        current = 1;

	    } else current++;

	}, 2500);



	

	//SERVICES TOOLTIP

	(function() {

		function tooltipInit(){

			var tooltip = jQuery('.tooltip'),

				target = jQuery('.icon'),

				arrow = jQuery ('.arrow-down'),

				mobile = jQuery(window).width() < 960,

				desktop = jQuery(window).width() > 960



			if (mobile) {



				jQuery( ".overview:odd" ).addClass('pull-left');



				target.click(function(){

					target.css({ "background-position": "top" });

					jQuery(this).css({ "background-position": "bottom" });



					tooltip.removeClass('visible'); arrow.removeClass('visible');

					jQuery(this).siblings('.tooltip, .arrow-down').addClass('visible');

				});



				tooltip.click(function(){

					jQuery(this).removeClass('visible');

					jQuery(this).siblings('.arrow-down').removeClass('visible');

					jQuery(this).siblings('.icon').css({

						"background-position": "top"

					});

				});



				target.unbind('mouseenter');

				target.unbind('mouseleave');

			}



			if (desktop) {

				jQuery('.pull-left').removeClass('pull-left');

				target.css({"background-position" : "top"})

				tooltip.removeClass('visible');

				arrow.removeClass('visible');

				target.bind('mouseenter', function(){

					jQuery(this).siblings('.tooltip, .arrow-down').addClass('visible');

					jQuery(this).css({"background-position" : "bottom"});



					var removeTooltip = function(){ tooltip.removeClass('visible'); arrow.removeClass('visible'); };

					target.bind( 'mouseleave', removeTooltip );

					target.bind( 'mouseleave', function(){

						jQuery(this).css({"background-position" : "top"});

					});

				});

			}



		}



		jQuery(window).on("resize", tooltipInit);

	    jQuery(document).on("ready", tooltipInit);



	})();



	

	//ANIMATIONS

	jQuery('.animated').appear();



	jQuery(document.body).on('appear', '.fade', function() {

		jQuery(this).each(function(){ jQuery(this).addClass('ae-animation-fade') });

	});

	jQuery(document.body).on('appear', '.slide', function() {

		jQuery(this).each(function(){ jQuery(this).addClass('ae-animation-slide') });

	});

	jQuery(document.body).on('appear', '.hatch', function() {

		jQuery(this).each(function(){ jQuery(this).addClass('ae-animation-hatch') });

	});

	jQuery(document.body).on('appear', '.entrance', function() {

		jQuery(this).each(function(){ jQuery(this).addClass('ae-animation-entrance') });

	});



	



	//CONTACT-FORM

	

	jQuery('#contact-open').click(function (e) {

		e.preventDefault();

		if ( jQuery('#contact-form').is(':hidden') ) {

			jQuery('#contact-form').slideDown();

			jQuery('html, body').delay(200).animate({ 

			    scrollTop: jQuery('#contact-form').offset().top 

			}, 1000);

		} else {

			jQuery('#contact-form').slideUp();

		}

	});



	

	



	//PARALLAX EFFECTS

	jQuery('.parallax-bg1').parallax("50%", 0.5);

	jQuery('.parallax-bg2').parallax("50%", 0.5);

	jQuery('.parallax-bg3').parallax("50%", 0.4);

	jQuery('.parallax-bg4').parallax("50%", 0.4);



	//RESPONSIVE VIDEO

	jQuery(".container").fitVids();

	//jQuery('.video, .post .video').fitVids();

	





	

};



		



/* =Window Load Trigger

-------------------------------------------------------------- */

jQuery(window).load(function(){



	jQuery(window).trigger( 'hashchange' );

	jQuery(window).trigger( 'resize' );

  	jQuery('[data-spy="scroll"]').each(function () {

    	var $spy = jQuery(this).scrollspy('refresh');

	});



});

/* END ------------------------------------------------------- */





/* =Document Ready Trigger

-------------------------------------------------------------- */

jQuery(document).ready(function(){



	initializeVisia();

	//initializePortfolio();



});

/* END ------------------------------------------------------- */



