// JavaScript Document
$(document).ready(function(){
			$(".device-nav").click(function(){
				$("nav").toggleClass("reveal");
			$(".device-nav").toggleClass("reveal");
			});
			$('.device-nav').click(function(){

				$('.hamburger').toggleClass('is-active');
			  });
			  
			  $('#dpd1').datepicker({
				format: 'dd-mm-yyyy',
			});
			
			$('#dpd2').datepicker({
				format: 'dd-mm-yyyy',
			});
		});
		
		
		
	//var count = 100;
		var countEl = document.getElementById("count");
		function plus(){
		    var count = $('#count').val();
			count++;
			countEl.value = count;
		}
		function minus(){
		      var count = $('#count').val();
		  if (count > 1) {
		    
			count--;
			countEl.value = count;
		  }  
		}
		
		
		var countEl1 = document.getElementById("count1");
		function plus1(){
		    var count = $('#count1').val();
			count++;
			countEl1.value = count;
		}
		function minus1(){
		      var count = $('#count1').val();
		  if (count > 1) {
		    
			count--;
			countEl1.value = count;
		  }  
		}
		
		
	$(document).on('click','#submit', function(){
	
	var data = new Object();
	data['surname'] = $('#surname').val().trim();
	data['name'] = $('#name').val().trim();
	data['preferred_date'] = $('#dpd1').val().trim();
	data['no_of_persons'] = $('#count').val().trim();
	data['email'] = $('#email1').val().trim();
	data['message'] = $('#message').val().trim();
	if($('#terms').is(':checked'))
	{
	    data['terms'] = 1;
	}
	else
	{
	    data['terms'] = 0;
	}
	$('.error_message').html('<div class="alert alert-warning">Processing.....</div>').show();
	$('#submit').attr('disabled', 'disabled');
	$.post('submit.php', {data:data}, function(){
		$('#submit').removeAttr('disabled');
	    $('.error_message').html('');
	    alert('Form Submitted Successfully');
	    $('#popup-gaidam').modal('hide');

	},'json').fail(function(xhr) {
		$('#submit').removeAttr('disabled');
		
        var html = '';
        var res = xhr.responseJSON;
        $(res.error_description).each(function(i, value){
                html+= '<p>' + value + '</p>';
        });
        $('.error_message').html('<div class="alert alert-danger">' + html + ' <i class="fa fa-close"></i></div>').show();
        window.location.href = '#body';
    },'json');
});
	$(document).on('click','#submit1', function(){
	
    	var data = new Object();
    
    	data['name'] = $('#name1').val().trim();
    	data['preferred_date'] = $('#dpd2').val().trim();
    	data['no_of_persons'] = $('#count1').val().trim();
    	data['preffered_time'] = $('#time').val().trim();
    	data['phone'] = $('#phone1').val().trim();
	
    	if($('#terms1').is(':checked'))
    	{
    	    data['terms'] = 1;
    	}
    	else
    	{
    	    data['terms'] = 0;
    	}
	    $('.error_message1').html('<div class="alert alert-warning">Processing.....</div>').show();
	    $('#submit1').attr('disabled', 'disabled');
    	$.post('submit-new.php', {data:data}, function(){
    		$('#submit1').removeAttr('disabled');
    		$('.error_message1').html('');
    	    alert('Form Submitted Successfully');
	        $('#popup-gaidam-new').modal('hide');
    
    	},'json').fail(function(xhr) {
    		$('#submit1').removeAttr('disabled');
    		
            var html = '';
            var res = xhr.responseJSON;
            $(res.error_description).each(function(i, value){
                    html+= '<p>' + value + '</p>';
            });
            $('.error_message1').html('<div class="alert alert-danger">' + html + ' <i class="fa fa-close"></i></div>').show();
            window.location.href = '#body';
        },'json');
});