$(document).ready(function() {
    //UI To Top Button
    $().UItoTop({
        easingType:'easeOutQuart'
    });

    //LightBox
    if ($('.gal').length) {
        $('.gal').lightbox();
    }

    //Google Event Tracking
    if ($('#button').length) {
        $('#button').on('click', function() {
            //ga('send', 'event', 'button', 'click', 'nav-buttons');
        });
    }

    //Owl-Carousel
    if ($(".owl-slide").length) {
        var owl = $(".owl-slide");
        owl.owlCarousel({
            nav:true,
            navText:[
            	'<span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-arrow-left fa-stack-1x fa-inverse"></i></span>',
            	'<span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-arrow-right fa-stack-1x fa-inverse"></i></span>'
            ],
            autoplay:true,
            autoplayTimeout:3500,
            autoplayHoverPause:true,
            loop:true,
            items:1,
            animateOut:'fadeOut'
        });
    }
		
    //Map Button Controls
    $("#print").click(function() {
        window.print()
    });
    
    $("#clear").click(function() {
        $('#directions-panel').empty();
        $('#searchTextField').val("");
        $('#directions-panel').text("Please Calculate Route First");
        initialize();
        $("#print").prop("disabled", true);
    });
});
$(document).ready (
	function ()
	{
	    //Load Php Form
	    $.ajax (
		    {
		        url:'/includes/form/form.php',
		        type:'POST',
		        data:"",
		    }
		).done(
			function(response)
			{
		        $("#foot_form").html(response);
		        $("#submit").removeAttr("disabled");
		        //Handle Form Submit
		        $.validate (
			        {
			            form:'#query',
			            scrollToTopOnError:false,
			            onSuccess:function (event)
				            {
				                $(".busy").show();
				                $("#submit").attr("disabled", "disabled");
				                var datastring = $("#query").serialize();
				                $.ajax (
					                {
					                    url:'/includes/form/processor.php',
					                    type:'POST',
					                    data:datastring,
					                }
				                ).done(
					                function (response)
					                {
					                    $("#query").html(response);
					                }
				                ).fail(
					                function(response)
					                {
					                    $("#query").html("Failed To Load Form");
					                }
				                );
				                return false;
				            },
			            onError:function ()
				            {
				            }
			        }
		        );
		        $('#message').restrictLength($('#maxlength'));
		    }
	    ).fail(
		    function (response)
		    {
		        $("#foot_form").html("Failed To Load Form");
		    }
	    );
	}
);

function preventdefault(event)
{
    if (event.preventDefault)
    {
        event.preventDefault();
    }
    else if (!event.preventDefault)
    {
        event.returnValue = false;
    }
}
