$(document).ready(function () { 


/*--------------------------------------------------*/


	
	$('body').append('<div id="dialog"></div>');
	
	$('#dialog').dialog({
		autoOpen: false, 
		resizable: false 
	});
	
	$('.popup_table').click(function() {
		
	   $('#dialog').html('<div class="popuppreloader"><img src="images/rule-ajax-loader.gif" width="16" heigth="16" /></div>')
	   .dialog( 'option' , 'title' , 'Book a table' )
	   .dialog( 'option' , 'bgiframe' , true )
	   .dialog( 'option' , 'autoOpen' , false )
	   .dialog( 'option' , 'width' , 500 )
	   .dialog( 'option' , 'height' , 430 )
	   .dialog( 'option' , 'modal' , true )
	   .dialog( 'option' , 'buttons' , {
			'Send': function() {
				sendemail1();
			}			
	   })
	   .dialog('open');


  		var $ajaxcontent = $.ajax({
  			url: 'table-popup.php',
			data: 'booktablelink=' + $('#booktablelink').val(),
  			async: false
  		}).responseText;


	   $('#dialog').html($ajaxcontent);
		
	   return false;
    });

	$('.popup_party').click(function() {
		
	   $('#dialog').html('<div class="popuppreloader"><img src="images/rule-ajax-loader.gif" width="16" heigth="16" /></div>')
	   .dialog( 'option' , 'title' , 'Book a party' )
	   .dialog( 'option' , 'bgiframe' , true )
	   .dialog( 'option' , 'autoOpen' , false )
	   .dialog( 'option' , 'width' , 500 )
	   .dialog( 'option' , 'height' , 430 )
	   .dialog( 'option' , 'modal' , true )
	   .dialog( 'option' , 'buttons' , {
			'Send': function() {
				sendemail2();
			}			
	   })
	   .dialog('open');


  		var $ajaxcontent = $.ajax({
  			url: 'party-popup.php',
			data: 'bookaparty=' + $('#bookaparty').val(),
  			async: false
  		}).responseText;


	   $('#dialog').html($ajaxcontent);
		
	   return false;
    });

});


function sendemail1 () {
	
  var error = false;
  
  if ($('#equiry_name').val() == '') {
    error = true;
  }
	
  if ($('#equiry_email').val() == '') {
    error = true;
  }

  

  if (error) {
	$('#eqm').html('Error: missing fields '); 	
  }	else {

	var $equiry_name = $('#equiry_name').val();
	var $booktablelink = $('#booktablelink').val();
	var $equiry_email = $('#equiry_email').val();
	var $equiry_phone = $('#equiry_phone').val();
	var $equiry_day = $('#equiry_day').val();
	var $equiry_month = $('#equiry_month').val();	
	var $equiry_time = $('#equiry_time').val();	
	var $equiry_people = $('#equiry_people').val();			
	var $comment = $('#comment').val();		
	
	$('#dialog').html('<div class="popuppreloader"><img src="images/rule-ajax-loader.gif" width="16" heigth="16" /></div>');
	
	$.post('sendmailajax1.php', { 
		   
	    equiry_name : $equiry_name, 
	    booktablelink : $booktablelink, 		
	    equiry_email : $equiry_email,
	    equiry_phone : $equiry_phone,
	    equiry_day : $equiry_day,
	    equiry_month : $equiry_month,		
	    equiry_time : $equiry_time,		
	    equiry_people : $equiry_people,						
	    comment : $comment				
		
	  },
	  function success(data) {	
		$('#dialog').html(data.msg)
		.dialog( 'option' , 'buttons' , {
			'Close': function() {
				$(this).dialog('close');
			}
	   })

	  }, 'json');
	
  }
	
}


function sendemail2 () {
	
  var error = false;
  
  if ($('#equiry_name').val() == '') {
    error = true;
  }
	
  if ($('#equiry_email').val() == '') {
    error = true;
  }

  

  if (error) {
	$('#eqm').html('Error: missing fields '); 	
  }	else {

	var $equiry_name = $('#equiry_name').val();
	var $bookaparty = $('#bookaparty').val();
	var $equiry_email = $('#equiry_email').val();
	var $equiry_phone = $('#equiry_phone').val();
	var $equiry_day = $('#equiry_day').val();
	var $equiry_month = $('#equiry_month').val();	
	var $equiry_time = $('#equiry_time').val();	
	var $equiry_people = $('#equiry_people').val();			
	var $comment = $('#comment').val();		
	
	$('#dialog').html('<div class="popuppreloader"><img src="images/rule-ajax-loader.gif" width="16" heigth="16" /></div>');
	
	$.post('sendmailajax2.php', { 
		   
	    equiry_name : $equiry_name, 
	    bookaparty : $bookaparty, 		
	    equiry_email : $equiry_email,
	    equiry_phone : $equiry_phone,
	    equiry_day : $equiry_day,
	    equiry_month : $equiry_month,		
	    equiry_time : $equiry_time,		
	    equiry_people : $equiry_people,						
	    comment : $comment				
		
	  },
	  function success(data) {	
		$('#dialog').html(data.msg)
		.dialog( 'option' , 'buttons' , {
			'Close': function() {
				$(this).dialog('close');
			}
	   })

	  }, 'json');
	
  }
	
}





