$(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,
            autoplay: true,
            autoplayTimeout: 3500,
            autoplayHoverPause: true,
            loop: true,
            smartSpeed:450,
            items: 1,
			animateOut: 'fadeOut'
        });
    }
	if($(".owl-room").length)
	{
		var owl = $(".owl-room");
		owl.owlCarousel(
		{
			nav: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;
    }
}
