
function main() {

	function isMobile() {
		var a = navigator.userAgent || navigator.vendor || window.opera;
		if ((/mac/i.test(a)) && !(/iphone/i.test(a))) return false;
		if ((/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|ip(hone|od|ad)|iris|kindle|lge|maemo|midp|mmp|mobile|o2|opera m(ob|in)i|palm( os)?|p(ixi|re)\/|plucker|pocket|psp|smartphone|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce; (iemobile|ppc)|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a)))
			return true;
		else
			return false;
	}

	$(document).ready(function () {
		$(".rf-link").bind("click", function () {
			$("#slides-portifolios").html('<img src="assets/img/loading.gif" class="gif_ajung"/>');
			hash = $(this).data("cliente");
			/**/
			_href = window.location.href;
			hash2 = _href.match('#\/?([%a-zA-Z0-9-\\-\\_\\s,]+)([\/A-Za-z0-9]*)');

			//console.log(hash2);

			if (hash2 != null && hash2 !== undefined) {
				window.location.href = _href.replace(hash2[1], hash);
			} else {
				window.location.href = "#" + hash;
			}
			window.location.hash = hash;

			/**/

			_portifolio = $(this).data("portifolio");

			$(".close-modal").unbind();

			setTimeout(function () {
				$.ajax({
					url: "funcoes.php?portifolio=" + _portifolio
					, success: function (out) {
						$("#slides-portifolios").html(out);
						$(".close-modal").bind("click", function () {
							window.location.hash = "protifolio";
							$(".close-modal").unbind();
						});
					}
				});
			}, 1200);
		});

		/* ****  */

		_hash = "click_" + location.hash.replace("#", "");
		if (document.getElementsByClassName(_hash).length > 0) {
			console.log(_hash);
			console.log(document.getElementsByClassName(_hash));
			console.log(document.getElementById(_hash));
			setTimeout(
				function () {
					document.getElementsByClassName(_hash)[0].click();
				}, 1000
			);
		}
		/* **** */

		$("img.lazy").lazyload({
			threshold: 400
		});

		Slidebanner(document.getElementById('banner'));


		/*videos*/
		/*will*/
		$('.img_will').hover(function () {
			/*$('.img_will').hide();*/

			$('.video_will').css('display', 'block');
			$('.video_will').trigger('play');
		},
			function () {
				$('.video_will').css('display', 'none');
				$('.video_will').trigger('stop');
			}
		);
		/*will*/

		/*rose*/
		$('.img_rose').hover(function () {
			/*$('.img_will').hide();*/

			$('.video_rose').css('display', 'block');
			$('.video_rose').trigger('play');
		},
			function () {
				$('.video_rose').css('display', 'none');
				$('.video_rose').trigger('stop');
			}
		);
		/*rose*/

		/*adrina*/
		$('.img_adriana').hover(function () {
			/*$('.img_will').hide();*/

			$('.video_adriana').css('display', 'block');
			$('.video_adriana').trigger('play');
		},
			function () {
				$('.video_adriana').css('display', 'none');
				$('.video_adriana').trigger('stop');
			}
		);
		/*adriana*/

		/*nazario*/
		$('.img_nazario').hover(function () {
			/*$('.img_will').hide();*/

			$('.video_nazario').css('display', 'block');
			$('.video_nazario').trigger('play');
		},
			function () {
				$('.video_nazario').css('display', 'none');
				$('.video_nazario').trigger('stop');
			}
		);
		/*nazario*/

		/*thiago*/
		$('.img_thiago').hover(function () {
			/*$('.img_will').hide();*/

			$('.video_thiago').css('display', 'block');
			$('.video_thiago').trigger('play');
		},
			function () {
				$('.video_thiago').css('display', 'none');
				$('.video_thiago').trigger('stop');
			}
		);
		/*thiago*/

		/*estela*/
		$('.img_estela').hover(function () {
			/*$('.img_will').hide();*/

			$('.video_estela').css('display', 'block');
			$('.video_estela').trigger('play');
		},
			function () {
				$('.video_estela').css('display', 'none');
				$('.video_estela').trigger('stop');
			}
		);
		/*estela*/

		/*edu*/
		$('.img_edu').hover(function () {
			/*$('.img_will').hide();*/

			$('.video_edu').css('display', 'block');
			$('.video_edu').trigger('play');
		},
			function () {
				$('.video_edu').css('display', 'none');
				$('.video_edu').trigger('stop');
			}
		);
		/*edu*/

		/*daniel*/
		$('.img_daniel').hover(function () {
			/*$('.img_will').hide();*/

			$('.video_daniel').css('display', 'block');
			$('.video_daniel').trigger('play');
		},
			function () {
				$('.video_daniel').css('display', 'none');
				$('.video_daniel').trigger('stop');
			}
		);
		/*daniel*/
		/*gabriel*/
		$('.img_gabriel').hover(function () {
			/*$('.img_will').hide();*/

			$('.video_gabriel').css('display', 'block');
			$('.video_gabriel').trigger('play');
		},
			function () {
				$('.video_gabriel').css('display', 'none');
				$('.video_gabriel').trigger('stop');
			}
		);
		/*gabriel*/
		/*gabriel*/
		$('.img_marina').hover(function () {
			/*$('.img_will').hide();*/

			$('.video_marina').css('display', 'block');
			$('.video_marina').trigger('play');
		},
			function () {
				$('.video_marina').css('display', 'none');
				$('.video_marina').trigger('stop');
			}
		);
		/*gabriel*/
		/*img_andre*/
		$('.img_andre').hover(function () {
			/*$('.img_will').hide();*/

			$('.video_andre').css('display', 'block');
			$('.video_andre').trigger('play');
		},
			function () {
				$('.video_andre').css('display', 'none');
				$('.video_andre').trigger('stop');
			}
		);
		/*img_andre*/
		/*gabriel*/
		$('.img_felipe').hover(function () {
			/*$('.img_will').hide();*/

			$('.video_felipe').css('display', 'block');
			$('.video_felipe').trigger('play');
		},
			function () {
				$('.video_felipe').css('display', 'none');
				$('.video_felipe').trigger('stop');
			}
		);
		/*gabriel*/
		/*marta*/
		$('.img_martinha').hover(function () {
			/*$('.img_will').hide();*/

			$('.video_martinha').css('display', 'block');
			$('.video_martinha').trigger('play');
		},
			function () {
				$('.video_martinha').css('display', 'none');
				$('.video_martinha').trigger('stop');
			}
		);
		/*marta*/
		/*claudio*/
		$('.img_claudinho').hover(function () {
			/*$('.img_will').hide();*/

			$('.video_claudinho').css('display', 'block');
			$('.video_claudinho').trigger('play');
		},
			function () {
				$('.video_claudinho').css('display', 'none');
				$('.video_claudinho').trigger('stop');
			}
		);
		/*clauido*/

		/* idiomas */
		$(".setlang").bind("click", function (e) {
			_href = this.dataset.url;
			$.ajax({
				url: "funcoes.php/" + _href
				, success: function (out) {
					if (out == 1) {
						location.reload();
					}
				}
			});
			e.preventDefault();
		});
		/* *** */

	});


	function Slidebanner(obj) {
		var cont = 0;
		var intervalo = '';
		var time = 7000;

		carregaBanner = function (id) {
			if ($("#" + id + " img").size() > 1) {
				$("#" + id + " .nav").show();
				$("#" + id + " .slidebanner > li").css("width", $("#" + id + "").width() + "px");
				_qtd = $("#" + id + " .slidebanner > li").size();
				_wid = $("#" + id + " .slidebanner > li").width();
				$("#" + id + " .slidebanner").css('width', (_qtd * _wid) + "px");
				$("#thumb" + cont).switchClass('nda', 'ativo', 230);


				_thumb = $("#" + id + " .nav > .thumb");
				_thumb.bind('click', function () {
					clearInterval(intervalo);
					direction = "-=";
					passo = 1;

					if ($(this).data('cont') < cont) {
						direction = "+=";
					}
					if ((eval($(this).data('cont')) - cont) > 0) {
						passo = eval($(this).data('cont')) - cont;
					}
					if ((eval($(this).data('cont')) - 1) < 0) {
						cont = 0;
					} else {
						cont = eval($(this).data('cont')) - 1;
					}
					if ($(this).data('cont') == 0) {
						cont = $("#" + id + " .slidebanner > li").size();
					}
					animacao(id, direction, passo, 0);
					animacaoBanner(id);
				});

				animacaoBanner(id);
			}
		}
		setarTamanhoSlide = function (id) {
			$("#" + id + " .slidebanner > li").css("width", $("#" + id + "").width() + "px");
			_qtd = $("#" + id + " .slidebanner > li").size();
			_wid = $("#" + id + " .slidebanner > li").width();
			$("#" + id + " .slidebanner").css('width', (_qtd * _wid) + "px");
			$("#" + id + " .slidebanner").css('left', "0");
			animacaoBanner(id);
		}
		animacaoBanner = function (id) {
			intervalo = setInterval(function () {
				animacao(id, "-=", 1, 1);
			}, time);
		}

		animacao = function (id, direction, passo, zerar) {
			_left = $("#" + id + " .slidebanner").css('left');
			_left = _left.replace('px', '');
			if (_left == 0 && zerar > 0) { cont = 0 };
			if (cont < ($("#" + id + " .slidebanner > li").size() - 1)) {
				_wid = eval($("#" + id + " .slidebanner > li").width()) * passo;
				$("#" + id + " .slidebanner").animate({ 'left': direction + _wid }, 900);
				cont++;
			} else {
				//_wid = eval($("#"+id+" .slidebanner").width())-eval($("#"+id+" .slidebanner > li").width());
				$("#" + id + " .slidebanner").animate({ 'left': "0" }, 600);
				cont = 0;
			}
			$("#" + id + " .nav > li").switchClass('ativo', 'nda', 230);
			$("#thumb" + cont).switchClass('nda', 'ativo', 230);
		}

		carregaBanner($(obj).attr('id'));
		$(window).resize(function () {
			clearInterval(intervalo);
			setarTamanhoSlide($(obj).attr('id'));
		});
	}


	(function () {
		'use strict';

		/* ==============================================
			 Testimonial Slider
			 =============================================== */

		$('a.page-scroll').click(function () {
			// var target = $(this.hash);
			// target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
			// $('html,body').animate({
			// scrollTop: target.offset().top - 40
			// }, 900);
			if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
				var target = $(this.hash);
				// remove a class do menu
				var aberto = $('#bs-example-navbar-collapse-1').hasClass('in');
				$('#bs-example-navbar-collapse-1').toggleClass('in', !aberto);

				target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
				if (target.length) {
					$('html,body').animate({
						scrollTop: target.offset().top - 68
					}, 900);
					return false;

				}
			}
		});

		/*====================================
		Show Menu
		======================================*/
		var c = 0;
		$(window).bind('scroll', function () {
			var navHeight = $(window).height() - 900;
			if ($(window).scrollTop() > navHeight) {
				$('.navbar-default').addClass('on');
				//$('#logo_img').addClass('on_img');
				if (c == 0) {
					$('#logo_img').animate({ width: '40%' });
					c = 1;
				}
			} else {
				if (c == 1) {
					$('#logo_img').animate({ width: '90%' });
					c = 0;
				}
				$('.navbar-default').removeClass('on');
				//$('#logo_img').removeClass('on_img');
			}
		});

		$('body').scrollspy({
			target: '.navbar-default',
			offset: 80
		})

		$(document).ready(function () {
			$("#team").owlCarousel({

				navigation: false, // Show next and prev buttons
				slideSpeed: 300,
				paginationSpeed: 400,
				autoHeight: true,
				itemsCustom: [
					[0, 1],
					[450, 2],
					[600, 2],
					[700, 2],
					[1000, 4],
					[1200, 4],
					[1400, 4],
					[1600, 4]
				],
			});

			$("#clients").owlCarousel({

				navigation: false, // Show next and prev buttons
				slideSpeed: 300,
				paginationSpeed: 400,
				autoHeight: true,
				itemsCustom: [
					[0, 1],
					[450, 2],
					[600, 2],
					[700, 2],
					[1000, 4],
					[1200, 5],
					[1400, 5],
					[1600, 5]
				],
			});

			$("#testimonial").owlCarousel({
				navigation: false, // Show next and prev buttons
				slideSpeed: 300,
				paginationSpeed: 400,
				singleItem: true
			});

		});

		/*====================================
	Portfolio Isotope Filter
	======================================*/
		$(window).load(function () {
			var $container = $('.portfolio-items');
			$container.isotope({
				filter: '*',
				animationOptions: {
					duration: 750,
					easing: 'linear',
					queue: false
				}
			});
			$('.cat a').click(function () {
				$('.cat .active').removeClass('active');
				$(this).addClass('active');
				var selector = $(this).attr('data-filter');
				$container.isotope({
					filter: selector,
					animationOptions: {
						duration: 750,
						easing: 'linear',
						queue: false
					}
				});
				return false;
			});

		});

		/*====================================
		Gambiarra
		======================================*/
		$(document).ready(function () {
			$(window).bind("resize", function () {
				$(".link_portifolio.active").click();
			});
		});

		/*====================================
		CounterUp
		======================================*/

		$(document).ready(function ($) {
			if ($("span.count").length > 0) {
				$('span.count').counterUp({
					delay: 10, // the delay time in ms
					time: 1000 // the speed time in ms
				});
			}
		});

		/*====================================
		WOW JS
		======================================*/

		new WOW().init();
		//smoothScroll
		//smoothScroll.init();

	}());


}
main();