<?php /* Body tag */ ?>
<?php $__env->startSection('body_tag'); ?>
<body class="left-slider two-column">
    <?php $__env->stopSection(); ?>
    <?php /* Content */ ?>
    <?php $__env->startSection('content'); ?>
    <div class="row">
     <div class="large-12 medium-12 columns">
      <div id="main">	
        <div id="primary">
            <?php echo $showContent; ?>

        </div>
    </div>
     </div>
    </div>
    <?php $__env->stopSection(); ?>

    <?php $__env->startSection('scripts'); ?>
    <script type="text/javascript">
        $(document).ready(function () {
            $('.email_copy').click(function (e) {
                e.preventDefault();
				
				$(this).find('span').html('Please Wait ...');
				var $element = $(this);
                var href = $(this).attr('href');
				$(this).removeAttr('href');
                $.ajax({
                    url: href,
                    context: document.body
                }).done(function (data) {
                    if (data.status === 'ERROR')
                    {
                        
						$element.find('span').html('Email a copy');
						$element.attr('href',href);
                        $("#messages").show().html("<div class='messages error'><p class='error'>" + data.error_message + "</p></div>").fadeOut(5000);
                    }
                    else if (data.status === 'SUCCESS')
                    {
                        $("#messages").removeClass('hidden');
                        $("#messages").fadeIn('fast').html("<div class='messages success'><p class='success'>" + data.success_message + "</p></div>").fadeOut(5000);
						$element.find('span').html('Email a copy');
						$element.attr('href',href);
                    }
                });
            });
            $('.cancel_reservation').click(function (e)
            {
                e.preventDefault();
                var href = $(this).attr('href');
                $("#dialog-confirm").dialog({
                    resizable: false,
                    height: 140,
                    modal: true,
                    buttons: {
                        "Don't Cancel": function () {
                            $(this).dialog("close");
                        },
                        Cancel: function () {
						
							var $element = $('.cancel_reservation');
							$element.removeAttr('href');
							$element.find('span').html('Cancelling ...');
                            $.ajax({
                                url: href,
                                context: document.body
                            }).done(function (data) {
								
                                if (typeof data.Error !== 'undefined' && data.Error !== null)
                                {
                                    alert(data.Error['!']);
									$element.find('span').html('Cancel');
									$element.attr('href',href);
                                }
                                else if (data.Status === 'Success')
                                {
									
									 <?php if(Sentry::check()): ?>
                                    window.location.assign("<?php echo URL::to('/account/reservations'); ?>");
									<?php else: ?>
										 alert('Reservation has been Cancelled Successfully');
										 window.location.assign("<?php echo URL::to('/'); ?>");
									<?php endif; ?>
                                }
                            });
                            $(this).dialog("close");
                        }
                    }
                });
            });
			
			initializeMaps();
			


			function getPickupMap() {
				var pickup_address = "<?php echo $resDetails['car']['pickLocation']; ?>";
				$.ajax({
				  url:"https://maps.googleapis.com/maps/api/geocode/json?address="+pickup_address+"&sensor=false",
				  type: "POST",
				  success:function(res){
					 var lat = res.results[0].geometry.location.lat ;
					 var lng = res.results[0].geometry.location.lng ;
					 
						getLocationMap('pickupMap', lat, lng, pickup_address);
				  }
				});
			}
			
			
			function getDropoffMap() {
				var dropoff_address = "<?php echo $resDetails['car']['dropLocation']; ?>";
				$.ajax({
				  url:"https://maps.googleapis.com/maps/api/geocode/json?address="+dropoff_address+"&sensor=false",
				  type: "POST",
				  success:function(res){
					 var lat = res.results[0].geometry.location.lat ;
					 var lng = res.results[0].geometry.location.lng ;
						getLocationMap('dropoffMap', lat, lng, dropoff_address);
				  }
				});					
			}

			
			$('body').on('click', '#dropoffMapLink', function (e) {
			 
				e.preventDefault();
			 
				$('#dropoffMap').toggle('slow',function(){
					if($('#dropoffMapLink').html()=='Map <span class="arrow arrow_bottm"></span>'){
						$('#dropoffMapLink').html('Close Map <span class="arrow arrow_up"></span>');
						getDropoffMap();
					}
					else if($('#dropoffMapLink').html()=='Close Map <span class="arrow arrow_up"></span>'){
						$('#dropoffMapLink').html('Map <span class="arrow arrow_bottm"></span>');
					}
				});
			});
			
			$('body').on('click', '#pickupMapLink', function (e) {
			 
				e.preventDefault();
				$('#pickupMap').toggle('slow',function(){
					if($('#pickupMapLink').html()=='Map <span class="arrow arrow_bottm"></span>'){
						$('#pickupMapLink').html('Close Map <span class="arrow arrow_up"></span>');
						 
							getPickupMap();
						 
					}
					else if($('#pickupMapLink').html() =='Close Map <span class="arrow arrow_up"></span>'){
						$('#pickupMapLink').html('Map <span class="arrow arrow_bottm"></span>');
					}
				});
			});

        });
         
    </script>
    <?php $__env->stopSection(); ?>

<?php echo $__env->make('site.default', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>