// pagetop
$(function() {
	"use strict";
	var pagetop = $('.pagetop');
	$(window).scroll(function () {
		if ($(this).scrollTop() > 800) {
			pagetop.fadeIn();
		} else {
			pagetop.fadeOut();
		}
	});
	pagetop.click(function () {
		$('body, html').animate({ scrollTop: 0 }, 700);
		return false;
	});
	$('a[href^=#]').click(function(){
		var speed = 500;
		var href= $(this).attr("href");
		var target = $(href == "#" || href == "" ? 'html' : href);
		var position = target.offset().top;
		$("html, body").animate({scrollTop:position}, speed, "swing");
		return false;
	});
});

// pagetop-smp
$(function() {
    $('.pagetops').click(function () {
        $('body, html').animate({ scrollTop: 0 }, 700);
        return false;
    });
});

$(window).load(function() {
	var fbH = $('.fNavi-wrap').height();
    $('footer').css('margin-bottom',fbH);
});

$(function(){
    var ua = navigator.userAgent.toLowerCase();
		var isMobile = /iphone/.test(ua)||/android(.+)?mobile/.test(ua);
		if (!isMobile) {
    $('a[href^="tel:"]').on('click', function(e) {
        e.preventDefault();
    });
		 $('header .tel a').css('cursor','default');
	}
});

$(function(){
   var ua = navigator.userAgent;
    if (ua.indexOf('iPhone') > 0 || ua.indexOf('Android') > 0) {
      $('.tel-link').each(function () {
        var str = $(this).text();
        $(this).html($('<a>').attr({
          'href': 'tel:' + str.replace(/-/g, ''),
          // 'onclick': "gtag_report_conversion_tel ('tel:" + str + "');",
        }).append(str + '</a>'));
      });
      $('.tel-link').css('text-decoration', 'underline');
    }  
});

// $(function(){
//   $('.web-link').each(function() {
//     var url = $(this).prop("href");
//     $(this).attr({
//       'onclick': "gtag_report_conversion_web ('" + url + "');"
//     });
//   });
// });

