$.widget('ui.ajaxform', {
		options: {
			reqclass: '',
			type: 'POST'
		},
		
		_create: function() {
			var obj = this;
			var parent = this.element;
			var reqclass = this.options.reqclass;
			
			parent.submit(function(){
				setTimeout(function(){
					if(reqclass.length > 0){
						if(parent.hasClass(reqclass)){
							obj.sendout();
						}
					}else{
						obj.sendout();
					}
				}, 400)
				return false;
			});
		},
		
		sendout: function(){
			var formdata = this.element.serialize();
			var callback = this.options.change;
			var type = this.options.type;
			var address = this.options.address;
			
			$.ajax({
				type: type,
				url: address,
				data: formdata,
				success: function(data) {
					if ($.isFunction(callback)) callback(data); 
				}
			});
		}
		
	});

$().ready(function() {
	
	$('.check-location').click(function(){
		$('html, body').animate({
			scrollTop: $(".check-location-header").offset().top - 159
		}, 600);
	});
	$('.booking-enquries').click(function(){
		$('html, body').animate({
			scrollTop: $(".booking-enquries-header").offset().top - 159
		}, 600);
	});
	$('.view-menu').click(function(){
		$('html, body').animate({
			scrollTop: $(".view-menu-header").offset().top -159
		}, 600);
	});

});

