$(function() {
	// Banner
	$('#banner ul').owlCarousel({
		items: 1,
		nav: false,
		dots: true,
		smartSpeed: 500,
		loop: false,
		animateIn: 'animatein',
		animateOut: 'animateout',
		autoplay: 4000,
		loop: true
	})

	// Input file
	$('.form__file').each(function() {
		var fileInput = $(this).find('input'),
			label = $(this).find('.file-name')

		fileInput.on('change', function(e) {
			var fileName = ''

			if (e.target.value) fileName = e.target.value.split('\\').pop()

			if (fileName) label.html(fileName)
			else label.html('')
		})
	})

	// Máscara de telefone
	var ElevenMaskBehavior = function(val) {
			return val.replace(/\D/g, '').length === 11
				? '(00) 00000-0000'
				: '(00) 0000-00009'
		},
		elevenOptions = {
			onKeyPress: function(val, e, field, options) {
				field.mask(ElevenMaskBehavior.apply({}, arguments), options)
			}
		}

	$('.phone').each(function() {
		$(this).mask(ElevenMaskBehavior, elevenOptions)
	})
})
