 
$(document).ready(function() {
						   
	
 
 	if($(".login-booking").length >0) 
	 
	 	{
			
			$(".login-booking").click(function(event){
															 
										event.preventDefault();
												
										var URL =  $(this).attr("href");
										
										alert("You must be logged in to book tables. Click 'OK' to log in now");
										
										location.href=URL;
										
										});
			
	 
		}

	
	
	/* This is the link in results page */
	
	
		 if($(".bookingprocessstop").length >0) 
	 
	 	{
		
			$(".bookingprocessstop").click(function(event){
															 
																event.preventDefault();
																var obj = new Object();
																
																$.ajax({
																type: "POST",
																url: websiteURL+ "loaddynamic.cfm?template=cancelbooking",
																data: obj, 
																dataType: "json",
																success: function (data) {
																	
																			$("#bookingprocess").hide();
																			
																			openpopupdiv('msgbox',500,'terminateBooking');
																			
																			//alert(data.cancelmsg);
																	
																	
																	
																	}
																 
																});
											});
			
		}
	 
	 if($(".thickbox-bookatable-results").length >0) 
	 
	 	{
		  
		 	$(".thickbox-bookatable-results").click(function(event){
															 
										event.preventDefault();
										
										var URL =  $(this).attr("href");
										
										var obj = new Object();

											$.ajax({
												type: "POST",
												url: websiteURL + "loaddynamic.cfm?template=checkreversesmsauthorise",
												data: obj, 
												dataType: "json",
												success: function (data) {
																				
																				if (data.MESSAGE !='' && data.REVERSEBILLEDAUTHORISE ==0)
																				
																				{
																					
																						// alert(data.MESSAGE);
																						
																						var cPhone = confirm("Booking process on hold while SMS message is awaited\ Ok button : Will wait for SMS confirmation. \n Cancel : Ends the SMS and reopens booking selection");
																						
																						if (cPhone)
																						{
																							return;
																						}
																						
																						if (cPhone == false)
																						
																						{
																							
																							$.ajax({
																							  type: "GET",
																							  url: websiteURL + "loaddynamic.cfm?template=unregistermobile",
																							  success: function(){
																								  
																								  	
																									openpopup('myfirstpopup',900,URL);
																									/*tb_show("",URL);
																									tb_init('a.thickbox');
																									*/
																									
																									}
																							   
																							});
																	
																																													  
																						}
																					
																					} else  {
																						
																					
																					
																						//alert('entered');
																						
																						//reload_pop('myfirstpopup',URL);
																						
																						openpopup('myfirstpopup',900,URL);
																						
																						//tb_show("",URL);
											
																						//tb_init('a.thickbox');
																						
																					}
																			 	
																	
																			}
												});
 	
										
										/*
										var URL =  $(this).attr("href");
										
										tb_show("",URL);
										
										tb_init('a.thickbox');
										
										*/
										 
												
										});			
			}
			
		 
		
	
	
	

	
});